diff --git a/dist/diagram.js b/dist/diagram.js index e45cdf2a..950ea86b 100644 --- a/dist/diagram.js +++ b/dist/diagram.js @@ -1,4 +1,4 @@ -"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[465],{"./src/container/container.ts":(e,t,n)=>{let r,i,o,s;n.d(t,{W:()=>nB});var a,l=n("./src/events/gameevent.ts"),c=n("./src/events/eventtype.ts");function u(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*y.R){var i=100*(10*y.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,v.AA)(e.angle),-(18*y.R)),t),this.camera.position.z=n,this.camera.up=v.up,this.camera.lookAt(e.pos.clone().addScaledVector(v.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*y.R?e/8:e,this.height=d.M8C.clamp(this.height+e,6*y.R,120*y.R),this.height>110*y.R&&this.suggestMode(this.topView),this.height<105*y.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],b(n.prototype,e),t&&b(n,t),n}();function k(e,t=1/0,n=null){i||(i=new d._12(2,2,1,1)),o||(o=new d.jyz({uniforms:{blitTexture:new d.xWb(e)},vertexShader:` +"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[465],{"./src/container/container.ts":(e,t,n)=>{let r,i,o,s;n.d(t,{W:()=>nH});var a,l=n("./src/events/gameevent.ts"),c=n("./src/events/eventtype.ts");function u(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*y.R){var i=100*(10*y.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,v.AA)(e.angle),-(18*y.R)),t),this.camera.position.z=n,this.camera.up=v.up,this.camera.lookAt(e.pos.clone().addScaledVector(v.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*y.R?e/8:e,this.height=d.M8C.clamp(this.height+e,6*y.R,120*y.R),this.height>110*y.R&&this.suggestMode(this.topView),this.height<105*y.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],b(n.prototype,e),t&&b(n,t),n}();function k(e,t=1/0,n=null){i||(i=new d._12(2,2,1,1)),o||(o=new d.jyz({uniforms:{blitTexture:new d.xWb(e)},vertexShader:` varying vec2 vUv; void main(){ vUv = uv; @@ -15,4 +15,4 @@ #else gl_FragColor = texture2D( blitTexture, vUv); #endif - }`})),o.uniforms.blitTexture.value=e,o.defines.IS_SRGB=e.colorSpace==d.KI_,o.needsUpdate=!0,s||((s=new d.Kj0(i,o)).frustrumCulled=!1);let a=new d.cPb,l=new d.xsS;l.add(s),n||(n=r=new d.CP7({antialias:!1})),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(l,a);let c=new d.xEZ(n.domElement);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,r&&(r.dispose(),r=null),c}let x={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class T{constructor(){this.pluginCallbacks=[],this.register(function(e){return new N(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new U(e)}),this.register(function(e){return new D(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new B(e)}),this.register(function(e){return new H(e)}),this.register(function(e){return new z(e)}),this.register(function(e){return new K(e)}),this.register(function(e){return new V(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i=new C,o=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class C{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,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),this.processInput(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let o=this.extensionsUsed,s=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o),c=Object.keys(s);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=_(e.result),o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,5130562,!0);let s=_((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,s.byteLength,!0),a.setUint32(4,1313821514,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+s.byteLength+o.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,s,o,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}let n=this.uids.get(e);return n.get(t)}isNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return!1;let n=new d.Pa4;for(let t=0,r=e.count;t5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new d.Pa4;for(let e=0,t=n.count;e4?r=e.array[i*e.itemSize+n]:(0===n?r=e.getX(i):1===n?r=e.getY(i):2===n?r=e.getZ(i):3===n&&(r=e.getW(i)),!0===e.normalized&&(r=d.M8C.normalize(r,e.array))),t===R.FLOAT?l.setFloat32(c,r,!0):t===R.INT?l.setInt32(c,r,!0):t===R.UNSIGNED_INT?l.setUint32(c,r,!0):t===R.SHORT?l.setInt16(c,r,!0):t===R.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===R.BYTE?l.setInt8(c,r):t===R.UNSIGNED_BYTE&&l.setUint8(c,r),c+=o}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==i&&(u.target=i),i===R.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);let h={id:s.bufferViews.length-1,byteLength:0};return h}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=_(i.result),o={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(o)-1)}})}processAccessor(e,t,n,r){let i,o;let s=this.json;if(e.array.constructor===Float32Array)i=R.FLOAT;else if(e.array.constructor===Int32Array)i=R.INT;else if(e.array.constructor===Uint32Array)i=R.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=R.SHORT;else if(e.array.constructor===Uint16Array)i=R.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=R.BYTE;else if(e.array.constructor===Uint8Array)i=R.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),void 0===r&&(r=e.count),0===r)return null;let a=function(e,t,n){let r={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i4?n=e.array[i*e.itemSize+t]:(0===t?n=e.getX(i):1===t?n=e.getY(i):2===t?n=e.getZ(i):3===t&&(n=e.getW(i)),!0===e.normalized&&(n=d.M8C.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}(e,n,r);void 0!==t&&(o=e===t.index?R.ELEMENT_ARRAY_BUFFER:R.ARRAY_BUFFER);let l=this.processBufferView(e,i,n,r,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(c)-1}processImage(e,t,n,r="image/png"){if(null!==e){let i=this,o=i.cache,s=i.json,a=i.options,l=i.pending;o.images.has(e)||o.images.set(e,{});let c=o.images.get(e),u=r+":flipY/"+n.toString();if(void 0!==c[u])return c[u];s.images||(s.images=[]);let h={mimeType:r},f=I();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==d.wk1&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ti.processBufferViewImage(e)).then(e=>{h.bufferView=e})):void 0!==f.toDataURL?h.uri=f.toDataURL(r):l.push(j(f,r).then(e=>new FileReader().readAsDataURL(e)).then(e=>{h.uri=e}));let v=s.images.push(h)-1;return c[u]=v,v}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:E[e.magFilter],minFilter:E[e.minFilter],wrapS:E[e.wrapS],wrapT:E[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||(r.textures=[]),e instanceof d.EB7&&(e=k(e,t.maxTextureSize));let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive,n=Math.max(t.r,t.g,t.b);if(n>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.ehD&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let o=n.materials.push(r)-1;return t.materials.set(e,o),o}processMesh(e){let t;let n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o0&&(a.extras={},a.extras.targetNames=r)}let v=Array.isArray(e.material);if(v&&0===s.groups.length)return null;let m=v?e.material:[e.material],y=v?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=y.length;e0&&(r.targets=u),null!==s.index){let t=this.getUID(s.index);(void 0!==y[e].start||void 0!==y[e].count)&&(t+=":"+y[e].start+":"+y[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(s.index,s,y[e].start,y[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=this.processMaterial(m[y[e].materialIndex]);null!==i&&(r.material=i),c.push(r)}a.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,a)});let b=r.meshes.push(a)-1;return n.meshes.set(o,b),b}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[A])return;switch(t.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}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];x[r]&&x[r].includes(n)&&(this.extensionsUsed[A]=!0,this.extensionsRequired[A]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.M8C.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=T.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,o=[],s=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let o=t.nodes.push(i)-1;return r.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new d.xsS;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.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."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let s=r.extensions[this.name].lights;s.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}}class L{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer,r=n.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class B{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class H{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class F{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class U{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class D{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer,r=n.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class G{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(S)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class z{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class K{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class V{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer,r=n.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}function X(e,t){if(t===d.WwZ)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==d.z$h&&t!==d.UlW)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let n=e.getIndex();if(null===n){let t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;eMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),o.set(s.evaluate(t),0),o.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(s.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),o.set(e.values.slice(0,(a+1)*r),0),o.set(s.evaluate(t),(a+1)*r),o.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=o,n},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eN(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function W(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let Z={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_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 J{constructor(e){this.parser=e,this.name=Z.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,o)}}class el{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class ec{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eu{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,o=e.count,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t})})}}}class eh{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==ek.TRIANGLES&&e.mode!==ek.TRIANGLE_STRIP&&e.mode!==ek.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name],o=i.attributes,s=[],a={};for(let e in o)s.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d.yGw,n=new d.Pa4,o=new d._fP,s=new d.Pa4(1,1,1),l=new d.SPe(e.geometry,e.material,r);for(let e=0;e-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new d.dpR(this.options.manager):this.textureLoader=new d.QRU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.hH6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return eM(i,o,r),e_(o,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,o]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(o,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,h[e*a+1]),a>=3&&o.setZ(t,h[e*a+2]),a>=4&&o.setW(t,h[e*a+3]),a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e],i=r.source,o=t.images[i],s=this.textureLoader;if(o.uri){let e=n.manager.getHandler(o.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){let r=this,i=this.json,o=i.textures[e],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];let l=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=i.samplers||{},a=n[o.sampler]||{};return t.magFilter=eT[a.magFilter]||d.wem,t.minFilter=eT[a.minFilter]||d.D1R,t.wrapS=eR[a.wrapS]||d.rpg,t.wrapT=eR[a.wrapT]||d.rpg,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){let n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=n.images[e],o=self.URL||self.webkitURL,s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then(function(e){a=!0;let t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then(function(e){return new Promise(function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new d.xEZ(e);t.needsUpdate=!0,n(t)}),t.load(d.Zp0.resolveURL(e,r.path),o,void 0,i)})}).then(function(e){var t;return!0===a&&o.revokeObjectURL(s),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),i.extensions[Z.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.UY4,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.nls,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return d.Wid}loadMaterial(e){let t;let n=this,r=this.json,i=this.extensions,o=r.materials[e],s={},a=o.extensions||{},l=[];if(a[Z.KHR_MATERIALS_UNLIT]){let e=i[Z.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(s,o,n))}else{let r=o.pbrMetallicRoughness||{};if(s.color=new d.Ilk(1,1,1),s.opacity=1,Array.isArray(r.baseColorFactor)){let e=r.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],d.GUF),s.opacity=e[3]}void 0!==r.baseColorTexture&&l.push(n.assignTexture(s,"map",r.baseColorTexture,d.KI_)),s.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,s.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(n.assignTexture(s,"metalnessMap",r.metallicRoughnessTexture)),l.push(n.assignTexture(s,"roughnessMap",r.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}!0===o.doubleSided&&(s.side=d.ehD);let c=o.alphaMode||eO.OPAQUE;if(c===eO.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===eO.MASK&&(s.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"normalMap",o.normalTexture)),s.normalScale=new d.FM8(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(s.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==d.vBJ){let e=o.emissiveFactor;s.emissive=new d.Ilk().setRGB(e[0],e[1],e[2],d.GUF)}return void 0!==o.emissiveTexture&&t!==d.vBJ&&l.push(n.assignTexture(s,"emissiveMap",o.emissiveTexture,d.KI_)),Promise.all(l).then(function(){let r=new t(s);return o.name&&(r.name=o.name),e_(r,o),n.associations.set(r,{materials:e}),o.extensions&&eM(i,r,o),r})}createUniqueName(e){let t=d.iUV.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache,i=[];for(let o=0,s=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new d.ZAu:1===t.length?t[0]:new d.Tme)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof d.F5T||e instanceof d.xEZ)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let o;let s=[],a=e.name?e.name:e.uuid,l=[];switch(eP[i.path]===eP.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),eP[i.path]){case eP.weights:o=d.dUE;break;case eP.rotation:o=d.iLg;break;case eP.position:case eP.scale:o=d.yC1;break;default:o=1===n.itemSize?d.dUE:d.yC1}let c=void 0!==r.interpolation?eS[r.interpolation]:d.NMF,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e3&&void 0!==arguments[3]?arguments[3]:function(){};new Y().load(e,function(e){e.scene.scale.set(y.R/.5,y.R/.5,y.R/.5),e.scene.matrixAutoUpdate=!1,e.scene.visible=n,e.scene.updateMatrix(),t.add(e.scene),r()},function(e){return console.log(e.loaded+" bytes loaded")},eB)}var eF=n("./src/view/tablegeometry.ts");function eU(e,t){for(var n=0;nthis.radius-y.R){var r=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-y.R/2&&e.vel.addScaledVector(r,7*y.R*t*y.g),0>e.vel.dot(r)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=r.x*e.vel.length()/2,e.vel.y=r.y*e.vel.length()/2)}var i=this.restingDepth(e);n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*y.R/.5,t,n).position.setZ(-(.25*y.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new d.fHI(t,t,n,16),s=new d.Kj0(o,i);return s.position.copy(e),s.geometry.applyMatrix4(new d.yGw().identity().makeRotationAxis(new d.Pa4(1,0,0),Math.PI/2)),r.add(s),s}},{key:"addCushions",value:function(e,t){var n=10*y.R/.5;this.plane(new d.Pa4(0,0,-y.R-n/2),2*eF.H.X,2*eF.H.Y,n,e,this.cloth);var r=1*y.R/.5,i=.75*y.R/.5,o=-(.25*y.R)/.5/2,s=eF.H.X,a=eF.H.Y,l=Math.abs(eJ.pockets.pocketNW.knuckleNE.pos.x-eJ.pockets.pocketN.knuckleNW.pos.x),c=Math.abs(eJ.pockets.pocketNW.knuckleSW.pos.y-eJ.pockets.pocketSW.knuckleNW.pos.y);t||(l=2*eF.H.Y,c=2*eF.H.Y+4*y.R),this.plane(new d.Pa4(s+r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s-r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(-s/2,-a-r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,-a-r/2,o),l,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,s=new d.DvJ(t,n,r),a=new d.Kj0(s,o);a.receiveShadow=!0,a.position.copy(e),i.add(a)}}],eq(n.prototype,e),t&&eq(n,t),n}(),e0=n("./src/events/watchevent.ts");function e1(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.Pot="Pot",e.Cushion="Cushion",e.Collision="Collision",e.Hit="Hit"}(a||(a={}));var e2=function(){var e;function t(e,n,r,i){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),e1(this,"type",void 0),e1(this,"timestamp",void 0),e1(this,"ballA",null),e1(this,"ballB",null),e1(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=r,this.incidentSpeed=i,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,o=!0,s=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n-eF.H.tableX&&n.overlapsAny(r,t);)r.x-=y.R/8;t.pos.copy(r),t.state=eV.Z.Stationary}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),tb(tm(r=i.call(this,e)),"delay",void 0),tb(tm(r),"shots",void 0),tb(tm(r),"firstShot",void 0),tb(tm(r),"timer",void 0),tb(tm(r),"init",void 0),r.init=t,r.shots=tk(n),r.firstShot=r.shots[0],r.delay=a,r.container.table.showTraces(!0),r.container.table.updateFromShortSerialised(r.init),s){var l=new tp.l(t,n);l.retry=!0,r.container.eventQueue.push(l)}else r.container.view.camera.forceMode(r.container.view.camera.topView),r.playNextShot(1.5*r.delay);return r}return n=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===c.t.RERACK){td.K.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var r=e3.f.fromJson(n);this.container.table.cueball=this.container.table.balls[r.i],this.container.table.cueball.pos.copy(r.pos),this.container.table.cue.aim=r,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new e8.O(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=tk(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=e3.f.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new tE(this.container)}}],ty(o.prototype,n),r&&ty(o,r),o}(tl);function tT(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tG.h_,o=e.futurePosition(n);if(t.willBounceLong(o,r)){var s=o.y>eF.H.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(s,e,i)}if(t.willBounceShort(o,r)){var a=o.x>eF.H.tableX?0:Math.PI;return t.bounceIn(a,e,i)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(eJ.pockets.pocketNW.knuckleSW.pos.y,eJ.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(eF.H.Y,-eF.H.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(eJ.pockets.pocketNW.knuckleNE.pos.x,eJ.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(eJ.pockets.pocketN.knuckleNE.pos.x,eJ.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-eF.H.X,eF.H.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xeF.H.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yeF.H.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,tG.ZI)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(tK.willCollide(e,t,n)){var r=tK.collide(e,t);return this.outcome.push(e2.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*y.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return eV.e.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&tX(n.prototype,e),t&&tX(n,t),n}();function tZ(e,t){for(var n=0;n0){if(this.previousPotRed)this.previousPotRed=!1,this.respot(e);else if(e2.onlyRedsPotted(e))this.previousPotRed=!0;else if(1===t){var n=e2.pots(e)[0].id;n>1&&this.container.table.balls.filter(function(e){return e.id0}).some(function(e){return e.onTable()})&&this.respot(e)}else this.respot(e)}return t1(t2(o.prototype),"update",this).call(this,e)}},{key:"respot",value:function(e){var t=this.respotAllPottedColours(e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new e0.g(n);this.container.sendEvent(r),this.container.recoder.record(r)}}},{key:"respotAllPottedColours",value:function(e){var t=this;return e2.pots(e).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(e){return e5.respot(e,t.container.table)})}}],t$(o.prototype,n),r&&t$(o,r),o}(tq);function t3(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],no(n.prototype,e),t&&no(n,t),n}();function nl(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=d.Hmr.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(d.M8C.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],nl(n.prototype,e),t&&nl(n,t),n}();function nh(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function nf(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==c.t.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],nv(n.prototype,e),t&&nv(n,t),n}(),nb=n("./src/view/sliders.ts"),ng=n("./node_modules/jsoncrush/JSONCrush.js");function nw(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart))}},{key:"state",value:function(e,t){return{init:e,shots:t}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=e2.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last())}},{key:"lastShotLink",value:function(e,t){var n="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),r=JSON.stringify(this.lastShot());this.generateLink(n,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n="break(".concat(t.shots.length,")"),r=JSON.stringify(t),i=ng.Z.crush(r);this.generateLink(n,i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(e.shots.length,")"),n=JSON.stringify(e),r=ng.Z.crush(n);this.generateLink(t,r)}},{key:"generateLink",value:function(e,t){var n="".concat(this.replayUrl).concat(encodeURIComponent(t)),r='').concat(e,"");this.container.eventQueue.push(new tU.s(null,"".concat(r)))}}],nw(n.prototype,e),t&&nw(n,t),n}();function nT(e,t){for(var n=0;n').concat(e,"")));r.push(new tU.s(null,s))})},this.redo.onclick=function(e){var r=new tp.l(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new p),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],nI(n.prototype,e),t&&nI(n,t),n}();function nN(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,l=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),nL(this,"table",void 0),nL(this,"view",void 0),nL(this,"controller",void 0),nL(this,"inputQueue",[]),nL(this,"eventQueue",[]),nL(this,"keyboard",void 0),nL(this,"sound",void 0),nL(this,"chat",void 0),nL(this,"sliders",void 0),nL(this,"recoder",void 0),nL(this,"id",""),nL(this,"isSinglePlayer",!0),nL(this,"rules",void 0),nL(this,"menu",void 0),nL(this,"last",performance.now()),nL(this,"step",.001953125),nL(this,"broadcast",void 0),nL(this,"log",void 0),nL(this,"sendChat",function(e){l.sendEvent(new tU.s(l.id,e))}),nL(this,"throttle",new ny(200,function(e){l.broadcast(e)})),nL(this,"lastEventTime",performance.now()),this.log=t,this.rules=n_.create(i,this),this.table=this.rules.table(),this.view=new t6(e,s,this.table,r,this.rules.asset()),this.table.cue.aimInputs=new na(this),this.keyboard=o,this.sound=new nu(this.view.camera.camera,r),this.chat=new nd(this.sendChat),this.sliders=new nb.E,this.recoder=new nx(this),this.id=a,this.menu=new nC(this),this.table.addToScene(this.view.scene),this.updateController(new nt(this))}return e=[{key:"sendEvent",value:function(e){this.throttle.send(e)}},{key:"advance",value:function(e){for(var t=Math.floor(e/this.step),n=t*this.step,r=this.table.allStationary(),i=0;i0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{var r,i,o,s,a,l,c,u,h,f=n("./src/model/physics/physics.ts"),p=n("./node_modules/three/build/three.module.js");function d(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:.9,o={dx:n-e,dy:r-t},s={x:o.dx*i+e,y:o.dy*i+t},a={dx:n-s.x,dy:r-s.y};this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(s.x,s.y),this.context.moveTo(s.x+.5*a.dy,s.y-.5*a.dx),this.context.lineTo(s.x-.5*a.dy,s.y+.5*a.dx),this.context.lineTo(n,r),this.context.closePath(),this.context.stroke()}}],d(n.prototype,e),t&&d(n,t),n}();function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{n.d(t,{Y:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{f:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function a(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){for(var n=0;n{n.d(t,{Z:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{l:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{s:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r;n.d(t,{t:()=>r}),function(e){e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK"}(r||(r={}))},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{O:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{I:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{N:()=>l});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),o=n.n(i);function s(e,t){for(var n=0;nMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),o=[];return t.forEach(function(t){var s=performance.now()-e.pressed[t];o.push(new r.I(i?s/3:s,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return o.push(new r.I(e.released[t],t+"Up"))}),this.released={},o}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),o()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}})}}],s(n.prototype,e),t&&s(n,t),n}()},"./src/events/placeballevent.ts":(e,t,n)=>{n.d(t,{I:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts");function s(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){for(var n=0;n{n.d(t,{K:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{g:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{e:()=>m,Z:()=>r});var r,i=n("./src/utils/utils.ts"),o=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),a=n("./src/model/physics/constants.ts");function l(e,t){for(var n=0;nMath.PI/32?.01*a.R:a.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var o=this.geometry.drawRange.count;0!==o&&n1&&i<1e-4&&o--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,o))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],l(n.prototype,e),t&&l(n,t),n}();function h(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(i.bM),this.rvel.copy(i.bM),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,o.E9)(this.vel,this.rvel).length(){n.d(t,{Dt:()=>c,Ew:()=>v,G3:()=>w,Hz:()=>i,I:()=>o,Mz:()=>r,R:()=>f,Xm:()=>k,_5:()=>u,dE:()=>y,e:()=>p,f7:()=>g,fN:()=>m,g:()=>s,m:()=>h,mu:()=>a,zq:()=>b,zv:()=>l});var r,i,o,s=9.8,a=.00985,l=.105,c=.8,u=.024,h=.23,f=.03275,p=.86;function d(){r=a*h*s*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*s,o=.4*h*f*f}function v(e){f=e,d()}function m(e){h=e,d()}function y(e){a=e,d()}function b(e){u=e,d()}function g(e){l=e}function w(e){p=e}function k(e){c=e}d()},"./src/model/physics/physics.ts":(e,t,n)=>{n.d(t,{E9:()=>a,Fn:()=>R,IT:()=>h,NP:()=>g,QC:()=>u,Vp:()=>c,WL:()=>P,ZI:()=>f,al:()=>b,c0:()=>y,h_:()=>A,s0:()=>m,vZ:()=>w});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),o=n("./src/model/physics/constants.ts"),s=new r.Pa4;function a(e,t){return s.copy(e).addScaledVector((0,i.a1)(t),o.R)}var l={v:new r.Pa4,w:new r.Pa4};function c(e,t){var n=a(e,t).setZ(0);return l.v.copy((0,i.KO)(n).multiplyScalar(-o.zv*o.g)),l.w.copy((0,i.KO)((0,i.a1)(n)).multiplyScalar(2.5*o.zv*o.g/o.R)),l.w.setZ(-2.5*(o.Mz/(o.R*o.R))*Math.sign(t.z)),l}function u(e){var t=new r.Pa4(e.x,e.y,0).length(),n=5/7*o.Hz/(o.m*o.R)/t,i=5/7*o.Hz/(o.m*o.R*o.R)/t;return l.v.set(-n*e.y,n*e.x,0),l.w.set(-i*e.x,-i*e.y,-2.5*(o.Mz/(o.m*o.R*o.R))*Math.sign(e.z)),l}function h(e,t){var n=t.z;t.copy((0,i.a1)(e).multiplyScalar(1/o.R)),t.setZ(n)}function f(e,t,n,r){var o=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return o.v.applyAxisAngle(i.up,-e),o.w.applyAxisAngle(i.up,-e),o}Object.freeze(l);var p=Math.asin(.1*o.R/o.R),d=Math.sin(p),v=Math.cos(p);function m(e,t){return new r.Pa4(e.x*d-e.z*v+o.R*t.y,-e.y-o.R*t.z*v+o.R*t.x*d)}function y(e){return e.x*v}function b(e){var t=3.5/o.m;return e.length()/t}function g(e){var t,n=1/o.m,i=.39+.257*(t=new r.Pa4(e/v,0,0)).x-.044*t.x*t.x;return o.Dt*((1+i)*e)/n}function w(e,t){var n=g(y(e));return b(m(e,t))<=n}function k(e,t){return{c:y(e),s:m(e,t),A:3.5/o.m,B:1/o.m}}function x(e,t){var n=k(e,t),r=n.c,i=n.s,s=n.A,a=n.B,l=(1+o.e)*(r/a);return E(-i.x/s*d-l*v,i.y/s,i.x/s*v-l*d)}function T(e,t){var n=k(e,t),r=n.c,i=n.B,s=(1+o.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l),u=-a*s*c*v-s*v,h=a*s*c*v-s*d;return E(u,a*s*Math.sin(l),h)}function R(e,t){return w(e,t)?x(e,t):T(e,t)}function A(e,t){var n=x(e,t),r=T(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pa4(e/o.m,t/o.m),w:new r.Pa4(-o.R/o.I*t*d,o.R/o.I*(e*d-n*v),o.R/o.I*t*v)}}function P(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*o.R)/(o.R*o.R),s=t.clone().normalize();return(0,i.a1)(s).applyAxisAngle(s,n).multiplyScalar(r)}},"./src/utils/utils.ts":(e,t,n)=>{n.d(t,{$2:()=>y,AA:()=>p,Bh:()=>s,KO:()=>u,Ls:()=>f,NM:()=>d,Xp:()=>v,a1:()=>l,bM:()=>i,up:()=>o,wK:()=>m});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pa4(0,0,0),o=new r.Pa4(0,0,1);function s(e){return new r.Pa4(e.x,e.y,e.z)}var a=new r.Pa4;function l(e){return a.copy(o).cross(e)}var c=new r.Pa4;function u(e){return c.copy(e).normalize()}var h=new r.Pa4;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pa4(1,0,0).applyAxisAngle(o,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return Math.round((e+Number.EPSILON)*100)/100}function m(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}function y(e){return e.x=v(e.x),e.y=v(e.y),e.z=v(e.z),e}},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{c:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),o=n("./src/model/physics/constants.ts");function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var s=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.H.tableY:2.4*i.H.tableX/e;return new r.Pa4(0,-.01*o.R,s*a)}var l=e>1/t.aspectLimit?4.9*i.H.tableY:1.35*i.H.tableX/e;return new r.Pa4(-.01*o.R,0,s*l)}}],function(e,t){for(var n=0;n{n.d(t,{N:()=>d});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),o=n("./src/events/aimevent.ts"),s=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/model/physics/constants.ts"),c=n("./node_modules/three/build/three.module.js");function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"createHelper",value:function(){var e=new c.fHI(l.R,l.R,30*l.R/.5,12,1,!0),t=new c.Kj0(e,this.helpermaterial);return t.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(15*l.R/.5,0,-(.01*l.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new c.fHI(.01*l.R/.5,l.R,l.R,4),n=new c.Kj0(e,t.helpermaterial);return n.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(0,0,.7*l.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,r){var o=new c.fHI(e,n,r,11),s=new c.Kj0(o,t.material);return s.castShadow=!1,s.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-.1)).applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(-r/2-l.R,0,2*l.R)),s}}],function(e,t){for(var n=0;nthis.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset=(0,i.$2)(e),this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower)}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=(0,i.a1)((0,i.AA)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*l.R).setZ(2*this.aim.offset.y*l.R),n=(Math.sin(this.t+Math.PI/2)-1)*3*l.R*(this.aim.power/this.maxPower),r=(0,i.AA)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"intersectsAnything",value:function(e){var t=e.cueball.pos.clone().addScaledVector((0,i.AA)(this.aim.angle),-this.length/2);t.z=this.aim.offset.y;var n=(0,i.AA)(this.aim.angle);return new c.iMs(t,n,0,this.length/2-.6).intersectObjects(e.balls.map(function(e){return e.ballmesh.mesh})).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],f(n.prototype,e),t&&f(n,t),n}()},"./src/view/sliders.ts":(e,t,n)=>{n.d(t,{E:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:1,i=this,o=this.getInputElement(e);o.step="0.001",o.min="0.01",o.max="".concat(r),o.value=t,this.showValue(e,t),o.oninput=function(t){var r=parseFloat(t.target.value);n(r),i.showValue(e,r),i.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],i(n.prototype,e),t&&i(n,t),n}()},"./src/view/tablegeometry.ts":(e,t,n)=>{n.d(t,{H:()=>o});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/diagrams.ts")}]); \ No newline at end of file + }`})),o.uniforms.blitTexture.value=e,o.defines.IS_SRGB=e.colorSpace==d.KI_,o.needsUpdate=!0,s||((s=new d.Kj0(i,o)).frustrumCulled=!1);let a=new d.cPb,l=new d.xsS;l.add(s),n||(n=r=new d.CP7({antialias:!1})),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(l,a);let c=new d.xEZ(n.domElement);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,r&&(r.dispose(),r=null),c}let T={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class x{constructor(){this.pluginCallbacks=[],this.register(function(e){return new N(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new U(e)}),this.register(function(e){return new D(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new B(e)}),this.register(function(e){return new H(e)}),this.register(function(e){return new z(e)}),this.register(function(e){return new K(e)}),this.register(function(e){return new V(e)}),this.register(function(e){return new X(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i=new C,o=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class C{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,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),this.processInput(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let o=this.extensionsUsed,s=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o),c=Object.keys(s);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=_(e.result),o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,5130562,!0);let s=_((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,s.byteLength,!0),a.setUint32(4,1313821514,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+s.byteLength+o.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,s,o,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}let n=this.uids.get(e);return n.get(t)}isNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return!1;let n=new d.Pa4;for(let t=0,r=e.count;t5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new d.Pa4;for(let e=0,t=n.count;e4?r=e.array[i*e.itemSize+n]:(0===n?r=e.getX(i):1===n?r=e.getY(i):2===n?r=e.getZ(i):3===n&&(r=e.getW(i)),!0===e.normalized&&(r=d.M8C.normalize(r,e.array))),t===R.FLOAT?l.setFloat32(c,r,!0):t===R.INT?l.setInt32(c,r,!0):t===R.UNSIGNED_INT?l.setUint32(c,r,!0):t===R.SHORT?l.setInt16(c,r,!0):t===R.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===R.BYTE?l.setInt8(c,r):t===R.UNSIGNED_BYTE&&l.setUint8(c,r),c+=o}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==i&&(u.target=i),i===R.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);let h={id:s.bufferViews.length-1,byteLength:0};return h}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=_(i.result),o={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(o)-1)}})}processAccessor(e,t,n,r){let i,o;let s=this.json;if(e.array.constructor===Float32Array)i=R.FLOAT;else if(e.array.constructor===Int32Array)i=R.INT;else if(e.array.constructor===Uint32Array)i=R.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=R.SHORT;else if(e.array.constructor===Uint16Array)i=R.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=R.BYTE;else if(e.array.constructor===Uint8Array)i=R.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===r||r===1/0)&&(r=e.count),0===r)return null;let a=function(e,t,n){let r={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i4?n=e.array[i*e.itemSize+t]:(0===t?n=e.getX(i):1===t?n=e.getY(i):2===t?n=e.getZ(i):3===t&&(n=e.getW(i)),!0===e.normalized&&(n=d.M8C.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}(e,n,r);void 0!==t&&(o=e===t.index?R.ELEMENT_ARRAY_BUFFER:R.ARRAY_BUFFER);let l=this.processBufferView(e,i,n,r,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(c)-1}processImage(e,t,n,r="image/png"){if(null!==e){let i=this,o=i.cache,s=i.json,a=i.options,l=i.pending;o.images.has(e)||o.images.set(e,{});let c=o.images.get(e),u=r+":flipY/"+n.toString();if(void 0!==c[u])return c[u];s.images||(s.images=[]);let h={mimeType:r},f=I();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==d.wk1&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ti.processBufferViewImage(e)).then(e=>{h.bufferView=e})):void 0!==f.toDataURL?h.uri=f.toDataURL(r):l.push(j(f,r).then(e=>new FileReader().readAsDataURL(e)).then(e=>{h.uri=e}));let v=s.images.push(h)-1;return c[u]=v,v}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:E[e.magFilter],minFilter:E[e.minFilter],wrapS:E[e.wrapS],wrapT:E[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||(r.textures=[]),e instanceof d.EB7&&(e=k(e,t.maxTextureSize));let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive,n=Math.max(t.r,t.g,t.b);if(n>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.ehD&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let o=n.materials.push(r)-1;return t.materials.set(e,o),o}processMesh(e){let t;let n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o0&&(a.extras={},a.extras.targetNames=r)}let v=Array.isArray(e.material);if(v&&0===s.groups.length)return null;let m=v?e.material:[e.material],y=v?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=y.length;e0&&(r.targets=u),null!==s.index){let t=this.getUID(s.index);(void 0!==y[e].start||void 0!==y[e].count)&&(t+=":"+y[e].start+":"+y[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(s.index,s,y[e].start,y[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=this.processMaterial(m[y[e].materialIndex]);null!==i&&(r.material=i),c.push(r)}a.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,a)});let b=r.meshes.push(a)-1;return n.meshes.set(o,b),b}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[A])return;switch(t.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}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];T[r]&&T[r].includes(n)&&(this.extensionsUsed[A]=!0,this.extensionsRequired[A]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.M8C.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=x.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,o=[],s=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let o=t.nodes.push(i)-1;return r.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new d.xsS;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.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."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let s=r.extensions[this.name].lights;s.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}}class L{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer,r=n.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class B{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class H{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class F{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class U{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class D{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer,r=n.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class G{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(S)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class z{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class K{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class V{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer,r=n.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class X{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=new Float32Array(3*e.count),i=new Float32Array(4*e.count),o=new Float32Array(3*e.count),s=new d.yGw,a=new d.Pa4,l=new d._fP,c=new d.Pa4;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),o.set(s.evaluate(t),0),o.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(s.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),o.set(e.values.slice(0,(a+1)*r),0),o.set(s.evaluate(t),(a+1)*r),o.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=o,n},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eL(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function Z(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let J={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_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 q{constructor(e){this.parser=e,this.name=J.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,o)}}class ec{constructor(e){this.parser=e,this.name=J.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eu{constructor(e){this.parser=e,this.name=J.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eh{constructor(e){this.name=J.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,o=e.count,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t})})}}}class ef{constructor(e){this.name=J.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==eT.TRIANGLES&&e.mode!==eT.TRIANGLE_STRIP&&e.mode!==eT.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name],o=i.attributes,s=[],a={};for(let e in o)s.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d.yGw,n=new d.Pa4,o=new d._fP,s=new d.Pa4(1,1,1),l=new d.SPe(e.geometry,e.material,r);for(let e=0;e-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new d.dpR(this.options.manager):this.textureLoader=new d.QRU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.hH6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return e_(i,o,r),eI(o,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,o]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(o,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,h[e*a+1]),a>=3&&o.setZ(t,h[e*a+2]),a>=4&&o.setW(t,h[e*a+3]),a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e],i=r.source,o=t.images[i],s=this.textureLoader;if(o.uri){let e=n.manager.getHandler(o.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){let r=this,i=this.json,o=i.textures[e],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];let l=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=i.samplers||{},a=n[o.sampler]||{};return t.magFilter=eR[a.magFilter]||d.wem,t.minFilter=eR[a.minFilter]||d.D1R,t.wrapS=eA[a.wrapS]||d.rpg,t.wrapT=eA[a.wrapT]||d.rpg,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){let n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=n.images[e],o=self.URL||self.webkitURL,s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then(function(e){a=!0;let t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then(function(e){return new Promise(function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new d.xEZ(e);t.needsUpdate=!0,n(t)}),t.load(d.Zp0.resolveURL(e,r.path),o,void 0,i)})}).then(function(e){var t;return!0===a&&o.revokeObjectURL(s),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),i.extensions[J.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[J.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[J.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.UY4,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.nls,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return d.Wid}loadMaterial(e){let t;let n=this,r=this.json,i=this.extensions,o=r.materials[e],s={},a=o.extensions||{},l=[];if(a[J.KHR_MATERIALS_UNLIT]){let e=i[J.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(s,o,n))}else{let r=o.pbrMetallicRoughness||{};if(s.color=new d.Ilk(1,1,1),s.opacity=1,Array.isArray(r.baseColorFactor)){let e=r.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],d.GUF),s.opacity=e[3]}void 0!==r.baseColorTexture&&l.push(n.assignTexture(s,"map",r.baseColorTexture,d.KI_)),s.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,s.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(n.assignTexture(s,"metalnessMap",r.metallicRoughnessTexture)),l.push(n.assignTexture(s,"roughnessMap",r.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}!0===o.doubleSided&&(s.side=d.ehD);let c=o.alphaMode||eM.OPAQUE;if(c===eM.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===eM.MASK&&(s.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"normalMap",o.normalTexture)),s.normalScale=new d.FM8(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(s.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==d.vBJ){let e=o.emissiveFactor;s.emissive=new d.Ilk().setRGB(e[0],e[1],e[2],d.GUF)}return void 0!==o.emissiveTexture&&t!==d.vBJ&&l.push(n.assignTexture(s,"emissiveMap",o.emissiveTexture,d.KI_)),Promise.all(l).then(function(){let r=new t(s);return o.name&&(r.name=o.name),eI(r,o),n.associations.set(r,{materials:e}),o.extensions&&e_(i,r,o),r})}createUniqueName(e){let t=d.iUV.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache,i=[];for(let o=0,s=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new d.ZAu:1===t.length?t[0]:new d.Tme)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof d.F5T||e instanceof d.xEZ)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let o;let s=[],a=e.name?e.name:e.uuid,l=[];switch(eS[i.path]===eS.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),eS[i.path]){case eS.weights:o=d.dUE;break;case eS.rotation:o=d.iLg;break;case eS.position:case eS.scale:o=d.yC1;break;default:o=1===n.itemSize?d.dUE:d.yC1}let c=void 0!==r.interpolation?eO[r.interpolation]:d.NMF,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e3&&void 0!==arguments[3]?arguments[3]:function(){};new W().load(e,function(e){e.scene.scale.set(y.R/.5,y.R/.5,y.R/.5),e.scene.matrixAutoUpdate=!1,e.scene.visible=n,e.scene.updateMatrix(),t.add(e.scene),r()},function(e){return console.log(e.loaded+" bytes loaded")},eH)}var eU=n("./src/view/tablegeometry.ts");function eD(e,t){for(var n=0;nthis.radius-y.R){var r=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-y.R/2&&e.vel.addScaledVector(r,7*y.R*t*y.g),0>e.vel.dot(r)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=r.x*e.vel.length()/2,e.vel.y=r.y*e.vel.length()/2)}var i=this.restingDepth(e);n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*y.R/.5,t,n).position.setZ(-(.25*y.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new d.fHI(t,t,n,16),s=new d.Kj0(o,i);return s.position.copy(e),s.geometry.applyMatrix4(new d.yGw().identity().makeRotationAxis(new d.Pa4(1,0,0),Math.PI/2)),r.add(s),s}},{key:"addCushions",value:function(e,t){var n=10*y.R/.5;this.plane(new d.Pa4(0,0,-y.R-n/2),2*eU.H.X,2*eU.H.Y,n,e,this.cloth);var r=1*y.R/.5,i=.75*y.R/.5,o=-(.25*y.R)/.5/2,s=eU.H.X,a=eU.H.Y,l=Math.abs(eq.pockets.pocketNW.knuckleNE.pos.x-eq.pockets.pocketN.knuckleNW.pos.x),c=Math.abs(eq.pockets.pocketNW.knuckleSW.pos.y-eq.pockets.pocketSW.knuckleNW.pos.y);t||(l=2*eU.H.Y,c=2*eU.H.Y+4*y.R),this.plane(new d.Pa4(s+r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s-r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(-s/2,-a-r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,-a-r/2,o),l,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,s=new d.DvJ(t,n,r),a=new d.Kj0(s,o);a.receiveShadow=!0,a.position.copy(e),i.add(a)}}],eQ(n.prototype,e),t&&eQ(n,t),n}(),e1=n("./src/events/watchevent.ts");function e2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.Pot="Pot",e.Cushion="Cushion",e.Collision="Collision",e.Hit="Hit"}(a||(a={}));var e4=function(){var e;function t(e,n,r,i){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),e2(this,"type",void 0),e2(this,"timestamp",void 0),e2(this,"ballA",null),e2(this,"ballB",null),e2(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=r,this.incidentSpeed=i,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,o=!0,s=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n-eU.H.tableX&&n.overlapsAny(r,t);)r.x-=y.R/8;t.pos.copy(r),t.state=eX.Z.Stationary}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),tg(ty(r=i.call(this,e)),"delay",void 0),tg(ty(r),"shots",void 0),tg(ty(r),"firstShot",void 0),tg(ty(r),"timer",void 0),tg(ty(r),"init",void 0),r.init=t,r.shots=tT(n),r.firstShot=r.shots[0],r.delay=a,r.container.table.showTraces(!0),r.container.table.updateFromShortSerialised(r.init),s){var l=new td.l(t,n);l.retry=!0,r.container.eventQueue.push(l)}else r.container.view.camera.forceMode(r.container.view.camera.topView),r.playNextShot(1.5*r.delay);return r}return n=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===c.t.RERACK){tv.K.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var r=e8.f.fromJson(n);this.container.table.cueball=this.container.table.balls[r.i],this.container.table.cueball.pos.copy(r.pos),this.container.table.cue.aim=r,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new e6.O(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=tT(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=e8.f.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new tP(this.container)}}],tb(o.prototype,n),r&&tb(o,r),o}(tc);function tR(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tz.h_,o=e.futurePosition(n);if(t.willBounceLong(o,r)){var s=o.y>eU.H.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(s,e,i)}if(t.willBounceShort(o,r)){var a=o.x>eU.H.tableX?0:Math.PI;return t.bounceIn(a,e,i)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(eq.pockets.pocketNW.knuckleSW.pos.y,eq.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(eU.H.Y,-eU.H.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(eq.pockets.pocketNW.knuckleNE.pos.x,eq.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(eq.pockets.pocketN.knuckleNE.pos.x,eq.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-eU.H.X,eU.H.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xeU.H.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yeU.H.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,tz.ZI)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(tV.willCollide(e,t,n)){var r=tV.collide(e,t);return this.outcome.push(e4.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*y.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return eX.e.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&tY(n.prototype,e),t&&tY(n,t),n}();function tJ(e,t){for(var n=0;n0){if(this.previousPotRed)this.previousPotRed=!1,this.respot(e);else if(e4.onlyRedsPotted(e))this.previousPotRed=!0;else if(1===t){var n=e4.pots(e)[0].id;n>1&&this.container.table.balls.filter(function(e){return e.id0}).some(function(e){return e.onTable()})&&this.respot(e)}else this.respot(e)}return t2(t4(o.prototype),"update",this).call(this,e)}},{key:"respot",value:function(e){var t=this.respotAllPottedColours(e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new e1.g(n);this.container.sendEvent(r),this.container.recoder.record(r)}}},{key:"respotAllPottedColours",value:function(e){var t=this;return e4.pots(e).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(e){return e5.respot(e,t.container.table)})}}],t0(o.prototype,n),r&&t0(o,r),o}(tQ);function t8(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],ns(n.prototype,e),t&&ns(n,t),n}();function nc(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=d.Hmr.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(d.M8C.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],nc(n.prototype,e),t&&nc(n,t),n}();function nf(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function np(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==c.t.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],nm(n.prototype,e),t&&nm(n,t),n}(),ng=n("./src/view/sliders.ts"),nw=n("./node_modules/jsoncrush/JSONCrush.js");function nk(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart))}},{key:"state",value:function(e,t){return{init:e,shots:t}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=e4.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last())}},{key:"lastShotLink",value:function(e,t){var n="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),r=JSON.stringify(this.lastShot());this.generateLink(n,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n="break(".concat(t.shots.length,")"),r=JSON.stringify(t),i=nw.Z.crush(r);this.generateLink(n,i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(e.shots.length,")"),n=JSON.stringify(e),r=nw.Z.crush(n);this.generateLink(t,r)}},{key:"generateLink",value:function(e,t){var n="".concat(this.replayUrl).concat(encodeURIComponent(t)),r='').concat(e,"");this.container.eventQueue.push(new tD.s(null,"".concat(r)))}}],nk(n.prototype,e),t&&nk(n,t),n}();function nR(e,t){for(var n=0;n').concat(e,"")));r.push(new tD.s(null,s))})},this.redo.onclick=function(e){var r=new td.l(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new p),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],nj(n.prototype,e),t&&nj(n,t),n}();function nL(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,l=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),nB(this,"table",void 0),nB(this,"view",void 0),nB(this,"controller",void 0),nB(this,"inputQueue",[]),nB(this,"eventQueue",[]),nB(this,"keyboard",void 0),nB(this,"sound",void 0),nB(this,"chat",void 0),nB(this,"sliders",void 0),nB(this,"recoder",void 0),nB(this,"id",""),nB(this,"isSinglePlayer",!0),nB(this,"rules",void 0),nB(this,"menu",void 0),nB(this,"last",performance.now()),nB(this,"step",.001953125),nB(this,"broadcast",void 0),nB(this,"log",void 0),nB(this,"sendChat",function(e){l.sendEvent(new tD.s(l.id,e))}),nB(this,"throttle",new nb(200,function(e){l.broadcast(e)})),nB(this,"lastEventTime",performance.now()),this.log=t,this.rules=nI.create(i,this),this.table=this.rules.table(),this.view=new t9(e,s,this.table,r,this.rules.asset()),this.table.cue.aimInputs=new nl(this),this.keyboard=o,this.sound=new nh(this.view.camera.camera,r),this.chat=new nv(this.sendChat),this.sliders=new ng.E,this.recoder=new nx(this),this.id=a,this.menu=new nN(this),this.table.addToScene(this.view.scene),this.updateController(new nn(this))}return e=[{key:"sendEvent",value:function(e){this.throttle.send(e)}},{key:"advance",value:function(e){for(var t=Math.floor(e/this.step),n=t*this.step,r=this.table.allStationary(),i=0;i0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{var r,i,o,s,a,l,c,u,h,f=n("./src/model/physics/physics.ts"),p=n("./node_modules/three/build/three.module.js");function d(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:.9,o={dx:n-e,dy:r-t},s={x:o.dx*i+e,y:o.dy*i+t},a={dx:n-s.x,dy:r-s.y};this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(s.x,s.y),this.context.moveTo(s.x+.5*a.dy,s.y-.5*a.dx),this.context.lineTo(s.x-.5*a.dy,s.y+.5*a.dx),this.context.lineTo(n,r),this.context.closePath(),this.context.stroke()}}],d(n.prototype,e),t&&d(n,t),n}();function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{n.d(t,{Y:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{f:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function a(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){for(var n=0;n{n.d(t,{Z:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{l:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{s:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r;n.d(t,{t:()=>r}),function(e){e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK"}(r||(r={}))},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{O:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{I:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{N:()=>l});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),o=n.n(i);function s(e,t){for(var n=0;nMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),o=[];return t.forEach(function(t){var s=performance.now()-e.pressed[t];o.push(new r.I(i?s/3:s,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return o.push(new r.I(e.released[t],t+"Up"))}),this.released={},o}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),o()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}})}}],s(n.prototype,e),t&&s(n,t),n}()},"./src/events/placeballevent.ts":(e,t,n)=>{n.d(t,{I:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts");function s(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){for(var n=0;n{n.d(t,{K:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{g:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{e:()=>m,Z:()=>r});var r,i=n("./src/utils/utils.ts"),o=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),a=n("./src/model/physics/constants.ts");function l(e,t){for(var n=0;nMath.PI/32?.01*a.R:a.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var o=this.geometry.drawRange.count;0!==o&&n1&&i<1e-4&&o--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,o))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],l(n.prototype,e),t&&l(n,t),n}();function h(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(i.bM),this.rvel.copy(i.bM),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,o.E9)(this.vel,this.rvel).length(){n.d(t,{Dt:()=>c,Ew:()=>v,G3:()=>w,Hz:()=>i,I:()=>o,Mz:()=>r,R:()=>f,Xm:()=>k,_5:()=>u,dE:()=>y,e:()=>p,f7:()=>g,fN:()=>m,g:()=>s,m:()=>h,mu:()=>a,zq:()=>b,zv:()=>l});var r,i,o,s=9.8,a=.00985,l=.105,c=.8,u=.024,h=.23,f=.03275,p=.86;function d(){r=a*h*s*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*s,o=.4*h*f*f}function v(e){f=e,d()}function m(e){h=e,d()}function y(e){a=e,d()}function b(e){u=e,d()}function g(e){l=e}function w(e){p=e}function k(e){c=e}d()},"./src/model/physics/physics.ts":(e,t,n)=>{n.d(t,{E9:()=>a,Fn:()=>R,IT:()=>h,NP:()=>g,QC:()=>u,Vp:()=>c,WL:()=>P,ZI:()=>f,al:()=>b,c0:()=>y,h_:()=>A,s0:()=>m,vZ:()=>w});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),o=n("./src/model/physics/constants.ts"),s=new r.Pa4;function a(e,t){return s.copy(e).addScaledVector((0,i.a1)(t),o.R)}var l={v:new r.Pa4,w:new r.Pa4};function c(e,t){var n=a(e,t).setZ(0);return l.v.copy((0,i.KO)(n).multiplyScalar(-o.zv*o.g)),l.w.copy((0,i.KO)((0,i.a1)(n)).multiplyScalar(2.5*o.zv*o.g/o.R)),l.w.setZ(-2.5*(o.Mz/(o.R*o.R))*Math.sign(t.z)),l}function u(e){var t=new r.Pa4(e.x,e.y,0).length(),n=5/7*o.Hz/(o.m*o.R)/t,i=5/7*o.Hz/(o.m*o.R*o.R)/t;return l.v.set(-n*e.y,n*e.x,0),l.w.set(-i*e.x,-i*e.y,-2.5*(o.Mz/(o.m*o.R*o.R))*Math.sign(e.z)),l}function h(e,t){var n=t.z;t.copy((0,i.a1)(e).multiplyScalar(1/o.R)),t.setZ(n)}function f(e,t,n,r){var o=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return o.v.applyAxisAngle(i.up,-e),o.w.applyAxisAngle(i.up,-e),o}Object.freeze(l);var p=Math.asin(.1*o.R/o.R),d=Math.sin(p),v=Math.cos(p);function m(e,t){return new r.Pa4(e.x*d-e.z*v+o.R*t.y,-e.y-o.R*t.z*v+o.R*t.x*d)}function y(e){return e.x*v}function b(e){var t=3.5/o.m;return e.length()/t}function g(e){var t,n=1/o.m,i=.39+.257*(t=new r.Pa4(e/v,0,0)).x-.044*t.x*t.x;return o.Dt*((1+i)*e)/n}function w(e,t){var n=g(y(e));return b(m(e,t))<=n}function k(e,t){return{c:y(e),s:m(e,t),A:3.5/o.m,B:1/o.m}}function T(e,t){var n=k(e,t),r=n.c,i=n.s,s=n.A,a=n.B,l=(1+o.e)*(r/a);return E(-i.x/s*d-l*v,i.y/s,i.x/s*v-l*d)}function x(e,t){var n=k(e,t),r=n.c,i=n.B,s=(1+o.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l),u=-a*s*c*v-s*v,h=a*s*c*v-s*d;return E(u,a*s*Math.sin(l),h)}function R(e,t){return w(e,t)?T(e,t):x(e,t)}function A(e,t){var n=T(e,t),r=x(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pa4(e/o.m,t/o.m),w:new r.Pa4(-o.R/o.I*t*d,o.R/o.I*(e*d-n*v),o.R/o.I*t*v)}}function P(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*o.R)/(o.R*o.R),s=t.clone().normalize();return(0,i.a1)(s).applyAxisAngle(s,n).multiplyScalar(r)}},"./src/utils/utils.ts":(e,t,n)=>{n.d(t,{$2:()=>y,AA:()=>p,Bh:()=>s,KO:()=>u,Ls:()=>f,NM:()=>d,Xp:()=>v,a1:()=>l,bM:()=>i,up:()=>o,wK:()=>m});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pa4(0,0,0),o=new r.Pa4(0,0,1);function s(e){return new r.Pa4(e.x,e.y,e.z)}var a=new r.Pa4;function l(e){return a.copy(o).cross(e)}var c=new r.Pa4;function u(e){return c.copy(e).normalize()}var h=new r.Pa4;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pa4(1,0,0).applyAxisAngle(o,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return Math.round((e+Number.EPSILON)*100)/100}function m(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}function y(e){return e.x=v(e.x),e.y=v(e.y),e.z=v(e.z),e}},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{c:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),o=n("./src/model/physics/constants.ts");function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var s=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.H.tableY:2.4*i.H.tableX/e;return new r.Pa4(0,-.01*o.R,s*a)}var l=e>1/t.aspectLimit?4.9*i.H.tableY:1.35*i.H.tableX/e;return new r.Pa4(-.01*o.R,0,s*l)}}],function(e,t){for(var n=0;n{n.d(t,{N:()=>d});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),o=n("./src/events/aimevent.ts"),s=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/model/physics/constants.ts"),c=n("./node_modules/three/build/three.module.js");function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"createHelper",value:function(){var e=new c.fHI(l.R,l.R,30*l.R/.5,12,1,!0),t=new c.Kj0(e,this.helpermaterial);return t.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(15*l.R/.5,0,-(.01*l.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new c.fHI(.01*l.R/.5,l.R,l.R,4),n=new c.Kj0(e,t.helpermaterial);return n.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(0,0,.7*l.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,r){var o=new c.fHI(e,n,r,11),s=new c.Kj0(o,t.material);return s.castShadow=!1,s.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-.1)).applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(-r/2-l.R,0,2*l.R)),s}}],function(e,t){for(var n=0;nthis.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset=(0,i.$2)(e),this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower)}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=(0,i.a1)((0,i.AA)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*l.R).setZ(2*this.aim.offset.y*l.R),n=(Math.sin(this.t+Math.PI/2)-1)*3*l.R*(this.aim.power/this.maxPower),r=(0,i.AA)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"intersectsAnything",value:function(e){var t=e.cueball.pos.clone().addScaledVector((0,i.AA)(this.aim.angle),-this.length/2);t.z=this.aim.offset.y;var n=(0,i.AA)(this.aim.angle);return new c.iMs(t,n,0,this.length/2-.6).intersectObjects(e.balls.map(function(e){return e.ballmesh.mesh})).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],f(n.prototype,e),t&&f(n,t),n}()},"./src/view/sliders.ts":(e,t,n)=>{n.d(t,{E:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:1,i=this,o=this.getInputElement(e);o.step="0.001",o.min="0.01",o.max="".concat(r),o.value=t,this.showValue(e,t),o.oninput=function(t){var r=parseFloat(t.target.value);n(r),i.showValue(e,r),i.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],i(n.prototype,e),t&&i(n,t),n}()},"./src/view/tablegeometry.ts":(e,t,n)=>{n.d(t,{H:()=>o});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/diagrams.ts")}]); \ No newline at end of file diff --git a/dist/index.css b/dist/index.css index bd967c73..76d58620 100644 --- a/dist/index.css +++ b/dist/index.css @@ -40,13 +40,20 @@ p { height: 83%; cursor: none; caret-color: transparent; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; } .view3d:focus { outline-width: 0; + outline: none; } canvas { border-radius: 5px; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; } .panel { diff --git a/dist/index.js b/dist/index.js index df4456cc..c16eabbc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,4 +1,4 @@ -"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[826],{"./src/container/container.ts":(e,t,n)=>{let r,i,o,s;n.d(t,{W:()=>nB});var a,l=n("./src/events/gameevent.ts"),c=n("./src/events/eventtype.ts");function u(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*y.R){var i=100*(10*y.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,v.AA)(e.angle),-(18*y.R)),t),this.camera.position.z=n,this.camera.up=v.up,this.camera.lookAt(e.pos.clone().addScaledVector(v.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*y.R?e/8:e,this.height=d.M8C.clamp(this.height+e,6*y.R,120*y.R),this.height>110*y.R&&this.suggestMode(this.topView),this.height<105*y.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],b(n.prototype,e),t&&b(n,t),n}();function k(e,t=1/0,n=null){i||(i=new d._12(2,2,1,1)),o||(o=new d.jyz({uniforms:{blitTexture:new d.xWb(e)},vertexShader:` +"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[826],{"./src/container/container.ts":(e,t,n)=>{let r,i,o,s;n.d(t,{W:()=>nH});var a,l=n("./src/events/gameevent.ts"),c=n("./src/events/eventtype.ts");function u(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*y.R){var i=100*(10*y.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,v.AA)(e.angle),-(18*y.R)),t),this.camera.position.z=n,this.camera.up=v.up,this.camera.lookAt(e.pos.clone().addScaledVector(v.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*y.R?e/8:e,this.height=d.M8C.clamp(this.height+e,6*y.R,120*y.R),this.height>110*y.R&&this.suggestMode(this.topView),this.height<105*y.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],b(n.prototype,e),t&&b(n,t),n}();function k(e,t=1/0,n=null){i||(i=new d._12(2,2,1,1)),o||(o=new d.jyz({uniforms:{blitTexture:new d.xWb(e)},vertexShader:` varying vec2 vUv; void main(){ vUv = uv; @@ -15,4 +15,4 @@ #else gl_FragColor = texture2D( blitTexture, vUv); #endif - }`})),o.uniforms.blitTexture.value=e,o.defines.IS_SRGB=e.colorSpace==d.KI_,o.needsUpdate=!0,s||((s=new d.Kj0(i,o)).frustrumCulled=!1);let a=new d.cPb,l=new d.xsS;l.add(s),n||(n=r=new d.CP7({antialias:!1})),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(l,a);let c=new d.xEZ(n.domElement);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,r&&(r.dispose(),r=null),c}let T={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class R{constructor(){this.pluginCallbacks=[],this.register(function(e){return new N(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new U(e)}),this.register(function(e){return new D(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new B(e)}),this.register(function(e){return new H(e)}),this.register(function(e){return new z(e)}),this.register(function(e){return new K(e)}),this.register(function(e){return new V(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i=new C,o=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class C{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,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),this.processInput(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let o=this.extensionsUsed,s=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o),c=Object.keys(s);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=_(e.result),o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,5130562,!0);let s=_((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,s.byteLength,!0),a.setUint32(4,1313821514,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+s.byteLength+o.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,s,o,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}let n=this.uids.get(e);return n.get(t)}isNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return!1;let n=new d.Pa4;for(let t=0,r=e.count;t5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new d.Pa4;for(let e=0,t=n.count;e4?r=e.array[i*e.itemSize+n]:(0===n?r=e.getX(i):1===n?r=e.getY(i):2===n?r=e.getZ(i):3===n&&(r=e.getW(i)),!0===e.normalized&&(r=d.M8C.normalize(r,e.array))),t===A.FLOAT?l.setFloat32(c,r,!0):t===A.INT?l.setInt32(c,r,!0):t===A.UNSIGNED_INT?l.setUint32(c,r,!0):t===A.SHORT?l.setInt16(c,r,!0):t===A.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===A.BYTE?l.setInt8(c,r):t===A.UNSIGNED_BYTE&&l.setUint8(c,r),c+=o}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==i&&(u.target=i),i===A.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);let h={id:s.bufferViews.length-1,byteLength:0};return h}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=_(i.result),o={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(o)-1)}})}processAccessor(e,t,n,r){let i,o;let s=this.json;if(e.array.constructor===Float32Array)i=A.FLOAT;else if(e.array.constructor===Int32Array)i=A.INT;else if(e.array.constructor===Uint32Array)i=A.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=A.SHORT;else if(e.array.constructor===Uint16Array)i=A.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=A.BYTE;else if(e.array.constructor===Uint8Array)i=A.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),void 0===r&&(r=e.count),0===r)return null;let a=function(e,t,n){let r={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i4?n=e.array[i*e.itemSize+t]:(0===t?n=e.getX(i):1===t?n=e.getY(i):2===t?n=e.getZ(i):3===t&&(n=e.getW(i)),!0===e.normalized&&(n=d.M8C.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}(e,n,r);void 0!==t&&(o=e===t.index?A.ELEMENT_ARRAY_BUFFER:A.ARRAY_BUFFER);let l=this.processBufferView(e,i,n,r,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(c)-1}processImage(e,t,n,r="image/png"){if(null!==e){let i=this,o=i.cache,s=i.json,a=i.options,l=i.pending;o.images.has(e)||o.images.set(e,{});let c=o.images.get(e),u=r+":flipY/"+n.toString();if(void 0!==c[u])return c[u];s.images||(s.images=[]);let h={mimeType:r},f=I();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==d.wk1&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ti.processBufferViewImage(e)).then(e=>{h.bufferView=e})):void 0!==f.toDataURL?h.uri=f.toDataURL(r):l.push(j(f,r).then(e=>new FileReader().readAsDataURL(e)).then(e=>{h.uri=e}));let v=s.images.push(h)-1;return c[u]=v,v}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:E[e.magFilter],minFilter:E[e.minFilter],wrapS:E[e.wrapS],wrapT:E[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||(r.textures=[]),e instanceof d.EB7&&(e=k(e,t.maxTextureSize));let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive,n=Math.max(t.r,t.g,t.b);if(n>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.ehD&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let o=n.materials.push(r)-1;return t.materials.set(e,o),o}processMesh(e){let t;let n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o0&&(a.extras={},a.extras.targetNames=r)}let v=Array.isArray(e.material);if(v&&0===s.groups.length)return null;let m=v?e.material:[e.material],y=v?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=y.length;e0&&(r.targets=u),null!==s.index){let t=this.getUID(s.index);(void 0!==y[e].start||void 0!==y[e].count)&&(t+=":"+y[e].start+":"+y[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(s.index,s,y[e].start,y[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=this.processMaterial(m[y[e].materialIndex]);null!==i&&(r.material=i),c.push(r)}a.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,a)});let b=r.meshes.push(a)-1;return n.meshes.set(o,b),b}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[x])return;switch(t.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}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];T[r]&&T[r].includes(n)&&(this.extensionsUsed[x]=!0,this.extensionsRequired[x]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.M8C.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=R.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,o=[],s=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let o=t.nodes.push(i)-1;return r.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new d.xsS;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.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."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let s=r.extensions[this.name].lights;s.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}}class L{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer,r=n.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class B{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class H{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class F{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class U{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class D{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer,r=n.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class G{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(P)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class z{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class K{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class V{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer,r=n.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}function X(e,t){if(t===d.WwZ)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==d.z$h&&t!==d.UlW)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let n=e.getIndex();if(null===n){let t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;eMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),o.set(s.evaluate(t),0),o.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(s.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),o.set(e.values.slice(0,(a+1)*r),0),o.set(s.evaluate(t),(a+1)*r),o.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=o,n},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eN(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function W(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let J={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_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 Z{constructor(e){this.parser=e,this.name=J.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,o)}}class el{constructor(e){this.parser=e,this.name=J.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class ec{constructor(e){this.parser=e,this.name=J.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eu{constructor(e){this.name=J.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,o=e.count,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t})})}}}class eh{constructor(e){this.name=J.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==ek.TRIANGLES&&e.mode!==ek.TRIANGLE_STRIP&&e.mode!==ek.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name],o=i.attributes,s=[],a={};for(let e in o)s.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d.yGw,n=new d.Pa4,o=new d._fP,s=new d.Pa4(1,1,1),l=new d.SPe(e.geometry,e.material,r);for(let e=0;e-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new d.dpR(this.options.manager):this.textureLoader=new d.QRU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.hH6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return eM(i,o,r),e_(o,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,o]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(o,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,h[e*a+1]),a>=3&&o.setZ(t,h[e*a+2]),a>=4&&o.setW(t,h[e*a+3]),a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e],i=r.source,o=t.images[i],s=this.textureLoader;if(o.uri){let e=n.manager.getHandler(o.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){let r=this,i=this.json,o=i.textures[e],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];let l=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=i.samplers||{},a=n[o.sampler]||{};return t.magFilter=eR[a.magFilter]||d.wem,t.minFilter=eR[a.minFilter]||d.D1R,t.wrapS=eA[a.wrapS]||d.rpg,t.wrapT=eA[a.wrapT]||d.rpg,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){let n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=n.images[e],o=self.URL||self.webkitURL,s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then(function(e){a=!0;let t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then(function(e){return new Promise(function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new d.xEZ(e);t.needsUpdate=!0,n(t)}),t.load(d.Zp0.resolveURL(e,r.path),o,void 0,i)})}).then(function(e){var t;return!0===a&&o.revokeObjectURL(s),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),i.extensions[J.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[J.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[J.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.UY4,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.nls,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return d.Wid}loadMaterial(e){let t;let n=this,r=this.json,i=this.extensions,o=r.materials[e],s={},a=o.extensions||{},l=[];if(a[J.KHR_MATERIALS_UNLIT]){let e=i[J.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(s,o,n))}else{let r=o.pbrMetallicRoughness||{};if(s.color=new d.Ilk(1,1,1),s.opacity=1,Array.isArray(r.baseColorFactor)){let e=r.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],d.GUF),s.opacity=e[3]}void 0!==r.baseColorTexture&&l.push(n.assignTexture(s,"map",r.baseColorTexture,d.KI_)),s.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,s.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(n.assignTexture(s,"metalnessMap",r.metallicRoughnessTexture)),l.push(n.assignTexture(s,"roughnessMap",r.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}!0===o.doubleSided&&(s.side=d.ehD);let c=o.alphaMode||eO.OPAQUE;if(c===eO.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===eO.MASK&&(s.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"normalMap",o.normalTexture)),s.normalScale=new d.FM8(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(s.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==d.vBJ){let e=o.emissiveFactor;s.emissive=new d.Ilk().setRGB(e[0],e[1],e[2],d.GUF)}return void 0!==o.emissiveTexture&&t!==d.vBJ&&l.push(n.assignTexture(s,"emissiveMap",o.emissiveTexture,d.KI_)),Promise.all(l).then(function(){let r=new t(s);return o.name&&(r.name=o.name),e_(r,o),n.associations.set(r,{materials:e}),o.extensions&&eM(i,r,o),r})}createUniqueName(e){let t=d.iUV.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache,i=[];for(let o=0,s=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new d.ZAu:1===t.length?t[0]:new d.Tme)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof d.F5T||e instanceof d.xEZ)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let o;let s=[],a=e.name?e.name:e.uuid,l=[];switch(eS[i.path]===eS.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),eS[i.path]){case eS.weights:o=d.dUE;break;case eS.rotation:o=d.iLg;break;case eS.position:case eS.scale:o=d.yC1;break;default:o=1===n.itemSize?d.dUE:d.yC1}let c=void 0!==r.interpolation?eP[r.interpolation]:d.NMF,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e3&&void 0!==arguments[3]?arguments[3]:function(){};new Y().load(e,function(e){e.scene.scale.set(y.R/.5,y.R/.5,y.R/.5),e.scene.matrixAutoUpdate=!1,e.scene.visible=n,e.scene.updateMatrix(),t.add(e.scene),r()},function(e){return console.log(e.loaded+" bytes loaded")},eB)}var eF=n("./src/view/tablegeometry.ts");function eU(e,t){for(var n=0;nthis.radius-y.R){var r=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-y.R/2&&e.vel.addScaledVector(r,7*y.R*t*y.g),0>e.vel.dot(r)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=r.x*e.vel.length()/2,e.vel.y=r.y*e.vel.length()/2)}var i=this.restingDepth(e);n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*y.R/.5,t,n).position.setZ(-(.25*y.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new d.fHI(t,t,n,16),s=new d.Kj0(o,i);return s.position.copy(e),s.geometry.applyMatrix4(new d.yGw().identity().makeRotationAxis(new d.Pa4(1,0,0),Math.PI/2)),r.add(s),s}},{key:"addCushions",value:function(e,t){var n=10*y.R/.5;this.plane(new d.Pa4(0,0,-y.R-n/2),2*eF.H.X,2*eF.H.Y,n,e,this.cloth);var r=1*y.R/.5,i=.75*y.R/.5,o=-(.25*y.R)/.5/2,s=eF.H.X,a=eF.H.Y,l=Math.abs(eZ.pockets.pocketNW.knuckleNE.pos.x-eZ.pockets.pocketN.knuckleNW.pos.x),c=Math.abs(eZ.pockets.pocketNW.knuckleSW.pos.y-eZ.pockets.pocketSW.knuckleNW.pos.y);t||(l=2*eF.H.Y,c=2*eF.H.Y+4*y.R),this.plane(new d.Pa4(s+r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s-r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(-s/2,-a-r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,-a-r/2,o),l,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,s=new d.DvJ(t,n,r),a=new d.Kj0(s,o);a.receiveShadow=!0,a.position.copy(e),i.add(a)}}],eq(n.prototype,e),t&&eq(n,t),n}(),e0=n("./src/events/watchevent.ts");function e1(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.Pot="Pot",e.Cushion="Cushion",e.Collision="Collision",e.Hit="Hit"}(a||(a={}));var e2=function(){var e;function t(e,n,r,i){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),e1(this,"type",void 0),e1(this,"timestamp",void 0),e1(this,"ballA",null),e1(this,"ballB",null),e1(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=r,this.incidentSpeed=i,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,o=!0,s=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n-eF.H.tableX&&n.overlapsAny(r,t);)r.x-=y.R/8;t.pos.copy(r),t.state=eV.Z.Stationary}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),tb(tm(r=i.call(this,e)),"delay",void 0),tb(tm(r),"shots",void 0),tb(tm(r),"firstShot",void 0),tb(tm(r),"timer",void 0),tb(tm(r),"init",void 0),r.init=t,r.shots=tk(n),r.firstShot=r.shots[0],r.delay=a,r.container.table.showTraces(!0),r.container.table.updateFromShortSerialised(r.init),s){var l=new tp.l(t,n);l.retry=!0,r.container.eventQueue.push(l)}else r.container.view.camera.forceMode(r.container.view.camera.topView),r.playNextShot(1.5*r.delay);return r}return n=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===c.t.RERACK){td.K.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var r=e5.f.fromJson(n);this.container.table.cueball=this.container.table.balls[r.i],this.container.table.cueball.pos.copy(r.pos),this.container.table.cue.aim=r,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new e8.O(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=tk(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=e5.f.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new tE(this.container)}}],ty(o.prototype,n),r&&ty(o,r),o}(tl);function tR(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tG.h_,o=e.futurePosition(n);if(t.willBounceLong(o,r)){var s=o.y>eF.H.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(s,e,i)}if(t.willBounceShort(o,r)){var a=o.x>eF.H.tableX?0:Math.PI;return t.bounceIn(a,e,i)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(eZ.pockets.pocketNW.knuckleSW.pos.y,eZ.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(eF.H.Y,-eF.H.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(eZ.pockets.pocketNW.knuckleNE.pos.x,eZ.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(eZ.pockets.pocketN.knuckleNE.pos.x,eZ.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-eF.H.X,eF.H.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xeF.H.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yeF.H.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,tG.ZI)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(tK.willCollide(e,t,n)){var r=tK.collide(e,t);return this.outcome.push(e2.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*y.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return eV.e.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&tX(n.prototype,e),t&&tX(n,t),n}();function tJ(e,t){for(var n=0;n0){if(this.previousPotRed)this.previousPotRed=!1,this.respot(e);else if(e2.onlyRedsPotted(e))this.previousPotRed=!0;else if(1===t){var n=e2.pots(e)[0].id;n>1&&this.container.table.balls.filter(function(e){return e.id0}).some(function(e){return e.onTable()})&&this.respot(e)}else this.respot(e)}return t1(t2(o.prototype),"update",this).call(this,e)}},{key:"respot",value:function(e){var t=this.respotAllPottedColours(e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new e0.g(n);this.container.sendEvent(r),this.container.recoder.record(r)}}},{key:"respotAllPottedColours",value:function(e){var t=this;return e2.pots(e).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(e){return e3.respot(e,t.container.table)})}}],t$(o.prototype,n),r&&t$(o,r),o}(tq);function t5(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],no(n.prototype,e),t&&no(n,t),n}();function nl(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=d.Hmr.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(d.M8C.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],nl(n.prototype,e),t&&nl(n,t),n}();function nh(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function nf(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==c.t.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],nv(n.prototype,e),t&&nv(n,t),n}(),nb=n("./src/view/sliders.ts"),ng=n("./node_modules/jsoncrush/JSONCrush.js");function nw(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart))}},{key:"state",value:function(e,t){return{init:e,shots:t}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=e2.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last())}},{key:"lastShotLink",value:function(e,t){var n="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),r=JSON.stringify(this.lastShot());this.generateLink(n,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n="break(".concat(t.shots.length,")"),r=JSON.stringify(t),i=ng.Z.crush(r);this.generateLink(n,i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(e.shots.length,")"),n=JSON.stringify(e),r=ng.Z.crush(n);this.generateLink(t,r)}},{key:"generateLink",value:function(e,t){var n="".concat(this.replayUrl).concat(encodeURIComponent(t)),r='').concat(e,"");this.container.eventQueue.push(new tU.s(null,"".concat(r)))}}],nw(n.prototype,e),t&&nw(n,t),n}();function nR(e,t){for(var n=0;n').concat(e,"")));r.push(new tU.s(null,s))})},this.redo.onclick=function(e){var r=new tp.l(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new p),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],nI(n.prototype,e),t&&nI(n,t),n}();function nN(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,l=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),nL(this,"table",void 0),nL(this,"view",void 0),nL(this,"controller",void 0),nL(this,"inputQueue",[]),nL(this,"eventQueue",[]),nL(this,"keyboard",void 0),nL(this,"sound",void 0),nL(this,"chat",void 0),nL(this,"sliders",void 0),nL(this,"recoder",void 0),nL(this,"id",""),nL(this,"isSinglePlayer",!0),nL(this,"rules",void 0),nL(this,"menu",void 0),nL(this,"last",performance.now()),nL(this,"step",.001953125),nL(this,"broadcast",void 0),nL(this,"log",void 0),nL(this,"sendChat",function(e){l.sendEvent(new tU.s(l.id,e))}),nL(this,"throttle",new ny(200,function(e){l.broadcast(e)})),nL(this,"lastEventTime",performance.now()),this.log=t,this.rules=n_.create(i,this),this.table=this.rules.table(),this.view=new t6(e,s,this.table,r,this.rules.asset()),this.table.cue.aimInputs=new na(this),this.keyboard=o,this.sound=new nu(this.view.camera.camera,r),this.chat=new nd(this.sendChat),this.sliders=new nb.E,this.recoder=new nT(this),this.id=a,this.menu=new nC(this),this.table.addToScene(this.view.scene),this.updateController(new nt(this))}return e=[{key:"sendEvent",value:function(e){this.throttle.send(e)}},{key:"advance",value:function(e){for(var t=Math.floor(e/this.step),n=t*this.step,r=this.table.allStationary(),i=0;i0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{Y:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{f:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function a(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){for(var n=0;n{n.d(t,{Z:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{l:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{s:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r;n.d(t,{t:()=>r}),function(e){e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK"}(r||(r={}))},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{O:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{I:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{N:()=>l});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),o=n.n(i);function s(e,t){for(var n=0;nMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),o=[];return t.forEach(function(t){var s=performance.now()-e.pressed[t];o.push(new r.I(i?s/3:s,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return o.push(new r.I(e.released[t],t+"Up"))}),this.released={},o}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),o()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}})}}],s(n.prototype,e),t&&s(n,t),n}()},"./src/events/placeballevent.ts":(e,t,n)=>{n.d(t,{I:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts");function s(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){for(var n=0;n{n.d(t,{K:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{g:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r=n("./src/container/container.ts"),i=n("./src/events/keyboard.ts"),o=n("./src/events/eventtype.ts"),s=n("./src/events/aimevent.ts"),a=n("./src/events/watchevent.ts"),l=n("./src/events/hitevent.ts"),c=n("./src/events/abortevent.ts"),u=n("./src/events/breakevent.ts"),h=n("./src/events/beginevent.ts"),f=n("./src/events/chatevent.ts");function p(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,s),v(p(e=i.call(this)),"clientResendFrom",void 0),v(p(e),"serverResendFrom",void 0),e.type=o.t.REJOIN,e.clientResendFrom=t,e.serverResendFrom=n,e}return n=[{key:"applyToController",value:function(e){return e.handleRejoin(this)}}],r=[{key:"fromJson",value:function(e){return new s(e.clientResendFrom,e.serverResendFrom)}}],n&&d(s.prototype,n),r&&d(s,r),s}(n("./src/events/gameevent.ts").Z),g=n("./src/events/placeballevent.ts"),w=n("./src/events/rerackevent.ts"),k=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"serialise",value:function(e){return JSON.stringify(e)}},{key:"fromJson",value:function(e){switch(e.type){case o.t.BEGIN:return new h.Z;case o.t.AIM:return s.f.fromJson(e);case o.t.BREAK:return u.l.fromJson(e);case o.t.WATCHAIM:return a.g.fromJson(e.json);case o.t.HIT:return l.O.fromJson(e);case o.t.CHAT:return f.s.fromJson(e);case o.t.REJOIN:return b.fromJson(e);case o.t.ABORT:return new c.Y;case o.t.PLACEBALL:return g.I.fromJson(e);case o.t.RERACK:return w.K.fromJson(e);default:throw Error("Unknown GameEvent :"+e)}}},{key:"fromSerialised",value:function(e){var n=JSON.parse(e),r=t.fromJson(n);return"sequence"in n&&(r.sequence=n.sequence),r}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m,Z:()=>r});var r,i=n("./src/utils/utils.ts"),o=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),a=n("./src/model/physics/constants.ts");function l(e,t){for(var n=0;nMath.PI/32?.01*a.R:a.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var o=this.geometry.drawRange.count;0!==o&&n1&&i<1e-4&&o--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,o))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],l(n.prototype,e),t&&l(n,t),n}();function h(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(i.bM),this.rvel.copy(i.bM),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,o.E9)(this.vel,this.rvel).length(){n.d(t,{Dt:()=>c,Ew:()=>v,G3:()=>w,Hz:()=>i,I:()=>o,Mz:()=>r,R:()=>f,Xm:()=>k,_5:()=>u,dE:()=>y,e:()=>p,f7:()=>g,fN:()=>m,g:()=>s,m:()=>h,mu:()=>a,zq:()=>b,zv:()=>l});var r,i,o,s=9.8,a=.00985,l=.105,c=.8,u=.024,h=.23,f=.03275,p=.86;function d(){r=a*h*s*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*s,o=.4*h*f*f}function v(e){f=e,d()}function m(e){h=e,d()}function y(e){a=e,d()}function b(e){u=e,d()}function g(e){l=e}function w(e){p=e}function k(e){c=e}d()},"./src/model/physics/physics.ts":(e,t,n)=>{n.d(t,{E9:()=>a,Fn:()=>A,IT:()=>h,NP:()=>g,QC:()=>u,Vp:()=>c,WL:()=>S,ZI:()=>f,al:()=>b,c0:()=>y,h_:()=>x,s0:()=>m,vZ:()=>w});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),o=n("./src/model/physics/constants.ts"),s=new r.Pa4;function a(e,t){return s.copy(e).addScaledVector((0,i.a1)(t),o.R)}var l={v:new r.Pa4,w:new r.Pa4};function c(e,t){var n=a(e,t).setZ(0);return l.v.copy((0,i.KO)(n).multiplyScalar(-o.zv*o.g)),l.w.copy((0,i.KO)((0,i.a1)(n)).multiplyScalar(2.5*o.zv*o.g/o.R)),l.w.setZ(-2.5*(o.Mz/(o.R*o.R))*Math.sign(t.z)),l}function u(e){var t=new r.Pa4(e.x,e.y,0).length(),n=5/7*o.Hz/(o.m*o.R)/t,i=5/7*o.Hz/(o.m*o.R*o.R)/t;return l.v.set(-n*e.y,n*e.x,0),l.w.set(-i*e.x,-i*e.y,-2.5*(o.Mz/(o.m*o.R*o.R))*Math.sign(e.z)),l}function h(e,t){var n=t.z;t.copy((0,i.a1)(e).multiplyScalar(1/o.R)),t.setZ(n)}function f(e,t,n,r){var o=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return o.v.applyAxisAngle(i.up,-e),o.w.applyAxisAngle(i.up,-e),o}Object.freeze(l);var p=Math.asin(.1*o.R/o.R),d=Math.sin(p),v=Math.cos(p);function m(e,t){return new r.Pa4(e.x*d-e.z*v+o.R*t.y,-e.y-o.R*t.z*v+o.R*t.x*d)}function y(e){return e.x*v}function b(e){var t=3.5/o.m;return e.length()/t}function g(e){var t,n=1/o.m,i=.39+.257*(t=new r.Pa4(e/v,0,0)).x-.044*t.x*t.x;return o.Dt*((1+i)*e)/n}function w(e,t){var n=g(y(e));return b(m(e,t))<=n}function k(e,t){return{c:y(e),s:m(e,t),A:3.5/o.m,B:1/o.m}}function T(e,t){var n=k(e,t),r=n.c,i=n.s,s=n.A,a=n.B,l=(1+o.e)*(r/a);return E(-i.x/s*d-l*v,i.y/s,i.x/s*v-l*d)}function R(e,t){var n=k(e,t),r=n.c,i=n.B,s=(1+o.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l),u=-a*s*c*v-s*v,h=a*s*c*v-s*d;return E(u,a*s*Math.sin(l),h)}function A(e,t){return w(e,t)?T(e,t):R(e,t)}function x(e,t){var n=T(e,t),r=R(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pa4(e/o.m,t/o.m),w:new r.Pa4(-o.R/o.I*t*d,o.R/o.I*(e*d-n*v),o.R/o.I*t*v)}}function S(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*o.R)/(o.R*o.R),s=t.clone().normalize();return(0,i.a1)(s).applyAxisAngle(s,n).multiplyScalar(r)}},"./src/utils/utils.ts":(e,t,n)=>{n.d(t,{$2:()=>y,AA:()=>p,Bh:()=>s,KO:()=>u,Ls:()=>f,NM:()=>d,Xp:()=>v,a1:()=>l,bM:()=>i,up:()=>o,wK:()=>m});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pa4(0,0,0),o=new r.Pa4(0,0,1);function s(e){return new r.Pa4(e.x,e.y,e.z)}var a=new r.Pa4;function l(e){return a.copy(o).cross(e)}var c=new r.Pa4;function u(e){return c.copy(e).normalize()}var h=new r.Pa4;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pa4(1,0,0).applyAxisAngle(o,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return Math.round((e+Number.EPSILON)*100)/100}function m(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}function y(e){return e.x=v(e.x),e.y=v(e.y),e.z=v(e.z),e}},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{c:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),o=n("./src/model/physics/constants.ts");function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var s=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.H.tableY:2.4*i.H.tableX/e;return new r.Pa4(0,-.01*o.R,s*a)}var l=e>1/t.aspectLimit?4.9*i.H.tableY:1.35*i.H.tableX/e;return new r.Pa4(-.01*o.R,0,s*l)}}],function(e,t){for(var n=0;n{n.d(t,{N:()=>d});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),o=n("./src/events/aimevent.ts"),s=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/model/physics/constants.ts"),c=n("./node_modules/three/build/three.module.js");function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"createHelper",value:function(){var e=new c.fHI(l.R,l.R,30*l.R/.5,12,1,!0),t=new c.Kj0(e,this.helpermaterial);return t.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(15*l.R/.5,0,-(.01*l.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new c.fHI(.01*l.R/.5,l.R,l.R,4),n=new c.Kj0(e,t.helpermaterial);return n.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(0,0,.7*l.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,r){var o=new c.fHI(e,n,r,11),s=new c.Kj0(o,t.material);return s.castShadow=!1,s.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-.1)).applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(-r/2-l.R,0,2*l.R)),s}}],function(e,t){for(var n=0;nthis.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset=(0,i.$2)(e),this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower)}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=(0,i.a1)((0,i.AA)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*l.R).setZ(2*this.aim.offset.y*l.R),n=(Math.sin(this.t+Math.PI/2)-1)*3*l.R*(this.aim.power/this.maxPower),r=(0,i.AA)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"intersectsAnything",value:function(e){var t=e.cueball.pos.clone().addScaledVector((0,i.AA)(this.aim.angle),-this.length/2);t.z=this.aim.offset.y;var n=(0,i.AA)(this.aim.angle);return new c.iMs(t,n,0,this.length/2-.6).intersectObjects(e.balls.map(function(e){return e.ballmesh.mesh})).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],f(n.prototype,e),t&&f(n,t),n}()},"./src/view/sliders.ts":(e,t,n)=>{n.d(t,{E:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:1,i=this,o=this.getInputElement(e);o.step="0.001",o.min="0.01",o.max="".concat(r),o.value=t,this.showValue(e,t),o.oninput=function(t){var r=parseFloat(t.target.value);n(r),i.showValue(e,r),i.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],i(n.prototype,e),t&&i(n,t),n}()},"./src/view/tablegeometry.ts":(e,t,n)=>{n.d(t,{H:()=>o});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/index.ts")}]); \ No newline at end of file + }`})),o.uniforms.blitTexture.value=e,o.defines.IS_SRGB=e.colorSpace==d.KI_,o.needsUpdate=!0,s||((s=new d.Kj0(i,o)).frustrumCulled=!1);let a=new d.cPb,l=new d.xsS;l.add(s),n||(n=r=new d.CP7({antialias:!1})),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(l,a);let c=new d.xEZ(n.domElement);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,r&&(r.dispose(),r=null),c}let T={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class R{constructor(){this.pluginCallbacks=[],this.register(function(e){return new N(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new U(e)}),this.register(function(e){return new D(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new B(e)}),this.register(function(e){return new H(e)}),this.register(function(e){return new z(e)}),this.register(function(e){return new K(e)}),this.register(function(e){return new V(e)}),this.register(function(e){return new X(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i=new C,o=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class C{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,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),this.processInput(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let o=this.extensionsUsed,s=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o),c=Object.keys(s);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=_(e.result),o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,5130562,!0);let s=_((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,s.byteLength,!0),a.setUint32(4,1313821514,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+s.byteLength+o.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,s,o,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}let n=this.uids.get(e);return n.get(t)}isNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return!1;let n=new d.Pa4;for(let t=0,r=e.count;t5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new d.Pa4;for(let e=0,t=n.count;e4?r=e.array[i*e.itemSize+n]:(0===n?r=e.getX(i):1===n?r=e.getY(i):2===n?r=e.getZ(i):3===n&&(r=e.getW(i)),!0===e.normalized&&(r=d.M8C.normalize(r,e.array))),t===A.FLOAT?l.setFloat32(c,r,!0):t===A.INT?l.setInt32(c,r,!0):t===A.UNSIGNED_INT?l.setUint32(c,r,!0):t===A.SHORT?l.setInt16(c,r,!0):t===A.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===A.BYTE?l.setInt8(c,r):t===A.UNSIGNED_BYTE&&l.setUint8(c,r),c+=o}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==i&&(u.target=i),i===A.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);let h={id:s.bufferViews.length-1,byteLength:0};return h}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=_(i.result),o={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(o)-1)}})}processAccessor(e,t,n,r){let i,o;let s=this.json;if(e.array.constructor===Float32Array)i=A.FLOAT;else if(e.array.constructor===Int32Array)i=A.INT;else if(e.array.constructor===Uint32Array)i=A.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=A.SHORT;else if(e.array.constructor===Uint16Array)i=A.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=A.BYTE;else if(e.array.constructor===Uint8Array)i=A.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===r||r===1/0)&&(r=e.count),0===r)return null;let a=function(e,t,n){let r={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i4?n=e.array[i*e.itemSize+t]:(0===t?n=e.getX(i):1===t?n=e.getY(i):2===t?n=e.getZ(i):3===t&&(n=e.getW(i)),!0===e.normalized&&(n=d.M8C.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}(e,n,r);void 0!==t&&(o=e===t.index?A.ELEMENT_ARRAY_BUFFER:A.ARRAY_BUFFER);let l=this.processBufferView(e,i,n,r,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(c)-1}processImage(e,t,n,r="image/png"){if(null!==e){let i=this,o=i.cache,s=i.json,a=i.options,l=i.pending;o.images.has(e)||o.images.set(e,{});let c=o.images.get(e),u=r+":flipY/"+n.toString();if(void 0!==c[u])return c[u];s.images||(s.images=[]);let h={mimeType:r},f=I();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==d.wk1&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ti.processBufferViewImage(e)).then(e=>{h.bufferView=e})):void 0!==f.toDataURL?h.uri=f.toDataURL(r):l.push(j(f,r).then(e=>new FileReader().readAsDataURL(e)).then(e=>{h.uri=e}));let v=s.images.push(h)-1;return c[u]=v,v}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:E[e.magFilter],minFilter:E[e.minFilter],wrapS:E[e.wrapS],wrapT:E[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||(r.textures=[]),e instanceof d.EB7&&(e=k(e,t.maxTextureSize));let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive,n=Math.max(t.r,t.g,t.b);if(n>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.ehD&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let o=n.materials.push(r)-1;return t.materials.set(e,o),o}processMesh(e){let t;let n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o0&&(a.extras={},a.extras.targetNames=r)}let v=Array.isArray(e.material);if(v&&0===s.groups.length)return null;let m=v?e.material:[e.material],y=v?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=y.length;e0&&(r.targets=u),null!==s.index){let t=this.getUID(s.index);(void 0!==y[e].start||void 0!==y[e].count)&&(t+=":"+y[e].start+":"+y[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(s.index,s,y[e].start,y[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=this.processMaterial(m[y[e].materialIndex]);null!==i&&(r.material=i),c.push(r)}a.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,a)});let b=r.meshes.push(a)-1;return n.meshes.set(o,b),b}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[x])return;switch(t.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}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];T[r]&&T[r].includes(n)&&(this.extensionsUsed[x]=!0,this.extensionsRequired[x]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.M8C.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=R.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,o=[],s=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let o=t.nodes.push(i)-1;return r.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new d.xsS;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.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."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let s=r.extensions[this.name].lights;s.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}}class L{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer,r=n.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class B{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class H{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class F{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class U{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class D{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer,r=n.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class G{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(P)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class z{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class K{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class V{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer,r=n.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class X{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=new Float32Array(3*e.count),i=new Float32Array(4*e.count),o=new Float32Array(3*e.count),s=new d.yGw,a=new d.Pa4,l=new d._fP,c=new d.Pa4;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),o.set(s.evaluate(t),0),o.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(s.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),o.set(e.values.slice(0,(a+1)*r),0),o.set(s.evaluate(t),(a+1)*r),o.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=o,n},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eL(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function J(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let Z={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_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 q{constructor(e){this.parser=e,this.name=Z.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,o)}}class ec{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eu{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],s=r.images[o.source],a=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eh{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,o=e.count,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t})})}}}class ef{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==eT.TRIANGLES&&e.mode!==eT.TRIANGLE_STRIP&&e.mode!==eT.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name],o=i.attributes,s=[],a={};for(let e in o)s.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d.yGw,n=new d.Pa4,o=new d._fP,s=new d.Pa4(1,1,1),l=new d.SPe(e.geometry,e.material,r);for(let e=0;e-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new d.dpR(this.options.manager):this.textureLoader=new d.QRU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.hH6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return e_(i,o,r),eI(o,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,o]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(o,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,h[e*a+1]),a>=3&&o.setZ(t,h[e*a+2]),a>=4&&o.setW(t,h[e*a+3]),a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e],i=r.source,o=t.images[i],s=this.textureLoader;if(o.uri){let e=n.manager.getHandler(o.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){let r=this,i=this.json,o=i.textures[e],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];let l=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=i.samplers||{},a=n[o.sampler]||{};return t.magFilter=eA[a.magFilter]||d.wem,t.minFilter=eA[a.minFilter]||d.D1R,t.wrapS=ex[a.wrapS]||d.rpg,t.wrapT=ex[a.wrapT]||d.rpg,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){let n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=n.images[e],o=self.URL||self.webkitURL,s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then(function(e){a=!0;let t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then(function(e){return new Promise(function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new d.xEZ(e);t.needsUpdate=!0,n(t)}),t.load(d.Zp0.resolveURL(e,r.path),o,void 0,i)})}).then(function(e){var t;return!0===a&&o.revokeObjectURL(s),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),i.extensions[Z.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.UY4,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new d.nls,d.F5T.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return d.Wid}loadMaterial(e){let t;let n=this,r=this.json,i=this.extensions,o=r.materials[e],s={},a=o.extensions||{},l=[];if(a[Z.KHR_MATERIALS_UNLIT]){let e=i[Z.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(s,o,n))}else{let r=o.pbrMetallicRoughness||{};if(s.color=new d.Ilk(1,1,1),s.opacity=1,Array.isArray(r.baseColorFactor)){let e=r.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],d.GUF),s.opacity=e[3]}void 0!==r.baseColorTexture&&l.push(n.assignTexture(s,"map",r.baseColorTexture,d.KI_)),s.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,s.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(n.assignTexture(s,"metalnessMap",r.metallicRoughnessTexture)),l.push(n.assignTexture(s,"roughnessMap",r.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}!0===o.doubleSided&&(s.side=d.ehD);let c=o.alphaMode||eM.OPAQUE;if(c===eM.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===eM.MASK&&(s.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"normalMap",o.normalTexture)),s.normalScale=new d.FM8(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==d.vBJ&&(l.push(n.assignTexture(s,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(s.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==d.vBJ){let e=o.emissiveFactor;s.emissive=new d.Ilk().setRGB(e[0],e[1],e[2],d.GUF)}return void 0!==o.emissiveTexture&&t!==d.vBJ&&l.push(n.assignTexture(s,"emissiveMap",o.emissiveTexture,d.KI_)),Promise.all(l).then(function(){let r=new t(s);return o.name&&(r.name=o.name),eI(r,o),n.associations.set(r,{materials:e}),o.extensions&&e_(i,r,o),r})}createUniqueName(e){let t=d.iUV.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache,i=[];for(let o=0,s=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new d.ZAu:1===t.length?t[0]:new d.Tme)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof d.F5T||e instanceof d.xEZ)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let o;let s=[],a=e.name?e.name:e.uuid,l=[];switch(eP[i.path]===eP.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),eP[i.path]){case eP.weights:o=d.dUE;break;case eP.rotation:o=d.iLg;break;case eP.position:case eP.scale:o=d.yC1;break;default:o=1===n.itemSize?d.dUE:d.yC1}let c=void 0!==r.interpolation?eO[r.interpolation]:d.NMF,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e3&&void 0!==arguments[3]?arguments[3]:function(){};new W().load(e,function(e){e.scene.scale.set(y.R/.5,y.R/.5,y.R/.5),e.scene.matrixAutoUpdate=!1,e.scene.visible=n,e.scene.updateMatrix(),t.add(e.scene),r()},function(e){return console.log(e.loaded+" bytes loaded")},eH)}var eU=n("./src/view/tablegeometry.ts");function eD(e,t){for(var n=0;nthis.radius-y.R){var r=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-y.R/2&&e.vel.addScaledVector(r,7*y.R*t*y.g),0>e.vel.dot(r)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=r.x*e.vel.length()/2,e.vel.y=r.y*e.vel.length()/2)}var i=this.restingDepth(e);n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*y.R/.5,t,n).position.setZ(-(.25*y.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new d.fHI(t,t,n,16),s=new d.Kj0(o,i);return s.position.copy(e),s.geometry.applyMatrix4(new d.yGw().identity().makeRotationAxis(new d.Pa4(1,0,0),Math.PI/2)),r.add(s),s}},{key:"addCushions",value:function(e,t){var n=10*y.R/.5;this.plane(new d.Pa4(0,0,-y.R-n/2),2*eU.H.X,2*eU.H.Y,n,e,this.cloth);var r=1*y.R/.5,i=.75*y.R/.5,o=-(.25*y.R)/.5/2,s=eU.H.X,a=eU.H.Y,l=Math.abs(eq.pockets.pocketNW.knuckleNE.pos.x-eq.pockets.pocketN.knuckleNW.pos.x),c=Math.abs(eq.pockets.pocketNW.knuckleSW.pos.y-eq.pockets.pocketSW.knuckleNW.pos.y);t||(l=2*eU.H.Y,c=2*eU.H.Y+4*y.R),this.plane(new d.Pa4(s+r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s-r/2,0,o),r,c,i,e),this.plane(new d.Pa4(-s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(-s/2,-a-r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,a+r/2,o),l,r,i,e),this.plane(new d.Pa4(s/2,-a-r/2,o),l,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,s=new d.DvJ(t,n,r),a=new d.Kj0(s,o);a.receiveShadow=!0,a.position.copy(e),i.add(a)}}],eQ(n.prototype,e),t&&eQ(n,t),n}(),e1=n("./src/events/watchevent.ts");function e2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.Pot="Pot",e.Cushion="Cushion",e.Collision="Collision",e.Hit="Hit"}(a||(a={}));var e4=function(){var e;function t(e,n,r,i){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),e2(this,"type",void 0),e2(this,"timestamp",void 0),e2(this,"ballA",null),e2(this,"ballB",null),e2(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=r,this.incidentSpeed=i,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,o=!0,s=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n-eU.H.tableX&&n.overlapsAny(r,t);)r.x-=y.R/8;t.pos.copy(r),t.state=eX.Z.Stationary}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),tg(ty(r=i.call(this,e)),"delay",void 0),tg(ty(r),"shots",void 0),tg(ty(r),"firstShot",void 0),tg(ty(r),"timer",void 0),tg(ty(r),"init",void 0),r.init=t,r.shots=tT(n),r.firstShot=r.shots[0],r.delay=a,r.container.table.showTraces(!0),r.container.table.updateFromShortSerialised(r.init),s){var l=new td.l(t,n);l.retry=!0,r.container.eventQueue.push(l)}else r.container.view.camera.forceMode(r.container.view.camera.topView),r.playNextShot(1.5*r.delay);return r}return n=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===c.t.RERACK){tv.K.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var r=e8.f.fromJson(n);this.container.table.cueball=this.container.table.balls[r.i],this.container.table.cueball.pos.copy(r.pos),this.container.table.cue.aim=r,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new e6.O(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=tT(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=e8.f.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new tS(this.container)}}],tb(o.prototype,n),r&&tb(o,r),o}(tc);function tA(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tz.h_,o=e.futurePosition(n);if(t.willBounceLong(o,r)){var s=o.y>eU.H.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(s,e,i)}if(t.willBounceShort(o,r)){var a=o.x>eU.H.tableX?0:Math.PI;return t.bounceIn(a,e,i)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(eq.pockets.pocketNW.knuckleSW.pos.y,eq.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(eU.H.Y,-eU.H.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(eq.pockets.pocketNW.knuckleNE.pos.x,eq.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(eq.pockets.pocketN.knuckleNE.pos.x,eq.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-eU.H.X,eU.H.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xeU.H.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yeU.H.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,tz.ZI)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(tV.willCollide(e,t,n)){var r=tV.collide(e,t);return this.outcome.push(e4.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*y.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return eX.e.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&tY(n.prototype,e),t&&tY(n,t),n}();function tZ(e,t){for(var n=0;n0){if(this.previousPotRed)this.previousPotRed=!1,this.respot(e);else if(e4.onlyRedsPotted(e))this.previousPotRed=!0;else if(1===t){var n=e4.pots(e)[0].id;n>1&&this.container.table.balls.filter(function(e){return e.id0}).some(function(e){return e.onTable()})&&this.respot(e)}else this.respot(e)}return t2(t4(o.prototype),"update",this).call(this,e)}},{key:"respot",value:function(e){var t=this.respotAllPottedColours(e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new e1.g(n);this.container.sendEvent(r),this.container.recoder.record(r)}}},{key:"respotAllPottedColours",value:function(e){var t=this;return e4.pots(e).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(e){return e5.respot(e,t.container.table)})}}],t0(o.prototype,n),r&&t0(o,r),o}(tQ);function t8(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],ns(n.prototype,e),t&&ns(n,t),n}();function nc(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=d.Hmr.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(d.M8C.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],nc(n.prototype,e),t&&nc(n,t),n}();function nf(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function np(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==c.t.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],nm(n.prototype,e),t&&nm(n,t),n}(),ng=n("./src/view/sliders.ts"),nw=n("./node_modules/jsoncrush/JSONCrush.js");function nk(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart))}},{key:"state",value:function(e,t){return{init:e,shots:t}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=e4.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last())}},{key:"lastShotLink",value:function(e,t){var n="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),r=JSON.stringify(this.lastShot());this.generateLink(n,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n="break(".concat(t.shots.length,")"),r=JSON.stringify(t),i=nw.Z.crush(r);this.generateLink(n,i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(e.shots.length,")"),n=JSON.stringify(e),r=nw.Z.crush(n);this.generateLink(t,r)}},{key:"generateLink",value:function(e,t){var n="".concat(this.replayUrl).concat(encodeURIComponent(t)),r='').concat(e,"");this.container.eventQueue.push(new tD.s(null,"".concat(r)))}}],nk(n.prototype,e),t&&nk(n,t),n}();function nA(e,t){for(var n=0;n').concat(e,"")));r.push(new tD.s(null,s))})},this.redo.onclick=function(e){var r=new td.l(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new p),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],nj(n.prototype,e),t&&nj(n,t),n}();function nL(e,t){for(var n=0;n2)||void 0===arguments[2]||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,l=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),nB(this,"table",void 0),nB(this,"view",void 0),nB(this,"controller",void 0),nB(this,"inputQueue",[]),nB(this,"eventQueue",[]),nB(this,"keyboard",void 0),nB(this,"sound",void 0),nB(this,"chat",void 0),nB(this,"sliders",void 0),nB(this,"recoder",void 0),nB(this,"id",""),nB(this,"isSinglePlayer",!0),nB(this,"rules",void 0),nB(this,"menu",void 0),nB(this,"last",performance.now()),nB(this,"step",.001953125),nB(this,"broadcast",void 0),nB(this,"log",void 0),nB(this,"sendChat",function(e){l.sendEvent(new tD.s(l.id,e))}),nB(this,"throttle",new nb(200,function(e){l.broadcast(e)})),nB(this,"lastEventTime",performance.now()),this.log=t,this.rules=nI.create(i,this),this.table=this.rules.table(),this.view=new t9(e,s,this.table,r,this.rules.asset()),this.table.cue.aimInputs=new nl(this),this.keyboard=o,this.sound=new nh(this.view.camera.camera,r),this.chat=new nv(this.sendChat),this.sliders=new ng.E,this.recoder=new nR(this),this.id=a,this.menu=new nN(this),this.table.addToScene(this.view.scene),this.updateController(new nn(this))}return e=[{key:"sendEvent",value:function(e){this.throttle.send(e)}},{key:"advance",value:function(e){for(var t=Math.floor(e/this.step),n=t*this.step,r=this.table.allStationary(),i=0;i0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{Y:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{f:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function a(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){for(var n=0;n{n.d(t,{Z:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e,t){for(var n=0;n{n.d(t,{l:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{s:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r;n.d(t,{t:()=>r}),function(e){e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK"}(r||(r={}))},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{O:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{I:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{N:()=>l});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),o=n.n(i);function s(e,t){for(var n=0;nMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),o=[];return t.forEach(function(t){var s=performance.now()-e.pressed[t];o.push(new r.I(i?s/3:s,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return o.push(new r.I(e.released[t],t+"Up"))}),this.released={},o}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),o()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}})}}],s(n.prototype,e),t&&s(n,t),n}()},"./src/events/placeballevent.ts":(e,t,n)=>{n.d(t,{I:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),o=n("./src/utils/utils.ts");function s(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){for(var n=0;n{n.d(t,{K:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{n.d(t,{g:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function o(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n{var r=n("./src/container/container.ts"),i=n("./src/events/keyboard.ts"),o=n("./src/events/eventtype.ts"),s=n("./src/events/aimevent.ts"),a=n("./src/events/watchevent.ts"),l=n("./src/events/hitevent.ts"),c=n("./src/events/abortevent.ts"),u=n("./src/events/breakevent.ts"),h=n("./src/events/beginevent.ts"),f=n("./src/events/chatevent.ts");function p(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,s),v(p(e=i.call(this)),"clientResendFrom",void 0),v(p(e),"serverResendFrom",void 0),e.type=o.t.REJOIN,e.clientResendFrom=t,e.serverResendFrom=n,e}return n=[{key:"applyToController",value:function(e){return e.handleRejoin(this)}}],r=[{key:"fromJson",value:function(e){return new s(e.clientResendFrom,e.serverResendFrom)}}],n&&d(s.prototype,n),r&&d(s,r),s}(n("./src/events/gameevent.ts").Z),g=n("./src/events/placeballevent.ts"),w=n("./src/events/rerackevent.ts"),k=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"serialise",value:function(e){return JSON.stringify(e)}},{key:"fromJson",value:function(e){switch(e.type){case o.t.BEGIN:return new h.Z;case o.t.AIM:return s.f.fromJson(e);case o.t.BREAK:return u.l.fromJson(e);case o.t.WATCHAIM:return a.g.fromJson(e.json);case o.t.HIT:return l.O.fromJson(e);case o.t.CHAT:return f.s.fromJson(e);case o.t.REJOIN:return b.fromJson(e);case o.t.ABORT:return new c.Y;case o.t.PLACEBALL:return g.I.fromJson(e);case o.t.RERACK:return w.K.fromJson(e);default:throw Error("Unknown GameEvent :"+e)}}},{key:"fromSerialised",value:function(e){var n=JSON.parse(e),r=t.fromJson(n);return"sequence"in n&&(r.sequence=n.sequence),r}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m,Z:()=>r});var r,i=n("./src/utils/utils.ts"),o=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),a=n("./src/model/physics/constants.ts");function l(e,t){for(var n=0;nMath.PI/32?.01*a.R:a.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var o=this.geometry.drawRange.count;0!==o&&n1&&i<1e-4&&o--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,o))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],l(n.prototype,e),t&&l(n,t),n}();function h(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(i.bM),this.rvel.copy(i.bM),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,o.E9)(this.vel,this.rvel).length(){n.d(t,{Dt:()=>c,Ew:()=>v,G3:()=>w,Hz:()=>i,I:()=>o,Mz:()=>r,R:()=>f,Xm:()=>k,_5:()=>u,dE:()=>y,e:()=>p,f7:()=>g,fN:()=>m,g:()=>s,m:()=>h,mu:()=>a,zq:()=>b,zv:()=>l});var r,i,o,s=9.8,a=.00985,l=.105,c=.8,u=.024,h=.23,f=.03275,p=.86;function d(){r=a*h*s*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*s,o=.4*h*f*f}function v(e){f=e,d()}function m(e){h=e,d()}function y(e){a=e,d()}function b(e){u=e,d()}function g(e){l=e}function w(e){p=e}function k(e){c=e}d()},"./src/model/physics/physics.ts":(e,t,n)=>{n.d(t,{E9:()=>a,Fn:()=>A,IT:()=>h,NP:()=>g,QC:()=>u,Vp:()=>c,WL:()=>S,ZI:()=>f,al:()=>b,c0:()=>y,h_:()=>x,s0:()=>m,vZ:()=>w});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),o=n("./src/model/physics/constants.ts"),s=new r.Pa4;function a(e,t){return s.copy(e).addScaledVector((0,i.a1)(t),o.R)}var l={v:new r.Pa4,w:new r.Pa4};function c(e,t){var n=a(e,t).setZ(0);return l.v.copy((0,i.KO)(n).multiplyScalar(-o.zv*o.g)),l.w.copy((0,i.KO)((0,i.a1)(n)).multiplyScalar(2.5*o.zv*o.g/o.R)),l.w.setZ(-2.5*(o.Mz/(o.R*o.R))*Math.sign(t.z)),l}function u(e){var t=new r.Pa4(e.x,e.y,0).length(),n=5/7*o.Hz/(o.m*o.R)/t,i=5/7*o.Hz/(o.m*o.R*o.R)/t;return l.v.set(-n*e.y,n*e.x,0),l.w.set(-i*e.x,-i*e.y,-2.5*(o.Mz/(o.m*o.R*o.R))*Math.sign(e.z)),l}function h(e,t){var n=t.z;t.copy((0,i.a1)(e).multiplyScalar(1/o.R)),t.setZ(n)}function f(e,t,n,r){var o=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return o.v.applyAxisAngle(i.up,-e),o.w.applyAxisAngle(i.up,-e),o}Object.freeze(l);var p=Math.asin(.1*o.R/o.R),d=Math.sin(p),v=Math.cos(p);function m(e,t){return new r.Pa4(e.x*d-e.z*v+o.R*t.y,-e.y-o.R*t.z*v+o.R*t.x*d)}function y(e){return e.x*v}function b(e){var t=3.5/o.m;return e.length()/t}function g(e){var t,n=1/o.m,i=.39+.257*(t=new r.Pa4(e/v,0,0)).x-.044*t.x*t.x;return o.Dt*((1+i)*e)/n}function w(e,t){var n=g(y(e));return b(m(e,t))<=n}function k(e,t){return{c:y(e),s:m(e,t),A:3.5/o.m,B:1/o.m}}function T(e,t){var n=k(e,t),r=n.c,i=n.s,s=n.A,a=n.B,l=(1+o.e)*(r/a);return E(-i.x/s*d-l*v,i.y/s,i.x/s*v-l*d)}function R(e,t){var n=k(e,t),r=n.c,i=n.B,s=(1+o.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l),u=-a*s*c*v-s*v,h=a*s*c*v-s*d;return E(u,a*s*Math.sin(l),h)}function A(e,t){return w(e,t)?T(e,t):R(e,t)}function x(e,t){var n=T(e,t),r=R(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pa4(e/o.m,t/o.m),w:new r.Pa4(-o.R/o.I*t*d,o.R/o.I*(e*d-n*v),o.R/o.I*t*v)}}function S(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*o.R)/(o.R*o.R),s=t.clone().normalize();return(0,i.a1)(s).applyAxisAngle(s,n).multiplyScalar(r)}},"./src/utils/utils.ts":(e,t,n)=>{n.d(t,{$2:()=>y,AA:()=>p,Bh:()=>s,KO:()=>u,Ls:()=>f,NM:()=>d,Xp:()=>v,a1:()=>l,bM:()=>i,up:()=>o,wK:()=>m});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pa4(0,0,0),o=new r.Pa4(0,0,1);function s(e){return new r.Pa4(e.x,e.y,e.z)}var a=new r.Pa4;function l(e){return a.copy(o).cross(e)}var c=new r.Pa4;function u(e){return c.copy(e).normalize()}var h=new r.Pa4;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pa4(1,0,0).applyAxisAngle(o,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return Math.round((e+Number.EPSILON)*100)/100}function m(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}function y(e){return e.x=v(e.x),e.y=v(e.y),e.z=v(e.z),e}},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{c:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),o=n("./src/model/physics/constants.ts");function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var s=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.H.tableY:2.4*i.H.tableX/e;return new r.Pa4(0,-.01*o.R,s*a)}var l=e>1/t.aspectLimit?4.9*i.H.tableY:1.35*i.H.tableX/e;return new r.Pa4(-.01*o.R,0,s*l)}}],function(e,t){for(var n=0;n{n.d(t,{N:()=>d});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),o=n("./src/events/aimevent.ts"),s=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/model/physics/constants.ts"),c=n("./node_modules/three/build/three.module.js");function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"createHelper",value:function(){var e=new c.fHI(l.R,l.R,30*l.R/.5,12,1,!0),t=new c.Kj0(e,this.helpermaterial);return t.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(15*l.R/.5,0,-(.01*l.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new c.fHI(.01*l.R/.5,l.R,l.R,4),n=new c.Kj0(e,t.helpermaterial);return n.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(0,0,.7*l.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,r){var o=new c.fHI(e,n,r,11),s=new c.Kj0(o,t.material);return s.castShadow=!1,s.geometry.applyMatrix4(new c.yGw().identity().makeRotationAxis(new c.Pa4(1,0,0),-.1)).applyMatrix4(new c.yGw().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new c.yGw().identity().makeTranslation(-r/2-l.R,0,2*l.R)),s}}],function(e,t){for(var n=0;nthis.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset=(0,i.$2)(e),this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower)}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=(0,i.a1)((0,i.AA)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*l.R).setZ(2*this.aim.offset.y*l.R),n=(Math.sin(this.t+Math.PI/2)-1)*3*l.R*(this.aim.power/this.maxPower),r=(0,i.AA)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"intersectsAnything",value:function(e){var t=e.cueball.pos.clone().addScaledVector((0,i.AA)(this.aim.angle),-this.length/2);t.z=this.aim.offset.y;var n=(0,i.AA)(this.aim.angle);return new c.iMs(t,n,0,this.length/2-.6).intersectObjects(e.balls.map(function(e){return e.ballmesh.mesh})).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],f(n.prototype,e),t&&f(n,t),n}()},"./src/view/sliders.ts":(e,t,n)=>{n.d(t,{E:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:1,i=this,o=this.getInputElement(e);o.step="0.001",o.min="0.01",o.max="".concat(r),o.value=t,this.showValue(e,t),o.oninput=function(t){var r=parseFloat(t.target.value);n(r),i.showValue(e,r),i.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],i(n.prototype,e),t&&i(n,t),n}()},"./src/view/tablegeometry.ts":(e,t,n)=>{n.d(t,{H:()=>o});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/index.ts")}]); \ No newline at end of file diff --git a/dist/vendor.js b/dist/vendor.js index 810a4155..0ef50cf5 100644 --- a/dist/vendor.js +++ b/dist/vendor.js @@ -1,4 +1,4 @@ -(()=>{var e={"./node_modules/interactjs/dist/interact.min.js":e=>{e.exports=function(){var e,n,i={};Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0,i.default=function(e){return!(!e||!e.Window)&&e instanceof e.Window};var r={};Object.defineProperty(r,"__esModule",{value:!0}),r.getWindow=function(e){return(0,i.default)(e)?e:(e.ownerDocument||e).defaultView||s.window},r.init=o,r.window=r.realWindow=void 0;var a=void 0;r.realWindow=a;var s=void 0;function o(e){r.realWindow=a=e;var n=e.document.createTextNode("");n.ownerDocument!==e.document&&"function"==typeof e.wrap&&e.wrap(n)===n&&(e=e.wrap(e)),r.window=s=e}r.window=s,"undefined"!=typeof window&&window&&o(window);var l={};function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var c=function(e){return!!e&&"object"===u(e)},h=function(e){return"function"==typeof e};l.default={window:function(e){return e===r.window||(0,i.default)(e)},docFrag:function(e){return c(e)&&11===e.nodeType},object:c,func:h,number:function(e){return"number"==typeof e},bool:function(e){return"boolean"==typeof e},string:function(e){return"string"==typeof e},element:function(e){if(!e||"object"!==u(e))return!1;var n=r.getWindow(e)||r.window;return/object|function/.test("undefined"==typeof Element?"undefined":u(Element))?e instanceof Element||e instanceof n.Element:1===e.nodeType&&"string"==typeof e.nodeName},plainObject:function(e){return c(e)&&!!e.constructor&&/function Object\b/.test(e.constructor.toString())},array:function(e){return c(e)&&void 0!==e.length&&h(e.splice)}};var d={};function p(e){var n=e.interaction;if("drag"===n.prepared.name){var i=n.prepared.axis;"x"===i?(n.coords.cur.page.y=n.coords.start.page.y,n.coords.cur.client.y=n.coords.start.client.y,n.coords.velocity.client.y=0,n.coords.velocity.page.y=0):"y"===i&&(n.coords.cur.page.x=n.coords.start.page.x,n.coords.cur.client.x=n.coords.start.client.x,n.coords.velocity.client.x=0,n.coords.velocity.page.x=0)}}function f(e){var n=e.iEvent,i=e.interaction;if("drag"===i.prepared.name){var r=i.prepared.axis;if("x"===r||"y"===r){var a="x"===r?"y":"x";n.page[a]=i.coords.start.page[a],n.client[a]=i.coords.start.client[a],n.delta[a]=0}}}Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var m={id:"actions/drag",install:function(e){var n=e.actions,i=e.Interactable,r=e.defaults;i.prototype.draggable=m.draggable,n.map.drag=m,n.methodDict.drag="draggable",r.actions.drag=m.defaults},listeners:{"interactions:before-action-move":p,"interactions:action-resume":p,"interactions:action-move":f,"auto-start:check":function(e){var n=e.interaction,i=e.interactable,r=e.buttons,a=i.options.drag;if(a&&a.enabled&&(!n.pointerIsDown||!/mouse|pointer/.test(n.pointerType)||0!=(r&i.options.drag.mouseButtons)))return e.action={name:"drag",axis:"start"===a.lockAxis?a.startAxis:a.lockAxis},!1}},draggable:function(e){return l.default.object(e)?(this.options.drag.enabled=!1!==e.enabled,this.setPerAction("drag",e),this.setOnEvents("drag",e),/^(xy|x|y|start)$/.test(e.lockAxis)&&(this.options.drag.lockAxis=e.lockAxis),/^(xy|x|y)$/.test(e.startAxis)&&(this.options.drag.startAxis=e.startAxis),this):l.default.bool(e)?(this.options.drag.enabled=e,this):this.options.drag},beforeMove:p,move:f,defaults:{startAxis:"xy",lockAxis:"xy"},getCursor:function(){return"move"}};d.default=m;var g={};Object.defineProperty(g,"__esModule",{value:!0}),g.default=void 0;var v={init:function(e){v.document=e.document,v.DocumentFragment=e.DocumentFragment||_,v.SVGElement=e.SVGElement||_,v.SVGSVGElement=e.SVGSVGElement||_,v.SVGElementInstance=e.SVGElementInstance||_,v.Element=e.Element||_,v.HTMLElement=e.HTMLElement||v.Element,v.Event=e.Event,v.Touch=e.Touch||_,v.PointerEvent=e.PointerEvent||e.MSPointerEvent},document:null,DocumentFragment:null,SVGElement:null,SVGSVGElement:null,SVGElementInstance:null,Element:null,HTMLElement:null,Event:null,Touch:null,PointerEvent:null};function _(){}g.default=v;var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.default=void 0;var x={init:function(e){var n=g.default.Element,i=e.navigator||{};x.supportsTouch="ontouchstart"in e||l.default.func(e.DocumentTouch)&&g.default.document instanceof e.DocumentTouch,x.supportsPointerEvent=!1!==i.pointerEnabled&&!!g.default.PointerEvent,x.isIOS=/iP(hone|od|ad)/.test(i.platform),x.isIOS7=/iP(hone|od|ad)/.test(i.platform)&&/OS 7[^\d]/.test(i.appVersion),x.isIe9=/MSIE 9/.test(i.userAgent),x.isOperaMobile="Opera"===i.appName&&x.supportsTouch&&/Presto/.test(i.userAgent),x.prefixedMatchesSelector="matches"in n.prototype?"matches":"webkitMatchesSelector"in n.prototype?"webkitMatchesSelector":"mozMatchesSelector"in n.prototype?"mozMatchesSelector":"oMatchesSelector"in n.prototype?"oMatchesSelector":"msMatchesSelector",x.pEventTypes=x.supportsPointerEvent?g.default.PointerEvent===e.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"}:null,x.wheelEvent=g.default.document&&"onmousewheel"in g.default.document?"mousewheel":"wheel"},supportsTouch:null,supportsPointerEvent:null,isIOS7:null,isIOS:null,isIe9:null,isOperaMobile:null,prefixedMatchesSelector:null,pEventTypes:null,wheelEvent:null};y.default=x;var b={};function M(e){var n=e.parentNode;if(l.default.docFrag(n))for(;(n=n.host)&&l.default.docFrag(n););return n}function S(e,n){return r.window!==r.realWindow&&(n=n.replace(/\/deep\//g," ")),e[y.default.prefixedMatchesSelector](n)}Object.defineProperty(b,"__esModule",{value:!0}),b.closest=function(e,n){for(;l.default.element(e);){if(S(e,n))return e;e=M(e)}return null},b.getActualElement=function(e){return e.correspondingUseElement||e},b.getElementClientRect=A,b.getElementRect=function(e){var n=A(e);if(!y.default.isIOS7&&n){var i=w(r.getWindow(e));n.left+=i.x,n.right+=i.x,n.top+=i.y,n.bottom+=i.y}return n},b.getPath=function(e){for(var n=[];e;)n.push(e),e=M(e);return n},b.getScrollXY=w,b.indexOfDeepestElement=function(e){for(var n,i=[],a=0;a=(parseInt(r.getWindow(o).getComputedStyle(o).zIndex,10)||0)&&(n=a)}else n=a}}else n=a}}return n},b.matchesSelector=S,b.matchesUpTo=function(e,n,i){for(;l.default.element(e);){if(S(e,n))return!0;if((e=M(e))===i)return S(e,n)}return!1},b.nodeContains=function(e,n){if(e.contains)return e.contains(n);for(;n;){if(n===e)return!0;n=n.parentNode}return!1},b.parentNode=M,b.trySelector=function(e){return!!l.default.string(e)&&(g.default.document.querySelector(e),!0)};var E=function(e){return e.parentNode||e.host};function T(e,n){for(var i,r=[],a=e;(i=E(a))&&a!==n&&i!==a.ownerDocument;)r.unshift(a),a=i;return r}function w(e){return{x:(e=e||r.window).scrollX||e.document.documentElement.scrollLeft,y:e.scrollY||e.document.documentElement.scrollTop}}function A(e){var n=e instanceof g.default.SVGElement?e.getBoundingClientRect():e.getClientRects()[0];return n&&{left:n.left,right:n.right,top:n.top,bottom:n.bottom,width:n.width||n.right-n.left,height:n.height||n.bottom-n.top}}var R={};Object.defineProperty(R,"__esModule",{value:!0}),R.default=function(e,n){for(var i in n)e[i]=n[i];return e};var P={};function C(e,n){(null==n||n>e.length)&&(n=e.length);for(var i=0,r=Array(n);i1?W(n):n[0];H(r,e.page),V(r,e.client),e.timeStamp=i},z.setZeroCoords=function(e){e.page.x=0,e.page.y=0,e.client.x=0,e.client.y=0},z.touchAngle=function(e,n){var i=n+"X",r=n+"Y",a=G(e),s=a[1][i]-a[0][i];return 180*Math.atan2(a[1][r]-a[0][r],s)/Math.PI},z.touchBBox=function(e){if(!e.length)return null;var n=G(e),i=Math.min(n[0].pageX,n[1].pageX),r=Math.min(n[0].pageY,n[1].pageY),a=Math.max(n[0].pageX,n[1].pageX),s=Math.max(n[0].pageY,n[1].pageY);return{x:i,y:r,left:i,top:r,right:a,bottom:s,width:a-i,height:s-r}},z.touchDistance=function(e,n){var i=n+"X",r=n+"Y",a=G(e),s=a[0][i]-a[1][i],o=a[0][r]-a[1][r];return(0,U.default)(s,o)};var j={};function X(e,n,i){return n in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}Object.defineProperty(j,"__esModule",{value:!0}),j.BaseEvent=void 0;var q=function(){function e(n){(function(e,n){if(!(e instanceof n))throw TypeError("Cannot call a class as a function")})(this,e),X(this,"immediatePropagationStopped",!1),X(this,"propagationStopped",!1),this._interaction=n}return function(e,n){for(var i=0;io.left&&d.xo.top&&d.y=o.left&&g<=o.right&&v>=o.top&&v<=o.bottom}return m&&l.default.number(c)&&(u=Math.max(0,Math.min(o.right,m.right)-Math.max(o.left,m.left))*Math.max(0,Math.min(o.bottom,m.bottom)-Math.max(o.top,m.top))/(m.width*m.height)>=c),e.options.drop.checker&&(u=e.options.drop.checker(n,i,u,e,s,r,a)),u}(this,e,n,i,r,a,s)},i.dynamicDrop=function(n){return l.default.bool(n)?(e.dynamicDrop=n,i):e.dynamicDrop},(0,R.default)(n.phaselessTypes,{dragenter:!0,dragleave:!0,dropactivate:!0,dropdeactivate:!0,dropmove:!0,drop:!0}),n.methodDict.drop="dropzone",e.dynamicDrop=!1,a.actions.drop=eh.defaults},listeners:{"interactions:before-action-start":function(e){var n=e.interaction;"drag"===n.prepared.name&&(n.dropState={cur:{dropzone:null,element:null},prev:{dropzone:null,element:null},rejected:null,events:null,activeDrops:[]})},"interactions:after-action-start":function(e,n){var i=e.interaction,r=(e.event,e.iEvent);if("drag"===i.prepared.name){var a=i.dropState;a.activeDrops=null,a.events=null,a.activeDrops=es(n,i.element),a.events=el(i,0,r),a.events.activate&&(ea(a.activeDrops,a.events.activate),n.fire("actions/drop:start",{interaction:i,dragEvent:r}))}},"interactions:action-move":ec,"interactions:after-action-move":function(e,n){var i=e.interaction,r=e.iEvent;"drag"===i.prepared.name&&(eu(i,i.dropState.events),n.fire("actions/drop:move",{interaction:i,dragEvent:r}),i.dropState.events={})},"interactions:action-end":function(e,n){if("drag"===e.interaction.prepared.name){var i=e.interaction,r=e.iEvent;ec(e,n),eu(i,i.dropState.events),n.fire("actions/drop:end",{interaction:i,dragEvent:r})}},"interactions:stop":function(e){var n=e.interaction;if("drag"===n.prepared.name){var i=n.dropState;i&&(i.activeDrops=null,i.events=null,i.cur.dropzone=null,i.cur.element=null,i.prev.dropzone=null,i.prev.element=null,i.rejected=!1)}}},getActiveDrops:es,getDrop:eo,getDropEvents:el,fireDropEvents:eu,defaults:{enabled:!1,accept:null,overlap:"pointer"}};er.default=eh;var ed={};function ep(e){var n=e.interaction,i=e.iEvent,r=e.phase;if("gesture"===n.prepared.name){var a=n.pointers.map(function(e){return e.pointer}),s=n.interactable.options.deltaSource;if(i.touches=[a[0],a[1]],"start"===r)i.distance=z.touchDistance(a,s),i.box=z.touchBBox(a),i.scale=1,i.ds=0,i.angle=z.touchAngle(a,s),i.da=0,n.gesture.startDistance=i.distance,n.gesture.startAngle=i.angle;else if("end"===r){var o=n.prevEvent;i.distance=o.distance,i.box=o.box,i.scale=o.scale,i.ds=0,i.angle=o.angle,i.da=0}else i.distance=z.touchDistance(a,s),i.box=z.touchBBox(a),i.scale=i.distance/n.gesture.startDistance,i.angle=z.touchAngle(a,s),i.ds=i.scale-n.gesture.scale,i.da=i.angle-n.gesture.angle;n.gesture.distance=i.distance,n.gesture.angle=i.angle,l.default.number(i.scale)&&i.scale!==1/0&&!isNaN(i.scale)&&(n.gesture.scale=i.scale)}}Object.defineProperty(ed,"__esModule",{value:!0}),ed.default=void 0;var ef={id:"actions/gesture",before:["actions/drag","actions/resize"],install:function(e){var n=e.actions,i=e.Interactable,r=e.defaults;i.prototype.gesturable=function(e){return l.default.object(e)?(this.options.gesture.enabled=!1!==e.enabled,this.setPerAction("gesture",e),this.setOnEvents("gesture",e),this):l.default.bool(e)?(this.options.gesture.enabled=e,this):this.options.gesture},n.map.gesture=ef,n.methodDict.gesture="gesturable",r.actions.gesture=ef.defaults},listeners:{"interactions:action-start":ep,"interactions:action-move":ep,"interactions:action-end":ep,"interactions:new":function(e){e.interaction.gesture={angle:0,distance:0,scale:1,startAngle:0,startDistance:0}},"auto-start:check":function(e){if(!(e.interaction.pointers.length<2)){var n=e.interactable.options.gesture;if(n&&n.enabled)return e.action={name:"gesture"},!1}}},defaults:{},getCursor:function(){return""}};ed.default=ef;var em={};function eg(e){var n=e.iEvent,i=e.interaction;"resize"===i.prepared.name&&i.resizeAxes&&(i.interactable.options.resize.square?("y"===i.resizeAxes?n.delta.x=n.delta.y:n.delta.y=n.delta.x,n.axes="xy"):(n.axes=i.resizeAxes,"x"===i.resizeAxes?n.delta.y=0:"y"===i.resizeAxes&&(n.delta.x=0)))}Object.defineProperty(em,"__esModule",{value:!0}),em.default=void 0;var ev={id:"actions/resize",before:["actions/drag"],install:function(e){var n=e.actions,i=e.browser,r=e.Interactable,a=e.defaults;ev.cursors=i.isIe9?{x:"e-resize",y:"s-resize",xy:"se-resize",top:"n-resize",left:"w-resize",bottom:"s-resize",right:"e-resize",topleft:"se-resize",bottomright:"se-resize",topright:"ne-resize",bottomleft:"ne-resize"}:{x:"ew-resize",y:"ns-resize",xy:"nwse-resize",top:"ns-resize",left:"ew-resize",bottom:"ns-resize",right:"ew-resize",topleft:"nwse-resize",bottomright:"nwse-resize",topright:"nesw-resize",bottomleft:"nesw-resize"},ev.defaultMargin=i.supportsTouch||i.supportsPointerEvent?20:10,r.prototype.resizable=function(n){return l.default.object(n)?(this.options.resize.enabled=!1!==n.enabled,this.setPerAction("resize",n),this.setOnEvents("resize",n),l.default.string(n.axis)&&/^x$|^y$|^xy$/.test(n.axis)?this.options.resize.axis=n.axis:null===n.axis&&(this.options.resize.axis=e.defaults.actions.resize.axis),l.default.bool(n.preserveAspectRatio)?this.options.resize.preserveAspectRatio=n.preserveAspectRatio:l.default.bool(n.square)&&(this.options.resize.square=n.square),this):l.default.bool(n)?(this.options.resize.enabled=n,this):this.options.resize},n.map.resize=ev,n.methodDict.resize="resizable",a.actions.resize=ev.defaults},listeners:{"interactions:new":function(e){e.interaction.resizeAxes="xy"},"interactions:action-start":function(e){(function(e){var n=e.iEvent,i=e.interaction;if("resize"===i.prepared.name&&i.prepared.edges){var r=i.rect;i._rects={start:(0,R.default)({},r),corrected:(0,R.default)({},r),previous:(0,R.default)({},r),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},n.edges=i.prepared.edges,n.rect=i._rects.corrected,n.deltaRect=i._rects.delta}})(e),eg(e)},"interactions:action-move":function(e){(function(e){var n=e.iEvent,i=e.interaction;if("resize"===i.prepared.name&&i.prepared.edges){var r=i.interactable.options.resize.invert,a=i.rect,s=i._rects,o=s.start,l=s.corrected,u=s.delta,c=s.previous;if((0,R.default)(c,l),"reposition"===r||"negate"===r){if((0,R.default)(l,a),"reposition"===r){if(l.top>l.bottom){var h=l.top;l.top=l.bottom,l.bottom=h}if(l.left>l.right){var d=l.left;l.left=l.right,l.right=d}}}else l.top=Math.min(a.top,o.bottom),l.bottom=Math.max(a.bottom,o.top),l.left=Math.min(a.left,o.right),l.right=Math.max(a.right,o.left);for(var p in l.width=l.right-l.left,l.height=l.bottom-l.top,l)u[p]=l[p]-c[p];n.edges=i.prepared.edges,n.rect=l,n.deltaRect=u}})(e),eg(e)},"interactions:action-end":function(e){var n=e.iEvent,i=e.interaction;"resize"===i.prepared.name&&i.prepared.edges&&(n.edges=i.prepared.edges,n.rect=i._rects.corrected,n.deltaRect=i._rects.delta)},"auto-start:check":function(e){var n=e.interaction,i=e.interactable,r=e.element,a=e.rect,s=e.buttons;if(a){var o=(0,R.default)({},n.coords.cur.page),u=i.options.resize;if(u&&u.enabled&&(!n.pointerIsDown||!/mouse|pointer/.test(n.pointerType)||0!=(s&u.mouseButtons))){if(l.default.object(u.edges)){var c={left:!1,right:!1,top:!1,bottom:!1};for(var h in c)c[h]=function(e,n,i,r,a,s,o){if(!n)return!1;if(!0===n){var u=l.default.number(s.width)?s.width:s.right-s.left,c=l.default.number(s.height)?s.height:s.bottom-s.top;if(o=Math.min(o,Math.abs(("left"===e||"right"===e?u:c)/2)),u<0&&("left"===e?e="right":"right"===e&&(e="left")),c<0&&("top"===e?e="bottom":"bottom"===e&&(e="top")),"left"===e){var h=u>=0?s.left:s.right;return i.x=0?s.top:s.bottom;return i.y(u>=0?s.right:s.left)-o;if("bottom"===e)return i.y>(c>=0?s.bottom:s.top)-o}return!!l.default.element(r)&&(l.default.element(n)?n===r:b.matchesUpTo(r,n,a))}(h,u.edges[h],o,n._latestPointer.eventTarget,r,a,u.margin||ev.defaultMargin);c.left=c.left&&!c.right,c.top=c.top&&!c.bottom,(c.left||c.right||c.top||c.bottom)&&(e.action={name:"resize",edges:c})}else{var d="y"!==u.axis&&o.x>a.right-ev.defaultMargin,p="x"!==u.axis&&o.y>a.bottom-ev.defaultMargin;(d||p)&&(e.action={name:"resize",axes:(d?"x":"")+(p?"y":"")})}return!e.action&&void 0}}}},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor:function(e){var n=e.edges,i=e.axis,r=e.name,a=ev.cursors,s=null;if(i)s=a[r+i];else if(n){for(var o="",l=["top","bottom","left","right"],u=0;u=1){var h={x:eE.x*c,y:eE.y*c};if(h.x||h.y){var d=ew(s);l.default.window(s)?s.scrollBy(h.x,h.y):s&&(s.scrollLeft+=h.x,s.scrollTop+=h.y);var p=ew(s),f={x:p.x-d.x,y:p.y-d.y};(f.x||f.y)&&n.fire({type:"autoscroll",target:i,interactable:n,delta:f,interaction:e,container:s})}eE.prevTime=o}eE.isScrolling&&(ey.default.cancel(eE.i),eE.i=ey.default.request(eE.scroll))},check:function(e,n){var i;return null==(i=e.options[n].autoScroll)?void 0:i.enabled},onInteractionMove:function(e){var n=e.interaction,i=e.pointer;if(n.interacting()&&eE.check(n.interactable,n.prepared.name)){if(n.simulation)eE.x=eE.y=0;else{var r,a,s,o,u=n.interactable,c=n.element,h=n.prepared.name,d=u.options[h].autoScroll,p=eT(d.container,u,c);if(l.default.window(p))o=i.clientXp.innerWidth-eE.margin,s=i.clientY>p.innerHeight-eE.margin;else{var f=b.getElementClientRect(p);o=i.clientXf.right-eE.margin,s=i.clientY>f.bottom-eE.margin}eE.x=a?1:o?-1:0,eE.y=s?1:r?-1:0,eE.isScrolling||(eE.margin=d.margin,eE.speed=d.speed,eE.start(n))}}}};function eT(e,n,i){return(l.default.string(e)?(0,P.getStringOptionResult)(e,n,i):e)||(0,r.getWindow)(i)}function ew(e){return l.default.window(e)&&(e=window.document.body),{x:e.scrollLeft,y:e.scrollTop}}var eA={id:"auto-scroll",install:function(e){var n=e.defaults,i=e.actions;e.autoScroll=eE,eE.now=function(){return e.now()},i.phaselessTypes.autoscroll=!0,n.perAction.autoScroll=eE.defaults},listeners:{"interactions:new":function(e){e.interaction.autoScroll=null},"interactions:destroy":function(e){e.interaction.autoScroll=null,eE.stop(),eE.interaction&&(eE.interaction=null)},"interactions:stop":eE.stop,"interactions:action-move":function(e){return eE.onInteractionMove(e)}}};eS.default=eA;var eR={};Object.defineProperty(eR,"__esModule",{value:!0}),eR.copyAction=function(e,n){return e.name=n.name,e.axis=n.axis,e.edges=n.edges,e},eR.sign=void 0,eR.warnOnce=function(e,n){var i=!1;return function(){return i||(r.window.console.warn(n),i=!0),e.apply(this,arguments)}},eR.sign=function(e){return e>=0?1:-1};var eP={};function eC(e){return l.default.bool(e)?(this.options.styleCursor=e,this):null===e?(delete this.options.styleCursor,this):this.options.styleCursor}function eL(e){return l.default.func(e)?(this.options.actionChecker=e,this):null===e?(delete this.options.actionChecker,this):this.options.actionChecker}Object.defineProperty(eP,"__esModule",{value:!0}),eP.default=void 0,eP.default={id:"auto-start/interactableMethods",install:function(e){var n=e.Interactable;n.prototype.getAction=function(n,i,r,a){var s,o,l=(s=this.getRect(a),o={action:null,interactable:this,interaction:r,element:a,rect:s,buttons:i.buttons||({0:1,1:4,3:8,4:16})[i.button]},e.fire("auto-start:check",o),o.action);return this.options.actionChecker?this.options.actionChecker(n,i,l,this,a,r):l},n.prototype.ignoreFrom=(0,eR.warnOnce)(function(e){return this._backCompatOption("ignoreFrom",e)},"Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."),n.prototype.allowFrom=(0,eR.warnOnce)(function(e){return this._backCompatOption("allowFrom",e)},"Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."),n.prototype.actionChecker=eL,n.prototype.styleCursor=eC}};var eO={};function eI(e,n,i,r,a){return n.testIgnoreAllow(n.options[e.name],i,r)&&n.options[e.name].enabled&&eN(n,i,e,a)?e:null}function eD(e,n,i,r,a){var s=[],o=[],u=r;function c(e){s.push(e),o.push(u)}for(;l.default.element(u);){s=[],o=[],a.interactables.forEachMatch(u,c);var h=function(e,n,i,r,a,s,o){for(var l=0,u=r.length;l=l||p.interactable===e&&((c+=f===i.name?1:0)>=s||p.element===n&&(h++,f===i.name&&h>=o))))return!1}return l>0}function eF(e,n){return l.default.number(e)?(n.autoStart.maxInteractions=e,this):n.autoStart.maxInteractions}function ez(e,n,i){var r=i.autoStart.cursorElement;r&&r!==e&&(r.style.cursor=""),e.ownerDocument.documentElement.style.cursor=n,e.style.cursor=n,i.autoStart.cursorElement=n?e:null}function eB(e,n){var i=e.interactable,r=e.element,a=e.prepared;if("mouse"===e.pointerType&&i&&i.options.styleCursor){var s="";if(a.name){var o=i.options[a.name].cursorChecker;s=l.default.func(o)?o(a,i,r,e._interacting):n.actions.map[a.name].getCursor(a)}ez(e.element,s||"",n)}else n.autoStart.cursorElement&&ez(n.autoStart.cursorElement,"",n)}Object.defineProperty(eO,"__esModule",{value:!0}),eO.default=void 0,eO.default={id:"auto-start/base",before:["actions"],install:function(e){var n=e.interactStatic,i=e.defaults;e.usePlugin(eP.default),i.base.actionChecker=null,i.base.styleCursor=!0,(0,R.default)(i.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),n.maxInteractions=function(n){return eF(n,e)},e.autoStart={maxInteractions:1/0,withinInteractionLimit:eN,cursorElement:null}},listeners:{"interactions:down":function(e,n){var i=e.interaction,r=e.pointer,a=e.event,s=e.eventTarget;i.interacting()||eU(i,eD(i,r,a,s,n),n)},"interactions:move":function(e,n){var i,r,a,s;i=e.interaction,r=e.pointer,a=e.event,s=e.eventTarget,"mouse"!==i.pointerType||i.pointerIsDown||i.interacting()||eU(i,eD(i,r,a,s,n),n),function(e,n){var i=e.interaction;if(i.pointerIsDown&&!i.interacting()&&i.pointerWasMoved&&i.prepared.name){n.fire("autoStart:before-start",e);var r=i.interactable,a=i.prepared.name;a&&r&&(r.options[a].manualStart||!eN(r,i.element,i.prepared,n)?i.stop():(i.start(i.prepared,r,i.element),eB(i,n)))}}(e,n)},"interactions:stop":function(e,n){var i=e.interaction,r=i.interactable;r&&r.options.styleCursor&&ez(i.element,"",n)}},maxInteractions:eF,withinInteractionLimit:eN,validateAction:eI};var ek={};Object.defineProperty(ek,"__esModule",{value:!0}),ek.default=void 0,ek.default={id:"auto-start/dragAxis",listeners:{"autoStart:before-start":function(e,n){var i=e.interaction,r=e.eventTarget,a=e.dx,s=e.dy;if("drag"===i.prepared.name){var o=Math.abs(a),u=Math.abs(s),c=i.interactable.options.drag,h=c.startAxis,d=o>u?"x":o0&&(n.autoStartHoldTimer=setTimeout(function(){n.start(n.prepared,n.interactable,n.element)},i))},"interactions:move":function(e){var n=e.interaction,i=e.duplicate;n.autoStartHoldTimer&&n.pointerWasMoved&&!i&&(clearTimeout(n.autoStartHoldTimer),n.autoStartHoldTimer=null)},"autoStart:before-start":function(e){var n=e.interaction;eV(n)>0&&(n.prepared.name=null)}},getHoldDuration:eV};var eG={};Object.defineProperty(eG,"__esModule",{value:!0}),eG.default=void 0,eG.default={id:"auto-start",install:function(e){e.usePlugin(eO.default),e.usePlugin(eH.default),e.usePlugin(ek.default)}};var eW={};function ej(e){return/^(always|never|auto)$/.test(e)?(this.options.preventDefault=e,this):l.default.bool(e)?(this.options.preventDefault=e?"always":"never",this):this.options.preventDefault}function eX(e){var n=e.interaction,i=e.event;n.interactable&&n.interactable.checkAndPreventDefault(i)}function eq(e){var n=e.Interactable;n.prototype.preventDefault=ej,n.prototype.checkAndPreventDefault=function(n){return function(e,n,i){var a=e.options.preventDefault;if("never"!==a){if("always"!==a){if(n.events.supportsPassive&&/^touch(start|move)$/.test(i.type)){var s=(0,r.getWindow)(i.target).document,o=n.getDocOptions(s);if(!o||!o.events||!1!==o.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(i.type)||l.default.element(i.target)&&(0,b.matchesSelector)(i.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||i.preventDefault()}else i.preventDefault()}}(this,e,n)},e.interactions.docEvents.push({type:"dragstart",listener:function(n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);i150)return null;var n=180*Math.atan2(e.prevEvent.velocityY,e.prevEvent.velocityX)/Math.PI;n<0&&(n+=360);var i=112.5<=n&&n<247.5,r=202.5<=n&&n<337.5;return{up:r,down:!r&&22.5<=n&&n<157.5,left:i,right:!i&&(292.5<=n||n<67.5),angle:n,speed:e.prevEvent.speed,velocity:{x:e.prevEvent.velocityX,y:e.prevEvent.velocityY}}}},{key:"preventDefault",value:function(){}},{key:"stopImmediatePropagation",value:function(){this.immediatePropagationStopped=this.propagationStopped=!0}},{key:"stopPropagation",value:function(){this.propagationStopped=!0}}],function(e,n){for(var i=0;ithis.pointerMoveTolerance);var o=this.getPointerIndex(e),l={pointer:e,pointerIndex:o,pointerInfo:this.pointers[o],event:n,type:"move",eventTarget:i,dx:r,dy:a,duplicate:s,interaction:this};s||z.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",l),s||this.simulation||(this.interacting()&&(l.type=null,this.move(l)),this.pointerWasMoved&&z.copyCoords(this.coords.prev,this.coords.cur))}},{key:"move",value:function(e){e&&e.event||z.setZeroCoords(this.coords.delta),(e=(0,R.default)({pointer:this._latestPointer.pointer,event:this._latestPointer.event,eventTarget:this._latestPointer.eventTarget,interaction:this},e||{})).phase="move",this._doPhase(e)}},{key:"pointerUp",value:function(e,n,i,r){var a=this.getPointerIndex(e);-1===a&&(a=this.updatePointer(e,n,i,!1));var s=/cancel$/i.test(n.type)?"cancel":"up";this._scopeFire("interactions:".concat(s),{pointer:e,pointerIndex:a,pointerInfo:this.pointers[a],event:n,eventTarget:i,type:s,curEventTarget:r,interaction:this}),this.simulation||this.end(n),this.removePointer(e,n)}},{key:"documentBlur",value:function(e){this.end(e),this._scopeFire("interactions:blur",{event:e,type:"blur",interaction:this})}},{key:"end",value:function(e){var n;this._ending=!0,e=e||this._latestPointer.event,this.interacting()&&(n=this._doPhase({event:e,interaction:this,phase:"end"})),this._ending=!1,!0===n&&this.stop()}},{key:"currentAction",value:function(){return this._interacting?this.prepared.name:null}},{key:"interacting",value:function(){return this._interacting}},{key:"stop",value:function(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}},{key:"getPointerIndex",value:function(e){var n=z.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:Y.findIndex(this.pointers,function(e){return e.id===n})}},{key:"getPointerInfo",value:function(e){return this.pointers[this.getPointerIndex(e)]}},{key:"updatePointer",value:function(e,n,i,r){var a=z.getPointerId(e),s=this.getPointerIndex(e),o=this.pointers[s];return r=!1!==r&&(r||/(down|start)$/i.test(n.type)),o?o.pointer=e:(o=new ts.PointerInfo(a,e,n,null,null),s=this.pointers.length,this.pointers.push(o)),z.setCoords(this.coords.cur,this.pointers.map(function(e){return e.pointer}),this._now()),z.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),r&&(this.pointerIsDown=!0,o.downTime=this.coords.cur.timeStamp,o.downTarget=i,z.pointerExtend(this.downPointer,e),this.interacting()||(z.copyCoords(this.coords.start,this.coords.cur),z.copyCoords(this.coords.prev,this.coords.cur),this.downEvent=n,this.pointerWasMoved=!1)),this._updateLatestPointer(e,n,i),this._scopeFire("interactions:update-pointer",{pointer:e,event:n,eventTarget:i,down:r,pointerInfo:o,pointerIndex:s,interaction:this}),s}},{key:"removePointer",value:function(e,n){var i=this.getPointerIndex(e);if(-1!==i){var r=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:e,event:n,eventTarget:null,pointerIndex:i,pointerInfo:r,interaction:this}),this.pointers.splice(i,1),this.pointerIsDown=!1}}},{key:"_updateLatestPointer",value:function(e,n,i){this._latestPointer.pointer=e,this._latestPointer.event=n,this._latestPointer.eventTarget=i}},{key:"destroy",value:function(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}},{key:"_createPreparedEvent",value:function(e,n,i,r){return new e9.InteractEvent(this,e,this.prepared.name,n,this.element,i,r)}},{key:"_fireEvent",value:function(e){var n;null==(n=this.interactable)||n.fire(e),(!this.prevEvent||e.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=e)}},{key:"_doPhase",value:function(e){var n=e.event,i=e.phase,r=e.preEnd,a=e.type,s=this.rect;if(s&&"move"===i&&(P.addEdges(this.edges,s,this.coords.delta[this.interactable.options.deltaSource]),s.width=s.right-s.left,s.height=s.bottom-s.top),!1===this._scopeFire("interactions:before-action-".concat(i),e))return!1;var o=e.iEvent=this._createPreparedEvent(n,i,r,a);return this._scopeFire("interactions:action-".concat(i),e),"start"===i&&(this.prevEvent=o),this._fireEvent(o),this._scopeFire("interactions:after-action-".concat(i),e),!0}},{key:"_now",value:function(){return Date.now()}}],function(e,n){for(var i=0;ii.minSpeed&&a>i.endSpeed)this.startInertia();else{if(s.result=s.setAll(this.modifierArg),!s.result.changed)return!1;this.startSmoothEnd()}return n.modification.result.rect=null,n.offsetBy(this.targetOffset),n._doPhase({interaction:n,event:e,phase:"inertiastart"}),n.offsetBy({x:-this.targetOffset.x,y:-this.targetOffset.y}),n.modification.result.rect=null,this.active=!0,n.simulation=this,!0}},{key:"startInertia",value:function(){var e=this,n=this.interaction.coords.velocity.client,i=tP(this.interaction),r=i.resistance,a=-Math.log(i.endSpeed/this.v0)/r;this.targetOffset={x:(n.x-a)/r,y:(n.y-a)/r},this.te=a,this.lambda_v0=r/this.v0,this.one_ve_v0=1-i.endSpeed/this.v0;var s=this.modification,o=this.modifierArg;o.pageCoords={x:this.startCoords.x+this.targetOffset.x,y:this.startCoords.y+this.targetOffset.y},s.result=s.setAll(o),s.result.changed&&(this.isModified=!0,this.modifiedOffset={x:this.targetOffset.x+s.result.delta.x,y:this.targetOffset.y+s.result.delta.y}),this.onNextFrame(function(){return e.inertiaTick()})}},{key:"startSmoothEnd",value:function(){var e=this;this.smoothEnd=!0,this.isModified=!0,this.targetOffset={x:this.modification.result.delta.x,y:this.modification.result.delta.y},this.onNextFrame(function(){return e.smoothEndTick()})}},{key:"onNextFrame",value:function(e){var n=this;this.timeout=ey.default.request(function(){n.active&&e()})}},{key:"inertiaTick",value:function(){var e,n,i,r,a=this,s=this.interaction,o=tP(s).resistance,l=(s._now()-this.t0)/1e3;if(l=0;i--){var r=n[i],a=r.selector,s=r.context,o=r.listeners;a===this.target&&s===this._context&&n.splice(i,1);for(var u=o.length-1;u>=0;u--)this._scopeEvents.removeDelegate(this.target,this._context,e,o[u][0],o[u][1])}else this._scopeEvents.remove(this.target,"all")}}],function(e,n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);i=0;o--){var f=d[o];if(f.selector===e&&f.context===n){for(var m=f.listeners,g=m.length-1;g>=0;g--){var v=tX(m[g],2),_=v[0],y=v[1],x=y.capture,b=y.passive;if(_===a&&x===l.capture&&b===l.passive){m.splice(g,1),m.length||(d.splice(o,1),u(n,i,c),u(n,i,h,!0)),p=!0;break}}if(p)break}}},delegateListener:c,delegateUseCapture:h,delegatedEvents:r,documents:a,targets:i,supportsOptions:!1,supportsPassive:!1};function o(e,n,r,a){var o=tJ(a),l=Y.find(i,function(n){return n.eventTarget===e});l||(l={eventTarget:e,events:{}},i.push(l)),l.events[n]||(l.events[n]=[]),e.addEventListener&&!Y.contains(l.events[n],r)&&(e.addEventListener(n,r,s.supportsOptions?o:o.capture),l.events[n].push(r))}function u(e,n,r,a){var o=tJ(a),l=Y.findIndex(i,function(n){return n.eventTarget===e}),c=i[l];if(c&&c.events){if("all"!==n){var h=!1,d=c.events[n];if(d){if("all"===r){for(var p=d.length-1;p>=0;p--)u(e,n,d[p],o);return}for(var f=0;f=2)continue;if(!a.interacting()&&n===a.pointerType)return a}return null}};function t$(e,n){return e.pointers.some(function(e){return e.id===n})}tZ.default=tK;var tQ={};function t0(e){return(t0="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t1(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,a,s=[],o=!0,l=!1;try{for(i=i.call(e);!(o=(r=i.next()).done)&&(s.push(r.value),!n||s.length!==n);o=!0);}catch(e){l=!0,a=e}finally{try{o||null==i.return||i.return()}finally{if(l)throw a}}return s}}(e,n)||function(e,n){if(e){if("string"==typeof e)return t2(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t2(e,n):void 0}}(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t2(e,n){(null==n||n>e.length)&&(n=e.length);for(var i=0,r=Array(n);i=0;r--){var a=n.interactions.list[r];a.interactable===i&&(a.stop(),n.fire("interactions:destroy",{interaction:a}),a.destroy(),n.interactions.list.length>2&&n.interactions.list.splice(r,1))}}},onDocSignal:t8,doOnInteractions:t6,methodNames:t5};var t9={};function ne(e){return(ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function nt(){return(nt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,n,i){var r=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=ni(e)););return e}(e,n);if(r){var a=Object.getOwnPropertyDescriptor(r,n);return a.get?a.get.call(arguments.length<3?e:i):a.value}}).apply(this,arguments)}function nn(e,n){return(nn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e})(e,n)}function ni(e){return(ni=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function nr(e,n){if(!(e instanceof n))throw TypeError("Cannot call a class as a function")}function na(e,n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);iMath.abs(c.y),u.coords,u.rect),(0,R.default)(r,u.coords)),u.eventProps},defaults:{ratio:"preserve",equalDelta:!1,modifiers:[],enabled:!1}};function nw(e,n,i){var r=e.startCoords,a=e.edgeSign;n?i.y=r.y+(i.x-r.x)*a.y:i.x=r.x+(i.y-r.y)*a.x}function nA(e,n,i,r){var a=e.startRect,s=e.startCoords,o=e.ratio,l=e.edgeSign;if(n){var u=r.width/o;i.y=s.y+(u-a.height)*l.y}else{var c=r.height*o;i.x=s.x+(c-a.width)*l.x}}nM.aspectRatio=nT;var nR=(0,e6.makeModifier)(nT,"aspectRatio");nM.default=nR;var nP={};Object.defineProperty(nP,"__esModule",{value:!0}),nP.default=void 0;var nC=function(){};nC._defaults={},nP.default=nC;var nL={};Object.defineProperty(nL,"__esModule",{value:!0}),Object.defineProperty(nL,"default",{enumerable:!0,get:function(){return nP.default}});var nO={};function nI(e,n,i){return l.default.func(e)?P.resolveRectLike(e,n.interactable,n.element,[i.x,i.y,n]):P.resolveRectLike(e,n.interactable,n.element)}Object.defineProperty(nO,"__esModule",{value:!0}),nO.default=void 0,nO.getRestrictionRect=nI,nO.restrict=void 0;var nD={start:function(e){var n=e.rect,i=e.startOffset,r=e.state,a=e.interaction,s=e.pageCoords,o=r.options,l=o.elementRect,u=(0,R.default)({left:0,top:0,right:0,bottom:0},o.offset||{});if(n&&l){var c=nI(o.restriction,a,s);if(c){var h=c.right-c.left-n.width,d=c.bottom-c.top-n.height;h<0&&(u.left+=h,u.right+=h),d<0&&(u.top+=d,u.bottom+=d)}u.left+=i.left-n.width*l.left,u.top+=i.top-n.height*l.top,u.right+=i.right-n.width*(1-l.right),u.bottom+=i.bottom-n.height*(1-l.bottom)}r.offset=u},set:function(e){var n=e.coords,i=e.interaction,r=e.state,a=r.options,s=r.offset,o=nI(a.restriction,i,n);if(o){var l=P.xywhToTlbr(o);n.x=Math.max(Math.min(l.right-s.right,n.x),l.left+s.left),n.y=Math.max(Math.min(l.bottom-s.bottom,n.y),l.top+s.top)}},defaults:{restriction:null,elementRect:null,offset:null,endOnly:!1,enabled:!1}};nO.restrict=nD;var nU=(0,e6.makeModifier)(nD,"restrict");nO.default=nU;var nN={};Object.defineProperty(nN,"__esModule",{value:!0}),nN.restrictEdges=nN.default=void 0;var nF={top:1/0,left:1/0,bottom:-1/0,right:-1/0},nz={top:-1/0,left:-1/0,bottom:1/0,right:1/0};function nB(e,n){for(var i=["top","left","bottom","right"],r=0;re.length)&&(n=e.length);for(var i=0,r=Array(n);i{"use strict";i.d(n,{Z:()=>r});let r={crush:(e,n=50)=>{let i=[];for(let e=127;--e;)(e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||"-_.!~*'()".includes(String.fromCharCode(e)))&&i.push(String.fromCharCode(e));for(let e=32;e<255;++e){let n=String.fromCharCode(e);"\\"==n||i.includes(n)||i.unshift(n)}e=a(e=e.replace(RegExp("\x01","g"),""));let r=((e,i)=>{let r=i.length,a="",s=e=>encodeURI(encodeURIComponent(e)).replace(/%../g,"i").length,o=e=>{let n=e.charCodeAt(0),i=e.charCodeAt(e.length-1);return n>=56320&&n<=57343||i>=55296&&i<=56319},l={};for(let i=2;i=0;++a)s=e.indexOf(r,s+i);a>1&&(l[r]=a)}for(;;){let n;for(;r--&&e.includes(i[r]););if(r<0)break;let o=i[r],u=0,c=s(o);for(let e in l){let i=l[e],r=(i-1)*s(e)-(i+1)*c;a.length||(r-=s("\x01")),r<=0?delete l[e]:r>u&&(n=e,u=r)}if(!n)break;e=e.split(n).join(o)+o+n,a=o+a;let h={};for(let i in l){let r=i.split(n).join(o),a=0;for(let n=e.indexOf(r);n>=0;++a)n=e.indexOf(r,n+r.length);a>1&&(h[r]=a)}l=h}return{a:e,b:a}})(e,i),s=r.a;return r.b.length&&(s+="\x01"+r.b),s+="_"},uncrush:e=>{e=e.substring(0,e.length-1);let n=e.split("\x01"),i=n[0];if(n.length>1)for(let e of n[1]){let n=i.split(e);i=n.join(n.pop())}return a(i,0)}},a=(e,n=1)=>{let i=[['"',"'"],["':","!"],[",'","~"],["}",")","\\","\\"],["{","(","\\","\\"]],r=(e,n)=>{let i=RegExp(`${(n[2]?n[2]:"")+n[0]}|${(n[3]?n[3]:"")+n[1]}`,"g");return e.replace(i,e=>e===n[0]?n[1]:n[0])};if(n)for(let n=0;n{"use strict";let r,a,s,o;i.d(n,{BbS:()=>s6,CP7:()=>rL,D1R:()=>_,DvJ:()=>nn,EB7:()=>af,EJi:()=>sl,F5T:()=>tT,FM8:()=>J,GUF:()=>A,Hmr:()=>sK,Hw6:()=>eh,Ilk:()=>tC,KI_:()=>w,Kj0:()=>ne,M8C:()=>Y,Mig:()=>sY,N$j:()=>rX,NMF:()=>b,OdW:()=>rZ,OoA:()=>d,Ox3:()=>sq,PMe:()=>sk,Pa4:()=>ex,QRU:()=>sZ,SJI:()=>s5,SPe:()=>r5,Syv:()=>x,TUv:()=>rj,TlE:()=>tU,Tme:()=>th,TyD:()=>p,UY4:()=>ao,UlW:()=>S,Wid:()=>so,Wl3:()=>l,WwZ:()=>M,YLQ:()=>f,ZAu:()=>rE,Zp0:()=>sJ,ZzF:()=>eS,Zzh:()=>of,_12:()=>nM,_C8:()=>sp,_fP:()=>ey,aCh:()=>T,aH4:()=>m,aLr:()=>eH,aNw:()=>sR,blk:()=>as,cJO:()=>a8,cPb:()=>nu,cek:()=>sj,dUE:()=>sx,dpR:()=>sI,ehD:()=>u,ejS:()=>aa,epp:()=>es,fHI:()=>aN,hH6:()=>sL,iKG:()=>nI,iLg:()=>sM,iMs:()=>ou,iUV:()=>oo,iWj:()=>ny,jyz:()=>no,kB5:()=>rU,m7l:()=>sT,mTL:()=>s$,nls:()=>r6,qyh:()=>v,rpg:()=>c,tGC:()=>og,u9r:()=>tX,uWy:()=>h,vBJ:()=>tO,vpT:()=>rI,wem:()=>g,wk1:()=>y,woe:()=>ad,x12:()=>an,xEZ:()=>ef,xWb:()=>ol,xoR:()=>su,xsS:()=>rO,yC1:()=>sE,yGw:()=>eZ,z$h:()=>E,zf8:()=>aU});let l=0,u=2,c=1e3,h=1001,d=1002,p=1003,f=1004,m=1005,g=1006,v=1007,_=1008,y=1023,x=2300,b=2301,M=0,S=1,E=2,T="",w="srgb",A="srgb-linear",R="display-p3",P="display-p3-linear",C="linear",L="srgb",O="rec709",I="300 es";class D{addEventListener(e,n){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(n)&&i[e].push(n)}hasEventListener(e,n){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(n)}removeEventListener(e,n){if(void 0===this._listeners)return;let i=this._listeners,r=i[e];if(void 0!==r){let e=r.indexOf(n);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let n=this._listeners,i=n[e.type];if(void 0!==i){e.target=this;let n=i.slice(0);for(let i=0,r=n.length;i>8&255]+U[e>>16&255]+U[e>>24&255]+"-"+U[255&n]+U[n>>8&255]+"-"+U[n>>16&15|64]+U[n>>24&255]+"-"+U[63&i|128]+U[i>>8&255]+"-"+U[i>>16&255]+U[i>>24&255]+U[255&r]+U[r>>8&255]+U[r>>16&255]+U[r>>24&255];return a.toLowerCase()}function k(e,n,i){return Math.max(n,Math.min(i,e))}function H(e,n){return(e%n+n)%n}function V(e,n,i){return(1-i)*e+i*n}function G(e){return(e&e-1)==0&&0!==e}function W(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function j(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function X(e,n){switch(n.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function q(e,n){switch(n.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}let Y={DEG2RAD:F,RAD2DEG:z,generateUUID:B,clamp:k,euclideanModulo:H,mapLinear:function(e,n,i,r,a){return r+(e-n)*(a-r)/(i-n)},inverseLerp:function(e,n,i){return e!==n?(i-e)/(n-e):0},lerp:V,damp:function(e,n,i,r){return V(e,n,1-Math.exp(-i*r))},pingpong:function(e,n=1){return n-Math.abs(H(e,2*n)-n)},smoothstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n))*e*(3-2*e)},smootherstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n))*e*e*(e*(6*e-15)+10)},randInt:function(e,n){return e+Math.floor(Math.random()*(n-e+1))},randFloat:function(e,n){return e+Math.random()*(n-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(N=e);let n=N+=1831565813;return n=Math.imul(n^n>>>15,1|n),(((n^=n+Math.imul(n^n>>>7,61|n))^n>>>14)>>>0)/4294967296},degToRad:function(e){return e*F},radToDeg:function(e){return e*z},isPowerOfTwo:G,ceilPowerOfTwo:W,floorPowerOfTwo:j,setQuaternionFromProperEuler:function(e,n,i,r,a){let s=Math.cos,o=Math.sin,l=s(i/2),u=o(i/2),c=s((n+r)/2),h=o((n+r)/2),d=s((n-r)/2),p=o((n-r)/2),f=s((r-n)/2),m=o((r-n)/2);switch(a){case"XYX":e.set(l*h,u*d,u*p,l*c);break;case"YZY":e.set(u*p,l*h,u*d,l*c);break;case"ZXZ":e.set(u*d,u*p,l*h,l*c);break;case"XZX":e.set(l*h,u*m,u*f,l*c);break;case"YXY":e.set(u*f,l*h,u*m,l*c);break;case"ZYZ":e.set(u*m,u*f,l*h,l*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}},normalize:q,denormalize:X};class J{constructor(e=0,n=0){J.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let n=this.x,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===n)return Math.PI/2;let i=this.dot(e)/n;return Math.acos(k(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,i=this.y-e.y;return n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){let i=Math.cos(n),r=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Z{constructor(e,n,i,r,a,s,o,l,u){Z.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,n,i,r,a,s,o,l,u)}set(e,n,i,r,a,s,o,l,u){let c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=n,c[4]=a,c[5]=l,c[6]=i,c[7]=s,c[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[3],l=i[6],u=i[1],c=i[4],h=i[7],d=i[2],p=i[5],f=i[8],m=r[0],g=r[3],v=r[6],_=r[1],y=r[4],x=r[7],b=r[2],M=r[5],S=r[8];return a[0]=s*m+o*_+l*b,a[3]=s*g+o*y+l*M,a[6]=s*v+o*x+l*S,a[1]=u*m+c*_+h*b,a[4]=u*g+c*y+h*M,a[7]=u*v+c*x+h*S,a[2]=d*m+p*_+f*b,a[5]=d*g+p*y+f*M,a[8]=d*v+p*x+f*S,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return n*s*c-n*o*u-i*a*c+i*o*l+r*a*u-r*s*l}invert(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=c*s-o*u,d=o*l-c*a,p=u*a-s*l,f=n*h+i*d+r*p;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=h*m,e[1]=(r*u-c*i)*m,e[2]=(o*i-r*s)*m,e[3]=d*m,e[4]=(c*n-r*l)*m,e[5]=(r*a-o*n)*m,e[6]=p*m,e[7]=(i*l-u*n)*m,e[8]=(s*n-i*a)*m,this}transpose(){let e;let n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,i,r,a,s,o){let l=Math.cos(a),u=Math.sin(a);return this.set(i*l,i*u,-i*(l*s+u*o)+s+e,-r*u,r*l,-r*(-u*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(K.makeScale(e,n)),this}rotate(e){return this.premultiply(K.makeRotation(-e)),this}translate(e,n){return this.premultiply(K.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){let n=this.elements,i=e.elements;for(let e=0;e<9;e++)if(n[e]!==i[e])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){let i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let K=new Z;function $(e){for(let n=e.length-1;n>=0;--n)if(e[n]>=65535)return!0;return!1}function Q(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;let ee={};function et(e){e in ee||(ee[e]=!0,console.warn(e))}let en=new Z().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ei=new Z().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),er={[A]:{transfer:C,primaries:O,toReference:e=>e,fromReference:e=>e},[w]:{transfer:L,primaries:O,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[P]:{transfer:C,primaries:"p3",toReference:e=>e.applyMatrix3(ei),fromReference:e=>e.applyMatrix3(en)},[R]:{transfer:L,primaries:"p3",toReference:e=>e.convertSRGBToLinear().applyMatrix3(ei),fromReference:e=>e.applyMatrix3(en).convertLinearToSRGB()}},ea=new Set([A,P]),es={enabled:!0,_workingColorSpace:A,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(legacyMode){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!legacyMode},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(colorSpace){if(!ea.has(colorSpace))throw Error(`Unsupported working color space, "${colorSpace}".`);this._workingColorSpace=colorSpace},convert:function(e,n,i){if(!1===this.enabled||n===i||!n||!i)return e;let r=er[n].toReference,a=er[i].fromReference;return a(r(e))},fromWorkingColorSpace:function(e,n){return this.convert(e,this._workingColorSpace,n)},toWorkingColorSpace:function(e,n){return this.convert(e,n,this._workingColorSpace)},getPrimaries:function(e){return er[e].primaries},getTransfer:function(e){return e===T?C:er[e].transfer}};function eo(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function el(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class eu{static getDataURL(e){let n;if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)n=e;else{void 0===r&&(r=Q("canvas")),r.width=e.width,r.height=e.height;let i=r.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=r}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let n=Q("canvas");n.width=e.width,n.height=e.height;let i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let e=0;e0&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case c:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case d:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case c:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case d:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return et("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===w?3001:3e3}set encoding(e){et("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=3001===e?w:T}}ef.DEFAULT_IMAGE=null,ef.DEFAULT_MAPPING=300,ef.DEFAULT_ANISOTROPY=1;class em{constructor(e=0,n=0,i=0,r=1){em.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let n=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*n+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*n+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*n+s[7]*i+s[11]*r+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,i,r;let a=e.elements,s=a[0],o=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-d)&&.01>Math.abs(h-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+d)&&.1>Math.abs(h+p)&&.1>Math.abs(s+c+f-3))return this.set(1,0,0,0),this;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+u)/4,v=(l+d)/4,_=(h+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(i=g/(n=Math.sqrt(e)),r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(n=g/(i=Math.sqrt(a)),r=_/i):m<.01?(n=.707106781,i=.707106781,r=0):(n=v/(r=Math.sqrt(m)),i=_/r),this.set(n,i,r,Math.PI),this}let m=Math.sqrt((p-h)*(p-h)+(l-d)*(l-d)+(u-o)*(u-o));return .001>Math.abs(m)&&(m=1),this.x=(p-h)/m,this.y=(l-d)/m,this.z=(u-o)/m,this.w=Math.acos((s+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class eg extends D{constructor(e=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new em(0,0,e,n),this.scissorTest=!1,this.viewport=new em(0,0,e,n),void 0!==i.encoding&&(et("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=3001===i.encoding?w:T),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:g,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new ef({width:e,height:n,depth:1},i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,n,i=1){(this.width!==e||this.height!==n||this.depth!==i)&&(this.width=e,this.height=n,this.depth=i,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let n=Object.assign({},e.texture.image);return this.texture.source=new eh(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ev extends eg{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class e_ extends ef{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=p,this.minFilter=p,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ey{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,a,s,o){let l=i[r+0],u=i[r+1],c=i[r+2],h=i[r+3],d=a[s+0],p=a[s+1],f=a[s+2],m=a[s+3];if(0===o){e[n+0]=l,e[n+1]=u,e[n+2]=c,e[n+3]=h;return}if(1===o){e[n+0]=d,e[n+1]=p,e[n+2]=f,e[n+3]=m;return}if(h!==m||l!==d||u!==p||c!==f){let e=1-o,n=l*d+u*p+c*f+h*m,i=n>=0?1:-1,r=1-n*n;if(r>Number.EPSILON){let a=Math.sqrt(r),s=Math.atan2(a,n*i);e=Math.sin(e*s)/a,o=Math.sin(o*s)/a}let a=o*i;if(l=l*e+d*a,u=u*e+p*a,c=c*e+f*a,h=h*e+m*a,e===1-o){let e=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=e,u*=e,c*=e,h*=e}}e[n]=l,e[n+1]=u,e[n+2]=c,e[n+3]=h}static multiplyQuaternionsFlat(e,n,i,r,a,s){let o=i[r],l=i[r+1],u=i[r+2],c=i[r+3],h=a[s],d=a[s+1],p=a[s+2],f=a[s+3];return e[n]=o*f+c*h+l*p-u*d,e[n+1]=l*f+c*d+u*h-o*p,e[n+2]=u*f+c*p+o*d-l*h,e[n+3]=c*f-o*h-l*d-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,u=o(i/2),c=o(r/2),h=o(a/2),d=l(i/2),p=l(r/2),f=l(a/2);switch(s){case"XYZ":this._x=d*c*h+u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h-d*p*f;break;case"YXZ":this._x=d*c*h+u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h+d*p*f;break;case"ZXY":this._x=d*c*h-u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h-d*p*f;break;case"ZYX":this._x=d*c*h-u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h+d*p*f;break;case"YZX":this._x=d*c*h+u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h-d*p*f;break;case"XZY":this._x=d*c*h-u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==n&&this._onChangeCallback(),this}setFromAxisAngle(e,n){let i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let n=e.elements,i=n[0],r=n[4],a=n[8],s=n[1],o=n[5],l=n[9],u=n[2],c=n[6],h=n[10],d=i+o+h;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-l)*e,this._y=(a-u)*e,this._z=(s-r)*e}else if(i>o&&i>h){let e=2*Math.sqrt(1+i-o-h);this._w=(c-l)/e,this._x=.25*e,this._y=(r+s)/e,this._z=(a+u)/e}else if(o>h){let e=2*Math.sqrt(1+o-i-h);this._w=(a-u)/e,this._x=(r+s)/e,this._y=.25*e,this._z=(l+c)/e}else{let e=2*Math.sqrt(1+h-i-o);this._w=(s-r)/e,this._x=(a+u)/e,this._y=(l+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x),this._w=i,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(k(this.dot(e),-1,1)))}rotateTowards(e,n){let i=this.angleTo(e);return 0===i||this.slerp(e,Math.min(1,n/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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){let i=e._x,r=e._y,a=e._z,s=e._w,o=n._x,l=n._y,u=n._z,c=n._w;return this._x=i*c+s*o+r*u-a*l,this._y=r*c+s*l+a*o-i*u,this._z=a*c+s*u+i*l-r*o,this._w=s*c-i*o-r*l-a*u,this._onChangeCallback(),this}slerp(e,n){if(0===n)return this;if(1===n)return this.copy(e);let i=this._x,r=this._y,a=this._z,s=this._w,o=s*e._w+i*e._x+r*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=i,this._y=r,this._z=a,this;let l=1-o*o;if(l<=Number.EPSILON){let e=1-n;return this._w=e*s+n*this._w,this._x=e*i+n*this._x,this._y=e*r+n*this._y,this._z=e*a+n*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,o),h=Math.sin((1-n)*c)/u,d=Math.sin(n*c)/u;return this._w=s*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=a*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){let e=Math.random(),n=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(r),i*Math.sin(a),i*Math.cos(a),n*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ex{constructor(e=0,n=0,i=0){ex.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return void 0===i&&(i=this.z),this.x=e,this.y=n,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(eM.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(eM.setFromAxisAngle(e,n))}applyMatrix3(e){let n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[3]*i+a[6]*r,this.y=a[1]*n+a[4]*i+a[7]*r,this.z=a[2]*n+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let n=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*n+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*n+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*n+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*n+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let n=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,l=e.w,u=l*n+s*r-o*i,c=l*i+o*n-a*r,h=l*r+a*i-s*n,d=-a*n-s*i-o*r;return this.x=u*l+-(d*a)+-(c*o)- -(h*s),this.y=c*l+-(d*s)+-(h*a)- -(u*o),this.z=h*l+-(d*o)+-(u*s)- -(c*a),this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[4]*i+a[8]*r,this.y=a[1]*n+a[5]*i+a[9]*r,this.z=a[2]*n+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){let i=e.x,r=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=r*l-a*o,this.y=a*s-i*l,this.z=i*o-r*s,this}projectOnVector(e){let n=e.lengthSq();if(0===n)return this.set(0,0,0);let i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return eb.copy(this).projectOnVector(e),this.sub(eb)}reflect(e){return this.sub(eb.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===n)return Math.PI/2;let i=this.dot(e)/n;return Math.acos(k(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,i){let r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){let n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){let n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,4*n)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,3*n)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(n),this.y=i*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let eb=new ex,eM=new ey;class eS{constructor(e=new ex(Infinity,Infinity,Infinity),n=new ex(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,i=e.length;nthis.max.x)&&!(e.ythis.max.y)&&!(e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x)&&!(e.max.ythis.max.y)&&!(e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,eT),eT.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eI),eD.subVectors(this.max,eI),eA.subVectors(e.a,eI),eR.subVectors(e.b,eI),eP.subVectors(e.c,eI),eC.subVectors(eR,eA),eL.subVectors(eP,eR),eO.subVectors(eA,eP);let n=[0,-eC.z,eC.y,0,-eL.z,eL.y,0,-eO.z,eO.y,eC.z,0,-eC.x,eL.z,0,-eL.x,eO.z,0,-eO.x,-eC.y,eC.x,0,-eL.y,eL.x,0,-eO.y,eO.x,0];return!!(eF(n,eA,eR,eP,eD)&&eF(n=[1,0,0,0,1,0,0,0,1],eA,eR,eP,eD))&&(eU.crossVectors(eC,eL),eF(n=[eU.x,eU.y,eU.z],eA,eR,eP,eD))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,eT).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(eT).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(eE[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),eE[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),eE[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),eE[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),eE[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),eE[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),eE[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),eE[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(eE)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}let eE=[new ex,new ex,new ex,new ex,new ex,new ex,new ex,new ex],eT=new ex,ew=new eS,eA=new ex,eR=new ex,eP=new ex,eC=new ex,eL=new ex,eO=new ex,eI=new ex,eD=new ex,eU=new ex,eN=new ex;function eF(e,n,i,r,a){for(let s=0,o=e.length-3;s<=o;s+=3){eN.fromArray(e,s);let o=a.x*Math.abs(eN.x)+a.y*Math.abs(eN.y)+a.z*Math.abs(eN.z),l=n.dot(eN),u=i.dot(eN),c=r.dot(eN);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>o)return!1}return!0}let ez=new eS,eB=new ex,ek=new ex;class eH{constructor(e=new ex,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){let i=this.center;void 0!==n?i.copy(n):ez.setFromPoints(e).getCenter(i);let r=0;for(let n=0,a=e.length;nthis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;eB.subVectors(e,this.center);let n=eB.lengthSq();if(n>this.radius*this.radius){let e=Math.sqrt(n),i=(e-this.radius)*.5;this.center.addScaledVector(eB,i/e),this.radius+=i}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(ek.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(eB.copy(e.center).add(ek)),this.expandByPoint(eB.copy(e.center).sub(ek)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}let eV=new ex,eG=new ex,eW=new ex,ej=new ex,eX=new ex,eq=new ex,eY=new ex;class eJ{constructor(e=new ex,n=new ex(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,eV)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);let i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let n=eV.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(eV.copy(this.origin).addScaledVector(this.direction,n),eV.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){let a,s,o,l;eG.copy(e).add(n).multiplyScalar(.5),eW.copy(n).sub(e).normalize(),ej.copy(this.origin).sub(eG);let u=.5*e.distanceTo(n),c=-this.direction.dot(eW),h=ej.dot(this.direction),d=-ej.dot(eW),p=ej.lengthSq(),f=Math.abs(1-c*c);if(f>0){if(a=c*d-h,s=c*h-d,l=u*f,a>=0){if(s>=-l){if(s<=l){let e=1/f;a*=e,s*=e,o=a*(a+c*s+2*h)+s*(c*a+s+2*d)+p}else o=-(a=Math.max(0,-(c*(s=u)+h)))*a+s*(s+2*d)+p}else o=-(a=Math.max(0,-(c*(s=-u)+h)))*a+s*(s+2*d)+p}else s<=-l?(s=(a=Math.max(0,-(-c*u+h)))>0?-u:Math.min(Math.max(-u,-d),u),o=-a*a+s*(s+2*d)+p):s<=l?(a=0,o=(s=Math.min(Math.max(-u,-d),u))*(s+2*d)+p):(s=(a=Math.max(0,-(c*u+h)))>0?u:Math.min(Math.max(-u,-d),u),o=-a*a+s*(s+2*d)+p)}else s=c>0?-u:u,o=-(a=Math.max(0,-(c*s+h)))*a+s*(s+2*d)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,a),r&&r.copy(eG).addScaledVector(eW,s),o}intersectSphere(e,n){eV.subVectors(e.center,this.origin);let i=eV.dot(this.direction),r=eV.dot(eV)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,l=i+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let n=e.normal.dot(this.direction);if(0===n)return 0===e.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){let i=this.distanceToPlane(e);return null===i?null:this.at(i,n)}intersectsPlane(e){let n=e.distanceToPoint(this.origin);if(0===n)return!0;let i=e.normal.dot(this.direction);return i*n<0}intersectBox(e,n){let i,r,a,s,o,l;let u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return(u>=0?(i=(e.min.x-d.x)*u,r=(e.max.x-d.x)*u):(i=(e.max.x-d.x)*u,r=(e.min.x-d.x)*u),c>=0?(a=(e.min.y-d.y)*c,s=(e.max.y-d.y)*c):(a=(e.max.y-d.y)*c,s=(e.min.y-d.y)*c),i>s||a>r)?null:((a>i||isNaN(i))&&(i=a),(s=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||o>r)?null:((o>i||i!=i)&&(i=o),(l=0?i:r,n)}intersectsBox(e){return null!==this.intersectBox(e,eV)}intersectTriangle(e,n,i,r,a){let s;eX.subVectors(n,e),eq.subVectors(i,e),eY.crossVectors(eX,eq);let o=this.direction.dot(eY);if(o>0){if(r)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}ej.subVectors(this.origin,e);let l=s*this.direction.dot(eq.crossVectors(ej,eq));if(l<0)return null;let u=s*this.direction.dot(eX.cross(ej));if(u<0||l+u>o)return null;let c=-s*ej.dot(eY);return c<0?null:this.at(c/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class eZ{constructor(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g){eZ.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g)}set(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g){let v=this.elements;return v[0]=e,v[4]=n,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=l,v[2]=u,v[6]=c,v[10]=h,v[14]=d,v[3]=p,v[7]=f,v[11]=m,v[15]=g,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 eZ().fromArray(this.elements)}copy(e){let n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){let n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(e){let n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){let n=this.elements,i=e.elements,r=1/eK.setFromMatrixColumn(e,0).length(),a=1/eK.setFromMatrixColumn(e,1).length(),s=1/eK.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*s,n[9]=i[9]*s,n[10]=i[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){let n=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),u=Math.sin(r),c=Math.cos(a),h=Math.sin(a);if("XYZ"===e.order){let e=s*c,i=s*h,r=o*c,a=o*h;n[0]=l*c,n[4]=-l*h,n[8]=u,n[1]=i+r*u,n[5]=e-a*u,n[9]=-o*l,n[2]=a-e*u,n[6]=r+i*u,n[10]=s*l}else if("YXZ"===e.order){let e=l*c,i=l*h,r=u*c,a=u*h;n[0]=e+a*o,n[4]=r*o-i,n[8]=s*u,n[1]=s*h,n[5]=s*c,n[9]=-o,n[2]=i*o-r,n[6]=a+e*o,n[10]=s*l}else if("ZXY"===e.order){let e=l*c,i=l*h,r=u*c,a=u*h;n[0]=e-a*o,n[4]=-s*h,n[8]=r+i*o,n[1]=i+r*o,n[5]=s*c,n[9]=a-e*o,n[2]=-s*u,n[6]=o,n[10]=s*l}else if("ZYX"===e.order){let e=s*c,i=s*h,r=o*c,a=o*h;n[0]=l*c,n[4]=r*u-i,n[8]=e*u+a,n[1]=l*h,n[5]=a*u+e,n[9]=i*u-r,n[2]=-u,n[6]=o*l,n[10]=s*l}else if("YZX"===e.order){let e=s*l,i=s*u,r=o*l,a=o*u;n[0]=l*c,n[4]=a-e*h,n[8]=r*h+i,n[1]=h,n[5]=s*c,n[9]=-o*c,n[2]=-u*c,n[6]=i*h+r,n[10]=e-a*h}else if("XZY"===e.order){let e=s*l,i=s*u,r=o*l,a=o*u;n[0]=l*c,n[4]=-h,n[8]=u*c,n[1]=e*h+a,n[5]=s*c,n[9]=i*h-r,n[2]=r*h-i,n[6]=o*c,n[10]=a*h+e}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(eQ,e,e0)}lookAt(e,n,i){let r=this.elements;return e3.subVectors(e,n),0===e3.lengthSq()&&(e3.z=1),e3.normalize(),e1.crossVectors(i,e3),0===e1.lengthSq()&&(1===Math.abs(i.z)?e3.x+=1e-4:e3.z+=1e-4,e3.normalize(),e1.crossVectors(i,e3)),e1.normalize(),e2.crossVectors(e3,e1),r[0]=e1.x,r[4]=e2.x,r[8]=e3.x,r[1]=e1.y,r[5]=e2.y,r[9]=e3.y,r[2]=e1.z,r[6]=e2.z,r[10]=e3.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[4],l=i[8],u=i[12],c=i[1],h=i[5],d=i[9],p=i[13],f=i[2],m=i[6],g=i[10],v=i[14],_=i[3],y=i[7],x=i[11],b=i[15],M=r[0],S=r[4],E=r[8],T=r[12],w=r[1],A=r[5],R=r[9],P=r[13],C=r[2],L=r[6],O=r[10],I=r[14],D=r[3],U=r[7],N=r[11],F=r[15];return a[0]=s*M+o*w+l*C+u*D,a[4]=s*S+o*A+l*L+u*U,a[8]=s*E+o*R+l*O+u*N,a[12]=s*T+o*P+l*I+u*F,a[1]=c*M+h*w+d*C+p*D,a[5]=c*S+h*A+d*L+p*U,a[9]=c*E+h*R+d*O+p*N,a[13]=c*T+h*P+d*I+p*F,a[2]=f*M+m*w+g*C+v*D,a[6]=f*S+m*A+g*L+v*U,a[10]=f*E+m*R+g*O+v*N,a[14]=f*T+m*P+g*I+v*F,a[3]=_*M+y*w+x*C+b*D,a[7]=_*S+y*A+x*L+b*U,a[11]=_*E+y*R+x*O+b*N,a[15]=_*T+y*P+x*I+b*F,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){let e=this.elements,n=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],l=e[9],u=e[13],c=e[2],h=e[6],d=e[10],p=e[14],f=e[3],m=e[7],g=e[11],v=e[15];return f*(+a*l*h-r*u*h-a*o*d+i*u*d+r*o*p-i*l*p)+m*(+n*l*p-n*u*d+a*s*d-r*s*p+r*u*c-a*l*c)+g*(+n*u*h-n*o*p-a*s*h+i*s*p+a*o*c-i*u*c)+v*(-r*o*c-n*l*h+n*o*d+r*s*h-i*s*d+i*l*c)}transpose(){let e;let n=this.elements;return e=n[1],n[1]=n[4],n[4]=e,e=n[2],n[2]=n[8],n[8]=e,e=n[6],n[6]=n[9],n[9]=e,e=n[3],n[3]=n[12],n[12]=e,e=n[7],n[7]=n[13],n[13]=e,e=n[11],n[11]=n[14],n[14]=e,this}setPosition(e,n,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],v=e[15],_=h*g*u-m*d*u+m*l*p-o*g*p-h*l*v+o*d*v,y=f*d*u-c*g*u-f*l*p+s*g*p+c*l*v-s*d*v,x=c*m*u-f*h*u+f*o*p-s*m*p-c*o*v+s*h*v,b=f*h*l-c*m*l-f*o*d+s*m*d+c*o*g-s*h*g,M=n*_+i*y+r*x+a*b;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/M;return e[0]=_*S,e[1]=(m*d*a-h*g*a-m*r*p+i*g*p+h*r*v-i*d*v)*S,e[2]=(o*g*a-m*l*a+m*r*u-i*g*u-o*r*v+i*l*v)*S,e[3]=(h*l*a-o*d*a-h*r*u+i*d*u+o*r*p-i*l*p)*S,e[4]=y*S,e[5]=(c*g*a-f*d*a+f*r*p-n*g*p-c*r*v+n*d*v)*S,e[6]=(f*l*a-s*g*a-f*r*u+n*g*u+s*r*v-n*l*v)*S,e[7]=(s*d*a-c*l*a+c*r*u-n*d*u-s*r*p+n*l*p)*S,e[8]=x*S,e[9]=(f*h*a-c*m*a-f*i*p+n*m*p+c*i*v-n*h*v)*S,e[10]=(s*m*a-f*o*a+f*i*u-n*m*u-s*i*v+n*o*v)*S,e[11]=(c*o*a-s*h*a-c*i*u+n*h*u+s*i*p-n*o*p)*S,e[12]=b*S,e[13]=(c*m*r-f*h*r+f*i*d-n*m*d-c*i*g+n*h*g)*S,e[14]=(f*o*r-s*m*r-f*i*l+n*m*l+s*i*g-n*o*g)*S,e[15]=(s*h*r-c*o*r+c*i*l-n*h*l-s*i*d+n*o*d)*S,this}scale(e){let n=this.elements,i=e.x,r=e.y,a=e.z;return n[0]*=i,n[4]*=r,n[8]*=a,n[1]*=i,n[5]*=r,n[9]*=a,n[2]*=i,n[6]*=r,n[10]*=a,n[3]*=i,n[7]*=r,n[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(e){let n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){let i=Math.cos(n),r=Math.sin(n),a=1-i,s=e.x,o=e.y,l=e.z,u=a*s,c=a*o;return this.set(u*s+i,u*o-r*l,u*l+r*o,0,u*o+r*l,c*o+i,c*l-r*s,0,u*l-r*o,c*l+r*s,a*l*l+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){let r=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,u=a+a,c=s+s,h=o+o,d=a*u,p=a*c,f=a*h,m=s*c,g=s*h,v=o*h,_=l*u,y=l*c,x=l*h,b=i.x,M=i.y,S=i.z;return r[0]=(1-(m+v))*b,r[1]=(p+x)*b,r[2]=(f-y)*b,r[3]=0,r[4]=(p-x)*M,r[5]=(1-(d+v))*M,r[6]=(g+_)*M,r[7]=0,r[8]=(f+y)*S,r[9]=(g-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){let r=this.elements,a=eK.set(r[0],r[1],r[2]).length(),s=eK.set(r[4],r[5],r[6]).length(),o=eK.set(r[8],r[9],r[10]).length(),l=this.determinant();l<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],e$.copy(this);let u=1/a,c=1/s,h=1/o;return e$.elements[0]*=u,e$.elements[1]*=u,e$.elements[2]*=u,e$.elements[4]*=c,e$.elements[5]*=c,e$.elements[6]*=c,e$.elements[8]*=h,e$.elements[9]*=h,e$.elements[10]*=h,n.setFromRotationMatrix(e$),i.x=a,i.y=s,i.z=o,this}makePerspective(e,n,i,r,a,s,o=2e3){let l,u;let c=this.elements;if(2e3===o)l=-(s+a)/(s-a),u=-2*s*a/(s-a);else if(2001===o)l=-s/(s-a),u=-s*a/(s-a);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=2*a/(n-e),c[4]=0,c[8]=(n+e)/(n-e),c[12]=0,c[1]=0,c[5]=2*a/(i-r),c[9]=(i+r)/(i-r),c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=2e3){let l,u;let c=this.elements,h=1/(n-e),d=1/(i-r),p=1/(s-a);if(2e3===o)l=(s+a)*p,u=-2*p;else if(2001===o)l=a*p,u=-1*p;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*h,c[4]=0,c[8]=0,c[12]=-((n+e)*h),c[1]=0,c[5]=2*d,c[9]=0,c[13]=-((i+r)*d),c[2]=0,c[6]=0,c[10]=u,c[14]=-l,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let n=this.elements,i=e.elements;for(let e=0;e<16;e++)if(n[e]!==i[e])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){let i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}}let eK=new ex,e$=new eZ,eQ=new ex(0,0,0),e0=new ex(1,1,1),e1=new ex,e2=new ex,e3=new ex,e4=new eZ,e5=new ey;class e6{constructor(e=0,n=0,i=0,r=e6.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],l=r[1],u=r[5],c=r[9],h=r[2],d=r[6],p=r[10];switch(n){case"XYZ":this._y=Math.asin(k(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-k(c,-1,1)),.9999999>Math.abs(c)?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(k(d,-1,1)),.9999999>Math.abs(d)?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-k(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(k(l,-1,1)),.9999999>Math.abs(l)?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-k(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(d,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return e4.makeRotationFromQuaternion(e),this.setFromRotationMatrix(e4,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return e5.setFromEuler(this),this.setFromQuaternion(e5,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}e6.DEFAULT_ORDER="XYZ";class e7{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ti,e,tr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ti,ta,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);let n=this.children;for(let i=0,r=n.length;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let n=this.geometry.parameters;if(void 0!==n&&void 0!==n.shapes){let i=n.shapes;if(Array.isArray(i))for(let n=0,r=i.length;n0){r.children=[];for(let n=0;n0){r.animations=[];for(let n=0;n0&&(i.geometries=n),r.length>0&&(i.materials=r),a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.shapes=l),u.length>0&&(i.skeletons=u),c.length>0&&(i.animations=c),h.length>0&&(i.nodes=h)}return i.object=r,i;function s(e){let n=[];for(let i in e){let r=e[i];delete r.metadata,n.push(r)}return n}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===n)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,n,i,r,a){td.subVectors(r,n),tp.subVectors(i,n),tf.subVectors(e,n);let s=td.dot(td),o=td.dot(tp),l=td.dot(tf),u=tp.dot(tp),c=tp.dot(tf),h=s*u-o*o;if(0===h)return a.set(-2,-1,-1);let d=1/h,p=(u*l-o*c)*d,f=(s*c-o*l)*d;return a.set(1-p-f,f,p)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,tm),tm.x>=0&&tm.y>=0&&tm.x+tm.y<=1}static getUV(e,n,i,r,a,s,o,l){return!1===tM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tM=!0),this.getInterpolation(e,n,i,r,a,s,o,l)}static getInterpolation(e,n,i,r,a,s,o,l){return this.getBarycoord(e,n,i,r,tm),l.setScalar(0),l.addScaledVector(a,tm.x),l.addScaledVector(s,tm.y),l.addScaledVector(o,tm.z),l}static isFrontFacing(e,n,i,r){return td.subVectors(i,n),tp.subVectors(e,n),0>td.cross(tp).dot(r)}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return td.subVectors(this.c,this.b),tp.subVectors(this.a,this.b),.5*td.cross(tp).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tS.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return tS.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,i,r,a){return!1===tM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tM=!0),tS.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}getInterpolation(e,n,i,r,a){return tS.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return tS.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tS.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){let i,r;let a=this.a,s=this.b,o=this.c;tg.subVectors(s,a),tv.subVectors(o,a),ty.subVectors(e,a);let l=tg.dot(ty),u=tv.dot(ty);if(l<=0&&u<=0)return n.copy(a);tx.subVectors(e,s);let c=tg.dot(tx),h=tv.dot(tx);if(c>=0&&h<=c)return n.copy(s);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return i=l/(l-c),n.copy(a).addScaledVector(tg,i);tb.subVectors(e,o);let p=tg.dot(tb),f=tv.dot(tb);if(f>=0&&p<=f)return n.copy(o);let m=p*u-l*f;if(m<=0&&u>=0&&f<=0)return r=u/(u-f),n.copy(a).addScaledVector(tv,r);let g=c*f-p*h;if(g<=0&&h-c>=0&&p-f>=0)return t_.subVectors(o,s),r=(h-c)/(h-c+(p-f)),n.copy(s).addScaledVector(t_,r);let v=1/(g+m+d);return i=m*v,r=d*v,n.copy(a).addScaledVector(tg,i).addScaledVector(tv,r)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let tE=0;class tT extends D{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:tE++}),this.uuid=B(),this.name="",this.type="Material",this.blending=1,this.side=l,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let n in e){let i=e[n];if(void 0===i){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}let r=this[n];if(void 0===r){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){let n=void 0===e||"string"==typeof e;n&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){let n=[];for(let i in e){let r=e[i];delete r.metadata,n.push(r)}return n}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),this.side!==l&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),n){let n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let n=e.clippingPlanes,i=null;if(null!==n){let e=n.length;i=Array(e);for(let r=0;r!==e;++r)i[r]=n[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}let tw={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},tA={h:0,s:0,l:0},tR={h:0,s:0,l:0};function tP(e,n,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?e+(n-e)*6*i:i<.5?n:i<2/3?e+(n-e)*6*(2/3-i):e}class tC{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){return void 0===n&&void 0===i?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,n,i),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=w){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,es.toWorkingColorSpace(this,n),this}setRGB(e,n,i,r=es.workingColorSpace){return this.r=e,this.g=n,this.b=i,es.toWorkingColorSpace(this,r),this}setHSL(e,n,i,r=es.workingColorSpace){if(e=H(e,1),n=k(n,0,1),i=k(i,0,1),0===n)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+n):i+n-i*n,a=2*i-r;this.r=tP(a,r,e+1/3),this.g=tP(a,r,e),this.b=tP(a,r,e-1/3)}return es.toWorkingColorSpace(this,r),this}setStyle(e,n=w){let i;function r(n){void 0!==n&&1>parseFloat(n)&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;let s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],a=r.length;if(3===a)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,n);if(6===a)return this.setHex(parseInt(r,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=w){let i=tw[e.toLowerCase()];return void 0!==i?this.setHex(i,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=eo(e.r),this.g=eo(e.g),this.b=eo(e.b),this}copyLinearToSRGB(e){return this.r=el(e.r),this.g=el(e.g),this.b=el(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=w){return es.fromWorkingColorSpace(tL.copy(this),e),65536*Math.round(k(255*tL.r,0,255))+256*Math.round(k(255*tL.g,0,255))+Math.round(k(255*tL.b,0,255))}getHexString(e=w){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=es.workingColorSpace){let i,r;es.fromWorkingColorSpace(tL.copy(this),n);let a=tL.r,s=tL.g,o=tL.b,l=Math.max(a,s,o),u=Math.min(a,s,o),c=(u+l)/2;if(u===l)i=0,r=0;else{let e=l-u;switch(r=c<=.5?e/(l+u):e/(2-l-u),l){case a:i=(s-o)/e+(s0&&(e.userData=this.userData),void 0!==this.parameters){let n=this.parameters;for(let i in n)void 0!==n[i]&&(e[i]=n[i]);return e}e.data={attributes:{}};let n=this.index;null!==n&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});let i=this.attributes;for(let n in i){let r=i[n];e.data.attributes[n]=r.toJSON(e.data)}let r={},a=!1;for(let n in this.morphAttributes){let i=this.morphAttributes[n],s=[];for(let n=0,r=i.length;n0&&(r[n]=s,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let n={};this.name=e.name;let i=e.index;null!==i&&this.setIndex(i.clone(n));let r=e.attributes;for(let e in r){let i=r[e];this.setAttribute(e,i.clone(n))}let a=e.morphAttributes;for(let e in a){let i=[],r=a[e];for(let e=0,a=r.length;e0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;n(e.far-e.near)**2)||(tq.copy(a).invert(),tY.copy(e.ray).applyMatrix4(tq),null!==i.boundingBox&&!1===tY.intersectsBox(i.boundingBox)))return;this._computeIntersections(e,n,tY)}}_computeIntersections(e,n,i){let r;let a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,u=a.attributes.uv,c=a.attributes.uv1,h=a.attributes.normal,d=a.groups,p=a.drawRange;if(null!==o){if(Array.isArray(s))for(let a=0,l=d.length;ai.far?null:{distance:c,point:t9.clone(),object:e}}(e,n,i,r,tK,t$,tQ,t8);if(d){a&&(t2.fromBufferAttribute(a,u),t3.fromBufferAttribute(a,c),t4.fromBufferAttribute(a,h),d.uv=tS.getInterpolation(t8,tK,t$,tQ,t2,t3,t4,new J)),s&&(t2.fromBufferAttribute(s,u),t3.fromBufferAttribute(s,c),t4.fromBufferAttribute(s,h),d.uv1=tS.getInterpolation(t8,tK,t$,tQ,t2,t3,t4,new J),d.uv2=d.uv1),o&&(t5.fromBufferAttribute(o,u),t6.fromBufferAttribute(o,c),t7.fromBufferAttribute(o,h),d.normal=tS.getInterpolation(t8,tK,t$,tQ,t5,t6,t7,new ex),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));let e={a:u,b:c,c:h,normal:new ex,materialIndex:0};tS.getNormal(tK,t$,tQ,e.normal),d.face=e}return d}class nn extends tX{constructor(e=1,n=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let l=[],u=[],c=[],h=[],d=0,p=0;function f(e,n,i,r,a,s,f,m,g,v,_){let y=s/g,x=f/v,b=s/2,M=f/2,S=m/2,E=g+1,T=v+1,w=0,A=0,R=new ex;for(let s=0;s0?1:-1,c.push(R.x,R.y,R.z),h.push(l/g),h.push(1-s/v),w+=1}}for(let e=0;e0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;let i={};for(let e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class nl extends th{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new eZ,this.projectionMatrix=new eZ,this.projectionMatrixInverse=new eZ,this.coordinateSystem=2e3}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class nu extends nl{constructor(e=50,n=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let n=.5*this.getFilmHeight()/e;this.fov=2*z*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*F*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*z*Math.atan(Math.tan(.5*F*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,i,r,a,s){this.aspect=e/n,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=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,n=e*Math.tan(.5*F*this.fov)/this.zoom,i=2*n,r=this.aspect*i,a=-.5*r,s=this.view;if(null!==this.view&&this.view.enabled){let e=s.fullWidth,o=s.fullHeight;a+=s.offsetX*r/e,n-=s.offsetY*i/o,r*=s.width/e,i*=s.height/o}let o=this.filmOffset;0!==o&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,n,n-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,null!==this.view&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}class nc extends th{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new nu(-90,1,e,n);r.layers=this.layers,this.add(r);let a=new nu(-90,1,e,n);a.layers=this.layers,this.add(a);let s=new nu(-90,1,e,n);s.layers=this.layers,this.add(s);let o=new nu(-90,1,e,n);o.layers=this.layers,this.add(o);let l=new nu(-90,1,e,n);l.layers=this.layers,this.add(l);let u=new nu(-90,1,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){let e=this.coordinateSystem,n=this.children.concat(),[i,r,a,s,o,l]=n;for(let e of n)this.remove(e);if(2e3===e)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(2001===e)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of n)this.add(e),e.updateMatrixWorld()}update(e,n){null===this.parent&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,l,u,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(n,a),e.setRenderTarget(i,1,r),e.render(n,s),e.setRenderTarget(i,2,r),e.render(n,o),e.setRenderTarget(i,3,r),e.render(n,l),e.setRenderTarget(i,4,r),e.render(n,u),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,r),e.render(n,c),e.setRenderTarget(h,d,p),e.xr.enabled=f,i.texture.needsPMREMUpdate=!0}}class nh extends ef{constructor(e,n,i,r,a,s,o,l,u,c){super(e=void 0!==e?e:[],n=void 0!==n?n:301,i,r,a,s,o,l,u,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class nd extends ev{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];void 0!==n.encoding&&(et("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=3001===n.encoding?w:T),this.texture=new nh(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:g}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` +(()=>{var e={"./node_modules/interactjs/dist/interact.min.js":e=>{e.exports=function(){var e,n,i={};Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0,i.default=function(e){return!(!e||!e.Window)&&e instanceof e.Window};var r={};Object.defineProperty(r,"__esModule",{value:!0}),r.getWindow=function(e){return(0,i.default)(e)?e:(e.ownerDocument||e).defaultView||s.window},r.init=o,r.window=r.realWindow=void 0;var a=void 0;r.realWindow=a;var s=void 0;function o(e){r.realWindow=a=e;var n=e.document.createTextNode("");n.ownerDocument!==e.document&&"function"==typeof e.wrap&&e.wrap(n)===n&&(e=e.wrap(e)),r.window=s=e}r.window=s,"undefined"!=typeof window&&window&&o(window);var l={};function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var c=function(e){return!!e&&"object"===u(e)},h=function(e){return"function"==typeof e};l.default={window:function(e){return e===r.window||(0,i.default)(e)},docFrag:function(e){return c(e)&&11===e.nodeType},object:c,func:h,number:function(e){return"number"==typeof e},bool:function(e){return"boolean"==typeof e},string:function(e){return"string"==typeof e},element:function(e){if(!e||"object"!==u(e))return!1;var n=r.getWindow(e)||r.window;return/object|function/.test("undefined"==typeof Element?"undefined":u(Element))?e instanceof Element||e instanceof n.Element:1===e.nodeType&&"string"==typeof e.nodeName},plainObject:function(e){return c(e)&&!!e.constructor&&/function Object\b/.test(e.constructor.toString())},array:function(e){return c(e)&&void 0!==e.length&&h(e.splice)}};var d={};function p(e){var n=e.interaction;if("drag"===n.prepared.name){var i=n.prepared.axis;"x"===i?(n.coords.cur.page.y=n.coords.start.page.y,n.coords.cur.client.y=n.coords.start.client.y,n.coords.velocity.client.y=0,n.coords.velocity.page.y=0):"y"===i&&(n.coords.cur.page.x=n.coords.start.page.x,n.coords.cur.client.x=n.coords.start.client.x,n.coords.velocity.client.x=0,n.coords.velocity.page.x=0)}}function f(e){var n=e.iEvent,i=e.interaction;if("drag"===i.prepared.name){var r=i.prepared.axis;if("x"===r||"y"===r){var a="x"===r?"y":"x";n.page[a]=i.coords.start.page[a],n.client[a]=i.coords.start.client[a],n.delta[a]=0}}}Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var m={id:"actions/drag",install:function(e){var n=e.actions,i=e.Interactable,r=e.defaults;i.prototype.draggable=m.draggable,n.map.drag=m,n.methodDict.drag="draggable",r.actions.drag=m.defaults},listeners:{"interactions:before-action-move":p,"interactions:action-resume":p,"interactions:action-move":f,"auto-start:check":function(e){var n=e.interaction,i=e.interactable,r=e.buttons,a=i.options.drag;if(a&&a.enabled&&(!n.pointerIsDown||!/mouse|pointer/.test(n.pointerType)||0!=(r&i.options.drag.mouseButtons)))return e.action={name:"drag",axis:"start"===a.lockAxis?a.startAxis:a.lockAxis},!1}},draggable:function(e){return l.default.object(e)?(this.options.drag.enabled=!1!==e.enabled,this.setPerAction("drag",e),this.setOnEvents("drag",e),/^(xy|x|y|start)$/.test(e.lockAxis)&&(this.options.drag.lockAxis=e.lockAxis),/^(xy|x|y)$/.test(e.startAxis)&&(this.options.drag.startAxis=e.startAxis),this):l.default.bool(e)?(this.options.drag.enabled=e,this):this.options.drag},beforeMove:p,move:f,defaults:{startAxis:"xy",lockAxis:"xy"},getCursor:function(){return"move"}};d.default=m;var g={};Object.defineProperty(g,"__esModule",{value:!0}),g.default=void 0;var v={init:function(e){v.document=e.document,v.DocumentFragment=e.DocumentFragment||_,v.SVGElement=e.SVGElement||_,v.SVGSVGElement=e.SVGSVGElement||_,v.SVGElementInstance=e.SVGElementInstance||_,v.Element=e.Element||_,v.HTMLElement=e.HTMLElement||v.Element,v.Event=e.Event,v.Touch=e.Touch||_,v.PointerEvent=e.PointerEvent||e.MSPointerEvent},document:null,DocumentFragment:null,SVGElement:null,SVGSVGElement:null,SVGElementInstance:null,Element:null,HTMLElement:null,Event:null,Touch:null,PointerEvent:null};function _(){}g.default=v;var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.default=void 0;var x={init:function(e){var n=g.default.Element,i=e.navigator||{};x.supportsTouch="ontouchstart"in e||l.default.func(e.DocumentTouch)&&g.default.document instanceof e.DocumentTouch,x.supportsPointerEvent=!1!==i.pointerEnabled&&!!g.default.PointerEvent,x.isIOS=/iP(hone|od|ad)/.test(i.platform),x.isIOS7=/iP(hone|od|ad)/.test(i.platform)&&/OS 7[^\d]/.test(i.appVersion),x.isIe9=/MSIE 9/.test(i.userAgent),x.isOperaMobile="Opera"===i.appName&&x.supportsTouch&&/Presto/.test(i.userAgent),x.prefixedMatchesSelector="matches"in n.prototype?"matches":"webkitMatchesSelector"in n.prototype?"webkitMatchesSelector":"mozMatchesSelector"in n.prototype?"mozMatchesSelector":"oMatchesSelector"in n.prototype?"oMatchesSelector":"msMatchesSelector",x.pEventTypes=x.supportsPointerEvent?g.default.PointerEvent===e.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"}:null,x.wheelEvent=g.default.document&&"onmousewheel"in g.default.document?"mousewheel":"wheel"},supportsTouch:null,supportsPointerEvent:null,isIOS7:null,isIOS:null,isIe9:null,isOperaMobile:null,prefixedMatchesSelector:null,pEventTypes:null,wheelEvent:null};y.default=x;var b={};function M(e){var n=e.parentNode;if(l.default.docFrag(n))for(;(n=n.host)&&l.default.docFrag(n););return n}function S(e,n){return r.window!==r.realWindow&&(n=n.replace(/\/deep\//g," ")),e[y.default.prefixedMatchesSelector](n)}Object.defineProperty(b,"__esModule",{value:!0}),b.closest=function(e,n){for(;l.default.element(e);){if(S(e,n))return e;e=M(e)}return null},b.getActualElement=function(e){return e.correspondingUseElement||e},b.getElementClientRect=A,b.getElementRect=function(e){var n=A(e);if(!y.default.isIOS7&&n){var i=w(r.getWindow(e));n.left+=i.x,n.right+=i.x,n.top+=i.y,n.bottom+=i.y}return n},b.getPath=function(e){for(var n=[];e;)n.push(e),e=M(e);return n},b.getScrollXY=w,b.indexOfDeepestElement=function(e){for(var n,i=[],a=0;a=(parseInt(r.getWindow(o).getComputedStyle(o).zIndex,10)||0)&&(n=a)}else n=a}}else n=a}}return n},b.matchesSelector=S,b.matchesUpTo=function(e,n,i){for(;l.default.element(e);){if(S(e,n))return!0;if((e=M(e))===i)return S(e,n)}return!1},b.nodeContains=function(e,n){if(e.contains)return e.contains(n);for(;n;){if(n===e)return!0;n=n.parentNode}return!1},b.parentNode=M,b.trySelector=function(e){return!!l.default.string(e)&&(g.default.document.querySelector(e),!0)};var E=function(e){return e.parentNode||e.host};function T(e,n){for(var i,r=[],a=e;(i=E(a))&&a!==n&&i!==a.ownerDocument;)r.unshift(a),a=i;return r}function w(e){return{x:(e=e||r.window).scrollX||e.document.documentElement.scrollLeft,y:e.scrollY||e.document.documentElement.scrollTop}}function A(e){var n=e instanceof g.default.SVGElement?e.getBoundingClientRect():e.getClientRects()[0];return n&&{left:n.left,right:n.right,top:n.top,bottom:n.bottom,width:n.width||n.right-n.left,height:n.height||n.bottom-n.top}}var R={};Object.defineProperty(R,"__esModule",{value:!0}),R.default=function(e,n){for(var i in n)e[i]=n[i];return e};var P={};function C(e,n){(null==n||n>e.length)&&(n=e.length);for(var i=0,r=Array(n);i1?W(n):n[0];H(r,e.page),V(r,e.client),e.timeStamp=i},z.setZeroCoords=function(e){e.page.x=0,e.page.y=0,e.client.x=0,e.client.y=0},z.touchAngle=function(e,n){var i=n+"X",r=n+"Y",a=G(e),s=a[1][i]-a[0][i];return 180*Math.atan2(a[1][r]-a[0][r],s)/Math.PI},z.touchBBox=function(e){if(!e.length)return null;var n=G(e),i=Math.min(n[0].pageX,n[1].pageX),r=Math.min(n[0].pageY,n[1].pageY),a=Math.max(n[0].pageX,n[1].pageX),s=Math.max(n[0].pageY,n[1].pageY);return{x:i,y:r,left:i,top:r,right:a,bottom:s,width:a-i,height:s-r}},z.touchDistance=function(e,n){var i=n+"X",r=n+"Y",a=G(e),s=a[0][i]-a[1][i],o=a[0][r]-a[1][r];return(0,U.default)(s,o)};var j={};function X(e,n,i){return n in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}Object.defineProperty(j,"__esModule",{value:!0}),j.BaseEvent=void 0;var q=function(){function e(n){(function(e,n){if(!(e instanceof n))throw TypeError("Cannot call a class as a function")})(this,e),X(this,"immediatePropagationStopped",!1),X(this,"propagationStopped",!1),this._interaction=n}return function(e,n){for(var i=0;io.left&&d.xo.top&&d.y=o.left&&g<=o.right&&v>=o.top&&v<=o.bottom}return m&&l.default.number(c)&&(u=Math.max(0,Math.min(o.right,m.right)-Math.max(o.left,m.left))*Math.max(0,Math.min(o.bottom,m.bottom)-Math.max(o.top,m.top))/(m.width*m.height)>=c),e.options.drop.checker&&(u=e.options.drop.checker(n,i,u,e,s,r,a)),u}(this,e,n,i,r,a,s)},i.dynamicDrop=function(n){return l.default.bool(n)?(e.dynamicDrop=n,i):e.dynamicDrop},(0,R.default)(n.phaselessTypes,{dragenter:!0,dragleave:!0,dropactivate:!0,dropdeactivate:!0,dropmove:!0,drop:!0}),n.methodDict.drop="dropzone",e.dynamicDrop=!1,a.actions.drop=eh.defaults},listeners:{"interactions:before-action-start":function(e){var n=e.interaction;"drag"===n.prepared.name&&(n.dropState={cur:{dropzone:null,element:null},prev:{dropzone:null,element:null},rejected:null,events:null,activeDrops:[]})},"interactions:after-action-start":function(e,n){var i=e.interaction,r=(e.event,e.iEvent);if("drag"===i.prepared.name){var a=i.dropState;a.activeDrops=null,a.events=null,a.activeDrops=es(n,i.element),a.events=el(i,0,r),a.events.activate&&(ea(a.activeDrops,a.events.activate),n.fire("actions/drop:start",{interaction:i,dragEvent:r}))}},"interactions:action-move":ec,"interactions:after-action-move":function(e,n){var i=e.interaction,r=e.iEvent;"drag"===i.prepared.name&&(eu(i,i.dropState.events),n.fire("actions/drop:move",{interaction:i,dragEvent:r}),i.dropState.events={})},"interactions:action-end":function(e,n){if("drag"===e.interaction.prepared.name){var i=e.interaction,r=e.iEvent;ec(e,n),eu(i,i.dropState.events),n.fire("actions/drop:end",{interaction:i,dragEvent:r})}},"interactions:stop":function(e){var n=e.interaction;if("drag"===n.prepared.name){var i=n.dropState;i&&(i.activeDrops=null,i.events=null,i.cur.dropzone=null,i.cur.element=null,i.prev.dropzone=null,i.prev.element=null,i.rejected=!1)}}},getActiveDrops:es,getDrop:eo,getDropEvents:el,fireDropEvents:eu,defaults:{enabled:!1,accept:null,overlap:"pointer"}};er.default=eh;var ed={};function ep(e){var n=e.interaction,i=e.iEvent,r=e.phase;if("gesture"===n.prepared.name){var a=n.pointers.map(function(e){return e.pointer}),s=n.interactable.options.deltaSource;if(i.touches=[a[0],a[1]],"start"===r)i.distance=z.touchDistance(a,s),i.box=z.touchBBox(a),i.scale=1,i.ds=0,i.angle=z.touchAngle(a,s),i.da=0,n.gesture.startDistance=i.distance,n.gesture.startAngle=i.angle;else if("end"===r){var o=n.prevEvent;i.distance=o.distance,i.box=o.box,i.scale=o.scale,i.ds=0,i.angle=o.angle,i.da=0}else i.distance=z.touchDistance(a,s),i.box=z.touchBBox(a),i.scale=i.distance/n.gesture.startDistance,i.angle=z.touchAngle(a,s),i.ds=i.scale-n.gesture.scale,i.da=i.angle-n.gesture.angle;n.gesture.distance=i.distance,n.gesture.angle=i.angle,l.default.number(i.scale)&&i.scale!==1/0&&!isNaN(i.scale)&&(n.gesture.scale=i.scale)}}Object.defineProperty(ed,"__esModule",{value:!0}),ed.default=void 0;var ef={id:"actions/gesture",before:["actions/drag","actions/resize"],install:function(e){var n=e.actions,i=e.Interactable,r=e.defaults;i.prototype.gesturable=function(e){return l.default.object(e)?(this.options.gesture.enabled=!1!==e.enabled,this.setPerAction("gesture",e),this.setOnEvents("gesture",e),this):l.default.bool(e)?(this.options.gesture.enabled=e,this):this.options.gesture},n.map.gesture=ef,n.methodDict.gesture="gesturable",r.actions.gesture=ef.defaults},listeners:{"interactions:action-start":ep,"interactions:action-move":ep,"interactions:action-end":ep,"interactions:new":function(e){e.interaction.gesture={angle:0,distance:0,scale:1,startAngle:0,startDistance:0}},"auto-start:check":function(e){if(!(e.interaction.pointers.length<2)){var n=e.interactable.options.gesture;if(n&&n.enabled)return e.action={name:"gesture"},!1}}},defaults:{},getCursor:function(){return""}};ed.default=ef;var em={};function eg(e){var n=e.iEvent,i=e.interaction;"resize"===i.prepared.name&&i.resizeAxes&&(i.interactable.options.resize.square?("y"===i.resizeAxes?n.delta.x=n.delta.y:n.delta.y=n.delta.x,n.axes="xy"):(n.axes=i.resizeAxes,"x"===i.resizeAxes?n.delta.y=0:"y"===i.resizeAxes&&(n.delta.x=0)))}Object.defineProperty(em,"__esModule",{value:!0}),em.default=void 0;var ev={id:"actions/resize",before:["actions/drag"],install:function(e){var n=e.actions,i=e.browser,r=e.Interactable,a=e.defaults;ev.cursors=i.isIe9?{x:"e-resize",y:"s-resize",xy:"se-resize",top:"n-resize",left:"w-resize",bottom:"s-resize",right:"e-resize",topleft:"se-resize",bottomright:"se-resize",topright:"ne-resize",bottomleft:"ne-resize"}:{x:"ew-resize",y:"ns-resize",xy:"nwse-resize",top:"ns-resize",left:"ew-resize",bottom:"ns-resize",right:"ew-resize",topleft:"nwse-resize",bottomright:"nwse-resize",topright:"nesw-resize",bottomleft:"nesw-resize"},ev.defaultMargin=i.supportsTouch||i.supportsPointerEvent?20:10,r.prototype.resizable=function(n){return l.default.object(n)?(this.options.resize.enabled=!1!==n.enabled,this.setPerAction("resize",n),this.setOnEvents("resize",n),l.default.string(n.axis)&&/^x$|^y$|^xy$/.test(n.axis)?this.options.resize.axis=n.axis:null===n.axis&&(this.options.resize.axis=e.defaults.actions.resize.axis),l.default.bool(n.preserveAspectRatio)?this.options.resize.preserveAspectRatio=n.preserveAspectRatio:l.default.bool(n.square)&&(this.options.resize.square=n.square),this):l.default.bool(n)?(this.options.resize.enabled=n,this):this.options.resize},n.map.resize=ev,n.methodDict.resize="resizable",a.actions.resize=ev.defaults},listeners:{"interactions:new":function(e){e.interaction.resizeAxes="xy"},"interactions:action-start":function(e){(function(e){var n=e.iEvent,i=e.interaction;if("resize"===i.prepared.name&&i.prepared.edges){var r=i.rect;i._rects={start:(0,R.default)({},r),corrected:(0,R.default)({},r),previous:(0,R.default)({},r),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},n.edges=i.prepared.edges,n.rect=i._rects.corrected,n.deltaRect=i._rects.delta}})(e),eg(e)},"interactions:action-move":function(e){(function(e){var n=e.iEvent,i=e.interaction;if("resize"===i.prepared.name&&i.prepared.edges){var r=i.interactable.options.resize.invert,a=i.rect,s=i._rects,o=s.start,l=s.corrected,u=s.delta,c=s.previous;if((0,R.default)(c,l),"reposition"===r||"negate"===r){if((0,R.default)(l,a),"reposition"===r){if(l.top>l.bottom){var h=l.top;l.top=l.bottom,l.bottom=h}if(l.left>l.right){var d=l.left;l.left=l.right,l.right=d}}}else l.top=Math.min(a.top,o.bottom),l.bottom=Math.max(a.bottom,o.top),l.left=Math.min(a.left,o.right),l.right=Math.max(a.right,o.left);for(var p in l.width=l.right-l.left,l.height=l.bottom-l.top,l)u[p]=l[p]-c[p];n.edges=i.prepared.edges,n.rect=l,n.deltaRect=u}})(e),eg(e)},"interactions:action-end":function(e){var n=e.iEvent,i=e.interaction;"resize"===i.prepared.name&&i.prepared.edges&&(n.edges=i.prepared.edges,n.rect=i._rects.corrected,n.deltaRect=i._rects.delta)},"auto-start:check":function(e){var n=e.interaction,i=e.interactable,r=e.element,a=e.rect,s=e.buttons;if(a){var o=(0,R.default)({},n.coords.cur.page),u=i.options.resize;if(u&&u.enabled&&(!n.pointerIsDown||!/mouse|pointer/.test(n.pointerType)||0!=(s&u.mouseButtons))){if(l.default.object(u.edges)){var c={left:!1,right:!1,top:!1,bottom:!1};for(var h in c)c[h]=function(e,n,i,r,a,s,o){if(!n)return!1;if(!0===n){var u=l.default.number(s.width)?s.width:s.right-s.left,c=l.default.number(s.height)?s.height:s.bottom-s.top;if(o=Math.min(o,Math.abs(("left"===e||"right"===e?u:c)/2)),u<0&&("left"===e?e="right":"right"===e&&(e="left")),c<0&&("top"===e?e="bottom":"bottom"===e&&(e="top")),"left"===e){var h=u>=0?s.left:s.right;return i.x=0?s.top:s.bottom;return i.y(u>=0?s.right:s.left)-o;if("bottom"===e)return i.y>(c>=0?s.bottom:s.top)-o}return!!l.default.element(r)&&(l.default.element(n)?n===r:b.matchesUpTo(r,n,a))}(h,u.edges[h],o,n._latestPointer.eventTarget,r,a,u.margin||ev.defaultMargin);c.left=c.left&&!c.right,c.top=c.top&&!c.bottom,(c.left||c.right||c.top||c.bottom)&&(e.action={name:"resize",edges:c})}else{var d="y"!==u.axis&&o.x>a.right-ev.defaultMargin,p="x"!==u.axis&&o.y>a.bottom-ev.defaultMargin;(d||p)&&(e.action={name:"resize",axes:(d?"x":"")+(p?"y":"")})}return!e.action&&void 0}}}},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor:function(e){var n=e.edges,i=e.axis,r=e.name,a=ev.cursors,s=null;if(i)s=a[r+i];else if(n){for(var o="",l=["top","bottom","left","right"],u=0;u=1){var h={x:eE.x*c,y:eE.y*c};if(h.x||h.y){var d=ew(s);l.default.window(s)?s.scrollBy(h.x,h.y):s&&(s.scrollLeft+=h.x,s.scrollTop+=h.y);var p=ew(s),f={x:p.x-d.x,y:p.y-d.y};(f.x||f.y)&&n.fire({type:"autoscroll",target:i,interactable:n,delta:f,interaction:e,container:s})}eE.prevTime=o}eE.isScrolling&&(ey.default.cancel(eE.i),eE.i=ey.default.request(eE.scroll))},check:function(e,n){var i;return null==(i=e.options[n].autoScroll)?void 0:i.enabled},onInteractionMove:function(e){var n=e.interaction,i=e.pointer;if(n.interacting()&&eE.check(n.interactable,n.prepared.name)){if(n.simulation)eE.x=eE.y=0;else{var r,a,s,o,u=n.interactable,c=n.element,h=n.prepared.name,d=u.options[h].autoScroll,p=eT(d.container,u,c);if(l.default.window(p))o=i.clientXp.innerWidth-eE.margin,s=i.clientY>p.innerHeight-eE.margin;else{var f=b.getElementClientRect(p);o=i.clientXf.right-eE.margin,s=i.clientY>f.bottom-eE.margin}eE.x=a?1:o?-1:0,eE.y=s?1:r?-1:0,eE.isScrolling||(eE.margin=d.margin,eE.speed=d.speed,eE.start(n))}}}};function eT(e,n,i){return(l.default.string(e)?(0,P.getStringOptionResult)(e,n,i):e)||(0,r.getWindow)(i)}function ew(e){return l.default.window(e)&&(e=window.document.body),{x:e.scrollLeft,y:e.scrollTop}}var eA={id:"auto-scroll",install:function(e){var n=e.defaults,i=e.actions;e.autoScroll=eE,eE.now=function(){return e.now()},i.phaselessTypes.autoscroll=!0,n.perAction.autoScroll=eE.defaults},listeners:{"interactions:new":function(e){e.interaction.autoScroll=null},"interactions:destroy":function(e){e.interaction.autoScroll=null,eE.stop(),eE.interaction&&(eE.interaction=null)},"interactions:stop":eE.stop,"interactions:action-move":function(e){return eE.onInteractionMove(e)}}};eS.default=eA;var eR={};Object.defineProperty(eR,"__esModule",{value:!0}),eR.copyAction=function(e,n){return e.name=n.name,e.axis=n.axis,e.edges=n.edges,e},eR.sign=void 0,eR.warnOnce=function(e,n){var i=!1;return function(){return i||(r.window.console.warn(n),i=!0),e.apply(this,arguments)}},eR.sign=function(e){return e>=0?1:-1};var eP={};function eC(e){return l.default.bool(e)?(this.options.styleCursor=e,this):null===e?(delete this.options.styleCursor,this):this.options.styleCursor}function eL(e){return l.default.func(e)?(this.options.actionChecker=e,this):null===e?(delete this.options.actionChecker,this):this.options.actionChecker}Object.defineProperty(eP,"__esModule",{value:!0}),eP.default=void 0,eP.default={id:"auto-start/interactableMethods",install:function(e){var n=e.Interactable;n.prototype.getAction=function(n,i,r,a){var s,o,l=(s=this.getRect(a),o={action:null,interactable:this,interaction:r,element:a,rect:s,buttons:i.buttons||({0:1,1:4,3:8,4:16})[i.button]},e.fire("auto-start:check",o),o.action);return this.options.actionChecker?this.options.actionChecker(n,i,l,this,a,r):l},n.prototype.ignoreFrom=(0,eR.warnOnce)(function(e){return this._backCompatOption("ignoreFrom",e)},"Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."),n.prototype.allowFrom=(0,eR.warnOnce)(function(e){return this._backCompatOption("allowFrom",e)},"Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."),n.prototype.actionChecker=eL,n.prototype.styleCursor=eC}};var eO={};function eI(e,n,i,r,a){return n.testIgnoreAllow(n.options[e.name],i,r)&&n.options[e.name].enabled&&eN(n,i,e,a)?e:null}function eD(e,n,i,r,a){var s=[],o=[],u=r;function c(e){s.push(e),o.push(u)}for(;l.default.element(u);){s=[],o=[],a.interactables.forEachMatch(u,c);var h=function(e,n,i,r,a,s,o){for(var l=0,u=r.length;l=l||p.interactable===e&&((c+=f===i.name?1:0)>=s||p.element===n&&(h++,f===i.name&&h>=o))))return!1}return l>0}function eF(e,n){return l.default.number(e)?(n.autoStart.maxInteractions=e,this):n.autoStart.maxInteractions}function ez(e,n,i){var r=i.autoStart.cursorElement;r&&r!==e&&(r.style.cursor=""),e.ownerDocument.documentElement.style.cursor=n,e.style.cursor=n,i.autoStart.cursorElement=n?e:null}function eB(e,n){var i=e.interactable,r=e.element,a=e.prepared;if("mouse"===e.pointerType&&i&&i.options.styleCursor){var s="";if(a.name){var o=i.options[a.name].cursorChecker;s=l.default.func(o)?o(a,i,r,e._interacting):n.actions.map[a.name].getCursor(a)}ez(e.element,s||"",n)}else n.autoStart.cursorElement&&ez(n.autoStart.cursorElement,"",n)}Object.defineProperty(eO,"__esModule",{value:!0}),eO.default=void 0,eO.default={id:"auto-start/base",before:["actions"],install:function(e){var n=e.interactStatic,i=e.defaults;e.usePlugin(eP.default),i.base.actionChecker=null,i.base.styleCursor=!0,(0,R.default)(i.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),n.maxInteractions=function(n){return eF(n,e)},e.autoStart={maxInteractions:1/0,withinInteractionLimit:eN,cursorElement:null}},listeners:{"interactions:down":function(e,n){var i=e.interaction,r=e.pointer,a=e.event,s=e.eventTarget;i.interacting()||eU(i,eD(i,r,a,s,n),n)},"interactions:move":function(e,n){var i,r,a,s;i=e.interaction,r=e.pointer,a=e.event,s=e.eventTarget,"mouse"!==i.pointerType||i.pointerIsDown||i.interacting()||eU(i,eD(i,r,a,s,n),n),function(e,n){var i=e.interaction;if(i.pointerIsDown&&!i.interacting()&&i.pointerWasMoved&&i.prepared.name){n.fire("autoStart:before-start",e);var r=i.interactable,a=i.prepared.name;a&&r&&(r.options[a].manualStart||!eN(r,i.element,i.prepared,n)?i.stop():(i.start(i.prepared,r,i.element),eB(i,n)))}}(e,n)},"interactions:stop":function(e,n){var i=e.interaction,r=i.interactable;r&&r.options.styleCursor&&ez(i.element,"",n)}},maxInteractions:eF,withinInteractionLimit:eN,validateAction:eI};var ek={};Object.defineProperty(ek,"__esModule",{value:!0}),ek.default=void 0,ek.default={id:"auto-start/dragAxis",listeners:{"autoStart:before-start":function(e,n){var i=e.interaction,r=e.eventTarget,a=e.dx,s=e.dy;if("drag"===i.prepared.name){var o=Math.abs(a),u=Math.abs(s),c=i.interactable.options.drag,h=c.startAxis,d=o>u?"x":o0&&(n.autoStartHoldTimer=setTimeout(function(){n.start(n.prepared,n.interactable,n.element)},i))},"interactions:move":function(e){var n=e.interaction,i=e.duplicate;n.autoStartHoldTimer&&n.pointerWasMoved&&!i&&(clearTimeout(n.autoStartHoldTimer),n.autoStartHoldTimer=null)},"autoStart:before-start":function(e){var n=e.interaction;eV(n)>0&&(n.prepared.name=null)}},getHoldDuration:eV};var eG={};Object.defineProperty(eG,"__esModule",{value:!0}),eG.default=void 0,eG.default={id:"auto-start",install:function(e){e.usePlugin(eO.default),e.usePlugin(eH.default),e.usePlugin(ek.default)}};var eW={};function ej(e){return/^(always|never|auto)$/.test(e)?(this.options.preventDefault=e,this):l.default.bool(e)?(this.options.preventDefault=e?"always":"never",this):this.options.preventDefault}function eX(e){var n=e.interaction,i=e.event;n.interactable&&n.interactable.checkAndPreventDefault(i)}function eq(e){var n=e.Interactable;n.prototype.preventDefault=ej,n.prototype.checkAndPreventDefault=function(n){return function(e,n,i){var a=e.options.preventDefault;if("never"!==a){if("always"!==a){if(n.events.supportsPassive&&/^touch(start|move)$/.test(i.type)){var s=(0,r.getWindow)(i.target).document,o=n.getDocOptions(s);if(!o||!o.events||!1!==o.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(i.type)||l.default.element(i.target)&&(0,b.matchesSelector)(i.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||i.preventDefault()}else i.preventDefault()}}(this,e,n)},e.interactions.docEvents.push({type:"dragstart",listener:function(n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);i150)return null;var n=180*Math.atan2(e.prevEvent.velocityY,e.prevEvent.velocityX)/Math.PI;n<0&&(n+=360);var i=112.5<=n&&n<247.5,r=202.5<=n&&n<337.5;return{up:r,down:!r&&22.5<=n&&n<157.5,left:i,right:!i&&(292.5<=n||n<67.5),angle:n,speed:e.prevEvent.speed,velocity:{x:e.prevEvent.velocityX,y:e.prevEvent.velocityY}}}},{key:"preventDefault",value:function(){}},{key:"stopImmediatePropagation",value:function(){this.immediatePropagationStopped=this.propagationStopped=!0}},{key:"stopPropagation",value:function(){this.propagationStopped=!0}}],function(e,n){for(var i=0;ithis.pointerMoveTolerance);var o=this.getPointerIndex(e),l={pointer:e,pointerIndex:o,pointerInfo:this.pointers[o],event:n,type:"move",eventTarget:i,dx:r,dy:a,duplicate:s,interaction:this};s||z.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",l),s||this.simulation||(this.interacting()&&(l.type=null,this.move(l)),this.pointerWasMoved&&z.copyCoords(this.coords.prev,this.coords.cur))}},{key:"move",value:function(e){e&&e.event||z.setZeroCoords(this.coords.delta),(e=(0,R.default)({pointer:this._latestPointer.pointer,event:this._latestPointer.event,eventTarget:this._latestPointer.eventTarget,interaction:this},e||{})).phase="move",this._doPhase(e)}},{key:"pointerUp",value:function(e,n,i,r){var a=this.getPointerIndex(e);-1===a&&(a=this.updatePointer(e,n,i,!1));var s=/cancel$/i.test(n.type)?"cancel":"up";this._scopeFire("interactions:".concat(s),{pointer:e,pointerIndex:a,pointerInfo:this.pointers[a],event:n,eventTarget:i,type:s,curEventTarget:r,interaction:this}),this.simulation||this.end(n),this.removePointer(e,n)}},{key:"documentBlur",value:function(e){this.end(e),this._scopeFire("interactions:blur",{event:e,type:"blur",interaction:this})}},{key:"end",value:function(e){var n;this._ending=!0,e=e||this._latestPointer.event,this.interacting()&&(n=this._doPhase({event:e,interaction:this,phase:"end"})),this._ending=!1,!0===n&&this.stop()}},{key:"currentAction",value:function(){return this._interacting?this.prepared.name:null}},{key:"interacting",value:function(){return this._interacting}},{key:"stop",value:function(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}},{key:"getPointerIndex",value:function(e){var n=z.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:Y.findIndex(this.pointers,function(e){return e.id===n})}},{key:"getPointerInfo",value:function(e){return this.pointers[this.getPointerIndex(e)]}},{key:"updatePointer",value:function(e,n,i,r){var a=z.getPointerId(e),s=this.getPointerIndex(e),o=this.pointers[s];return r=!1!==r&&(r||/(down|start)$/i.test(n.type)),o?o.pointer=e:(o=new ts.PointerInfo(a,e,n,null,null),s=this.pointers.length,this.pointers.push(o)),z.setCoords(this.coords.cur,this.pointers.map(function(e){return e.pointer}),this._now()),z.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),r&&(this.pointerIsDown=!0,o.downTime=this.coords.cur.timeStamp,o.downTarget=i,z.pointerExtend(this.downPointer,e),this.interacting()||(z.copyCoords(this.coords.start,this.coords.cur),z.copyCoords(this.coords.prev,this.coords.cur),this.downEvent=n,this.pointerWasMoved=!1)),this._updateLatestPointer(e,n,i),this._scopeFire("interactions:update-pointer",{pointer:e,event:n,eventTarget:i,down:r,pointerInfo:o,pointerIndex:s,interaction:this}),s}},{key:"removePointer",value:function(e,n){var i=this.getPointerIndex(e);if(-1!==i){var r=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:e,event:n,eventTarget:null,pointerIndex:i,pointerInfo:r,interaction:this}),this.pointers.splice(i,1),this.pointerIsDown=!1}}},{key:"_updateLatestPointer",value:function(e,n,i){this._latestPointer.pointer=e,this._latestPointer.event=n,this._latestPointer.eventTarget=i}},{key:"destroy",value:function(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}},{key:"_createPreparedEvent",value:function(e,n,i,r){return new e9.InteractEvent(this,e,this.prepared.name,n,this.element,i,r)}},{key:"_fireEvent",value:function(e){var n;null==(n=this.interactable)||n.fire(e),(!this.prevEvent||e.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=e)}},{key:"_doPhase",value:function(e){var n=e.event,i=e.phase,r=e.preEnd,a=e.type,s=this.rect;if(s&&"move"===i&&(P.addEdges(this.edges,s,this.coords.delta[this.interactable.options.deltaSource]),s.width=s.right-s.left,s.height=s.bottom-s.top),!1===this._scopeFire("interactions:before-action-".concat(i),e))return!1;var o=e.iEvent=this._createPreparedEvent(n,i,r,a);return this._scopeFire("interactions:action-".concat(i),e),"start"===i&&(this.prevEvent=o),this._fireEvent(o),this._scopeFire("interactions:after-action-".concat(i),e),!0}},{key:"_now",value:function(){return Date.now()}}],function(e,n){for(var i=0;ii.minSpeed&&a>i.endSpeed)this.startInertia();else{if(s.result=s.setAll(this.modifierArg),!s.result.changed)return!1;this.startSmoothEnd()}return n.modification.result.rect=null,n.offsetBy(this.targetOffset),n._doPhase({interaction:n,event:e,phase:"inertiastart"}),n.offsetBy({x:-this.targetOffset.x,y:-this.targetOffset.y}),n.modification.result.rect=null,this.active=!0,n.simulation=this,!0}},{key:"startInertia",value:function(){var e=this,n=this.interaction.coords.velocity.client,i=tP(this.interaction),r=i.resistance,a=-Math.log(i.endSpeed/this.v0)/r;this.targetOffset={x:(n.x-a)/r,y:(n.y-a)/r},this.te=a,this.lambda_v0=r/this.v0,this.one_ve_v0=1-i.endSpeed/this.v0;var s=this.modification,o=this.modifierArg;o.pageCoords={x:this.startCoords.x+this.targetOffset.x,y:this.startCoords.y+this.targetOffset.y},s.result=s.setAll(o),s.result.changed&&(this.isModified=!0,this.modifiedOffset={x:this.targetOffset.x+s.result.delta.x,y:this.targetOffset.y+s.result.delta.y}),this.onNextFrame(function(){return e.inertiaTick()})}},{key:"startSmoothEnd",value:function(){var e=this;this.smoothEnd=!0,this.isModified=!0,this.targetOffset={x:this.modification.result.delta.x,y:this.modification.result.delta.y},this.onNextFrame(function(){return e.smoothEndTick()})}},{key:"onNextFrame",value:function(e){var n=this;this.timeout=ey.default.request(function(){n.active&&e()})}},{key:"inertiaTick",value:function(){var e,n,i,r,a=this,s=this.interaction,o=tP(s).resistance,l=(s._now()-this.t0)/1e3;if(l=0;i--){var r=n[i],a=r.selector,s=r.context,o=r.listeners;a===this.target&&s===this._context&&n.splice(i,1);for(var u=o.length-1;u>=0;u--)this._scopeEvents.removeDelegate(this.target,this._context,e,o[u][0],o[u][1])}else this._scopeEvents.remove(this.target,"all")}}],function(e,n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);i=0;o--){var f=d[o];if(f.selector===e&&f.context===n){for(var m=f.listeners,g=m.length-1;g>=0;g--){var v=tX(m[g],2),_=v[0],y=v[1],x=y.capture,b=y.passive;if(_===a&&x===l.capture&&b===l.passive){m.splice(g,1),m.length||(d.splice(o,1),u(n,i,c),u(n,i,h,!0)),p=!0;break}}if(p)break}}},delegateListener:c,delegateUseCapture:h,delegatedEvents:r,documents:a,targets:i,supportsOptions:!1,supportsPassive:!1};function o(e,n,r,a){var o=tJ(a),l=Y.find(i,function(n){return n.eventTarget===e});l||(l={eventTarget:e,events:{}},i.push(l)),l.events[n]||(l.events[n]=[]),e.addEventListener&&!Y.contains(l.events[n],r)&&(e.addEventListener(n,r,s.supportsOptions?o:o.capture),l.events[n].push(r))}function u(e,n,r,a){var o=tJ(a),l=Y.findIndex(i,function(n){return n.eventTarget===e}),c=i[l];if(c&&c.events){if("all"!==n){var h=!1,d=c.events[n];if(d){if("all"===r){for(var p=d.length-1;p>=0;p--)u(e,n,d[p],o);return}for(var f=0;f=2)continue;if(!a.interacting()&&n===a.pointerType)return a}return null}};function t$(e,n){return e.pointers.some(function(e){return e.id===n})}tZ.default=tK;var tQ={};function t0(e){return(t0="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t1(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,a,s=[],o=!0,l=!1;try{for(i=i.call(e);!(o=(r=i.next()).done)&&(s.push(r.value),!n||s.length!==n);o=!0);}catch(e){l=!0,a=e}finally{try{o||null==i.return||i.return()}finally{if(l)throw a}}return s}}(e,n)||function(e,n){if(e){if("string"==typeof e)return t2(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t2(e,n):void 0}}(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t2(e,n){(null==n||n>e.length)&&(n=e.length);for(var i=0,r=Array(n);i=0;r--){var a=n.interactions.list[r];a.interactable===i&&(a.stop(),n.fire("interactions:destroy",{interaction:a}),a.destroy(),n.interactions.list.length>2&&n.interactions.list.splice(r,1))}}},onDocSignal:t8,doOnInteractions:t6,methodNames:t5};var t9={};function ne(e){return(ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function nt(){return(nt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,n,i){var r=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=ni(e)););return e}(e,n);if(r){var a=Object.getOwnPropertyDescriptor(r,n);return a.get?a.get.call(arguments.length<3?e:i):a.value}}).apply(this,arguments)}function nn(e,n){return(nn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e})(e,n)}function ni(e){return(ni=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function nr(e,n){if(!(e instanceof n))throw TypeError("Cannot call a class as a function")}function na(e,n){for(var i=0;ie.length)&&(n=e.length);for(var i=0,r=Array(n);iMath.abs(c.y),u.coords,u.rect),(0,R.default)(r,u.coords)),u.eventProps},defaults:{ratio:"preserve",equalDelta:!1,modifiers:[],enabled:!1}};function nw(e,n,i){var r=e.startCoords,a=e.edgeSign;n?i.y=r.y+(i.x-r.x)*a.y:i.x=r.x+(i.y-r.y)*a.x}function nA(e,n,i,r){var a=e.startRect,s=e.startCoords,o=e.ratio,l=e.edgeSign;if(n){var u=r.width/o;i.y=s.y+(u-a.height)*l.y}else{var c=r.height*o;i.x=s.x+(c-a.width)*l.x}}nM.aspectRatio=nT;var nR=(0,e6.makeModifier)(nT,"aspectRatio");nM.default=nR;var nP={};Object.defineProperty(nP,"__esModule",{value:!0}),nP.default=void 0;var nC=function(){};nC._defaults={},nP.default=nC;var nL={};Object.defineProperty(nL,"__esModule",{value:!0}),Object.defineProperty(nL,"default",{enumerable:!0,get:function(){return nP.default}});var nO={};function nI(e,n,i){return l.default.func(e)?P.resolveRectLike(e,n.interactable,n.element,[i.x,i.y,n]):P.resolveRectLike(e,n.interactable,n.element)}Object.defineProperty(nO,"__esModule",{value:!0}),nO.default=void 0,nO.getRestrictionRect=nI,nO.restrict=void 0;var nD={start:function(e){var n=e.rect,i=e.startOffset,r=e.state,a=e.interaction,s=e.pageCoords,o=r.options,l=o.elementRect,u=(0,R.default)({left:0,top:0,right:0,bottom:0},o.offset||{});if(n&&l){var c=nI(o.restriction,a,s);if(c){var h=c.right-c.left-n.width,d=c.bottom-c.top-n.height;h<0&&(u.left+=h,u.right+=h),d<0&&(u.top+=d,u.bottom+=d)}u.left+=i.left-n.width*l.left,u.top+=i.top-n.height*l.top,u.right+=i.right-n.width*(1-l.right),u.bottom+=i.bottom-n.height*(1-l.bottom)}r.offset=u},set:function(e){var n=e.coords,i=e.interaction,r=e.state,a=r.options,s=r.offset,o=nI(a.restriction,i,n);if(o){var l=P.xywhToTlbr(o);n.x=Math.max(Math.min(l.right-s.right,n.x),l.left+s.left),n.y=Math.max(Math.min(l.bottom-s.bottom,n.y),l.top+s.top)}},defaults:{restriction:null,elementRect:null,offset:null,endOnly:!1,enabled:!1}};nO.restrict=nD;var nU=(0,e6.makeModifier)(nD,"restrict");nO.default=nU;var nN={};Object.defineProperty(nN,"__esModule",{value:!0}),nN.restrictEdges=nN.default=void 0;var nF={top:1/0,left:1/0,bottom:-1/0,right:-1/0},nz={top:-1/0,left:-1/0,bottom:1/0,right:1/0};function nB(e,n){for(var i=["top","left","bottom","right"],r=0;re.length)&&(n=e.length);for(var i=0,r=Array(n);i{"use strict";i.d(n,{Z:()=>r});let r={crush:(e,n=50)=>{let i=[];for(let e=127;--e;)(e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||"-_.!~*'()".includes(String.fromCharCode(e)))&&i.push(String.fromCharCode(e));for(let e=32;e<255;++e){let n=String.fromCharCode(e);"\\"==n||i.includes(n)||i.unshift(n)}e=a(e=e.replace(RegExp("\x01","g"),""));let r=((e,i)=>{let r=i.length,a="",s=e=>encodeURI(encodeURIComponent(e)).replace(/%../g,"i").length,o=e=>{let n=e.charCodeAt(0),i=e.charCodeAt(e.length-1);return n>=56320&&n<=57343||i>=55296&&i<=56319},l={};for(let i=2;i=0;++a)s=e.indexOf(r,s+i);a>1&&(l[r]=a)}for(;;){let n;for(;r--&&e.includes(i[r]););if(r<0)break;let o=i[r],u=0,c=s(o);for(let e in l){let i=l[e],r=(i-1)*s(e)-(i+1)*c;a.length||(r-=s("\x01")),r<=0?delete l[e]:r>u&&(n=e,u=r)}if(!n)break;e=e.split(n).join(o)+o+n,a=o+a;let h={};for(let i in l){let r=i.split(n).join(o),a=0;for(let n=e.indexOf(r);n>=0;++a)n=e.indexOf(r,n+r.length);a>1&&(h[r]=a)}l=h}return{a:e,b:a}})(e,i),s=r.a;return r.b.length&&(s+="\x01"+r.b),s+="_"},uncrush:e=>{e=e.substring(0,e.length-1);let n=e.split("\x01"),i=n[0];if(n.length>1)for(let e of n[1]){let n=i.split(e);i=n.join(n.pop())}return a(i,0)}},a=(e,n=1)=>{let i=[['"',"'"],["':","!"],[",'","~"],["}",")","\\","\\"],["{","(","\\","\\"]],r=(e,n)=>{let i=RegExp(`${(n[2]?n[2]:"")+n[0]}|${(n[3]?n[3]:"")+n[1]}`,"g");return e.replace(i,e=>e===n[0]?n[1]:n[0])};if(n)for(let n=0;n{"use strict";let r,a,s,o;i.d(n,{BbS:()=>s9,CP7:()=>rD,D1R:()=>y,DvJ:()=>ni,EB7:()=>av,EJi:()=>sh,F5T:()=>tO,FM8:()=>Z,GUF:()=>R,Hmr:()=>s0,Hw6:()=>ed,Ilk:()=>tP,KI_:()=>A,Kj0:()=>nt,M8C:()=>J,Mig:()=>sK,N$j:()=>rJ,NMF:()=>M,OdW:()=>rQ,OoA:()=>p,Ox3:()=>sZ,PMe:()=>sG,Pa4:()=>eb,QRU:()=>sQ,SJI:()=>s8,SPe:()=>r8,Syv:()=>b,TUv:()=>rY,TlE:()=>tN,Tme:()=>td,TyD:()=>f,UY4:()=>ac,UlW:()=>E,Wid:()=>sc,Wl3:()=>l,WwZ:()=>S,YLQ:()=>m,ZAu:()=>rA,Zp0:()=>s$,ZzF:()=>eE,Zzh:()=>ov,_12:()=>nS,_C8:()=>sg,_fP:()=>ex,aCh:()=>w,aH4:()=>g,aLr:()=>eV,aNw:()=>sL,blk:()=>au,cJO:()=>st,cPb:()=>nc,cek:()=>sY,dUE:()=>sS,dpR:()=>sN,ehD:()=>u,ejS:()=>al,epp:()=>eo,fHI:()=>aB,hH6:()=>sD,iKG:()=>nD,iLg:()=>sT,iMs:()=>od,iUV:()=>oc,iWj:()=>nx,jyz:()=>nl,kB5:()=>rz,lb7:()=>r0,m7l:()=>sR,mTL:()=>s1,nls:()=>r9,qyh:()=>_,rpg:()=>h,tGC:()=>oy,u9r:()=>tq,uWy:()=>d,vBJ:()=>tI,vpT:()=>rN,wem:()=>v,wk1:()=>x,woe:()=>am,x12:()=>aa,xEZ:()=>em,xWb:()=>oh,xoR:()=>sd,xsS:()=>rU,yC1:()=>sA,yGw:()=>eK,z$h:()=>T,zf8:()=>az});let l=0,u=2,c="attached",h=1e3,d=1001,p=1002,f=1003,m=1004,g=1005,v=1006,_=1007,y=1008,x=1023,b=2300,M=2301,S=0,E=1,T=2,w="",A="srgb",R="srgb-linear",P="display-p3",C="display-p3-linear",L="linear",O="srgb",I="rec709",D="300 es";class U{addEventListener(e,n){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(n)&&i[e].push(n)}hasEventListener(e,n){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(n)}removeEventListener(e,n){if(void 0===this._listeners)return;let i=this._listeners,r=i[e];if(void 0!==r){let e=r.indexOf(n);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let n=this._listeners,i=n[e.type];if(void 0!==i){e.target=this;let n=i.slice(0);for(let i=0,r=n.length;i>8&255]+N[e>>16&255]+N[e>>24&255]+"-"+N[255&n]+N[n>>8&255]+"-"+N[n>>16&15|64]+N[n>>24&255]+"-"+N[63&i|128]+N[i>>8&255]+"-"+N[i>>16&255]+N[i>>24&255]+N[255&r]+N[r>>8&255]+N[r>>16&255]+N[r>>24&255];return a.toLowerCase()}function H(e,n,i){return Math.max(n,Math.min(i,e))}function V(e,n){return(e%n+n)%n}function G(e,n,i){return(1-i)*e+i*n}function W(e){return(e&e-1)==0&&0!==e}function j(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function X(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function q(e,n){switch(n.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function Y(e,n){switch(n.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}let J={DEG2RAD:z,RAD2DEG:B,generateUUID:k,clamp:H,euclideanModulo:V,mapLinear:function(e,n,i,r,a){return r+(e-n)*(a-r)/(i-n)},inverseLerp:function(e,n,i){return e!==n?(i-e)/(n-e):0},lerp:G,damp:function(e,n,i,r){return G(e,n,1-Math.exp(-i*r))},pingpong:function(e,n=1){return n-Math.abs(V(e,2*n)-n)},smoothstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n))*e*(3-2*e)},smootherstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n))*e*e*(e*(6*e-15)+10)},randInt:function(e,n){return e+Math.floor(Math.random()*(n-e+1))},randFloat:function(e,n){return e+Math.random()*(n-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(F=e);let n=F+=1831565813;return n=Math.imul(n^n>>>15,1|n),(((n^=n+Math.imul(n^n>>>7,61|n))^n>>>14)>>>0)/4294967296},degToRad:function(e){return e*z},radToDeg:function(e){return e*B},isPowerOfTwo:W,ceilPowerOfTwo:j,floorPowerOfTwo:X,setQuaternionFromProperEuler:function(e,n,i,r,a){let s=Math.cos,o=Math.sin,l=s(i/2),u=o(i/2),c=s((n+r)/2),h=o((n+r)/2),d=s((n-r)/2),p=o((n-r)/2),f=s((r-n)/2),m=o((r-n)/2);switch(a){case"XYX":e.set(l*h,u*d,u*p,l*c);break;case"YZY":e.set(u*p,l*h,u*d,l*c);break;case"ZXZ":e.set(u*d,u*p,l*h,l*c);break;case"XZX":e.set(l*h,u*m,u*f,l*c);break;case"YXY":e.set(u*f,l*h,u*m,l*c);break;case"ZYZ":e.set(u*m,u*f,l*h,l*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}},normalize:Y,denormalize:q};class Z{constructor(e=0,n=0){Z.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let n=this.x,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===n)return Math.PI/2;let i=this.dot(e)/n;return Math.acos(H(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,i=this.y-e.y;return n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){let i=Math.cos(n),r=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class K{constructor(e,n,i,r,a,s,o,l,u){K.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,n,i,r,a,s,o,l,u)}set(e,n,i,r,a,s,o,l,u){let c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=n,c[4]=a,c[5]=l,c[6]=i,c[7]=s,c[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[3],l=i[6],u=i[1],c=i[4],h=i[7],d=i[2],p=i[5],f=i[8],m=r[0],g=r[3],v=r[6],_=r[1],y=r[4],x=r[7],b=r[2],M=r[5],S=r[8];return a[0]=s*m+o*_+l*b,a[3]=s*g+o*y+l*M,a[6]=s*v+o*x+l*S,a[1]=u*m+c*_+h*b,a[4]=u*g+c*y+h*M,a[7]=u*v+c*x+h*S,a[2]=d*m+p*_+f*b,a[5]=d*g+p*y+f*M,a[8]=d*v+p*x+f*S,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return n*s*c-n*o*u-i*a*c+i*o*l+r*a*u-r*s*l}invert(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=c*s-o*u,d=o*l-c*a,p=u*a-s*l,f=n*h+i*d+r*p;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=h*m,e[1]=(r*u-c*i)*m,e[2]=(o*i-r*s)*m,e[3]=d*m,e[4]=(c*n-r*l)*m,e[5]=(r*a-o*n)*m,e[6]=p*m,e[7]=(i*l-u*n)*m,e[8]=(s*n-i*a)*m,this}transpose(){let e;let n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,i,r,a,s,o){let l=Math.cos(a),u=Math.sin(a);return this.set(i*l,i*u,-i*(l*s+u*o)+s+e,-r*u,r*l,-r*(-u*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply($.makeScale(e,n)),this}rotate(e){return this.premultiply($.makeRotation(-e)),this}translate(e,n){return this.premultiply($.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){let n=this.elements,i=e.elements;for(let e=0;e<9;e++)if(n[e]!==i[e])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){let i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let $=new K;function Q(e){for(let n=e.length-1;n>=0;--n)if(e[n]>=65535)return!0;return!1}function ee(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;let et={};function en(e){e in et||(et[e]=!0,console.warn(e))}let ei=new K().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),er=new K().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ea={[R]:{transfer:L,primaries:I,toReference:e=>e,fromReference:e=>e},[A]:{transfer:O,primaries:I,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[C]:{transfer:L,primaries:"p3",toReference:e=>e.applyMatrix3(er),fromReference:e=>e.applyMatrix3(ei)},[P]:{transfer:O,primaries:"p3",toReference:e=>e.convertSRGBToLinear().applyMatrix3(er),fromReference:e=>e.applyMatrix3(ei).convertLinearToSRGB()}},es=new Set([R,C]),eo={enabled:!0,_workingColorSpace:R,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(legacyMode){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!legacyMode},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(colorSpace){if(!es.has(colorSpace))throw Error(`Unsupported working color space, "${colorSpace}".`);this._workingColorSpace=colorSpace},convert:function(e,n,i){if(!1===this.enabled||n===i||!n||!i)return e;let r=ea[n].toReference,a=ea[i].fromReference;return a(r(e))},fromWorkingColorSpace:function(e,n){return this.convert(e,this._workingColorSpace,n)},toWorkingColorSpace:function(e,n){return this.convert(e,n,this._workingColorSpace)},getPrimaries:function(e){return ea[e].primaries},getTransfer:function(e){return e===w?L:ea[e].transfer}};function el(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function eu(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class ec{static getDataURL(e){let n;if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)n=e;else{void 0===r&&(r=ee("canvas")),r.width=e.width,r.height=e.height;let i=r.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=r}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let n=ee("canvas");n.width=e.width,n.height=e.height;let i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let e=0;e0&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case h:e.x=e.x-Math.floor(e.x);break;case d:e.x=e.x<0?0:1;break;case p:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case h:e.y=e.y-Math.floor(e.y);break;case d:e.y=e.y<0?0:1;break;case p:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return en("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===A?3001:3e3}set encoding(e){en("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=3001===e?A:w}}em.DEFAULT_IMAGE=null,em.DEFAULT_MAPPING=300,em.DEFAULT_ANISOTROPY=1;class eg{constructor(e=0,n=0,i=0,r=1){eg.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let n=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*n+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*n+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*n+s[7]*i+s[11]*r+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,i,r;let a=e.elements,s=a[0],o=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-d)&&.01>Math.abs(h-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+d)&&.1>Math.abs(h+p)&&.1>Math.abs(s+c+f-3))return this.set(1,0,0,0),this;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+u)/4,v=(l+d)/4,_=(h+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(i=g/(n=Math.sqrt(e)),r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(n=g/(i=Math.sqrt(a)),r=_/i):m<.01?(n=.707106781,i=.707106781,r=0):(n=v/(r=Math.sqrt(m)),i=_/r),this.set(n,i,r,Math.PI),this}let m=Math.sqrt((p-h)*(p-h)+(l-d)*(l-d)+(u-o)*(u-o));return .001>Math.abs(m)&&(m=1),this.x=(p-h)/m,this.y=(l-d)/m,this.z=(u-o)/m,this.w=Math.acos((s+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ev extends U{constructor(e=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new eg(0,0,e,n),this.scissorTest=!1,this.viewport=new eg(0,0,e,n),void 0!==i.encoding&&(en("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=3001===i.encoding?A:w),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:v,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new em({width:e,height:n,depth:1},i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,n,i=1){(this.width!==e||this.height!==n||this.depth!==i)&&(this.width=e,this.height=n,this.depth=i,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let n=Object.assign({},e.texture.image);return this.texture.source=new ed(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class e_ extends ev{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class ey extends em{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=f,this.minFilter=f,this.wrapR=d,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ex{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,a,s,o){let l=i[r+0],u=i[r+1],c=i[r+2],h=i[r+3],d=a[s+0],p=a[s+1],f=a[s+2],m=a[s+3];if(0===o){e[n+0]=l,e[n+1]=u,e[n+2]=c,e[n+3]=h;return}if(1===o){e[n+0]=d,e[n+1]=p,e[n+2]=f,e[n+3]=m;return}if(h!==m||l!==d||u!==p||c!==f){let e=1-o,n=l*d+u*p+c*f+h*m,i=n>=0?1:-1,r=1-n*n;if(r>Number.EPSILON){let a=Math.sqrt(r),s=Math.atan2(a,n*i);e=Math.sin(e*s)/a,o=Math.sin(o*s)/a}let a=o*i;if(l=l*e+d*a,u=u*e+p*a,c=c*e+f*a,h=h*e+m*a,e===1-o){let e=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=e,u*=e,c*=e,h*=e}}e[n]=l,e[n+1]=u,e[n+2]=c,e[n+3]=h}static multiplyQuaternionsFlat(e,n,i,r,a,s){let o=i[r],l=i[r+1],u=i[r+2],c=i[r+3],h=a[s],d=a[s+1],p=a[s+2],f=a[s+3];return e[n]=o*f+c*h+l*p-u*d,e[n+1]=l*f+c*d+u*h-o*p,e[n+2]=u*f+c*p+o*d-l*h,e[n+3]=c*f-o*h-l*d-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,u=o(i/2),c=o(r/2),h=o(a/2),d=l(i/2),p=l(r/2),f=l(a/2);switch(s){case"XYZ":this._x=d*c*h+u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h-d*p*f;break;case"YXZ":this._x=d*c*h+u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h+d*p*f;break;case"ZXY":this._x=d*c*h-u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h-d*p*f;break;case"ZYX":this._x=d*c*h-u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h+d*p*f;break;case"YZX":this._x=d*c*h+u*p*f,this._y=u*p*h+d*c*f,this._z=u*c*f-d*p*h,this._w=u*c*h-d*p*f;break;case"XZY":this._x=d*c*h-u*p*f,this._y=u*p*h-d*c*f,this._z=u*c*f+d*p*h,this._w=u*c*h+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==n&&this._onChangeCallback(),this}setFromAxisAngle(e,n){let i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let n=e.elements,i=n[0],r=n[4],a=n[8],s=n[1],o=n[5],l=n[9],u=n[2],c=n[6],h=n[10],d=i+o+h;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-l)*e,this._y=(a-u)*e,this._z=(s-r)*e}else if(i>o&&i>h){let e=2*Math.sqrt(1+i-o-h);this._w=(c-l)/e,this._x=.25*e,this._y=(r+s)/e,this._z=(a+u)/e}else if(o>h){let e=2*Math.sqrt(1+o-i-h);this._w=(a-u)/e,this._x=(r+s)/e,this._y=.25*e,this._z=(l+c)/e}else{let e=2*Math.sqrt(1+h-i-o);this._w=(s-r)/e,this._x=(a+u)/e,this._y=(l+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x),this._w=i,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(H(this.dot(e),-1,1)))}rotateTowards(e,n){let i=this.angleTo(e);return 0===i||this.slerp(e,Math.min(1,n/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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){let i=e._x,r=e._y,a=e._z,s=e._w,o=n._x,l=n._y,u=n._z,c=n._w;return this._x=i*c+s*o+r*u-a*l,this._y=r*c+s*l+a*o-i*u,this._z=a*c+s*u+i*l-r*o,this._w=s*c-i*o-r*l-a*u,this._onChangeCallback(),this}slerp(e,n){if(0===n)return this;if(1===n)return this.copy(e);let i=this._x,r=this._y,a=this._z,s=this._w,o=s*e._w+i*e._x+r*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=i,this._y=r,this._z=a,this;let l=1-o*o;if(l<=Number.EPSILON){let e=1-n;return this._w=e*s+n*this._w,this._x=e*i+n*this._x,this._y=e*r+n*this._y,this._z=e*a+n*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,o),h=Math.sin((1-n)*c)/u,d=Math.sin(n*c)/u;return this._w=s*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=a*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){let e=Math.random(),n=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(r),i*Math.sin(a),i*Math.cos(a),n*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class eb{constructor(e=0,n=0,i=0){eb.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return void 0===i&&(i=this.z),this.x=e,this.y=n,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(eS.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(eS.setFromAxisAngle(e,n))}applyMatrix3(e){let n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[3]*i+a[6]*r,this.y=a[1]*n+a[4]*i+a[7]*r,this.z=a[2]*n+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let n=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*n+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*n+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*n+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*n+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let n=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,l=e.w,u=2*(s*r-o*i),c=2*(o*n-a*r),h=2*(a*i-s*n);return this.x=n+l*u+s*h-o*c,this.y=i+l*c+o*u-a*h,this.z=r+l*h+a*c-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[4]*i+a[8]*r,this.y=a[1]*n+a[5]*i+a[9]*r,this.z=a[2]*n+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){let i=e.x,r=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=r*l-a*o,this.y=a*s-i*l,this.z=i*o-r*s,this}projectOnVector(e){let n=e.lengthSq();if(0===n)return this.set(0,0,0);let i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return eM.copy(this).projectOnVector(e),this.sub(eM)}reflect(e){return this.sub(eM.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===n)return Math.PI/2;let i=this.dot(e)/n;return Math.acos(H(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,i){let r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){let n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){let n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,4*n)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,3*n)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(n),this.y=i*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let eM=new eb,eS=new ex;class eE{constructor(e=new eb(Infinity,Infinity,Infinity),n=new eb(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,i=e.length;nthis.max.x)&&!(e.ythis.max.y)&&!(e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x)&&!(e.max.ythis.max.y)&&!(e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ew),ew.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eD),eU.subVectors(this.max,eD),eR.subVectors(e.a,eD),eP.subVectors(e.b,eD),eC.subVectors(e.c,eD),eL.subVectors(eP,eR),eO.subVectors(eC,eP),eI.subVectors(eR,eC);let n=[0,-eL.z,eL.y,0,-eO.z,eO.y,0,-eI.z,eI.y,eL.z,0,-eL.x,eO.z,0,-eO.x,eI.z,0,-eI.x,-eL.y,eL.x,0,-eO.y,eO.x,0,-eI.y,eI.x,0];return!!(ez(n,eR,eP,eC,eU)&&ez(n=[1,0,0,0,1,0,0,0,1],eR,eP,eC,eU))&&(eN.crossVectors(eL,eO),ez(n=[eN.x,eN.y,eN.z],eR,eP,eC,eU))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ew).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(ew).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(eT[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),eT[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),eT[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),eT[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),eT[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),eT[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),eT[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),eT[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(eT)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}let eT=[new eb,new eb,new eb,new eb,new eb,new eb,new eb,new eb],ew=new eb,eA=new eE,eR=new eb,eP=new eb,eC=new eb,eL=new eb,eO=new eb,eI=new eb,eD=new eb,eU=new eb,eN=new eb,eF=new eb;function ez(e,n,i,r,a){for(let s=0,o=e.length-3;s<=o;s+=3){eF.fromArray(e,s);let o=a.x*Math.abs(eF.x)+a.y*Math.abs(eF.y)+a.z*Math.abs(eF.z),l=n.dot(eF),u=i.dot(eF),c=r.dot(eF);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>o)return!1}return!0}let eB=new eE,ek=new eb,eH=new eb;class eV{constructor(e=new eb,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){let i=this.center;void 0!==n?i.copy(n):eB.setFromPoints(e).getCenter(i);let r=0;for(let n=0,a=e.length;nthis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ek.subVectors(e,this.center);let n=ek.lengthSq();if(n>this.radius*this.radius){let e=Math.sqrt(n),i=(e-this.radius)*.5;this.center.addScaledVector(ek,i/e),this.radius+=i}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(eH.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ek.copy(e.center).add(eH)),this.expandByPoint(ek.copy(e.center).sub(eH)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}let eG=new eb,eW=new eb,ej=new eb,eX=new eb,eq=new eb,eY=new eb,eJ=new eb;class eZ{constructor(e=new eb,n=new eb(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,eG)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);let i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let n=eG.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(eG.copy(this.origin).addScaledVector(this.direction,n),eG.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){let a,s,o,l;eW.copy(e).add(n).multiplyScalar(.5),ej.copy(n).sub(e).normalize(),eX.copy(this.origin).sub(eW);let u=.5*e.distanceTo(n),c=-this.direction.dot(ej),h=eX.dot(this.direction),d=-eX.dot(ej),p=eX.lengthSq(),f=Math.abs(1-c*c);if(f>0){if(a=c*d-h,s=c*h-d,l=u*f,a>=0){if(s>=-l){if(s<=l){let e=1/f;a*=e,s*=e,o=a*(a+c*s+2*h)+s*(c*a+s+2*d)+p}else o=-(a=Math.max(0,-(c*(s=u)+h)))*a+s*(s+2*d)+p}else o=-(a=Math.max(0,-(c*(s=-u)+h)))*a+s*(s+2*d)+p}else s<=-l?(s=(a=Math.max(0,-(-c*u+h)))>0?-u:Math.min(Math.max(-u,-d),u),o=-a*a+s*(s+2*d)+p):s<=l?(a=0,o=(s=Math.min(Math.max(-u,-d),u))*(s+2*d)+p):(s=(a=Math.max(0,-(c*u+h)))>0?u:Math.min(Math.max(-u,-d),u),o=-a*a+s*(s+2*d)+p)}else s=c>0?-u:u,o=-(a=Math.max(0,-(c*s+h)))*a+s*(s+2*d)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,a),r&&r.copy(eW).addScaledVector(ej,s),o}intersectSphere(e,n){eG.subVectors(e.center,this.origin);let i=eG.dot(this.direction),r=eG.dot(eG)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,l=i+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let n=e.normal.dot(this.direction);if(0===n)return 0===e.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){let i=this.distanceToPlane(e);return null===i?null:this.at(i,n)}intersectsPlane(e){let n=e.distanceToPoint(this.origin);if(0===n)return!0;let i=e.normal.dot(this.direction);return i*n<0}intersectBox(e,n){let i,r,a,s,o,l;let u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return(u>=0?(i=(e.min.x-d.x)*u,r=(e.max.x-d.x)*u):(i=(e.max.x-d.x)*u,r=(e.min.x-d.x)*u),c>=0?(a=(e.min.y-d.y)*c,s=(e.max.y-d.y)*c):(a=(e.max.y-d.y)*c,s=(e.min.y-d.y)*c),i>s||a>r)?null:((a>i||isNaN(i))&&(i=a),(s=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||o>r)?null:((o>i||i!=i)&&(i=o),(l=0?i:r,n)}intersectsBox(e){return null!==this.intersectBox(e,eG)}intersectTriangle(e,n,i,r,a){let s;eq.subVectors(n,e),eY.subVectors(i,e),eJ.crossVectors(eq,eY);let o=this.direction.dot(eJ);if(o>0){if(r)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}eX.subVectors(this.origin,e);let l=s*this.direction.dot(eY.crossVectors(eX,eY));if(l<0)return null;let u=s*this.direction.dot(eq.cross(eX));if(u<0||l+u>o)return null;let c=-s*eX.dot(eJ);return c<0?null:this.at(c/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class eK{constructor(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g){eK.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g)}set(e,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g){let v=this.elements;return v[0]=e,v[4]=n,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=l,v[2]=u,v[6]=c,v[10]=h,v[14]=d,v[3]=p,v[7]=f,v[11]=m,v[15]=g,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 eK().fromArray(this.elements)}copy(e){let n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){let n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(e){let n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){let n=this.elements,i=e.elements,r=1/e$.setFromMatrixColumn(e,0).length(),a=1/e$.setFromMatrixColumn(e,1).length(),s=1/e$.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*s,n[9]=i[9]*s,n[10]=i[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){let n=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),u=Math.sin(r),c=Math.cos(a),h=Math.sin(a);if("XYZ"===e.order){let e=s*c,i=s*h,r=o*c,a=o*h;n[0]=l*c,n[4]=-l*h,n[8]=u,n[1]=i+r*u,n[5]=e-a*u,n[9]=-o*l,n[2]=a-e*u,n[6]=r+i*u,n[10]=s*l}else if("YXZ"===e.order){let e=l*c,i=l*h,r=u*c,a=u*h;n[0]=e+a*o,n[4]=r*o-i,n[8]=s*u,n[1]=s*h,n[5]=s*c,n[9]=-o,n[2]=i*o-r,n[6]=a+e*o,n[10]=s*l}else if("ZXY"===e.order){let e=l*c,i=l*h,r=u*c,a=u*h;n[0]=e-a*o,n[4]=-s*h,n[8]=r+i*o,n[1]=i+r*o,n[5]=s*c,n[9]=a-e*o,n[2]=-s*u,n[6]=o,n[10]=s*l}else if("ZYX"===e.order){let e=s*c,i=s*h,r=o*c,a=o*h;n[0]=l*c,n[4]=r*u-i,n[8]=e*u+a,n[1]=l*h,n[5]=a*u+e,n[9]=i*u-r,n[2]=-u,n[6]=o*l,n[10]=s*l}else if("YZX"===e.order){let e=s*l,i=s*u,r=o*l,a=o*u;n[0]=l*c,n[4]=a-e*h,n[8]=r*h+i,n[1]=h,n[5]=s*c,n[9]=-o*c,n[2]=-u*c,n[6]=i*h+r,n[10]=e-a*h}else if("XZY"===e.order){let e=s*l,i=s*u,r=o*l,a=o*u;n[0]=l*c,n[4]=-h,n[8]=u*c,n[1]=e*h+a,n[5]=s*c,n[9]=i*h-r,n[2]=r*h-i,n[6]=o*c,n[10]=a*h+e}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(e0,e,e1)}lookAt(e,n,i){let r=this.elements;return e4.subVectors(e,n),0===e4.lengthSq()&&(e4.z=1),e4.normalize(),e2.crossVectors(i,e4),0===e2.lengthSq()&&(1===Math.abs(i.z)?e4.x+=1e-4:e4.z+=1e-4,e4.normalize(),e2.crossVectors(i,e4)),e2.normalize(),e3.crossVectors(e4,e2),r[0]=e2.x,r[4]=e3.x,r[8]=e4.x,r[1]=e2.y,r[5]=e3.y,r[9]=e4.y,r[2]=e2.z,r[6]=e3.z,r[10]=e4.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[4],l=i[8],u=i[12],c=i[1],h=i[5],d=i[9],p=i[13],f=i[2],m=i[6],g=i[10],v=i[14],_=i[3],y=i[7],x=i[11],b=i[15],M=r[0],S=r[4],E=r[8],T=r[12],w=r[1],A=r[5],R=r[9],P=r[13],C=r[2],L=r[6],O=r[10],I=r[14],D=r[3],U=r[7],N=r[11],F=r[15];return a[0]=s*M+o*w+l*C+u*D,a[4]=s*S+o*A+l*L+u*U,a[8]=s*E+o*R+l*O+u*N,a[12]=s*T+o*P+l*I+u*F,a[1]=c*M+h*w+d*C+p*D,a[5]=c*S+h*A+d*L+p*U,a[9]=c*E+h*R+d*O+p*N,a[13]=c*T+h*P+d*I+p*F,a[2]=f*M+m*w+g*C+v*D,a[6]=f*S+m*A+g*L+v*U,a[10]=f*E+m*R+g*O+v*N,a[14]=f*T+m*P+g*I+v*F,a[3]=_*M+y*w+x*C+b*D,a[7]=_*S+y*A+x*L+b*U,a[11]=_*E+y*R+x*O+b*N,a[15]=_*T+y*P+x*I+b*F,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){let e=this.elements,n=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],l=e[9],u=e[13],c=e[2],h=e[6],d=e[10],p=e[14],f=e[3],m=e[7],g=e[11],v=e[15];return f*(+a*l*h-r*u*h-a*o*d+i*u*d+r*o*p-i*l*p)+m*(+n*l*p-n*u*d+a*s*d-r*s*p+r*u*c-a*l*c)+g*(+n*u*h-n*o*p-a*s*h+i*s*p+a*o*c-i*u*c)+v*(-r*o*c-n*l*h+n*o*d+r*s*h-i*s*d+i*l*c)}transpose(){let e;let n=this.elements;return e=n[1],n[1]=n[4],n[4]=e,e=n[2],n[2]=n[8],n[8]=e,e=n[6],n[6]=n[9],n[9]=e,e=n[3],n[3]=n[12],n[12]=e,e=n[7],n[7]=n[13],n[13]=e,e=n[11],n[11]=n[14],n[14]=e,this}setPosition(e,n,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){let e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],v=e[15],_=h*g*u-m*d*u+m*l*p-o*g*p-h*l*v+o*d*v,y=f*d*u-c*g*u-f*l*p+s*g*p+c*l*v-s*d*v,x=c*m*u-f*h*u+f*o*p-s*m*p-c*o*v+s*h*v,b=f*h*l-c*m*l-f*o*d+s*m*d+c*o*g-s*h*g,M=n*_+i*y+r*x+a*b;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/M;return e[0]=_*S,e[1]=(m*d*a-h*g*a-m*r*p+i*g*p+h*r*v-i*d*v)*S,e[2]=(o*g*a-m*l*a+m*r*u-i*g*u-o*r*v+i*l*v)*S,e[3]=(h*l*a-o*d*a-h*r*u+i*d*u+o*r*p-i*l*p)*S,e[4]=y*S,e[5]=(c*g*a-f*d*a+f*r*p-n*g*p-c*r*v+n*d*v)*S,e[6]=(f*l*a-s*g*a-f*r*u+n*g*u+s*r*v-n*l*v)*S,e[7]=(s*d*a-c*l*a+c*r*u-n*d*u-s*r*p+n*l*p)*S,e[8]=x*S,e[9]=(f*h*a-c*m*a-f*i*p+n*m*p+c*i*v-n*h*v)*S,e[10]=(s*m*a-f*o*a+f*i*u-n*m*u-s*i*v+n*o*v)*S,e[11]=(c*o*a-s*h*a-c*i*u+n*h*u+s*i*p-n*o*p)*S,e[12]=b*S,e[13]=(c*m*r-f*h*r+f*i*d-n*m*d-c*i*g+n*h*g)*S,e[14]=(f*o*r-s*m*r-f*i*l+n*m*l+s*i*g-n*o*g)*S,e[15]=(s*h*r-c*o*r+c*i*l-n*h*l-s*i*d+n*o*d)*S,this}scale(e){let n=this.elements,i=e.x,r=e.y,a=e.z;return n[0]*=i,n[4]*=r,n[8]*=a,n[1]*=i,n[5]*=r,n[9]*=a,n[2]*=i,n[6]*=r,n[10]*=a,n[3]*=i,n[7]*=r,n[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(e){let n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){let n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){let i=Math.cos(n),r=Math.sin(n),a=1-i,s=e.x,o=e.y,l=e.z,u=a*s,c=a*o;return this.set(u*s+i,u*o-r*l,u*l+r*o,0,u*o+r*l,c*o+i,c*l-r*s,0,u*l-r*o,c*l+r*s,a*l*l+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){let r=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,u=a+a,c=s+s,h=o+o,d=a*u,p=a*c,f=a*h,m=s*c,g=s*h,v=o*h,_=l*u,y=l*c,x=l*h,b=i.x,M=i.y,S=i.z;return r[0]=(1-(m+v))*b,r[1]=(p+x)*b,r[2]=(f-y)*b,r[3]=0,r[4]=(p-x)*M,r[5]=(1-(d+v))*M,r[6]=(g+_)*M,r[7]=0,r[8]=(f+y)*S,r[9]=(g-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){let r=this.elements,a=e$.set(r[0],r[1],r[2]).length(),s=e$.set(r[4],r[5],r[6]).length(),o=e$.set(r[8],r[9],r[10]).length(),l=this.determinant();l<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],eQ.copy(this);let u=1/a,c=1/s,h=1/o;return eQ.elements[0]*=u,eQ.elements[1]*=u,eQ.elements[2]*=u,eQ.elements[4]*=c,eQ.elements[5]*=c,eQ.elements[6]*=c,eQ.elements[8]*=h,eQ.elements[9]*=h,eQ.elements[10]*=h,n.setFromRotationMatrix(eQ),i.x=a,i.y=s,i.z=o,this}makePerspective(e,n,i,r,a,s,o=2e3){let l,u;let c=this.elements;if(2e3===o)l=-(s+a)/(s-a),u=-2*s*a/(s-a);else if(2001===o)l=-s/(s-a),u=-s*a/(s-a);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=2*a/(n-e),c[4]=0,c[8]=(n+e)/(n-e),c[12]=0,c[1]=0,c[5]=2*a/(i-r),c[9]=(i+r)/(i-r),c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=2e3){let l,u;let c=this.elements,h=1/(n-e),d=1/(i-r),p=1/(s-a);if(2e3===o)l=(s+a)*p,u=-2*p;else if(2001===o)l=a*p,u=-1*p;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*h,c[4]=0,c[8]=0,c[12]=-((n+e)*h),c[1]=0,c[5]=2*d,c[9]=0,c[13]=-((i+r)*d),c[2]=0,c[6]=0,c[10]=u,c[14]=-l,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let n=this.elements,i=e.elements;for(let e=0;e<16;e++)if(n[e]!==i[e])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){let i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}}let e$=new eb,eQ=new eK,e0=new eb(0,0,0),e1=new eb(1,1,1),e2=new eb,e3=new eb,e4=new eb,e5=new eK,e6=new ex;class e7{constructor(e=0,n=0,i=0,r=e7.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],l=r[1],u=r[5],c=r[9],h=r[2],d=r[6],p=r[10];switch(n){case"XYZ":this._y=Math.asin(H(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-H(c,-1,1)),.9999999>Math.abs(c)?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(H(d,-1,1)),.9999999>Math.abs(d)?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-H(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(H(l,-1,1)),.9999999>Math.abs(l)?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-H(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(d,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return e5.makeRotationFromQuaternion(e),this.setFromRotationMatrix(e5,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return e6.setFromEuler(this),this.setFromQuaternion(e6,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}e7.DEFAULT_ORDER="XYZ";class e8{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tr,e,ta),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tr,ts,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);let n=this.children;for(let i=0,r=n.length;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let n=this.geometry.parameters;if(void 0!==n&&void 0!==n.shapes){let i=n.shapes;if(Array.isArray(i))for(let n=0,r=i.length;n0){r.children=[];for(let n=0;n0){r.animations=[];for(let n=0;n0&&(i.geometries=n),r.length>0&&(i.materials=r),a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.shapes=l),u.length>0&&(i.skeletons=u),c.length>0&&(i.animations=c),h.length>0&&(i.nodes=h)}return i.object=r,i;function s(e){let n=[];for(let i in e){let r=e[i];delete r.metadata,n.push(r)}return n}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===n)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,n,i,r,a){tp.subVectors(r,n),tf.subVectors(i,n),tm.subVectors(e,n);let s=tp.dot(tp),o=tp.dot(tf),l=tp.dot(tm),u=tf.dot(tf),c=tf.dot(tm),h=s*u-o*o;if(0===h)return a.set(-2,-1,-1);let d=1/h,p=(u*l-o*c)*d,f=(s*c-o*l)*d;return a.set(1-p-f,f,p)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,tg),tg.x>=0&&tg.y>=0&&tg.x+tg.y<=1}static getUV(e,n,i,r,a,s,o,l){return!1===tS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tS=!0),this.getInterpolation(e,n,i,r,a,s,o,l)}static getInterpolation(e,n,i,r,a,s,o,l){return this.getBarycoord(e,n,i,r,tg),l.setScalar(0),l.addScaledVector(a,tg.x),l.addScaledVector(s,tg.y),l.addScaledVector(o,tg.z),l}static isFrontFacing(e,n,i,r){return tp.subVectors(i,n),tf.subVectors(e,n),0>tp.cross(tf).dot(r)}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return tp.subVectors(this.c,this.b),tf.subVectors(this.a,this.b),.5*tp.cross(tf).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tE.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return tE.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,i,r,a){return!1===tS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tS=!0),tE.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}getInterpolation(e,n,i,r,a){return tE.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return tE.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tE.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){let i,r;let a=this.a,s=this.b,o=this.c;tv.subVectors(s,a),t_.subVectors(o,a),tx.subVectors(e,a);let l=tv.dot(tx),u=t_.dot(tx);if(l<=0&&u<=0)return n.copy(a);tb.subVectors(e,s);let c=tv.dot(tb),h=t_.dot(tb);if(c>=0&&h<=c)return n.copy(s);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return i=l/(l-c),n.copy(a).addScaledVector(tv,i);tM.subVectors(e,o);let p=tv.dot(tM),f=t_.dot(tM);if(f>=0&&p<=f)return n.copy(o);let m=p*u-l*f;if(m<=0&&u>=0&&f<=0)return r=u/(u-f),n.copy(a).addScaledVector(t_,r);let g=c*f-p*h;if(g<=0&&h-c>=0&&p-f>=0)return ty.subVectors(o,s),r=(h-c)/(h-c+(p-f)),n.copy(s).addScaledVector(ty,r);let v=1/(g+m+d);return i=m*v,r=d*v,n.copy(a).addScaledVector(tv,i).addScaledVector(t_,r)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let tT={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},tw={h:0,s:0,l:0},tA={h:0,s:0,l:0};function tR(e,n,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?e+(n-e)*6*i:i<.5?n:i<2/3?e+(n-e)*6*(2/3-i):e}class tP{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){return void 0===n&&void 0===i?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,n,i),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=A){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,eo.toWorkingColorSpace(this,n),this}setRGB(e,n,i,r=eo.workingColorSpace){return this.r=e,this.g=n,this.b=i,eo.toWorkingColorSpace(this,r),this}setHSL(e,n,i,r=eo.workingColorSpace){if(e=V(e,1),n=H(n,0,1),i=H(i,0,1),0===n)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+n):i+n-i*n,a=2*i-r;this.r=tR(a,r,e+1/3),this.g=tR(a,r,e),this.b=tR(a,r,e-1/3)}return eo.toWorkingColorSpace(this,r),this}setStyle(e,n=A){let i;function r(n){void 0!==n&&1>parseFloat(n)&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;let s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],a=r.length;if(3===a)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,n);if(6===a)return this.setHex(parseInt(r,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=A){let i=tT[e.toLowerCase()];return void 0!==i?this.setHex(i,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=el(e.r),this.g=el(e.g),this.b=el(e.b),this}copyLinearToSRGB(e){return this.r=eu(e.r),this.g=eu(e.g),this.b=eu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=A){return eo.fromWorkingColorSpace(tC.copy(this),e),65536*Math.round(H(255*tC.r,0,255))+256*Math.round(H(255*tC.g,0,255))+Math.round(H(255*tC.b,0,255))}getHexString(e=A){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=eo.workingColorSpace){let i,r;eo.fromWorkingColorSpace(tC.copy(this),n);let a=tC.r,s=tC.g,o=tC.b,l=Math.max(a,s,o),u=Math.min(a,s,o),c=(u+l)/2;if(u===l)i=0,r=0;else{let e=l-u;switch(r=c<=.5?e/(l+u):e/(2-l-u),l){case a:i=(s-o)/e+(s0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let n in e){let i=e[n];if(void 0===i){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}let r=this[n];if(void 0===r){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){let n=void 0===e||"string"==typeof e;n&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){let n=[];for(let i in e){let r=e[i];delete r.metadata,n.push(r)}return n}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),this.side!==l&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(i.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(i.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),n){let n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let n=e.clippingPlanes,i=null;if(null!==n){let e=n.length;i=Array(e);for(let r=0;r!==e;++r)i[r]=n[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class tI extends tO{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tP(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}let tD=new eb,tU=new Z;class tN{constructor(e,n,i=!1){if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=void 0!==e?e.length/n:0,this.normalized=i,this.usage=35044,this.updateRange={offset:0,count:-1},this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,i){e*=this.itemSize,i*=n.itemSize;for(let r=0,a=this.itemSize;r0&&(e.userData=this.userData),void 0!==this.parameters){let n=this.parameters;for(let i in n)void 0!==n[i]&&(e[i]=n[i]);return e}e.data={attributes:{}};let n=this.index;null!==n&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});let i=this.attributes;for(let n in i){let r=i[n];e.data.attributes[n]=r.toJSON(e.data)}let r={},a=!1;for(let n in this.morphAttributes){let i=this.morphAttributes[n],s=[];for(let n=0,r=i.length;n0&&(r[n]=s,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let n={};this.name=e.name;let i=e.index;null!==i&&this.setIndex(i.clone(n));let r=e.attributes;for(let e in r){let i=r[e];this.setAttribute(e,i.clone(n))}let a=e.morphAttributes;for(let e in a){let i=[],r=a[e];for(let e=0,a=r.length;e0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;n(e.far-e.near)**2)||(tY.copy(a).invert(),tJ.copy(e.ray).applyMatrix4(tY),null!==i.boundingBox&&!1===tJ.intersectsBox(i.boundingBox)))return;this._computeIntersections(e,n,tJ)}}_computeIntersections(e,n,i){let r;let a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,u=a.attributes.uv,c=a.attributes.uv1,h=a.attributes.normal,d=a.groups,p=a.drawRange;if(null!==o){if(Array.isArray(s))for(let a=0,l=d.length;ai.far?null:{distance:c,point:ne.clone(),object:e}}(e,n,i,r,t$,tQ,t0,t9);if(d){a&&(t3.fromBufferAttribute(a,u),t4.fromBufferAttribute(a,c),t5.fromBufferAttribute(a,h),d.uv=tE.getInterpolation(t9,t$,tQ,t0,t3,t4,t5,new Z)),s&&(t3.fromBufferAttribute(s,u),t4.fromBufferAttribute(s,c),t5.fromBufferAttribute(s,h),d.uv1=tE.getInterpolation(t9,t$,tQ,t0,t3,t4,t5,new Z),d.uv2=d.uv1),o&&(t6.fromBufferAttribute(o,u),t7.fromBufferAttribute(o,c),t8.fromBufferAttribute(o,h),d.normal=tE.getInterpolation(t9,t$,tQ,t0,t6,t7,t8,new eb),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));let e={a:u,b:c,c:h,normal:new eb,materialIndex:0};tE.getNormal(t$,tQ,t0,e.normal),d.face=e}return d}class ni extends tq{constructor(e=1,n=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let l=[],u=[],c=[],h=[],d=0,p=0;function f(e,n,i,r,a,s,f,m,g,v,_){let y=s/g,x=f/v,b=s/2,M=f/2,S=m/2,E=g+1,T=v+1,w=0,A=0,R=new eb;for(let s=0;s0?1:-1,c.push(R.x,R.y,R.z),h.push(l/g),h.push(1-s/v),w+=1}}for(let e=0;e0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;let i={};for(let e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class nu extends td{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new eK,this.projectionMatrix=new eK,this.projectionMatrixInverse=new eK,this.coordinateSystem=2e3}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class nc extends nu{constructor(e=50,n=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let n=.5*this.getFilmHeight()/e;this.fov=2*B*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*z*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*B*Math.atan(Math.tan(.5*z*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,i,r,a,s){this.aspect=e/n,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=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,n=e*Math.tan(.5*z*this.fov)/this.zoom,i=2*n,r=this.aspect*i,a=-.5*r,s=this.view;if(null!==this.view&&this.view.enabled){let e=s.fullWidth,o=s.fullHeight;a+=s.offsetX*r/e,n-=s.offsetY*i/o,r*=s.width/e,i*=s.height/o}let o=this.filmOffset;0!==o&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,n,n-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,null!==this.view&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}class nh extends td{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new nc(-90,1,e,n);r.layers=this.layers,this.add(r);let a=new nc(-90,1,e,n);a.layers=this.layers,this.add(a);let s=new nc(-90,1,e,n);s.layers=this.layers,this.add(s);let o=new nc(-90,1,e,n);o.layers=this.layers,this.add(o);let l=new nc(-90,1,e,n);l.layers=this.layers,this.add(l);let u=new nc(-90,1,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){let e=this.coordinateSystem,n=this.children.concat(),[i,r,a,s,o,l]=n;for(let e of n)this.remove(e);if(2e3===e)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(2001===e)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of n)this.add(e),e.updateMatrixWorld()}update(e,n){null===this.parent&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,l,u,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(n,a),e.setRenderTarget(i,1,r),e.render(n,s),e.setRenderTarget(i,2,r),e.render(n,o),e.setRenderTarget(i,3,r),e.render(n,l),e.setRenderTarget(i,4,r),e.render(n,u),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,r),e.render(n,c),e.setRenderTarget(h,d,p),e.xr.enabled=f,i.texture.needsPMREMUpdate=!0}}class nd extends em{constructor(e,n,i,r,a,s,o,l,u,c){super(e=void 0!==e?e:[],n=void 0!==n?n:301,i,r,a,s,o,l,u,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class np extends e_{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];void 0!==n.encoding&&(en("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=3001===n.encoding?A:w),this.texture=new nd(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:v}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -33,7 +33,7 @@ gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},r=new nn(5,5,5),a=new no({name:"CubemapFromEquirect",uniforms:ni(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});a.uniforms.tEquirect.value=n;let s=new ne(r,a),o=n.minFilter;n.minFilter===_&&(n.minFilter=g);let l=new nc(1,10,this);return l.update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,i,r){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,i,r);e.setRenderTarget(a)}}let np=new ex,nf=new ex,nm=new Z;class ng{constructor(e=new ex(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){let r=np.subVectors(i,n).cross(nf.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){let i=e.delta(np),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?n.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:n.copy(e.start).addScaledVector(i,a)}intersectsLine(e){let n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){let i=n||nm.getNormalMatrix(e),r=this.coplanarPoint(np).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let nv=new eH,n_=new ex;class ny{constructor(e=new ng,n=new ng,i=new ng,r=new ng,a=new ng,s=new ng){this.planes=[e,n,i,r,a,s]}set(e,n,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=2e3){let i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,d-u,g-p,x-v).normalize(),i[1].setComponents(l+a,d+u,g+p,x+v).normalize(),i[2].setComponents(l+s,d+c,g+f,x+_).normalize(),i[3].setComponents(l-s,d-c,g-f,x-_).normalize(),i[4].setComponents(l-o,d-h,g-m,x-y).normalize(),2e3===n)i[5].setComponents(l+o,d+h,g+m,x+y).normalize();else if(2001===n)i[5].setComponents(o,h,m,y).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),nv.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let n=e.geometry;null===n.boundingSphere&&n.computeBoundingSphere(),nv.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(nv)}intersectsSprite(e){return nv.center.set(0,0,0),nv.radius=.7071067811865476,nv.applyMatrix4(e.matrixWorld),this.intersectsSphere(nv)}intersectsSphere(e){let n=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++){let a=n[e].distanceToPoint(i);if(a0?e.max.x:e.min.x,n_.y=r.normal.y>0?e.max.y:e.min.y,n_.z=r.normal.z>0?e.max.z:e.min.z,0>r.distanceToPoint(n_))return!1}return!0}containsPoint(e){let n=this.planes;for(let i=0;i<6;i++)if(0>n[i].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}function nx(){let e=null,n=!1,i=null,r=null;function a(n,s){i(n,s),r=e.requestAnimationFrame(a)}return{start:function(){!0!==n&&null!==i&&(r=e.requestAnimationFrame(a),n=!0)},stop:function(){e.cancelAnimationFrame(r),n=!1},setAnimationLoop:function(e){i=e},setContext:function(n){e=n}}}function nb(e,n){let i=n.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=r.get(n);i&&(e.deleteBuffer(i.buffer),r.delete(n))},update:function(n,a){if(n.isGLBufferAttribute){let e=r.get(n);(!e||e.version 0\n vec4 plane;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.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 const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n mat3 tmp;\n tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n return tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n return dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_v0 0.339\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_v1 0.276\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_v4 0.046\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_v5 0.016\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_v6 0.0038\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n vec3( 0.8224621, 0.177538, 0.0 ),\n vec3( 0.0331941, 0.9668058, 0.0 ),\n vec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n vec3( 1.2249401, - 0.2249404, 0.0 ),\n vec3( - 0.0420569, 1.0420571, 0.0 ),\n vec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return 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}\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n reflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform 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 vec3 diffuseColor;\n float 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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n #if defined ( LEGACY_LIGHTS )\n if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n #else\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n #endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 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 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_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 vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float 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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_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 material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float specularF90;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = 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 float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float 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 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return saturate(v);\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColor;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return 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 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return 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 vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n return saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n return 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 vec2 fab = DFGApprox( normal, viewDir, roughness );\n return 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 vec2 fab = DFGApprox( normal, viewDir, roughness );\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void 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 vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.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 reflectedLight.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 #ifdef USE_CLEARCOAT\n clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n #endif\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n #endif\n vec3 totalScattering = singleScattering + multiScattering;\n vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n reflectedLight.indirectSpecular += radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return 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;\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n #else\n if ( isPerspectiveMatrix( projectionMatrix ) ) {\n gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\n #endif\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n \n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n #else\n objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n #endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n #else\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n #endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n #else\n transformed += morphTarget0 * morphTargetInfluences[ 0 ];\n transformed += morphTarget1 * morphTargetInfluences[ 1 ];\n transformed += morphTarget2 * morphTargetInfluences[ 2 ];\n transformed += morphTarget3 * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\n #endif\n #endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform 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 return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * PackFactors ), v );\n r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n return packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n return 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 return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n }\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n float occlusion = 1.0;\n vec2 distribution = texture2DDistribution( shadow, uv );\n float hard_shadow = step( compare , distribution.x );\n if (hard_shadow != 1.0 ) {\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n }\n return occlusion;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n float dx2 = dx0 / 2.0;\n float dy2 = dy0 / 2.0;\n float dx3 = dx1 / 2.0;\n float dy3 = dy1 / 2.0;\n shadow = (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 17.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_VSM )\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n #else\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #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 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureSize ) );\n float y = floor( j / float( boneTextureSize ) );\n float dx = 1.0 / float( boneTextureSize );\n float dy = 1.0 / float( boneTextureSize );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_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 return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( 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 vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = 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 #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform 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 #include \n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = 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 #include \n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #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 vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #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 #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying 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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - 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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - 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 varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying 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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #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 varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #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 #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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}",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 #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #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 #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},nE={common:{diffuse:{value:new tC(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Z},alphaMap:{value:null},alphaMapTransform:{value:new Z},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Z}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Z}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Z}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Z},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Z},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Z},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Z}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Z}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Z}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tC(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tC(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Z},alphaTest:{value:0},uvTransform:{value:new Z}},sprite:{diffuse:{value:new tC(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Z},alphaMap:{value:null},alphaMapTransform:{value:new Z},alphaTest:{value:0}}},nT={basic:{uniforms:nr([nE.common,nE.specularmap,nE.envmap,nE.aomap,nE.lightmap,nE.fog]),vertexShader:nS.meshbasic_vert,fragmentShader:nS.meshbasic_frag},lambert:{uniforms:nr([nE.common,nE.specularmap,nE.envmap,nE.aomap,nE.lightmap,nE.emissivemap,nE.bumpmap,nE.normalmap,nE.displacementmap,nE.fog,nE.lights,{emissive:{value:new tC(0)}}]),vertexShader:nS.meshlambert_vert,fragmentShader:nS.meshlambert_frag},phong:{uniforms:nr([nE.common,nE.specularmap,nE.envmap,nE.aomap,nE.lightmap,nE.emissivemap,nE.bumpmap,nE.normalmap,nE.displacementmap,nE.fog,nE.lights,{emissive:{value:new tC(0)},specular:{value:new tC(1118481)},shininess:{value:30}}]),vertexShader:nS.meshphong_vert,fragmentShader:nS.meshphong_frag},standard:{uniforms:nr([nE.common,nE.envmap,nE.aomap,nE.lightmap,nE.emissivemap,nE.bumpmap,nE.normalmap,nE.displacementmap,nE.roughnessmap,nE.metalnessmap,nE.fog,nE.lights,{emissive:{value:new tC(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nS.meshphysical_vert,fragmentShader:nS.meshphysical_frag},toon:{uniforms:nr([nE.common,nE.aomap,nE.lightmap,nE.emissivemap,nE.bumpmap,nE.normalmap,nE.displacementmap,nE.gradientmap,nE.fog,nE.lights,{emissive:{value:new tC(0)}}]),vertexShader:nS.meshtoon_vert,fragmentShader:nS.meshtoon_frag},matcap:{uniforms:nr([nE.common,nE.bumpmap,nE.normalmap,nE.displacementmap,nE.fog,{matcap:{value:null}}]),vertexShader:nS.meshmatcap_vert,fragmentShader:nS.meshmatcap_frag},points:{uniforms:nr([nE.points,nE.fog]),vertexShader:nS.points_vert,fragmentShader:nS.points_frag},dashed:{uniforms:nr([nE.common,nE.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nS.linedashed_vert,fragmentShader:nS.linedashed_frag},depth:{uniforms:nr([nE.common,nE.displacementmap]),vertexShader:nS.depth_vert,fragmentShader:nS.depth_frag},normal:{uniforms:nr([nE.common,nE.bumpmap,nE.normalmap,nE.displacementmap,{opacity:{value:1}}]),vertexShader:nS.meshnormal_vert,fragmentShader:nS.meshnormal_frag},sprite:{uniforms:nr([nE.sprite,nE.fog]),vertexShader:nS.sprite_vert,fragmentShader:nS.sprite_frag},background:{uniforms:{uvTransform:{value:new Z},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:nS.background_vert,fragmentShader:nS.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:nS.backgroundCube_vert,fragmentShader:nS.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:nS.cube_vert,fragmentShader:nS.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nS.equirect_vert,fragmentShader:nS.equirect_frag},distanceRGBA:{uniforms:nr([nE.common,nE.displacementmap,{referencePosition:{value:new ex},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nS.distanceRGBA_vert,fragmentShader:nS.distanceRGBA_frag},shadow:{uniforms:nr([nE.lights,nE.fog,{color:{value:new tC(0)},opacity:{value:1}}]),vertexShader:nS.shadow_vert,fragmentShader:nS.shadow_frag}};nT.physical={uniforms:nr([nT.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Z},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Z},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Z},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Z},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Z},sheen:{value:0},sheenColor:{value:new tC(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Z},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Z},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Z},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Z},attenuationDistance:{value:0},attenuationColor:{value:new tC(0)},specularColor:{value:new tC(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Z},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Z},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Z}}]),vertexShader:nS.meshphysical_vert,fragmentShader:nS.meshphysical_frag};let nw={r:0,b:0,g:0};function nA(e,n,i,r,a,s,o){let u,c;let h=new tC(0),d=!0===s?0:1,p=null,f=0,m=null;function g(n,i){n.getRGB(nw,na(e)),r.buffers.color.setClear(nw.r,nw.g,nw.b,i,o)}return{getClearColor:function(){return h},setClearColor:function(e,n=1){h.set(e),g(h,d=n)},getClearAlpha:function(){return d},setClearAlpha:function(e){g(h,d=e)},render:function(s,v){let _=!1,y=!0===v.isScene?v.background:null;if(y&&y.isTexture){let e=v.backgroundBlurriness>0;y=(e?i:n).get(y)}null===y?g(h,d):y&&y.isColor&&(g(y,1),_=!0);let x=e.xr.getEnvironmentBlendMode();"additive"===x?r.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===x&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||_)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),y&&(y.isCubeTexture||306===y.mapping)?(void 0===c&&((c=new ne(new nn(1,1,1),new no({name:"BackgroundCubeMaterial",uniforms:ni(nT.backgroundCube.uniforms),vertexShader:nT.backgroundCube.vertexShader,fragmentShader:nT.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,n,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&!1===y.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=es.getTransfer(y.colorSpace)!==L,(p!==y||f!==y.version||m!==e.toneMapping)&&(c.material.needsUpdate=!0,p=y,f=y.version,m=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(void 0===u&&((u=new ne(new nM(2,2),new no({name:"BackgroundMaterial",uniforms:ni(nT.background.uniforms),vertexShader:nT.background.vertexShader,fragmentShader:nT.background.fragmentShader,side:l,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(u)),u.material.uniforms.t2D.value=y,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=es.getTransfer(y.colorSpace)!==L,!0===y.matrixAutoUpdate&&y.updateMatrix(),u.material.uniforms.uvTransform.value.copy(y.matrix),(p!==y||f!==y.version||m!==e.toneMapping)&&(u.material.needsUpdate=!0,p=y,f=y.version,m=e.toneMapping),u.layers.enableAll(),s.unshift(u,u.geometry,u.material,0,0,null))}}}function nR(e,n,i,r){let a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:n.get("OES_vertex_array_object"),o=r.isWebGL2||null!==s,l={},u=f(null),c=u,h=!1;function d(n){return r.isWebGL2?e.bindVertexArray(n):s.bindVertexArrayOES(n)}function p(n){return r.isWebGL2?e.deleteVertexArray(n):s.deleteVertexArrayOES(n)}function f(e){let n=[],i=[],r=[];for(let e=0;e=0){let i=a[n],r=s[n];if(void 0===r&&("instanceMatrix"===n&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(r=e.instanceColor)),void 0===i||i.attribute!==r||r&&i.data!==r.data)return!0;o++}}return c.attributesNum!==o||c.index!==r}(a,x,p,b))&&function(e,n,i,r){let a={},s=n.attributes,o=0,l=i.getAttributes();for(let n in l){let i=l[n];if(i.location>=0){let i=s[n];void 0===i&&("instanceMatrix"===n&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(i=e.instanceColor));let r={};r.attribute=i,i&&i.data&&(r.data=i.data),a[n]=r,o++}}c.attributes=a,c.attributesNum=o,c.index=r}(a,x,p,b)}else{let e=!0===u.wireframe;(c.geometry!==x.id||c.program!==p.id||c.wireframe!==e)&&(c.geometry=x.id,c.program=p.id,c.wireframe=e,M=!0)}null!==b&&i.update(b,e.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(a,s,o,l){if(!1===r.isWebGL2&&(a.isInstancedMesh||l.isInstancedBufferGeometry)&&null===n.get("ANGLE_instanced_arrays"))return;m();let u=l.attributes,c=o.getAttributes(),h=s.defaultAttributeValues;for(let n in c){let s=c[n];if(s.location>=0){let o=u[n];if(void 0===o&&("instanceMatrix"===n&&a.instanceMatrix&&(o=a.instanceMatrix),"instanceColor"===n&&a.instanceColor&&(o=a.instanceColor)),void 0!==o){let n=o.normalized,u=o.itemSize,c=i.get(o);if(void 0===c)continue;let h=c.buffer,d=c.type,p=c.bytesPerElement,f=!0===r.isWebGL2&&(d===e.INT||d===e.UNSIGNED_INT||1013===o.gpuType);if(o.isInterleavedBufferAttribute){let i=o.data,r=i.stride,c=o.offset;if(i.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";n="mediump"}return"mediump"===n&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,o=void 0!==i.precision?i.precision:"highp",l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);let u=s||n.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_TEXTURE_SIZE),f=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),_=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=d>0,x=s||n.has("OES_texture_float"),b=s?e.getParameter(e.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===n.has("EXT_texture_filter_anisotropic")){let i=n.get("EXT_texture_filter_anisotropic");r=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:f,maxAttributes:m,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:b}}function nL(e){let n=this,i=null,r=0,a=!1,s=!1,o=new ng,l=new Z,u={value:null,needsUpdate:!1};function c(e,i,r,a){let s=null!==e?e.length:0,c=null;if(0!==s){if(c=u.value,!0!==a||null===c){let n=r+4*s,a=i.matrixWorldInverse;l.getNormalMatrix(a),(null===c||c.length0),n.numPlanes=r,n.numIntersection=0)}}function nO(e){let n=new WeakMap;function i(e,n){return 303===n?e.mapping=301:304===n&&(e.mapping=302),e}function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=n.get(i);void 0!==a&&(n.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture&&!1===a.isRenderTargetTexture){let s=a.mapping;if(303===s||304===s){if(n.has(a)){let e=n.get(a).texture;return i(e,a.mapping)}{let s=a.image;if(!s||!(s.height>0))return null;{let o=new nd(s.height/2);return o.fromEquirectangularTexture(e,a),n.set(a,o),a.addEventListener("dispose",r),i(o.texture,a.mapping)}}}}return a},dispose:function(){n=new WeakMap}}}class nI extends nl{constructor(e=-1,n=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,n,i,r,a,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=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+n,l=r-n;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,n=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=e*this.view.offsetX,s=a+e*this.view.width,o-=n*this.view.offsetY,l=o-n*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,null!==this.view&&(n.object.view=Object.assign({},this.view)),n}}let nD=[.125,.215,.35,.446,.526,.582],nU=new nI,nN=new tC,nF=null,nz=(1+Math.sqrt(5))/2,nB=1/nz,nk=[new ex(1,1,1),new ex(-1,1,1),new ex(1,1,-1),new ex(-1,1,-1),new ex(0,nz,nB),new ex(0,nz,-nB),new ex(nB,0,nz),new ex(-nB,0,nz),new ex(nz,nB,0),new ex(-nz,nB,0)];class nH{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,i=.1,r=100){nF=this._renderer.getRenderTarget(),this._setSize(256);let a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,r,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=nj(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=nW(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=nD[o-e+4-1]:0===o&&(l=0),r.push(l);let u=1/(s-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],p=new Float32Array(108),f=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let n=e%3*2/3-1,i=e>2?0:-1,r=[n,i,0,n+2/3,i,0,n+2/3,i+1,0,n,i,0,n+2/3,i+1,0,n,i+1,0];p.set(r,18*e),f.set(d,12*e);let a=[e,e,e,e,e,e];m.set(a,6*e)}let g=new tX;g.setAttribute("position",new tU(p,3)),g.setAttribute("uv",new tU(f,2)),g.setAttribute("faceIndex",new tU(m,1)),n.push(g),a>4&&a--}return{lodPlanes:n,sizeLods:i,sigmas:r}}(r)),this._blurMaterial=function(e,n,i){let r=new Float32Array(20),a=new ex(0,1,0),s=new no({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/n,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:nX(),fragmentShader:` + `},r=new ni(5,5,5),a=new nl({name:"CubemapFromEquirect",uniforms:nr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});a.uniforms.tEquirect.value=n;let s=new nt(r,a),o=n.minFilter;n.minFilter===y&&(n.minFilter=v);let l=new nh(1,10,this);return l.update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,i,r){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,i,r);e.setRenderTarget(a)}}let nf=new eb,nm=new eb,ng=new K;class nv{constructor(e=new eb(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){let r=nf.subVectors(i,n).cross(nm.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){let i=e.delta(nf),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?n.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:n.copy(e.start).addScaledVector(i,a)}intersectsLine(e){let n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){let i=n||ng.getNormalMatrix(e),r=this.coplanarPoint(nf).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let n_=new eV,ny=new eb;class nx{constructor(e=new nv,n=new nv,i=new nv,r=new nv,a=new nv,s=new nv){this.planes=[e,n,i,r,a,s]}set(e,n,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=2e3){let i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,d-u,g-p,x-v).normalize(),i[1].setComponents(l+a,d+u,g+p,x+v).normalize(),i[2].setComponents(l+s,d+c,g+f,x+_).normalize(),i[3].setComponents(l-s,d-c,g-f,x-_).normalize(),i[4].setComponents(l-o,d-h,g-m,x-y).normalize(),2e3===n)i[5].setComponents(l+o,d+h,g+m,x+y).normalize();else if(2001===n)i[5].setComponents(o,h,m,y).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),n_.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let n=e.geometry;null===n.boundingSphere&&n.computeBoundingSphere(),n_.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(n_)}intersectsSprite(e){return n_.center.set(0,0,0),n_.radius=.7071067811865476,n_.applyMatrix4(e.matrixWorld),this.intersectsSphere(n_)}intersectsSphere(e){let n=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++){let a=n[e].distanceToPoint(i);if(a0?e.max.x:e.min.x,ny.y=r.normal.y>0?e.max.y:e.min.y,ny.z=r.normal.z>0?e.max.z:e.min.z,0>r.distanceToPoint(ny))return!1}return!0}containsPoint(e){let n=this.planes;for(let i=0;i<6;i++)if(0>n[i].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}function nb(){let e=null,n=!1,i=null,r=null;function a(n,s){i(n,s),r=e.requestAnimationFrame(a)}return{start:function(){!0!==n&&null!==i&&(r=e.requestAnimationFrame(a),n=!0)},stop:function(){e.cancelAnimationFrame(r),n=!1},setAnimationLoop:function(e){i=e},setContext:function(n){e=n}}}function nM(e,n){let i=n.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=r.get(n);i&&(e.deleteBuffer(i.buffer),r.delete(n))},update:function(n,a){if(n.isGLBufferAttribute){let e=r.get(n);(!e||e.version 0\n vec4 plane;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.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 const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n mat3 tmp;\n tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n return tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n return dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_v0 0.339\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_v1 0.276\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_v4 0.046\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_v5 0.016\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_v6 0.0038\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n vec3( 0.8224621, 0.177538, 0.0 ),\n vec3( 0.0331941, 0.9668058, 0.0 ),\n vec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n vec3( 1.2249401, - 0.2249404, 0.0 ),\n vec3( - 0.0420569, 1.0420571, 0.0 ),\n vec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return 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}\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n reflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform 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 vec3 diffuseColor;\n float 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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n #if defined ( LEGACY_LIGHTS )\n if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n #else\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n #endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 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 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_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 vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float 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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_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 material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float specularF90;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #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 float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float 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 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return saturate(v);\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColor;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return 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 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return 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 vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n return saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n return 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 vec2 fab = DFGApprox( normal, viewDir, roughness );\n return 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 vec2 fab = DFGApprox( normal, viewDir, roughness );\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void 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 vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\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 float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.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 reflectedLight.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 #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n #endif\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n #endif\n vec3 totalScattering = singleScattering + multiScattering;\n vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n reflectedLight.indirectSpecular += radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return 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 geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n #else\n if ( isPerspectiveMatrix( projectionMatrix ) ) {\n gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\n #endif\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n \n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n #else\n objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n #endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n #else\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n #endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n #ifdef MORPHTARGETS_TEXTURE\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n #else\n transformed += morphTarget0 * morphTargetInfluences[ 0 ];\n transformed += morphTarget1 * morphTargetInfluences[ 1 ];\n transformed += morphTarget2 * morphTargetInfluences[ 2 ];\n transformed += morphTarget3 * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\n #endif\n #endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform 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 return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * PackFactors ), v );\n r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n return packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n return 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 return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n }\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n float occlusion = 1.0;\n vec2 distribution = texture2DDistribution( shadow, uv );\n float hard_shadow = step( compare , distribution.x );\n if (hard_shadow != 1.0 ) {\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n }\n return occlusion;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n float dx2 = dx0 / 2.0;\n float dy2 = dy0 / 2.0;\n float dx3 = dx1 / 2.0;\n float dy3 = dy1 / 2.0;\n shadow = (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 17.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_VSM )\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n #else\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #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 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureSize ) );\n float y = floor( j / float( boneTextureSize ) );\n float dx = 1.0 / float( boneTextureSize );\n float dy = 1.0 / float( boneTextureSize );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_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 return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( 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 vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = 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 #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform 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 #include \n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = 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 #include \n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #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 vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #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 #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying 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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - 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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - 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 varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying 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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #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 \nvoid main() {\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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #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 #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #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 varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #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 #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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}",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 #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #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 #include \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},nT={common:{diffuse:{value:new tP(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new K},alphaMap:{value:null},alphaMapTransform:{value:new K},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new K}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new K}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new K}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new K},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new K},normalScale:{value:new Z(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new K},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new K}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new K}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new K}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tP(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tP(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new K},alphaTest:{value:0},uvTransform:{value:new K}},sprite:{diffuse:{value:new tP(16777215)},opacity:{value:1},center:{value:new Z(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new K},alphaMap:{value:null},alphaMapTransform:{value:new K},alphaTest:{value:0}}},nw={basic:{uniforms:na([nT.common,nT.specularmap,nT.envmap,nT.aomap,nT.lightmap,nT.fog]),vertexShader:nE.meshbasic_vert,fragmentShader:nE.meshbasic_frag},lambert:{uniforms:na([nT.common,nT.specularmap,nT.envmap,nT.aomap,nT.lightmap,nT.emissivemap,nT.bumpmap,nT.normalmap,nT.displacementmap,nT.fog,nT.lights,{emissive:{value:new tP(0)}}]),vertexShader:nE.meshlambert_vert,fragmentShader:nE.meshlambert_frag},phong:{uniforms:na([nT.common,nT.specularmap,nT.envmap,nT.aomap,nT.lightmap,nT.emissivemap,nT.bumpmap,nT.normalmap,nT.displacementmap,nT.fog,nT.lights,{emissive:{value:new tP(0)},specular:{value:new tP(1118481)},shininess:{value:30}}]),vertexShader:nE.meshphong_vert,fragmentShader:nE.meshphong_frag},standard:{uniforms:na([nT.common,nT.envmap,nT.aomap,nT.lightmap,nT.emissivemap,nT.bumpmap,nT.normalmap,nT.displacementmap,nT.roughnessmap,nT.metalnessmap,nT.fog,nT.lights,{emissive:{value:new tP(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nE.meshphysical_vert,fragmentShader:nE.meshphysical_frag},toon:{uniforms:na([nT.common,nT.aomap,nT.lightmap,nT.emissivemap,nT.bumpmap,nT.normalmap,nT.displacementmap,nT.gradientmap,nT.fog,nT.lights,{emissive:{value:new tP(0)}}]),vertexShader:nE.meshtoon_vert,fragmentShader:nE.meshtoon_frag},matcap:{uniforms:na([nT.common,nT.bumpmap,nT.normalmap,nT.displacementmap,nT.fog,{matcap:{value:null}}]),vertexShader:nE.meshmatcap_vert,fragmentShader:nE.meshmatcap_frag},points:{uniforms:na([nT.points,nT.fog]),vertexShader:nE.points_vert,fragmentShader:nE.points_frag},dashed:{uniforms:na([nT.common,nT.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nE.linedashed_vert,fragmentShader:nE.linedashed_frag},depth:{uniforms:na([nT.common,nT.displacementmap]),vertexShader:nE.depth_vert,fragmentShader:nE.depth_frag},normal:{uniforms:na([nT.common,nT.bumpmap,nT.normalmap,nT.displacementmap,{opacity:{value:1}}]),vertexShader:nE.meshnormal_vert,fragmentShader:nE.meshnormal_frag},sprite:{uniforms:na([nT.sprite,nT.fog]),vertexShader:nE.sprite_vert,fragmentShader:nE.sprite_frag},background:{uniforms:{uvTransform:{value:new K},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:nE.background_vert,fragmentShader:nE.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:nE.backgroundCube_vert,fragmentShader:nE.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:nE.cube_vert,fragmentShader:nE.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nE.equirect_vert,fragmentShader:nE.equirect_frag},distanceRGBA:{uniforms:na([nT.common,nT.displacementmap,{referencePosition:{value:new eb},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nE.distanceRGBA_vert,fragmentShader:nE.distanceRGBA_frag},shadow:{uniforms:na([nT.lights,nT.fog,{color:{value:new tP(0)},opacity:{value:1}}]),vertexShader:nE.shadow_vert,fragmentShader:nE.shadow_frag}};nw.physical={uniforms:na([nw.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new K},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new K},clearcoatNormalScale:{value:new Z(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new K},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new K},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new K},sheen:{value:0},sheenColor:{value:new tP(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new K},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new K},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new K},transmissionSamplerSize:{value:new Z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new K},attenuationDistance:{value:0},attenuationColor:{value:new tP(0)},specularColor:{value:new tP(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new K},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new K},anisotropyVector:{value:new Z},anisotropyMap:{value:null},anisotropyMapTransform:{value:new K}}]),vertexShader:nE.meshphysical_vert,fragmentShader:nE.meshphysical_frag};let nA={r:0,b:0,g:0};function nR(e,n,i,r,a,s,o){let u,c;let h=new tP(0),d=!0===s?0:1,p=null,f=0,m=null;function g(n,i){n.getRGB(nA,ns(e)),r.buffers.color.setClear(nA.r,nA.g,nA.b,i,o)}return{getClearColor:function(){return h},setClearColor:function(e,n=1){h.set(e),g(h,d=n)},getClearAlpha:function(){return d},setClearAlpha:function(e){g(h,d=e)},render:function(s,v){let _=!1,y=!0===v.isScene?v.background:null;if(y&&y.isTexture){let e=v.backgroundBlurriness>0;y=(e?i:n).get(y)}null===y?g(h,d):y&&y.isColor&&(g(y,1),_=!0);let x=e.xr.getEnvironmentBlendMode();"additive"===x?r.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===x&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||_)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),y&&(y.isCubeTexture||306===y.mapping)?(void 0===c&&((c=new nt(new ni(1,1,1),new nl({name:"BackgroundCubeMaterial",uniforms:nr(nw.backgroundCube.uniforms),vertexShader:nw.backgroundCube.vertexShader,fragmentShader:nw.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,n,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&!1===y.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=eo.getTransfer(y.colorSpace)!==O,(p!==y||f!==y.version||m!==e.toneMapping)&&(c.material.needsUpdate=!0,p=y,f=y.version,m=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(void 0===u&&((u=new nt(new nS(2,2),new nl({name:"BackgroundMaterial",uniforms:nr(nw.background.uniforms),vertexShader:nw.background.vertexShader,fragmentShader:nw.background.fragmentShader,side:l,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(u)),u.material.uniforms.t2D.value=y,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=eo.getTransfer(y.colorSpace)!==O,!0===y.matrixAutoUpdate&&y.updateMatrix(),u.material.uniforms.uvTransform.value.copy(y.matrix),(p!==y||f!==y.version||m!==e.toneMapping)&&(u.material.needsUpdate=!0,p=y,f=y.version,m=e.toneMapping),u.layers.enableAll(),s.unshift(u,u.geometry,u.material,0,0,null))}}}function nP(e,n,i,r){let a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:n.get("OES_vertex_array_object"),o=r.isWebGL2||null!==s,l={},u=f(null),c=u,h=!1;function d(n){return r.isWebGL2?e.bindVertexArray(n):s.bindVertexArrayOES(n)}function p(n){return r.isWebGL2?e.deleteVertexArray(n):s.deleteVertexArrayOES(n)}function f(e){let n=[],i=[],r=[];for(let e=0;e=0){let i=a[n],r=s[n];if(void 0===r&&("instanceMatrix"===n&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(r=e.instanceColor)),void 0===i||i.attribute!==r||r&&i.data!==r.data)return!0;o++}}return c.attributesNum!==o||c.index!==r}(a,x,p,b))&&function(e,n,i,r){let a={},s=n.attributes,o=0,l=i.getAttributes();for(let n in l){let i=l[n];if(i.location>=0){let i=s[n];void 0===i&&("instanceMatrix"===n&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(i=e.instanceColor));let r={};r.attribute=i,i&&i.data&&(r.data=i.data),a[n]=r,o++}}c.attributes=a,c.attributesNum=o,c.index=r}(a,x,p,b)}else{let e=!0===u.wireframe;(c.geometry!==x.id||c.program!==p.id||c.wireframe!==e)&&(c.geometry=x.id,c.program=p.id,c.wireframe=e,M=!0)}null!==b&&i.update(b,e.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(a,s,o,l){if(!1===r.isWebGL2&&(a.isInstancedMesh||l.isInstancedBufferGeometry)&&null===n.get("ANGLE_instanced_arrays"))return;m();let u=l.attributes,c=o.getAttributes(),h=s.defaultAttributeValues;for(let n in c){let s=c[n];if(s.location>=0){let o=u[n];if(void 0===o&&("instanceMatrix"===n&&a.instanceMatrix&&(o=a.instanceMatrix),"instanceColor"===n&&a.instanceColor&&(o=a.instanceColor)),void 0!==o){let n=o.normalized,u=o.itemSize,c=i.get(o);if(void 0===c)continue;let h=c.buffer,d=c.type,p=c.bytesPerElement,f=!0===r.isWebGL2&&(d===e.INT||d===e.UNSIGNED_INT||1013===o.gpuType);if(o.isInterleavedBufferAttribute){let i=o.data,r=i.stride,c=o.offset;if(i.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";n="mediump"}return"mediump"===n&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,o=void 0!==i.precision?i.precision:"highp",l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);let u=s||n.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_TEXTURE_SIZE),f=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),_=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=d>0,x=s||n.has("OES_texture_float"),b=s?e.getParameter(e.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===n.has("EXT_texture_filter_anisotropic")){let i=n.get("EXT_texture_filter_anisotropic");r=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:f,maxAttributes:m,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:b}}function nO(e){let n=this,i=null,r=0,a=!1,s=!1,o=new nv,l=new K,u={value:null,needsUpdate:!1};function c(e,i,r,a){let s=null!==e?e.length:0,c=null;if(0!==s){if(c=u.value,!0!==a||null===c){let n=r+4*s,a=i.matrixWorldInverse;l.getNormalMatrix(a),(null===c||c.length0),n.numPlanes=r,n.numIntersection=0)}}function nI(e){let n=new WeakMap;function i(e,n){return 303===n?e.mapping=301:304===n&&(e.mapping=302),e}function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=n.get(i);void 0!==a&&(n.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture&&!1===a.isRenderTargetTexture){let s=a.mapping;if(303===s||304===s){if(n.has(a)){let e=n.get(a).texture;return i(e,a.mapping)}{let s=a.image;if(!s||!(s.height>0))return null;{let o=new np(s.height/2);return o.fromEquirectangularTexture(e,a),n.set(a,o),a.addEventListener("dispose",r),i(o.texture,a.mapping)}}}}return a},dispose:function(){n=new WeakMap}}}class nD extends nu{constructor(e=-1,n=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,n,i,r,a,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=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+n,l=r-n;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,n=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=e*this.view.offsetX,s=a+e*this.view.width,o-=n*this.view.offsetY,l=o-n*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,null!==this.view&&(n.object.view=Object.assign({},this.view)),n}}let nU=[.125,.215,.35,.446,.526,.582],nN=new nD,nF=new tP,nz=null,nB=0,nk=0,nH=(1+Math.sqrt(5))/2,nV=1/nH,nG=[new eb(1,1,1),new eb(-1,1,1),new eb(1,1,-1),new eb(-1,1,-1),new eb(0,nH,nV),new eb(0,nH,-nV),new eb(nV,0,nH),new eb(-nV,0,nH),new eb(nH,nV,0),new eb(-nH,nV,0)];class nW{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,i=.1,r=100){nz=this._renderer.getRenderTarget(),nB=this._renderer.getActiveCubeFace(),nk=this._renderer.getActiveMipmapLevel(),this._setSize(256);let a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,r,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=nY(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=nq(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=nU[o-e+4-1]:0===o&&(l=0),r.push(l);let u=1/(s-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],p=new Float32Array(108),f=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let n=e%3*2/3-1,i=e>2?0:-1,r=[n,i,0,n+2/3,i,0,n+2/3,i+1,0,n,i,0,n+2/3,i+1,0,n,i+1,0];p.set(r,18*e),f.set(d,12*e);let a=[e,e,e,e,e,e];m.set(a,6*e)}let g=new tq;g.setAttribute("position",new tN(p,3)),g.setAttribute("uv",new tN(f,2)),g.setAttribute("faceIndex",new tN(m,1)),n.push(g),a>4&&a--}return{lodPlanes:n,sizeLods:i,sigmas:r}}(r)),this._blurMaterial=function(e,n,i){let r=new Float32Array(20),a=new eb(0,1,0),s=new nl({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/n,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:nJ(),fragmentShader:` precision mediump float; precision mediump int; @@ -93,7 +93,7 @@ } } - `,blending:0,depthTest:!1,depthWrite:!1});return s}(r,e,n)}return r}_compileMaterial(e){let n=new ne(this._lodPlanes[0],e);this._renderer.compile(n,nU)}_sceneToCubeUV(e,n,i,r){let a=new nu(90,1,n,i),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,u=l.autoClear,c=l.toneMapping;l.getClearColor(nN),l.toneMapping=0,l.autoClear=!1;let h=new tO({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new ne(new nn,h),p=!1,f=e.background;f?f.isColor&&(h.color.copy(f),e.background=null,p=!0):(h.color.copy(nN),p=!0);for(let n=0;n<6;n++){let i=n%3;0===i?(a.up.set(0,s[n],0),a.lookAt(o[n],0,0)):1===i?(a.up.set(0,0,s[n]),a.lookAt(0,o[n],0)):(a.up.set(0,s[n],0),a.lookAt(0,0,o[n]));let u=this._cubeSize;nG(r,i*u,n>2?u:0,u,u),l.setRenderTarget(r),p&&l.render(d,a),l.render(e,a)}d.geometry.dispose(),d.material.dispose(),l.toneMapping=c,l.autoClear=u,e.background=f}_textureToCubeUV(e,n){let i=this._renderer,r=301===e.mapping||302===e.mapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=nj()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=nW());let a=r?this._cubemapMaterial:this._equirectMaterial,s=new ne(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;let l=this._cubeSize;nG(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,nU)}_applyPMREM(e){let n=this._renderer,i=n.autoClear;n.autoClear=!1;for(let n=1;n20&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let g=[],v=0;for(let e=0;e<20;++e){let n=e/f,i=Math.exp(-n*n/2);g.push(i),0===e?v+=i:e_-4?r-_+4:0),b=4*(this._cubeSize-y);nG(n,x,b,3*y,2*y),l.setRenderTarget(n),l.render(c,nU)}}function nV(e,n,i){let r=new ev(e,n,i);return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function nG(e,n,i,r,a){e.viewport.set(n,i,r,a),e.scissor.set(n,i,r,a)}function nW(){return new no({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nX(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1});return s}(r,e,n)}return r}_compileMaterial(e){let n=new nt(this._lodPlanes[0],e);this._renderer.compile(n,nN)}_sceneToCubeUV(e,n,i,r){let a=new nc(90,1,n,i),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,u=l.autoClear,c=l.toneMapping;l.getClearColor(nF),l.toneMapping=0,l.autoClear=!1;let h=new tI({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new nt(new ni,h),p=!1,f=e.background;f?f.isColor&&(h.color.copy(f),e.background=null,p=!0):(h.color.copy(nF),p=!0);for(let n=0;n<6;n++){let i=n%3;0===i?(a.up.set(0,s[n],0),a.lookAt(o[n],0,0)):1===i?(a.up.set(0,0,s[n]),a.lookAt(0,o[n],0)):(a.up.set(0,s[n],0),a.lookAt(0,0,o[n]));let u=this._cubeSize;nX(r,i*u,n>2?u:0,u,u),l.setRenderTarget(r),p&&l.render(d,a),l.render(e,a)}d.geometry.dispose(),d.material.dispose(),l.toneMapping=c,l.autoClear=u,e.background=f}_textureToCubeUV(e,n){let i=this._renderer,r=301===e.mapping||302===e.mapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=nY()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=nq());let a=r?this._cubemapMaterial:this._equirectMaterial,s=new nt(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;let l=this._cubeSize;nX(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,nN)}_applyPMREM(e){let n=this._renderer,i=n.autoClear;n.autoClear=!1;for(let n=1;n20&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let g=[],v=0;for(let e=0;e<20;++e){let n=e/f,i=Math.exp(-n*n/2);g.push(i),0===e?v+=i:e_-4?r-_+4:0),b=4*(this._cubeSize-y);nX(n,x,b,3*y,2*y),l.setRenderTarget(n),l.render(c,nN)}}function nj(e,n,i){let r=new e_(e,n,i);return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function nX(e,n,i,r,a){e.viewport.set(n,i,r,a),e.scissor.set(n,i,r,a)}function nq(){return new nl({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nJ(),fragmentShader:` precision mediump float; precision mediump int; @@ -112,7 +112,7 @@ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function nj(){return new no({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nX(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function nY(){return new nl({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nJ(),fragmentShader:` precision mediump float; precision mediump int; @@ -128,7 +128,7 @@ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function nX(){return` + `,blending:0,depthTest:!1,depthWrite:!1})}function nJ(){return` precision mediump float; precision mediump int; @@ -183,4 +183,4 @@ gl_Position = vec4( position, 1.0 ); } - `}function nq(e){let n=new WeakMap,i=null;function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=n.get(i);void 0!==a&&(n.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture){let s=a.mapping,o=303===s||304===s,l=301===s||302===s;if(o||l){if(a.isRenderTargetTexture&&!0===a.needsPMREMUpdate){a.needsPMREMUpdate=!1;let r=n.get(a);return null===i&&(i=new nH(e)),r=o?i.fromEquirectangular(a,r):i.fromCubemap(a,r),n.set(a,r),r.texture}if(n.has(a))return n.get(a).texture;{let s=a.image;if(!(o&&s&&s.height>0||l&&s&&function(e){let n=0;for(let i=0;i<6;i++)void 0!==e[i]&&n++;return 6===n}(s)))return null;{null===i&&(i=new nH(e));let s=o?i.fromEquirectangular(a):i.fromCubemap(a);return n.set(a,s),a.addEventListener("dispose",r),s.texture}}}}return a},dispose:function(){n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function nY(e){let n={};function i(i){let r;if(void 0!==n[i])return n[i];switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return n[i]=r,r}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){let n=i(e);return null===n&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),n}}}function nJ(e,n,i,r){let a={},s=new WeakMap;function o(e){let l=e.target;for(let e in null!==l.index&&n.remove(l.index),l.attributes)n.remove(l.attributes[e]);for(let e in l.morphAttributes){let i=l.morphAttributes[e];for(let e=0,r=i.length;en.maxTextureSize&&(m=Math.ceil(f/n.maxTextureSize),f=n.maxTextureSize);let g=new Float32Array(f*m*4*a),v=new e_(g,f,m,a);v.type=1015,v.needsUpdate=!0;let _=4*p;for(let n=0;n0)return e;let a=n*i,s=n6[a];if(void 0===s&&(s=new Float32Array(a),n6[a]=s),0!==n){r.toArray(s,0);for(let r=1,a=0;r!==n;++r)a+=i,e[r].toArray(s,a)}return s}function ii(e,n){if(e.length!==n.length)return!1;for(let i=0,r=e.length;i":" "} ${a}: ${i[e]}`)}return r.join("\n")}(e.getShaderSource(n),r)}}function i0(e){return""!==e}function i1(e,n){let i=n.numSpotLightShadows+n.numSpotLightMaps-n.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,n.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,n.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function i2(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}let i3=/^[ \t]*#include +<([\w\d./]+)>/gm;function i4(e){return e.replace(i3,i6)}let i5=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function i6(e,n){let i=nS[n];if(void 0===i){let e=i5.get(n);if(void 0!==e)i=nS[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,e);else throw Error("Can not resolve #include <"+n+">")}return i4(i)}let i7=/#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 i8(e){return e.replace(i7,i9)}function i9(e,n,i,r){let a="";for(let e=parseInt(n);e0&&(a+="\n"),(s=[x,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b].filter(i0).join("\n")).length>0&&(s+="\n")):(a=[re(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+v:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(i0).join("\n"),s=[x,re(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+g:"",i.envMap?"#define "+v:"",i.envMap?"#define "+_:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?nS.tonemapping_pars_fragment:"",0!==i.toneMapping?function(e,n){let i;switch(n){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",n),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",nS.colorspace_pars_fragment,function(e,n){let i=function(e){let n;let i=es.getPrimaries(es.workingColorSpace),r=es.getPrimaries(e);switch(i===r?n="":"p3"===i&&r===O?n="LinearDisplayP3ToLinearSRGB":i===O&&"p3"===r&&(n="LinearSRGBToLinearDisplayP3"),e){case A:case P:return[n,"LinearTransferOETF"];case w:case R:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[n,"LinearTransferOETF"]}}(n);return`vec4 ${e}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(i0).join("\n")),p=i2(p=i1(p=i4(p),i),i),f=i2(f=i1(f=i4(f),i),i),p=i8(p),f=i8(f),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(S="#version 300 es\n",a="precision mediump sampler2DArray;\n#define attribute in\n#define varying out\n#define texture2D texture\n"+a,s=["#define varying in",i.glslVersion===I?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===I?"":"#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"+s);let E=S+a+p,T=S+s+f,C=iK(h,h.VERTEX_SHADER,E),L=iK(h,h.FRAGMENT_SHADER,T);if(h.attachShader(M,C),h.attachShader(M,L),void 0!==i.index0AttributeName?h.bindAttribLocation(M,0,i.index0AttributeName):!0===i.morphTargets&&h.bindAttribLocation(M,0,"position"),h.linkProgram(M),e.debug.checkShaderErrors){let n=h.getProgramInfoLog(M).trim(),i=h.getShaderInfoLog(C).trim(),r=h.getShaderInfoLog(L).trim(),o=!0,l=!0;if(!1===h.getProgramParameter(M,h.LINK_STATUS)){if(o=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(h,M,C,L);else{let e=iQ(h,C,"vertex"),i=iQ(h,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+h.getError()+" - VALIDATE_STATUS "+h.getProgramParameter(M,h.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+i)}}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):(""===i||""===r)&&(l=!1);l&&(this.diagnostics={runnable:o,programLog:n,vertexShader:{log:i,prefix:a},fragmentShader:{log:r,prefix:s}})}return h.deleteShader(C),h.deleteShader(L),this.getUniforms=function(){return void 0===o&&(o=new iZ(h,M)),o},this.getAttributes=function(){return void 0===l&&(l=function(e,n){let i={},r=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let a=0;a0,J=s.clearcoat>0,Z=s.iridescence>0,K=s.sheen>0,$=s.transmission>0,Q=Y&&!!s.anisotropyMap,ee=J&&!!s.clearcoatMap,et=J&&!!s.clearcoatNormalMap,en=J&&!!s.clearcoatRoughnessMap,ei=Z&&!!s.iridescenceMap,er=Z&&!!s.iridescenceThicknessMap,ea=K&&!!s.sheenColorMap,eo=K&&!!s.sheenRoughnessMap,el=!!s.specularMap,eu=!!s.specularColorMap,ec=!!s.specularIntensityMap,eh=$&&!!s.transmissionMap,ed=$&&!!s.thicknessMap,ep=!!s.gradientMap,ef=!!s.alphaMap,em=s.alphaTest>0,eg=!!s.alphaHash,ev=!!s.extensions,e_=!!T.attributes.uv1,ey=!!T.attributes.uv2,ex=!!T.attributes.uv3,eb=0;s.toneMapped&&(null===U||!0===U.isXRRenderTarget)&&(eb=e.toneMapping);let eM={isWebGL2:d,shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:x,fragmentShader:b,defines:s.defines,customVertexShaderID:M,customFragmentShaderID:S,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:m,instancing:N,instancingColor:N&&null!==y.instanceColor,supportsVertexTextures:f,outputColorSpace:null===U?e.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:A,map:F,matcap:z,envMap:B,envMapMode:B&&R.mapping,envMapCubeUVHeight:P,aoMap:k,lightMap:H,bumpMap:V,normalMap:G,displacementMap:f&&W,emissiveMap:j,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:X,roughnessMap:q,anisotropy:Y,anisotropyMap:Q,clearcoat:J,clearcoatMap:ee,clearcoatNormalMap:et,clearcoatRoughnessMap:en,iridescence:Z,iridescenceMap:ei,iridescenceThicknessMap:er,sheen:K,sheenColorMap:ea,sheenRoughnessMap:eo,specularMap:el,specularColorMap:eu,specularIntensityMap:ec,transmission:$,transmissionMap:eh,thicknessMap:ed,gradientMap:ep,opaque:!1===s.transparent&&1===s.blending,alphaMap:ef,alphaTest:em,alphaHash:eg,combine:s.combine,mapUv:F&&v(s.map.channel),aoMapUv:k&&v(s.aoMap.channel),lightMapUv:H&&v(s.lightMap.channel),bumpMapUv:V&&v(s.bumpMap.channel),normalMapUv:G&&v(s.normalMap.channel),displacementMapUv:W&&v(s.displacementMap.channel),emissiveMapUv:j&&v(s.emissiveMap.channel),metalnessMapUv:X&&v(s.metalnessMap.channel),roughnessMapUv:q&&v(s.roughnessMap.channel),anisotropyMapUv:Q&&v(s.anisotropyMap.channel),clearcoatMapUv:ee&&v(s.clearcoatMap.channel),clearcoatNormalMapUv:et&&v(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:en&&v(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ei&&v(s.iridescenceMap.channel),iridescenceThicknessMapUv:er&&v(s.iridescenceThicknessMap.channel),sheenColorMapUv:ea&&v(s.sheenColorMap.channel),sheenRoughnessMapUv:eo&&v(s.sheenRoughnessMap.channel),specularMapUv:el&&v(s.specularMap.channel),specularColorMapUv:eu&&v(s.specularColorMap.channel),specularIntensityMapUv:ec&&v(s.specularIntensityMap.channel),transmissionMapUv:eh&&v(s.transmissionMap.channel),thicknessMapUv:ed&&v(s.thicknessMap.channel),alphaMapUv:ef&&v(s.alphaMap.channel),vertexTangents:!!T.attributes.tangent&&(G||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!T.attributes.color&&4===T.attributes.color.itemSize,vertexUv1s:e_,vertexUv2s:ey,vertexUv3s:ex,pointsUvs:!0===y.isPoints&&!!T.attributes.uv&&(F||ef),fog:!!E,useFog:!0===s.fog,fogExp2:E&&E.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:p,skinning:!0===y.isSkinnedMesh,morphTargets:void 0!==T.morphAttributes.position,morphNormals:void 0!==T.morphAttributes.normal,morphColors:void 0!==T.morphAttributes.color,morphTargetsCount:I,morphTextureStride:D,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:eb,useLegacyLights:e._useLegacyLights,decodeVideoTexture:F&&!0===s.map.isVideoTexture&&es.getTransfer(s.map.colorSpace)===L,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===u,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:ev&&!0===s.extensions.derivatives,extensionFragDepth:ev&&!0===s.extensions.fragDepth,extensionDrawBuffers:ev&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:ev&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()};return eM},getProgramCacheKey:function(n){let i=[];if(n.shaderID?i.push(n.shaderID):(i.push(n.customVertexShaderID),i.push(n.customFragmentShaderID)),void 0!==n.defines)for(let e in n.defines)i.push(e),i.push(n.defines[e]);return!1===n.isRawShaderMaterial&&(i.push(n.precision),i.push(n.outputColorSpace),i.push(n.envMapMode),i.push(n.envMapCubeUVHeight),i.push(n.mapUv),i.push(n.alphaMapUv),i.push(n.lightMapUv),i.push(n.aoMapUv),i.push(n.bumpMapUv),i.push(n.normalMapUv),i.push(n.displacementMapUv),i.push(n.emissiveMapUv),i.push(n.metalnessMapUv),i.push(n.roughnessMapUv),i.push(n.anisotropyMapUv),i.push(n.clearcoatMapUv),i.push(n.clearcoatNormalMapUv),i.push(n.clearcoatRoughnessMapUv),i.push(n.iridescenceMapUv),i.push(n.iridescenceThicknessMapUv),i.push(n.sheenColorMapUv),i.push(n.sheenRoughnessMapUv),i.push(n.specularMapUv),i.push(n.specularColorMapUv),i.push(n.specularIntensityMapUv),i.push(n.transmissionMapUv),i.push(n.thicknessMapUv),i.push(n.combine),i.push(n.fogExp2),i.push(n.sizeAttenuation),i.push(n.morphTargetsCount),i.push(n.morphAttributeCount),i.push(n.numDirLights),i.push(n.numPointLights),i.push(n.numSpotLights),i.push(n.numSpotLightMaps),i.push(n.numHemiLights),i.push(n.numRectAreaLights),i.push(n.numDirLightShadows),i.push(n.numPointLightShadows),i.push(n.numSpotLightShadows),i.push(n.numSpotLightShadowsWithMaps),i.push(n.numLightProbes),i.push(n.shadowMapType),i.push(n.toneMapping),i.push(n.numClippingPlanes),i.push(n.numClipIntersection),i.push(n.depthPacking),l.disableAll(),n.isWebGL2&&l.enable(0),n.supportsVertexTextures&&l.enable(1),n.instancing&&l.enable(2),n.instancingColor&&l.enable(3),n.matcap&&l.enable(4),n.envMap&&l.enable(5),n.normalMapObjectSpace&&l.enable(6),n.normalMapTangentSpace&&l.enable(7),n.clearcoat&&l.enable(8),n.iridescence&&l.enable(9),n.alphaTest&&l.enable(10),n.vertexColors&&l.enable(11),n.vertexAlphas&&l.enable(12),n.vertexUv1s&&l.enable(13),n.vertexUv2s&&l.enable(14),n.vertexUv3s&&l.enable(15),n.vertexTangents&&l.enable(16),n.anisotropy&&l.enable(17),i.push(l.mask),l.disableAll(),n.fog&&l.enable(0),n.useFog&&l.enable(1),n.flatShading&&l.enable(2),n.logarithmicDepthBuffer&&l.enable(3),n.skinning&&l.enable(4),n.morphTargets&&l.enable(5),n.morphNormals&&l.enable(6),n.morphColors&&l.enable(7),n.premultipliedAlpha&&l.enable(8),n.shadowMapEnabled&&l.enable(9),n.useLegacyLights&&l.enable(10),n.doubleSided&&l.enable(11),n.flipSided&&l.enable(12),n.useDepthPacking&&l.enable(13),n.dithering&&l.enable(14),n.transmission&&l.enable(15),n.sheen&&l.enable(16),n.opaque&&l.enable(17),n.pointsUvs&&l.enable(18),n.decodeVideoTexture&&l.enable(19),i.push(l.mask),i.push(e.outputColorSpace)),i.push(n.customProgramCacheKey),i.join()},getUniforms:function(e){let n;let i=g[e.type];if(i){let e=nT[i];n=ns.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(n,i){let r;for(let e=0,n=h.length;e0?r.push(h):!0===o.transparent?a.push(h):i.push(h)},unshift:function(e,n,o,l,u,c){let h=s(e,n,o,l,u,c);o.transmission>0?r.unshift(h):!0===o.transparent?a.unshift(h):i.unshift(h)},finish:function(){for(let i=n,r=e.length;i1&&i.sort(e||ro),r.length>1&&r.sort(n||rl),a.length>1&&a.sort(n||rl)}}}function rc(){let e=new WeakMap;return{get:function(n,i){let r;let a=e.get(n);return void 0===a?(r=new ru,e.set(n,[r])):i>=a.length?(r=new ru,a.push(r)):r=a[i],r},dispose:function(){e=new WeakMap}}}function rh(){let e={};return{get:function(n){let i;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":i={direction:new ex,color:new tC};break;case"SpotLight":i={position:new ex,direction:new ex,color:new tC,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ex,color:new tC,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ex,skyColor:new tC,groundColor:new tC};break;case"RectAreaLight":i={color:new tC,position:new ex,halfWidth:new ex,halfHeight:new ex}}return e[n.id]=i,i}}}let rd=0;function rp(e,n){return(n.castShadow?2:0)-(e.castShadow?2:0)+(n.map?1:0)-(e.map?1:0)}function rf(e,n){let i=new rh,r=function(){let e={};return{get:function(n){let i;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3}}return e[n.id]=i,i}}}(),a={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 e=0;e<9;e++)a.probe.push(new ex);let s=new ex,o=new eZ,l=new eZ;return{setup:function(s,o){let l=0,u=0,c=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let h=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0,y=0,x=0,b=0;s.sort(rp);let M=!0===o?Math.PI:1;for(let e=0,n=s.length;e0&&(n.isWebGL2?(a.rectAreaLTC1=nE.LTC_FLOAT_1,a.rectAreaLTC2=nE.LTC_FLOAT_2):!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=nE.LTC_FLOAT_1,a.rectAreaLTC2=nE.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(a.rectAreaLTC1=nE.LTC_HALF_1,a.rectAreaLTC2=nE.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),a.ambient[0]=l,a.ambient[1]=u,a.ambient[2]=c;let S=a.hash;(S.directionalLength!==h||S.pointLength!==d||S.spotLength!==p||S.rectAreaLength!==f||S.hemiLength!==m||S.numDirectionalShadows!==g||S.numPointShadows!==v||S.numSpotShadows!==_||S.numSpotMaps!==y||S.numLightProbes!==b)&&(a.directional.length=h,a.spot.length=p,a.rectArea.length=f,a.point.length=d,a.hemi.length=m,a.directionalShadow.length=g,a.directionalShadowMap.length=g,a.pointShadow.length=v,a.pointShadowMap.length=v,a.spotShadow.length=_,a.spotShadowMap.length=_,a.directionalShadowMatrix.length=g,a.pointShadowMatrix.length=v,a.spotLightMatrix.length=_+y-x,a.spotLightMap.length=y,a.numSpotLightShadowsWithMaps=x,a.numLightProbes=b,S.directionalLength=h,S.pointLength=d,S.spotLength=p,S.rectAreaLength=f,S.hemiLength=m,S.numDirectionalShadows=g,S.numPointShadows=v,S.numSpotShadows=_,S.numSpotMaps=y,S.numLightProbes=b,a.version=rd++)},setupView:function(e,n){let i=0,r=0,u=0,c=0,h=0,d=n.matrixWorldInverse;for(let n=0,p=e.length;n=o.length?(s=new rm(e,n),o.push(s)):s=o[a],s},dispose:function(){i=new WeakMap}}}class rv extends tT{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class r_ extends tT{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function ry(e,n,i){let r=new ny,a=new J,s=new J,o=new em,c=new rv({depthPacking:3201}),h=new r_,d={},f=i.maxTextureSize,m={[l]:1,1:l,[u]:u},g=new no({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),v=g.clone();v.defines.HORIZONTAL_PASS=1;let _=new tX;_.setAttribute("position",new tU(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new ne(_,g),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let b=this.type;function M(n,i,r,a){let s=null,o=!0===r.isPointLight?n.customDistanceMaterial:n.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===r.isPointLight?h:c,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){let e=s.uuid,n=i.uuid,r=d[e];void 0===r&&(r={},d[e]=r);let a=r[n];void 0===a&&(a=s.clone(),r[n]=a),s=a}if(s.visible=i.visible,s.wireframe=i.wireframe,3===a?s.side=null!==i.shadowSide?i.shadowSide:i.side:s.side=null!==i.shadowSide?i.shadowSide:m[i.side],s.alphaMap=i.alphaMap,s.alphaTest=i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===r.isPointLight&&!0===s.isMeshDistanceMaterial){let n=e.properties.get(s);n.light=r}return s}this.render=function(i,l,u){if(!1===x.enabled||!1===x.autoUpdate&&!1===x.needsUpdate||0===i.length)return;let c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),m=e.state;m.setBlending(0),m.buffers.color.setClear(1,1,1,1),m.buffers.depth.setTest(!0),m.setScissorTest(!1);let _=3!==b&&3===this.type,S=3===b&&3!==this.type;for(let c=0,h=i.length;cf||a.y>f)&&(a.x>f&&(s.x=Math.floor(f/x.x),a.x=s.x*x.x,d.mapSize.x=s.x),a.y>f&&(s.y=Math.floor(f/x.y),a.y=s.y*x.y,d.mapSize.y=s.y)),null===d.map||!0===_||!0===S){let e=3!==this.type?{minFilter:p,magFilter:p}:{};null!==d.map&&d.map.dispose(),d.map=new ev(a.x,a.y,e),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let b=d.getViewportCount();for(let i=0;i=1:-1!==O.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(O)[1])>=2);let I=null,D={},U=e.getParameter(e.SCISSOR_BOX),N=e.getParameter(e.VIEWPORT),F=new em().fromArray(U),z=new em().fromArray(N);function B(n,i,a,s){let o=new Uint8Array(4),l=e.createTexture();e.bindTexture(n,l),e.texParameteri(n,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(n,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;lr||e.height>r)&&(a=r/Math.max(e.width,e.height)),a<1||!0===n){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let r=n?j:Math.floor,s=r(a*e.width),o=r(a*e.height);void 0===l&&(l=I(s,o));let u=i?I(s,o):l;u.width=s,u.height=o;let c=u.getContext("2d");return c.drawImage(e,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+o+")."),u}"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+").")}return e}function U(e){return G(e.width)&&G(e.height)}function N(e,n){return e.generateMipmaps&&n&&e.minFilter!==p&&e.minFilter!==g}function F(n){e.generateMipmap(n)}function z(i,r,a,s,o=!1){if(!1===u)return r;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=r;if(r===e.RED&&(a===e.FLOAT&&(l=e.R32F),a===e.HALF_FLOAT&&(l=e.R16F),a===e.UNSIGNED_BYTE&&(l=e.R8)),r===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.R8UI),a===e.UNSIGNED_SHORT&&(l=e.R16UI),a===e.UNSIGNED_INT&&(l=e.R32UI),a===e.BYTE&&(l=e.R8I),a===e.SHORT&&(l=e.R16I),a===e.INT&&(l=e.R32I)),r===e.RG&&(a===e.FLOAT&&(l=e.RG32F),a===e.HALF_FLOAT&&(l=e.RG16F),a===e.UNSIGNED_BYTE&&(l=e.RG8)),r===e.RGBA){let n=o?C:es.getTransfer(s);a===e.FLOAT&&(l=e.RGBA32F),a===e.HALF_FLOAT&&(l=e.RGBA16F),a===e.UNSIGNED_BYTE&&(l=n===L?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&n.get("EXT_color_buffer_float"),l}function B(e,n,i){return!0===N(e,i)||e.isFramebufferTexture&&e.minFilter!==p&&e.minFilter!==g?Math.log2(Math.max(n.width,n.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?n.mipmaps.length:1}function k(n){return n===p||n===f||n===m?e.NEAREST:e.LINEAR}function H(e){let n=e.target;n.removeEventListener("dispose",H),function(e){let n=r.get(e);if(void 0===n.__webglInit)return;let i=e.source,a=P.get(i);if(a){let r=a[n.__cacheKey];r.usedTimes--,0===r.usedTimes&&W(e),0===Object.keys(a).length&&P.delete(i)}r.remove(e)}(n),n.isVideoTexture&&R.delete(n)}function V(n){let i=n.target;i.removeEventListener("dispose",V),function(n){let i=n.texture,a=r.get(n),s=r.get(i);if(void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),o.memory.textures--),n.depthTexture&&n.depthTexture.dispose(),n.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(a.__webglFramebuffer[n]))for(let i=0;i0&&s.__version!==n.version){let e=n.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ee(s,n,a);return}}i.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+a)}let Y={[c]:e.REPEAT,[h]:e.CLAMP_TO_EDGE,[d]:e.MIRRORED_REPEAT},J={[p]:e.NEAREST,[f]:e.NEAREST_MIPMAP_NEAREST,[m]:e.NEAREST_MIPMAP_LINEAR,[g]:e.LINEAR,[v]:e.LINEAR_MIPMAP_NEAREST,[_]:e.LINEAR_MIPMAP_LINEAR},Z={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function K(i,s,o){if(o?(e.texParameteri(i,e.TEXTURE_WRAP_S,Y[s.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,Y[s.wrapT]),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,Y[s.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,J[s.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,J[s.minFilter])):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(s.wrapS!==h||s.wrapT!==h)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,e.TEXTURE_MAG_FILTER,k(s.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,k(s.minFilter)),s.minFilter!==p&&s.minFilter!==g&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(i,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(i,e.TEXTURE_COMPARE_FUNC,Z[s.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")){let o=n.get("EXT_texture_filter_anisotropic");s.magFilter!==p&&(s.minFilter===m||s.minFilter===_)&&(1015!==s.type||!1!==n.has("OES_texture_float_linear"))&&(!1!==u||1016!==s.type||!1!==n.has("OES_texture_half_float_linear"))&&(s.anisotropy>1||r.get(s).__currentAnisotropy)&&(e.texParameterf(i,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,a.getMaxAnisotropy())),r.get(s).__currentAnisotropy=s.anisotropy)}}function $(n,i){let r=!1;void 0===n.__webglInit&&(n.__webglInit=!0,i.addEventListener("dispose",H));let a=i.source,s=P.get(a);void 0===s&&(s={},P.set(a,s));let l=function(e){let n=[];return n.push(e.wrapS),n.push(e.wrapT),n.push(e.wrapR||0),n.push(e.magFilter),n.push(e.minFilter),n.push(e.anisotropy),n.push(e.internalFormat),n.push(e.format),n.push(e.type),n.push(e.generateMipmaps),n.push(e.premultiplyAlpha),n.push(e.flipY),n.push(e.unpackAlignment),n.push(e.colorSpace),n.join()}(i);if(l!==n.__cacheKey){void 0===s[l]&&(s[l]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),s[l].usedTimes++;let a=s[n.__cacheKey];void 0!==a&&(s[n.__cacheKey].usedTimes--,0===a.usedTimes&&W(i)),n.__cacheKey=l,n.__webglTexture=s[l].texture}return r}function ee(n,a,o){let l=e.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=e.TEXTURE_3D);let c=$(n,a),d=a.source;i.bindTexture(l,n.__webglTexture,e.TEXTURE0+o);let f=r.get(d);if(d.version!==f.__version||!0===c){let n;i.activeTexture(e.TEXTURE0+o);let r=es.getPrimaries(es.workingColorSpace),m=a.colorSpace===T?null:es.getPrimaries(a.colorSpace),v=a.colorSpace===T||r===m?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,v);let _=!u&&(a.wrapS!==h||a.wrapT!==h||a.minFilter!==p&&a.minFilter!==g)&&!1===U(a.image),x=D(a.image,_,!1,M);x=eo(a,x);let b=U(x)||u,S=s.convert(a.format,a.colorSpace),E=s.convert(a.type),w=z(a.internalFormat,S,E,a.colorSpace,a.isVideoTexture);K(l,a,b);let A=a.mipmaps,R=u&&!0!==a.isVideoTexture,P=void 0===f.__version||!0===c,C=B(a,x,b);if(a.isDepthTexture)w=e.DEPTH_COMPONENT,u?w=1015===a.type?e.DEPTH_COMPONENT32F:1014===a.type?e.DEPTH_COMPONENT24:1020===a.type?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:1015===a.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===a.format&&w===e.DEPTH_COMPONENT&&1012!==a.type&&1014!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),a.type=1014,E=s.convert(a.type)),1027===a.format&&w===e.DEPTH_COMPONENT&&(w=e.DEPTH_STENCIL,1020!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),a.type=1020,E=s.convert(a.type))),P&&(R?i.texStorage2D(e.TEXTURE_2D,1,w,x.width,x.height):i.texImage2D(e.TEXTURE_2D,0,w,x.width,x.height,0,S,E,null));else if(a.isDataTexture){if(A.length>0&&b){R&&P&&i.texStorage2D(e.TEXTURE_2D,C,w,A[0].width,A[0].height);for(let r=0,a=A.length;r>=1,r>>=1}}}else if(A.length>0&&b){R&&P&&i.texStorage2D(e.TEXTURE_2D,C,w,A[0].width,A[0].height);for(let r=0,a=A.length;r>c),r=Math.max(1,a.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?i.texImage3D(u,c,p,n,r,a.depth,0,h,d,null):i.texImage2D(u,c,p,n,r,0,h,d,null)}i.bindFramebuffer(e.FRAMEBUFFER,n),ea(a)?E.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,r.get(o).__webglTexture,0,er(a)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,r.get(o).__webglTexture,c),i.bindFramebuffer(e.FRAMEBUFFER,null)}function en(n,i,r){if(e.bindRenderbuffer(e.RENDERBUFFER,n),i.depthBuffer&&!i.stencilBuffer){let a=!0===u?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(r||ea(i)){let n=i.depthTexture;n&&n.isDepthTexture&&(1015===n.type?a=e.DEPTH_COMPONENT32F:1014===n.type&&(a=e.DEPTH_COMPONENT24));let r=er(i);ea(i)?E.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,a,i.width,i.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,a,i.width,i.height)}else e.renderbufferStorage(e.RENDERBUFFER,a,i.width,i.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n)}else if(i.depthBuffer&&i.stencilBuffer){let a=er(i);r&&!1===ea(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,a,e.DEPTH24_STENCIL8,i.width,i.height):ea(i)?E.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,a,e.DEPTH24_STENCIL8,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n)}else{let n=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let a=0;a0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function eo(e,i){let r=e.colorSpace,a=e.format,s=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||1035===e.format||r!==A&&r!==T&&(es.getTransfer(r)===L?!1===u?!0===n.has("EXT_sRGB")&&a===y?(e.format=1035,e.minFilter=g,e.generateMipmaps=!1):i=eu.sRGBToLinear(i):(a!==y||1009!==s)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",r)),i}this.allocateTextureUnit=function(){let e=X;return e>=x&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+x),X+=1,e},this.resetTextureUnits=function(){X=0},this.setTexture2D=q,this.setTexture2DArray=function(n,a){let s=r.get(n);if(n.version>0&&s.__version!==n.version){ee(s,n,a);return}i.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+a)},this.setTexture3D=function(n,a){let s=r.get(n);if(n.version>0&&s.__version!==n.version){ee(s,n,a);return}i.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(n,a){let o=r.get(n);if(n.version>0&&o.__version!==n.version){(function(n,a,o){if(6!==a.image.length)return;let l=$(n,a),c=a.source;i.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture,e.TEXTURE0+o);let h=r.get(c);if(c.version!==h.__version||!0===l){let n;i.activeTexture(e.TEXTURE0+o);let r=es.getPrimaries(es.workingColorSpace),d=a.colorSpace===T?null:es.getPrimaries(a.colorSpace),p=a.colorSpace===T||r===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let f=a.isCompressedTexture||a.image[0].isCompressedTexture,m=a.image[0]&&a.image[0].isDataTexture,g=[];for(let e=0;e<6;e++)f||m?g[e]=m?a.image[e].image:a.image[e]:g[e]=D(a.image[e],!1,!0,b),g[e]=eo(a,g[e]);let v=g[0],_=U(v)||u,x=s.convert(a.format,a.colorSpace),M=s.convert(a.type),S=z(a.internalFormat,x,M,a.colorSpace),E=u&&!0!==a.isVideoTexture,w=void 0===h.__version||!0===l,A=B(a,v,_);if(K(e.TEXTURE_CUBE_MAP,a,_),f){E&&w&&i.texStorage2D(e.TEXTURE_CUBE_MAP,A,S,v.width,v.height);for(let r=0;r<6;r++){n=g[r].mipmaps;for(let s=0;s0&&A++,i.texStorage2D(e.TEXTURE_CUBE_MAP,A,S,g[0].width,g[0].height));for(let r=0;r<6;r++)if(m){E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,0,0,g[r].width,g[r].height,x,M,g[r].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,S,g[r].width,g[r].height,0,x,M,g[r].data);for(let a=0;a0){c.__webglFramebuffer[n]=[];for(let i=0;i0){c.__webglFramebuffer=[];for(let n=0;n0&&!1===ea(n)){let r=p?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let i=0;i0)for(let r=0;r0)for(let i=0;i0&&!1===ea(n)){let a=n.isWebGLMultipleRenderTargets?n.texture:[n.texture],s=n.width,o=n.height,l=e.COLOR_BUFFER_BIT,u=[],c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=r.get(n),d=!0===n.isWebGLMultipleRenderTargets;if(d)for(let n=0;n.025?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&o<=.015&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==l&&e.gripSpace&&null!==(a=n.getPose(e.gripSpace,i))&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1);null!==o&&(null===(r=n.getPose(e.targetRaySpace,i))&&null!==a&&(r=a),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,this.dispatchEvent(rT)))}return null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),null!==u&&(u.visible=null!==s),this}_getHandJoint(e,n){if(void 0===e.joints[n.jointName]){let i=new rE;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}class rA extends ef{constructor(e,n,i,r,a,s,o,l,u,c){if(1026!==(c=void 0!==c?c:1026)&&1027!==c)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&1026===c&&(i=1014),void 0===i&&1027===c&&(i=1020),super(null,r,a,s,o,l,c,i,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=void 0!==o?o:p,this.minFilter=void 0!==l?l:p,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let n=super.toJSON(e);return null!==this.compareFunction&&(n.compareFunction=this.compareFunction),n}}class rR extends D{constructor(e,n){super();let i=this,r=null,a=1,s=null,o="local-floor",l=1,u=null,c=null,h=null,d=null,p=null,f=null,m=n.getContextAttributes(),g=null,v=null,_=[],x=[],b=new nu;b.layers.enable(1),b.viewport=new em;let M=new nu;M.layers.enable(2),M.viewport=new em;let S=[b,M],E=new rS;E.layers.enable(1),E.layers.enable(2);let T=null,w=null;function A(e){let n=x.indexOf(e.inputSource);if(-1===n)return;let i=_[n];void 0!==i&&(i.update(e.inputSource,e.frame,u||s),i.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){r.removeEventListener("select",A),r.removeEventListener("selectstart",A),r.removeEventListener("selectend",A),r.removeEventListener("squeeze",A),r.removeEventListener("squeezestart",A),r.removeEventListener("squeezeend",A),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",P);for(let e=0;e<_.length;e++){let n=x[e];null!==n&&(x[e]=null,_[e].disconnect(n))}T=null,w=null,e.setRenderTarget(g),p=null,d=null,h=null,r=null,v=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function P(e){for(let n=0;n=0&&(x[r]=null,_[r].disconnect(i))}for(let n=0;n=x.length){x.push(i),r=e;break}if(null===x[e]){x[e]=i,r=e;break}}if(-1===r)break}let a=_[r];a&&a.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let n=_[e];return void 0===n&&(n=new rw,_[e]=n),n.getTargetRaySpace()},this.getControllerGrip=function(e){let n=_[e];return void 0===n&&(n=new rw,_[e]=n),n.getGripSpace()},this.getHand=function(e){let n=_[e];return void 0===n&&(n=new rw,_[e]=n),n.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(e){u=e},this.getBaseLayer=function(){return null!==d?d:p},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(c){if(null!==(r=c)){if(g=e.getRenderTarget(),r.addEventListener("select",A),r.addEventListener("selectstart",A),r.addEventListener("selectend",A),r.addEventListener("squeeze",A),r.addEventListener("squeezestart",A),r.addEventListener("squeezeend",A),r.addEventListener("end",R),r.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await n.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){let i={antialias:void 0!==r.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(r,n,i),r.updateRenderState({baseLayer:p}),v=new ev(p.framebufferWidth,p.framebufferHeight,{format:y,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let i=null,s=null,o=null;m.depth&&(o=m.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,i=m.stencil?1027:1026,s=m.stencil?1020:1014);let l={colorFormat:n.RGBA8,depthFormat:o,scaleFactor:a};d=(h=new XRWebGLBinding(r,n)).createProjectionLayer(l),r.updateRenderState({layers:[d]}),v=new ev(d.textureWidth,d.textureHeight,{format:y,type:1009,depthTexture:new rA(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let u=e.properties.get(v);u.__ignoreDepthValues=d.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(l),u=null,s=await r.requestReferenceSpace(o),D.setContext(r),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode};let C=new ex,L=new ex;function O(e,n){null===n?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(n.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;E.near=M.near=b.near=e.near,E.far=M.far=b.far=e.far,(T!==E.near||w!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,w=E.far);let n=e.parent,i=E.cameras;O(E,n);for(let e=0;e0&&(r.alphaTest.value=a.alphaTest);let s=n.get(a).envMap;if(s&&(r.envMap.value=s,r.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,r.reflectivity.value=a.reflectivity,r.ior.value=a.ior,r.refractionRatio.value=a.refractionRatio),a.lightMap){r.lightMap.value=a.lightMap;let n=!0===e._useLegacyLights?Math.PI:1;r.lightMapIntensity.value=a.lightMapIntensity*n,i(a.lightMap,r.lightMapTransform)}a.aoMap&&(r.aoMap.value=a.aoMap,r.aoMapIntensity.value=a.aoMapIntensity,i(a.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(n,i){i.color.getRGB(n.fogColor.value,na(e)),i.isFog?(n.fogNear.value=i.near,n.fogFar.value=i.far):i.isFogExp2&&(n.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,a,s,o,l){a.isMeshBasicMaterial?r(e,a):a.isMeshLambertMaterial?r(e,a):a.isMeshToonMaterial?(r(e,a),a.gradientMap&&(e.gradientMap.value=a.gradientMap)):a.isMeshPhongMaterial?(r(e,a),e.specular.value.copy(a.specular),e.shininess.value=Math.max(a.shininess,1e-4)):a.isMeshStandardMaterial?(r(e,a),function(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,i(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,i(r.roughnessMap,e.roughnessMapTransform));let a=n.get(r).envMap;a&&(e.envMapIntensity.value=r.envMapIntensity)}(e,a),a.isMeshPhysicalMaterial&&(e.ior.value=a.ior,a.sheen>0&&(e.sheenColor.value.copy(a.sheenColor).multiplyScalar(a.sheen),e.sheenRoughness.value=a.sheenRoughness,a.sheenColorMap&&(e.sheenColorMap.value=a.sheenColorMap,i(a.sheenColorMap,e.sheenColorMapTransform)),a.sheenRoughnessMap&&(e.sheenRoughnessMap.value=a.sheenRoughnessMap,i(a.sheenRoughnessMap,e.sheenRoughnessMapTransform))),a.clearcoat>0&&(e.clearcoat.value=a.clearcoat,e.clearcoatRoughness.value=a.clearcoatRoughness,a.clearcoatMap&&(e.clearcoatMap.value=a.clearcoatMap,i(a.clearcoatMap,e.clearcoatMapTransform)),a.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=a.clearcoatRoughnessMap,i(a.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),a.clearcoatNormalMap&&(e.clearcoatNormalMap.value=a.clearcoatNormalMap,i(a.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(a.clearcoatNormalScale),1===a.side&&e.clearcoatNormalScale.value.negate())),a.iridescence>0&&(e.iridescence.value=a.iridescence,e.iridescenceIOR.value=a.iridescenceIOR,e.iridescenceThicknessMinimum.value=a.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=a.iridescenceThicknessRange[1],a.iridescenceMap&&(e.iridescenceMap.value=a.iridescenceMap,i(a.iridescenceMap,e.iridescenceMapTransform)),a.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=a.iridescenceThicknessMap,i(a.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),a.transmission>0&&(e.transmission.value=a.transmission,e.transmissionSamplerMap.value=l.texture,e.transmissionSamplerSize.value.set(l.width,l.height),a.transmissionMap&&(e.transmissionMap.value=a.transmissionMap,i(a.transmissionMap,e.transmissionMapTransform)),e.thickness.value=a.thickness,a.thicknessMap&&(e.thicknessMap.value=a.thicknessMap,i(a.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=a.attenuationDistance,e.attenuationColor.value.copy(a.attenuationColor)),a.anisotropy>0&&(e.anisotropyVector.value.set(a.anisotropy*Math.cos(a.anisotropyRotation),a.anisotropy*Math.sin(a.anisotropyRotation)),a.anisotropyMap&&(e.anisotropyMap.value=a.anisotropyMap,i(a.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=a.specularIntensity,e.specularColor.value.copy(a.specularColor),a.specularColorMap&&(e.specularColorMap.value=a.specularColorMap,i(a.specularColorMap,e.specularColorMapTransform)),a.specularIntensityMap&&(e.specularIntensityMap.value=a.specularIntensityMap,i(a.specularIntensityMap,e.specularIntensityMapTransform)))):a.isMeshMatcapMaterial?(r(e,a),a.matcap&&(e.matcap.value=a.matcap)):a.isMeshDepthMaterial?r(e,a):a.isMeshDistanceMaterial?(r(e,a),function(e,i){let r=n.get(i).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,a)):a.isMeshNormalMaterial?r(e,a):a.isLineBasicMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,a.map&&(e.map.value=a.map,i(a.map,e.mapTransform)),a.isLineDashedMaterial&&(e.dashSize.value=a.dashSize,e.totalSize.value=a.dashSize+a.gapSize,e.scale.value=a.scale)):a.isPointsMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,e.size.value=a.size*s,e.scale.value=.5*o,a.map&&(e.map.value=a.map,i(a.map,e.uvTransform)),a.alphaMap&&(e.alphaMap.value=a.alphaMap,i(a.alphaMap,e.alphaMapTransform)),a.alphaTest>0&&(e.alphaTest.value=a.alphaTest)):a.isSpriteMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,e.rotation.value=a.rotation,a.map&&(e.map.value=a.map,i(a.map,e.mapTransform)),a.alphaMap&&(e.alphaMap.value=a.alphaMap,i(a.alphaMap,e.alphaMapTransform)),a.alphaTest>0&&(e.alphaTest.value=a.alphaTest)):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}function rC(e,n,i,r){let a={},s={},o=[],l=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(e){let n={boundary:0,storage:0};return"number"==typeof e?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=48,n.storage=48):e.isMatrix4?(n.boundary=64,n.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),n}function c(n){let i=n.target;i.removeEventListener("dispose",c);let r=o.indexOf(i.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(a[i.id]),delete a[i.id],delete s[i.id]}return{bind:function(e,n){let i=n.program;r.uniformBlockBinding(e,i)},update:function(i,h){let d=a[i.id];void 0===d&&(function(e){let n=e.uniforms,i=0,r=0;for(let e=0,a=n.length;e0){r=i%16;let e=16-r;0!==r&&e-s.boundary<0&&(i+=16-r,a.__offset=i)}i+=s.storage}(r=i%16)>0&&(i+=16-r),e.__size=i,e.__cache={}}(i),d=function(n){let i=function(){for(let e=0;el.matrixWorld.determinant(),_=function(e,n,i,s,l){var u;!0!==n.isScene&&(n=eR),c.resetTextureUnits();let p=n.fog,f=s.isMeshStandardMaterial?n.environment:null,m=null===en?K.outputColorSpace:!0===en.isXRRenderTarget?en.texture.colorSpace:A,g=(s.isMeshStandardMaterial?d:h).get(s.envMap||f),_=!0===s.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,y=!!i.attributes.tangent&&(!!s.normalMap||s.anisotropy>0),x=!!i.morphAttributes.position,b=!!i.morphAttributes.normal,S=!!i.morphAttributes.color,E=0;s.toneMapped&&(null===en||!0===en.isXRRenderTarget)&&(E=K.toneMapping);let w=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,R=void 0!==w?w.length:0,P=o.get(s),C=q.state.lights;if(!0===eM&&(!0===eS||e!==er)){let n=e===er&&s.id===ei;M.setState(s,e,n)}let L=!1;s.version===P.__version?P.needsLights&&P.lightsStateVersion!==C.state.version?L=!0:P.outputColorSpace!==m?L=!0:l.isInstancedMesh&&!1===P.instancing?L=!0:l.isInstancedMesh||!0!==P.instancing?l.isSkinnedMesh&&!1===P.skinning?L=!0:l.isSkinnedMesh||!0!==P.skinning?l.isInstancedMesh&&!0===P.instancingColor&&null===l.instanceColor?L=!0:l.isInstancedMesh&&!1===P.instancingColor&&null!==l.instanceColor?L=!0:P.envMap!==g?L=!0:!0===s.fog&&P.fog!==p?L=!0:void 0!==P.numClippingPlanes&&(P.numClippingPlanes!==M.numPlanes||P.numIntersection!==M.numIntersection)?L=!0:P.vertexAlphas!==_?L=!0:P.vertexTangents!==y?L=!0:P.morphTargets!==x?L=!0:P.morphNormals!==b?L=!0:P.morphColors!==S?L=!0:P.toneMapping!==E?L=!0:!0===r.isWebGL2&&P.morphTargetsCount!==R&&(L=!0):L=!0:L=!0:(L=!0,P.__version=s.version);let I=P.currentProgram;!0===L&&(I=ej(s,n,l));let D=!1,U=!1,N=!1,F=I.getUniforms(),z=P.uniforms;if(a.useProgram(I.program)&&(D=!0,U=!0,N=!0),s.id!==ei&&(ei=s.id,U=!0),D||er!==e){F.setValue(eC,"projectionMatrix",e.projectionMatrix),F.setValue(eC,"viewMatrix",e.matrixWorldInverse);let n=F.map.cameraPosition;void 0!==n&&n.setValue(eC,eA.setFromMatrixPosition(e.matrixWorld)),r.logarithmicDepthBuffer&&F.setValue(eC,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(s.isMeshPhongMaterial||s.isMeshToonMaterial||s.isMeshLambertMaterial||s.isMeshBasicMaterial||s.isMeshStandardMaterial||s.isShaderMaterial)&&F.setValue(eC,"isOrthographic",!0===e.isOrthographicCamera),er!==e&&(er=e,U=!0,N=!0)}if(l.isSkinnedMesh){F.setOptional(eC,l,"bindMatrix"),F.setOptional(eC,l,"bindMatrixInverse");let e=l.skeleton;e&&(r.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),F.setValue(eC,"boneTexture",e.boneTexture,c),F.setValue(eC,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let B=i.morphAttributes;if((void 0!==B.position||void 0!==B.normal||void 0!==B.color&&!0===r.isWebGL2)&&T.update(l,i,I),(U||P.receiveShadow!==l.receiveShadow)&&(P.receiveShadow=l.receiveShadow,F.setValue(eC,"receiveShadow",l.receiveShadow)),s.isMeshGouraudMaterial&&null!==s.envMap&&(z.envMap.value=g,z.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1),U&&(F.setValue(eC,"toneMappingExposure",K.toneMappingExposure),P.needsLights&&(u=N,z.ambientLightColor.needsUpdate=u,z.lightProbe.needsUpdate=u,z.directionalLights.needsUpdate=u,z.directionalLightShadows.needsUpdate=u,z.pointLights.needsUpdate=u,z.pointLightShadows.needsUpdate=u,z.spotLights.needsUpdate=u,z.spotLightShadows.needsUpdate=u,z.rectAreaLights.needsUpdate=u,z.hemisphereLights.needsUpdate=u),p&&!0===s.fog&&v.refreshFogUniforms(z,p),v.refreshMaterialUniforms(z,s,ed,eh,eE),iZ.upload(eC,P.uniformsList,z,c)),s.isShaderMaterial&&!0===s.uniformsNeedUpdate&&(iZ.upload(eC,P.uniformsList,z,c),s.uniformsNeedUpdate=!1),s.isSpriteMaterial&&F.setValue(eC,"center",l.center),F.setValue(eC,"modelViewMatrix",l.modelViewMatrix),F.setValue(eC,"normalMatrix",l.normalMatrix),F.setValue(eC,"modelMatrix",l.matrixWorld),s.isShaderMaterial||s.isRawShaderMaterial){let e=s.uniformsGroups;for(let n=0,i=e.length;n0&&function(e,n,a,s){let o=r.isWebGL2;null===eE&&(eE=new ev(1,1,{generateMipmaps:!0,type:i.has("EXT_color_buffer_half_float")?1016:1009,minFilter:_,samples:o?4:0})),K.getDrawingBufferSize(ew),o?eE.setSize(ew.x,ew.y):eE.setSize(j(ew.x),j(ew.y));let l=K.getRenderTarget();K.setRenderTarget(eE),K.getClearColor(el),(eu=K.getClearAlpha())<1&&K.setClearColor(16777215,.5),K.clear();let h=K.toneMapping;K.toneMapping=0,eG(e,a,s),c.updateMultisampleRenderTarget(eE),c.updateRenderTargetMipmap(eE);let d=!1;for(let e=0,i=n.length;e0&&eG(l,n,s),h.length>0&&eG(h,n,s),d.length>0&&eG(d,n,s),a.buffers.depth.setTest(!0),a.buffers.depth.setMask(!0),a.buffers.color.setMask(!0),a.setPolygonOffset(!1)}function eG(e,n,i){let r=!0===n.isScene?n.overrideMaterial:null;for(let a=0,s=e.length;a0?Z[Z.length-1]:null,Y.pop(),X=Y.length>0?Y[Y.length-1]:null},this.getActiveCubeFace=function(){return ee},this.getActiveMipmapLevel=function(){return et},this.getRenderTarget=function(){return en},this.setRenderTargetTextures=function(e,n,r){o.get(e.texture).__webglTexture=n,o.get(e.depthTexture).__webglTexture=r;let a=o.get(e);a.__hasExternalTextures=!0,a.__hasExternalTextures&&(a.__autoAllocateDepthBuffer=void 0===r,a.__autoAllocateDepthBuffer||!0!==i.has("WEBGL_multisampled_render_to_texture")||(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),a.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,n){let i=o.get(e);i.__webglFramebuffer=n,i.__useDefaultFramebuffer=void 0===n},this.setRenderTarget=function(e,n=0,i=0){en=e,ee=n,et=i;let s=!0,l=null,u=!1,h=!1;if(e){let d=o.get(e);void 0!==d.__useDefaultFramebuffer?(a.bindFramebuffer(eC.FRAMEBUFFER,null),s=!1):void 0===d.__webglFramebuffer?c.setupRenderTarget(e):d.__hasExternalTextures&&c.rebindTextures(e,o.get(e.texture).__webglTexture,o.get(e.depthTexture).__webglTexture);let p=e.texture;(p.isData3DTexture||p.isDataArrayTexture||p.isCompressedArrayTexture)&&(h=!0);let f=o.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(l=Array.isArray(f[n])?f[n][i]:f[n],u=!0):l=r.isWebGL2&&e.samples>0&&!1===c.useMultisampledRTT(e)?o.get(e).__webglMultisampledFramebuffer:Array.isArray(f)?f[i]:f,ea.copy(e.viewport),es.copy(e.scissor),eo=e.scissorTest}else ea.copy(eg).multiplyScalar(ed).floor(),es.copy(e_).multiplyScalar(ed).floor(),eo=ey;let d=a.bindFramebuffer(eC.FRAMEBUFFER,l);if(d&&r.drawBuffers&&s&&a.drawBuffers(e,l),a.viewport(ea),a.scissor(es),a.setScissorTest(eo),u){let r=o.get(e.texture);eC.framebufferTexture2D(eC.FRAMEBUFFER,eC.COLOR_ATTACHMENT0,eC.TEXTURE_CUBE_MAP_POSITIVE_X+n,r.__webglTexture,i)}else if(h){let r=o.get(e.texture),a=n||0;eC.framebufferTextureLayer(eC.FRAMEBUFFER,eC.COLOR_ATTACHMENT0,r.__webglTexture,i||0,a)}ei=-1},this.readRenderTargetPixels=function(e,n,s,l,u,c,h){if(!(e&&e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let d=o.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==h&&(d=d[h]),d){a.bindFramebuffer(eC.FRAMEBUFFER,d);try{let a=e.texture,o=a.format,h=a.type;if(o!==y&&C.convert(o)!==eC.getParameter(eC.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let d=1016===h&&(i.has("EXT_color_buffer_half_float")||r.isWebGL2&&i.has("EXT_color_buffer_float"));if(1009!==h&&C.convert(h)!==eC.getParameter(eC.IMPLEMENTATION_COLOR_READ_TYPE)&&!(1015===h&&(r.isWebGL2||i.has("OES_texture_float")||i.has("WEBGL_color_buffer_float")))&&!d){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}n>=0&&n<=e.width-l&&s>=0&&s<=e.height-u&&eC.readPixels(n,s,l,u,C.convert(o),C.convert(h),c)}finally{let e=null!==en?o.get(en).__webglFramebuffer:null;a.bindFramebuffer(eC.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,n,i=0){let r=Math.pow(2,-i),s=Math.floor(n.image.width*r),o=Math.floor(n.image.height*r);c.setTexture2D(n,0),eC.copyTexSubImage2D(eC.TEXTURE_2D,i,0,0,e.x,e.y,s,o),a.unbindTexture()},this.copyTextureToTexture=function(e,n,i,r=0){let s=n.image.width,o=n.image.height,l=C.convert(i.format),u=C.convert(i.type);c.setTexture2D(i,0),eC.pixelStorei(eC.UNPACK_FLIP_Y_WEBGL,i.flipY),eC.pixelStorei(eC.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),eC.pixelStorei(eC.UNPACK_ALIGNMENT,i.unpackAlignment),n.isDataTexture?eC.texSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,s,o,l,u,n.image.data):n.isCompressedTexture?eC.compressedTexSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,n.mipmaps[0].width,n.mipmaps[0].height,l,n.mipmaps[0].data):eC.texSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,l,u,n.image),0===r&&i.generateMipmaps&&eC.generateMipmap(eC.TEXTURE_2D),a.unbindTexture()},this.copyTextureToTexture3D=function(e,n,i,r,s=0){let o;if(K.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let l=e.max.x-e.min.x+1,u=e.max.y-e.min.y+1,h=e.max.z-e.min.z+1,d=C.convert(r.format),p=C.convert(r.type);if(r.isData3DTexture)c.setTexture3D(r,0),o=eC.TEXTURE_3D;else if(r.isDataArrayTexture)c.setTexture2DArray(r,0),o=eC.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}eC.pixelStorei(eC.UNPACK_FLIP_Y_WEBGL,r.flipY),eC.pixelStorei(eC.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),eC.pixelStorei(eC.UNPACK_ALIGNMENT,r.unpackAlignment);let f=eC.getParameter(eC.UNPACK_ROW_LENGTH),m=eC.getParameter(eC.UNPACK_IMAGE_HEIGHT),g=eC.getParameter(eC.UNPACK_SKIP_PIXELS),v=eC.getParameter(eC.UNPACK_SKIP_ROWS),_=eC.getParameter(eC.UNPACK_SKIP_IMAGES),y=i.isCompressedTexture?i.mipmaps[0]:i.image;eC.pixelStorei(eC.UNPACK_ROW_LENGTH,y.width),eC.pixelStorei(eC.UNPACK_IMAGE_HEIGHT,y.height),eC.pixelStorei(eC.UNPACK_SKIP_PIXELS,e.min.x),eC.pixelStorei(eC.UNPACK_SKIP_ROWS,e.min.y),eC.pixelStorei(eC.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?eC.texSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,p,y.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),eC.compressedTexSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,y.data)):eC.texSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,p,y),eC.pixelStorei(eC.UNPACK_ROW_LENGTH,f),eC.pixelStorei(eC.UNPACK_IMAGE_HEIGHT,m),eC.pixelStorei(eC.UNPACK_SKIP_PIXELS,g),eC.pixelStorei(eC.UNPACK_SKIP_ROWS,v),eC.pixelStorei(eC.UNPACK_SKIP_IMAGES,_),0===s&&r.generateMipmaps&&eC.generateMipmap(o),a.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?c.setTextureCube(e,0):e.isData3DTexture?c.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?c.setTexture2DArray(e,0):c.setTexture2D(e,0),a.unbindTexture()},this.resetState=function(){ee=0,et=0,en=null,a.reset(),L.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let n=this.getContext();n.drawingBufferColorSpace=e===R?"display-p3":"srgb",n.unpackColorSpace=es.workingColorSpace===P?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===w?3001:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=3001===e?w:A}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}(class extends rL{}).prototype.isWebGL1Renderer=!0;class rO extends th{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let n=super.toJSON(e);return null!==this.fog&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class rI{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=void 0!==e?e.length/n:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=B()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,i){e*=this.stride,i*=n.stride;for(let r=0,a=this.stride;rl)continue;d.applyMatrix4(this.matrixWorld);let o=e.ray.origin.distanceTo(d);oe.far||n.push({distance:o,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}else{let i=Math.max(0,s.start),r=Math.min(g.count,s.start+s.count);for(let a=i,s=r-1;al)continue;d.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(d);re.far||n.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry,n=e.morphAttributes,i=Object.keys(n);if(i.length>0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;n0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;na.far)return;s.push({distance:u,distanceToRay:Math.sqrt(l),point:i,index:n,face:null,object:o})}}class af extends ef{constructor(e,n,i,r,a,s,o,l,u,c,h,d){super(null,s,o,l,u,c,r,a,h,d),this.isCompressedTexture=!0,this.image={width:n,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class am{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,n){let i=this.getUtoTmapping(e);return this.getPoint(i,n)}getPoints(e=5){let n=[];for(let i=0;i<=e;i++)n.push(this.getPoint(i/e));return n}getSpacedPoints(e=5){let n=[];for(let i=0;i<=e;i++)n.push(this.getPointAt(i/e));return n}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let n=[],i,r=this.getPoint(0),a=0;n.push(0);for(let s=1;s<=e;s++)n.push(a+=(i=this.getPoint(s/e)).distanceTo(r)),r=i;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,n){let i;let r=this.getLengths(),a=0,s=r.length;i=n||e*r[s-1];let o=0,l=s-1,u;for(;o<=l;)if((u=r[a=Math.floor(o+(l-o)/2)]-i)<0)o=a+1;else if(u>0)l=a-1;else{l=a;break}if(r[a=l]===i)return a/(s-1);let c=r[a],h=r[a+1],d=(a+(i-c)/(h-c))/(s-1);return d}getTangent(e,n){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),o=n||(a.isVector2?new J:new ex);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,n){let i=this.getUtoTmapping(e);return this.getTangent(i,n)}computeFrenetFrames(e,n){let i=new ex,r=[],a=[],s=[],o=new ex,l=new eZ;for(let n=0;n<=e;n++){let i=n/e;r[n]=this.getTangentAt(i,new ex)}a[0]=new ex,s[0]=new ex;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=u&&(u=c,i.set(1,0,0)),h<=u&&(u=h,i.set(0,1,0)),d<=u&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let n=1;n<=e;n++){if(a[n]=a[n-1].clone(),s[n]=s[n-1].clone(),o.crossVectors(r[n-1],r[n]),o.length()>Number.EPSILON){o.normalize();let e=Math.acos(k(r[n-1].dot(r[n]),-1,1));a[n].applyMatrix4(l.makeRotationAxis(o,e))}s[n].crossVectors(r[n],a[n])}if(!0===n){let n=Math.acos(k(a[0].dot(a[e]),-1,1));n/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(n=-n);for(let i=1;i<=e;i++)a[i].applyMatrix4(l.makeRotationAxis(r[i],n*i)),s[i].crossVectors(r[i],a[i])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ag extends am{constructor(e=0,n=0,i=1,r=1,a=0,s=2*Math.PI,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=n,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=l}getPoint(e,n){let i=n||new J,r=2*Math.PI,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)r;)a-=r;ai.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(aM(s,o.x,l.x,u.x,c.x),aM(s,o.y,l.y,u.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let n=0,i=e.points.length;n0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===u&&l===s-1&&(l=s-2,u=1),this.closed||l>0?i=a[(l-1)%s]:(a_.subVectors(a[0],a[1]).add(a[0]),i=a_);let c=a[l%s],h=a[(l+1)%s];if(this.closed||l+2=i){let e=r[a]-i,s=this.curves[a],o=s.getLength(),l=0===o?0:1-e/o;return s.getPointAt(l,n)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],n=0;for(let i=0,r=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(e){super.copy(e),this.curves=[];for(let n=0,i=e.curves.length;n0){let e=u.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class aI extends tX{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],n=12,i=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:n,phiStart:i,phiLength:r},n=Math.floor(n),r=k(r,0,2*Math.PI);let a=[],s=[],o=[],l=[],u=[],c=1/n,h=new ex,d=new J,p=new ex,f=new ex,m=new ex,g=0,v=0;for(let n=0;n<=e.length-1;n++)switch(n){case 0:g=e[n+1].x-e[n].x,v=e[n+1].y-e[n].y,p.x=1*v,p.y=-g,p.z=0*v,m.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(m.x,m.y,m.z);break;default:g=e[n+1].x-e[n].x,v=e[n+1].y-e[n].y,p.x=1*v,p.y=-g,p.z=0*v,f.copy(p),p.x+=m.x,p.y+=m.y,p.z+=m.z,p.normalize(),l.push(p.x,p.y,p.z),m.copy(f)}for(let a=0;a<=n;a++){let p=i+a*c*r,f=Math.sin(p),m=Math.cos(p);for(let i=0;i<=e.length-1;i++){h.x=e[i].x*f,h.y=e[i].y,h.z=e[i].x*m,s.push(h.x,h.y,h.z),d.x=a/n,d.y=i/(e.length-1),o.push(d.x,d.y);let r=l[3*i+0]*f,c=l[3*i+1],p=l[3*i+0]*m;u.push(r,c,p)}}for(let i=0;i0&&_(!0),n>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new tz(h,3)),this.setAttribute("normal",new tz(d,3)),this.setAttribute("uv",new tz(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aN(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class aF extends aN{constructor(e=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(0,e,n,i,r,a,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o}}static fromJSON(e){return new aF(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class az extends tX{constructor(e=[],n=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:n,radius:i,detail:r};let a=[],s=[];function o(e){a.push(e.x,e.y,e.z)}function l(n,i){let r=3*n;i.x=e[r+0],i.y=e[r+1],i.z=e[r+2]}function u(e,n,i,r){r<0&&1===e.x&&(s[n]=e.x-1),0===i.x&&0===i.z&&(s[n]=r/2/Math.PI+.5)}function c(e){return Math.atan2(e.z,-e.x)}(function(e){let i=new ex,r=new ex,a=new ex;for(let s=0;s.9&&o<.1&&(n<.2&&(s[e+0]+=1),i<.2&&(s[e+2]+=1),r<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new tz(a,3)),this.setAttribute("normal",new tz(a.slice(),3)),this.setAttribute("uv",new tz(s,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new az(e.vertices,e.indices,e.radius,e.details)}}class aB extends az{constructor(e=1,n=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];super(a,[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],e,n),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new aB(e.radius,e.detail)}}class ak extends aO{constructor(e){super(e),this.uuid=B(),this.type="Shape",this.holes=[]}getPointsHoles(e){let n=[];for(let i=0,r=this.holes.length;i=i.next.y&&i.next.y!==i.y){let e=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,a=i.x=i.x&&i.x>=u&&s!==i.x&&aX(oa.x||i.x===a.x&&(p=a,f=i,0>aq(p.prev,p,f.prev)&&0>aq(f.next,p,p.next))))&&(a=i,h=d)),i=i.next}while(i!==l)return a}(e,n);if(!i)return n;let r=aQ(i,e);return aG(r,r.next),aG(i,i.next)}(c[a],i);return i}(e,n,p,i)),e.length>80*i){r=s=e[0],a=o=e[1];for(let n=i;ns&&(s=l),u>o&&(o=u);c=0!==(c=Math.max(s-r,o-a))?32767/c:0}return function e(n,i,r,a,s,o,l){if(!n)return;!l&&o&&function(e,n,i,r){let a=e;do 0===a.z&&(a.z=aj(a.x,a.y,n,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e)a.prevZ.nextZ=null,a.prevZ=null,function(e){let n,i,r,a,s,o,l,u,c=1;do{for(i=e,e=null,s=null,o=0;i;){for(o++,r=i,l=0,n=0;n0||u>0&&r;)0!==l&&(0===u||!r||i.z<=r.z)?(a=i,i=i.nextZ,l--):(a=r,r=r.nextZ,u--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,c*=2}while(o>1)}(a)}(n,a,s,o);let u=n,c,h;for(;n.prev!==n.next;){if(c=n.prev,h=n.next,o?function(e,n,i,r){let a=e.prev,s=e.next;if(aq(a,e,s)>=0)return!1;let o=a.x,l=e.x,u=s.x,c=a.y,h=e.y,d=s.y,p=ol?o>u?o:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,v=aj(p,f,n,i,r),_=aj(m,g,n,i,r),y=e.prevZ,x=e.nextZ;for(;y&&y.z>=v&&x&&x.z<=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==a&&y!==s&&aX(o,c,l,h,u,d,y.x,y.y)&&aq(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==a&&x!==s&&aX(o,c,l,h,u,d,x.x,x.y)&&aq(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==a&&y!==s&&aX(o,c,l,h,u,d,y.x,y.y)&&aq(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==a&&x!==s&&aX(o,c,l,h,u,d,x.x,x.y)&&aq(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}(n,a,s,o):function(e){let n=e.prev,i=e.next;if(aq(n,e,i)>=0)return!1;let r=n.x,a=e.x,s=i.x,o=n.y,l=e.y,u=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>u?o:u:l>u?l:u,f=i.next;for(;f!==n;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&aX(r,o,a,l,s,u,f.x,f.y)&&aq(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}(n)){i.push(c.i/r|0),i.push(n.i/r|0),i.push(h.i/r|0),a1(n),n=h.next,u=h.next;continue}if((n=h)===u){l?1===l?e(n=function(e,n,i){let r=e;do{let a=r.prev,s=r.next.next;!aY(a,s)&&aJ(a,r,r.next,s)&&a$(a,s)&&a$(s,a)&&(n.push(a.i/i|0),n.push(r.i/i|0),n.push(s.i/i|0),a1(r),a1(r.next),r=e=s),r=r.next}while(r!==e)return aG(r)}(aG(n),i,r),i,r,a,s,o,2):2===l&&function(n,i,r,a,s,o){let l=n;do{let n=l.next.next;for(;n!==l.prev;){var u,c;if(l.i!==n.i&&(u=l,c=n,u.next.i!==c.i&&u.prev.i!==c.i&&!function(e,n){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==n.i&&i.next.i!==n.i&&aJ(i,i.next,e,n))return!0;i=i.next}while(i!==e)return!1}(u,c)&&(a$(u,c)&&a$(c,u)&&function(e,n){let i=e,r=!1,a=(e.x+n.x)/2,s=(e.y+n.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e)return r}(u,c)&&(aq(u.prev,u,c.prev)||aq(u,c.prev,c))||aY(u,c)&&aq(u.prev,u,u.next)>0&&aq(c.prev,c,c.next)>0))){let u=aQ(l,n);l=aG(l,l.next),u=aG(u,u.next),e(l,i,r,a,s,o,0),e(u,i,r,a,s,o,0);return}n=n.next}l=l.next}while(l!==n)}(n,i,r,a,s,o):e(aG(n),i,r,a,s,o,1);break}}}(p,f,i,r,a,c,0),f}};function aV(e,n,i,r,a){let s,o;if(a===function(e,n,i,r){let a=0;for(let s=n,o=i-r;s0)for(s=n;s=n;s-=r)o=a0(s,e[s],e[s+1],o);return o&&aY(o,o.next)&&(a1(o),o=o.next),o}function aG(e,n){if(!e)return e;n||(n=e);let i=e,r;do if(r=!1,!i.steiner&&(aY(i,i.next)||0===aq(i.prev,i,i.next))){if(a1(i),(i=n=i.prev)===i.next)break;r=!0}else i=i.next;while(r||i!==n)return n}function aW(e,n){return e.x-n.x}function aj(e,n,i,r,a){return(e=((e=((e=((e=((e=(e-i)*a|0)|e<<8)&16711935)|e<<4)&252645135)|e<<2)&858993459)|e<<1)&1431655765)|(n=((n=((n=((n=((n=(n-r)*a|0)|n<<8)&16711935)|n<<4)&252645135)|n<<2)&858993459)|n<<1)&1431655765)<<1}function aX(e,n,i,r,a,s,o,l){return(a-o)*(n-l)>=(e-o)*(s-l)&&(e-o)*(r-l)>=(i-o)*(n-l)&&(i-o)*(s-l)>=(a-o)*(r-l)}function aq(e,n,i){return(n.y-e.y)*(i.x-n.x)-(n.x-e.x)*(i.y-n.y)}function aY(e,n){return e.x===n.x&&e.y===n.y}function aJ(e,n,i,r){let a=aK(aq(e,n,i)),s=aK(aq(e,n,r)),o=aK(aq(i,r,e)),l=aK(aq(i,r,n));return!!(a!==s&&o!==l||0===a&&aZ(e,i,n)||0===s&&aZ(e,r,n)||0===o&&aZ(i,e,r)||0===l&&aZ(i,n,r))}function aZ(e,n,i){return n.x<=Math.max(e.x,i.x)&&n.x>=Math.min(e.x,i.x)&&n.y<=Math.max(e.y,i.y)&&n.y>=Math.min(e.y,i.y)}function aK(e){return e>0?1:e<0?-1:0}function a$(e,n){return 0>aq(e.prev,e,e.next)?aq(e,n,e.next)>=0&&aq(e,e.prev,n)>=0:0>aq(e,n,e.prev)||0>aq(e,e.next,n)}function aQ(e,n){let i=new a2(e.i,e.x,e.y),r=new a2(n.i,n.x,n.y),a=e.next,s=n.prev;return e.next=n,n.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function a0(e,n,i,r){let a=new a2(e,n,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function a1(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function a2(e,n,i){this.i=e,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class a3{static area(e){let n=e.length,i=0;for(let r=n-1,a=0;aa3.area(e)}static triangulateShape(e,n){let i=[],r=[],a=[];a4(e),a5(i,e);let s=e.length;n.forEach(a4);for(let e=0;e2&&e[n-1].equals(e[0])&&e.pop()}function a5(e,n){for(let i=0;iNumber.EPSILON){let d=Math.sqrt(h),p=Math.sqrt(u*u+c*c),f=n.x-l/d,m=n.y+o/d,g=i.x-c/p,v=i.y+u/p,_=((g-f)*c-(v-m)*u)/(o*c-l*u);r=f+o*_-e.x,a=m+l*_-e.y;let y=r*r+a*a;if(y<=2)return new J(r,a);s=Math.sqrt(y/2)}else{let e=!1;o>Number.EPSILON?u>Number.EPSILON&&(e=!0):o<-Number.EPSILON?u<-Number.EPSILON&&(e=!0):Math.sign(l)===Math.sign(c)&&(e=!0),e?(r=-l,a=o,s=Math.sqrt(h)):(r=o,a=l,s=Math.sqrt(h/2))}return new J(r/s,a/s)}let I=[];for(let e=0,n=R.length,i=n-1,r=e+1;e=0;e--){let n=e/_,i=m*Math.cos(n*Math.PI/2),r=g*Math.sin(n*Math.PI/2)+v;for(let e=0,n=R.length;e=0;){let s=a,o=a-1;o<0&&(o=e.length-1);for(let e=0,a=d+2*_;e0)&&p.push(n,a,u),(e!==i-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class su extends tT{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new tC(16777215),this.specular=new tC(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tC(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function sc(e,n,i){return e&&(i||e.constructor!==n)?"number"==typeof n.BYTES_PER_ELEMENT?new n(e):Array.prototype.slice.call(e):e}function sh(e,n,i){let r=e.length,a=new e.constructor(r);for(let s=0,o=0;o!==r;++s){let r=i[s]*n;for(let i=0;i!==n;++i)a[o++]=e[r+i]}return a}function sd(e,n,i,r){let a=1,s=e[0];for(;void 0!==s&&void 0===s[r];)s=e[a++];if(void 0===s)return;let o=s[r];if(void 0!==o){if(Array.isArray(o))do void 0!==(o=s[r])&&(n.push(s.time),i.push.apply(i,o)),s=e[a++];while(void 0!==s)else if(void 0!==o.toArray)do void 0!==(o=s[r])&&(n.push(s.time),o.toArray(i,i.length)),s=e[a++];while(void 0!==s)else do void 0!==(o=s[r])&&(n.push(s.time),i.push(o)),s=e[a++];while(void 0!==s)}}class sp{constructor(e,n,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let n=this.parameterPositions,i=this._cachedIndex,r=n[i],a=n[i-1];e:{t:{let s;n:{i:if(!(e=a)){let o=n[1];e=(a=n[--i-1]))break t}s=i,i=0;break n}break e}for(;i>>1;en;)--s;if(++s,0!==a||s!==r){a>=s&&(a=(s=Math.max(s,1))-1);let e=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*e,s*e)}return this}validate(){let e=!0,n=this.getValueSize();n-Math.floor(n)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;0===a&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let r=i[n];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,r),e=!1;break}if(null!==s&&s>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,r,s),e=!1;break}s=r}if(void 0!==r&&ArrayBuffer.isView(r)&&!(r instanceof DataView))for(let n=0,i=r.length;n!==i;++n){let i=r[n];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,i),e=!1;break}}return e}optimize(){let e=this.times.slice(),n=this.values.slice(),i=this.getValueSize(),r=2302===this.getInterpolation(),a=e.length-1,s=1;for(let o=1;o0){e[s]=e[a];for(let e=a*i,r=s*i,o=0;o!==i;++o)n[r+o]=n[e+o];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=n.slice(0,s*i)):(this.times=e,this.values=n),this}clone(){let e=this.times.slice(),n=this.values.slice(),i=this.constructor,r=new i(this.name,e,n);return r.createInterpolant=this.createInterpolant,r}}sv.prototype.TimeBufferType=Float32Array,sv.prototype.ValueBufferType=Float32Array,sv.prototype.DefaultInterpolation=b;class s_ extends sv{}s_.prototype.ValueTypeName="bool",s_.prototype.ValueBufferType=Array,s_.prototype.DefaultInterpolation=x,s_.prototype.InterpolantFactoryMethodLinear=void 0,s_.prototype.InterpolantFactoryMethodSmooth=void 0;class sy extends sv{}sy.prototype.ValueTypeName="color";class sx extends sv{}sx.prototype.ValueTypeName="number";class sb extends sp{constructor(e,n,i,r){super(e,n,i,r)}interpolate_(e,n,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=(i-n)/(r-n),u=e*o;for(let e=u+o;u!==e;u+=4)ey.slerpFlat(a,0,s,u-o,s,u,l);return a}}class sM extends sv{InterpolantFactoryMethodLinear(e){return new sb(this.times,this.values,this.getValueSize(),e)}}sM.prototype.ValueTypeName="quaternion",sM.prototype.DefaultInterpolation=b,sM.prototype.InterpolantFactoryMethodSmooth=void 0;class sS extends sv{}sS.prototype.ValueTypeName="string",sS.prototype.ValueBufferType=Array,sS.prototype.DefaultInterpolation=x,sS.prototype.InterpolantFactoryMethodLinear=void 0,sS.prototype.InterpolantFactoryMethodSmooth=void 0;class sE extends sv{}sE.prototype.ValueTypeName="vector";class sT{constructor(e,n=-1,i,r=2500){this.name=e,this.tracks=i,this.duration=n,this.blendMode=r,this.uuid=B(),this.duration<0&&this.resetDuration()}static parse(e){let n=[],i=e.tracks,r=1/(e.fps||1);for(let e=0,a=i.length;e!==a;++e)n.push((function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let n=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sx;case"vector":case"vector2":case"vector3":case"vector4":return sE;case"color":return sy;case"quaternion":return sM;case"bool":case"boolean":return s_;case"string":return sS}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let n=[],i=[];sd(e.keys,n,i,"value"),e.times=n,e.values=i}return void 0!==n.parse?n.parse(e):new n(e.name,e.times,e.values,e.interpolation)})(i[e]).scale(r));let a=new this(e.name,e.duration,n,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let n=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=i.length;e!==r;++e)n.push(sv.toJSON(i[e]));return r}static CreateFromMorphTargetSequence(e,n,i,r){let a=n.length,s=[];for(let e=0;e1){let e=s[1],n=r[e];n||(r[e]=n=[]),n.push(i)}}let s=[];for(let e in r)s.push(this.CreateFromMorphTargetSequence(e,r[e],n,i));return s}static parseAnimation(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(e,n,i,r,a){if(0!==i.length){let s=[],o=[];sd(i,s,o,r),0!==s.length&&a.push(new e(n,s,o))}},r=[],a=e.name||"default",s=e.fps||30,o=e.blendMode,l=e.length||-1,u=e.hierarchy||[];for(let e=0;e{n&&n(a),this.manager.itemEnd(e)},0),a;if(void 0!==sP[e]){sP[e].push({onLoad:n,onProgress:i,onError:r});return}sP[e]=[],sP[e].push({onLoad:n,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(s).then(n=>{if(200===n.status||0===n.status){if(0===n.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===n.body||void 0===n.body.getReader)return n;let i=sP[e],r=n.body.getReader(),a=n.headers.get("Content-Length")||n.headers.get("X-File-Size"),s=a?parseInt(a):0,o=0!==s,l=0,u=new ReadableStream({start(e){(function n(){r.read().then(({done:r,value:a})=>{if(r)e.close();else{l+=a.byteLength;let r=new ProgressEvent("progress",{lengthComputable:o,loaded:l,total:s});for(let e=0,n=i.length;e{switch(l){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>{let n=new DOMParser;return n.parseFromString(e,o)});case"json":return e.json();default:if(void 0===o)return e.text();{let n=/charset="?([^;"\s]*)"?/i.exec(o),i=n&&n[1]?n[1].toLowerCase():void 0,r=new TextDecoder(i);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(n=>{sw.add(e,n);let i=sP[e];delete sP[e];for(let e=0,r=i.length;e{let i=sP[e];if(void 0===i)throw this.manager.itemError(e),n;delete sP[e];for(let e=0,r=i.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class sO extends sR{constructor(e){super(e)}load(e,n,i,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=sw.get(e);if(void 0!==s)return a.manager.itemStart(e),setTimeout(function(){n&&n(s),a.manager.itemEnd(e)},0),s;let o=Q("img");function l(){c(),sw.add(e,this),n&&n(this),a.manager.itemEnd(e)}function u(n){c(),r&&r(n),a.manager.itemError(e),a.manager.itemEnd(e)}function c(){o.removeEventListener("load",l,!1),o.removeEventListener("error",u,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",u,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),a.manager.itemStart(e),o.src=e,o}}class sI extends sR{constructor(e){super(e)}load(e,n,i,r){let a=new ef,s=new sO(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){a.image=e,a.needsUpdate=!0,void 0!==n&&n(a)},i,r),a}}class sD extends th{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new tC(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,void 0!==this.groundColor&&(n.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(n.object.distance=this.distance),void 0!==this.angle&&(n.object.angle=this.angle),void 0!==this.decay&&(n.object.decay=this.decay),void 0!==this.penumbra&&(n.object.penumbra=this.penumbra),void 0!==this.shadow&&(n.object.shadow=this.shadow.toJSON()),n}}let sU=new eZ,sN=new ex,sF=new ex;class sz{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new eZ,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ny,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new em(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let n=this.camera,i=this.matrix;sN.setFromMatrixPosition(e.matrixWorld),n.position.copy(sN),sF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(sF),n.updateMatrixWorld(),sU.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sU),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(sU)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class sB extends sz{constructor(){super(new nu(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let n=this.camera,i=2*z*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||n.far;(i!==n.fov||r!==n.aspect||a!==n.far)&&(n.fov=i,n.aspect=r,n.far=a,n.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sk extends sD{constructor(e,n,i=0,r=Math.PI/3,a=0,s=2){super(e,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(th.DEFAULT_UP),this.updateMatrix(),this.target=new th,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new sB}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let sH=new eZ,sV=new ex,sG=new ex;class sW extends sz{constructor(){super(new nu(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new em(2,1,1,1),new em(0,1,1,1),new em(3,1,1,1),new em(1,1,1,1),new em(3,0,1,1),new em(1,0,1,1)],this._cubeDirections=[new ex(1,0,0),new ex(-1,0,0),new ex(0,0,1),new ex(0,0,-1),new ex(0,1,0),new ex(0,-1,0)],this._cubeUps=[new ex(0,1,0),new ex(0,1,0),new ex(0,1,0),new ex(0,1,0),new ex(0,0,1),new ex(0,0,-1)]}updateMatrices(e,n=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),sV.setFromMatrixPosition(e.matrixWorld),i.position.copy(sV),sG.copy(i.position),sG.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(sG),i.updateMatrixWorld(),r.makeTranslation(-sV.x,-sV.y,-sV.z),sH.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sH)}}class sj extends sD{constructor(e,n,i=0,r=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new sW}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class sX extends sz{constructor(){super(new nI(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sq extends sD{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(th.DEFAULT_UP),this.updateMatrix(),this.target=new th,this.shadow=new sX}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class sY extends sD{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class sJ{static decodeText(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);let n="";for(let i=0,r=e.length;i0){this.source.connect(this.filters[0]);for(let e=1,n=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,n=this.filters.length;e.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{om.set(e.z,0,-e.x).normalize();let n=Math.acos(e.y);this.quaternion.setFromAxisAngle(om,n)}}setLength(e,n=.2*e,i=.2*n){this.line.scale.set(1,Math.max(1e-4,e-n),1),this.line.updateMatrix(),this.cone.scale.set(i,n,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"157"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="157")}},n={};function i(r){var a=n[r];if(void 0!==a)return a.exports;var s=n[r]={exports:{}};return e[r](s,s.exports,i),s.exports}i.m=e,(()=>{var e=[];i.O=(n,r,a,s)=>{if(r){s=s||0;for(var o=e.length;o>0&&e[o-1][2]>s;o--)e[o]=e[o-1];e[o]=[r,a,s];return}for(var l=1/0,o=0;o=s&&Object.keys(i.O).every(e=>i.O[e](r[c]))?r.splice(c--,1):(u=!1,s{var n=e&&e.__esModule?()=>e.default:()=>e;return i.d(n,{a:n}),n},i.d=(e,n)=>{for(var r in n)i.o(n,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={736:0};i.O.j=n=>0===e[n];var n=(n,r)=>{var a,s,[o,l,u]=r,c=0;if(o.some(n=>0!==e[n])){for(a in l)i.o(l,a)&&(i.m[a]=l[a]);if(u)var h=u(i)}for(n&&n(r);c0||l&&s&&function(e){let n=0;for(let i=0;i<6;i++)void 0!==e[i]&&n++;return 6===n}(s)))return null;{null===i&&(i=new nW(e));let s=o?i.fromEquirectangular(a):i.fromCubemap(a);return n.set(a,s),a.addEventListener("dispose",r),s.texture}}}}return a},dispose:function(){n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function nK(e){let n={};function i(i){let r;if(void 0!==n[i])return n[i];switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return n[i]=r,r}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){let n=i(e);return null===n&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),n}}}function n$(e,n,i,r){let a={},s=new WeakMap;function o(e){let l=e.target;for(let e in null!==l.index&&n.remove(l.index),l.attributes)n.remove(l.attributes[e]);for(let e in l.morphAttributes){let i=l.morphAttributes[e];for(let e=0,r=i.length;en.maxTextureSize&&(m=Math.ceil(f/n.maxTextureSize),f=n.maxTextureSize);let g=new Float32Array(f*m*4*a),v=new ey(g,f,m,a);v.type=1015,v.needsUpdate=!0;let _=4*p;for(let n=0;n0)return e;let a=n*i,s=n9[a];if(void 0===s&&(s=new Float32Array(a),n9[a]=s),0!==n){r.toArray(s,0);for(let r=1,a=0;r!==n;++r)a+=i,e[r].toArray(s,a)}return s}function is(e,n){if(e.length!==n.length)return!1;for(let i=0,r=e.length;i":" "} ${a}: ${i[e]}`)}return r.join("\n")}(e.getShaderSource(n),r)}}function i3(e){return""!==e}function i4(e,n){let i=n.numSpotLightShadows+n.numSpotLightMaps-n.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,n.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,n.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function i5(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}let i6=/^[ \t]*#include +<([\w\d./]+)>/gm;function i7(e){return e.replace(i6,i9)}let i8=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function i9(e,n){let i=nE[n];if(void 0===i){let e=i8.get(n);if(void 0!==e)i=nE[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,e);else throw Error("Can not resolve #include <"+n+">")}return i7(i)}let re=/#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 rt(e){return e.replace(re,rn)}function rn(e,n,i,r){let a="";for(let e=parseInt(n);e0&&(a+="\n"),(s=[x,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b].filter(i3).join("\n")).length>0&&(s+="\n")):(a=[ri(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+v:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(i3).join("\n"),s=[x,ri(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+g:"",i.envMap?"#define "+v:"",i.envMap?"#define "+_:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?nE.tonemapping_pars_fragment:"",0!==i.toneMapping?function(e,n){let i;switch(n){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",n),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",nE.colorspace_pars_fragment,function(e,n){let i=function(e){let n;let i=eo.getPrimaries(eo.workingColorSpace),r=eo.getPrimaries(e);switch(i===r?n="":"p3"===i&&r===I?n="LinearDisplayP3ToLinearSRGB":i===I&&"p3"===r&&(n="LinearSRGBToLinearDisplayP3"),e){case R:case C:return[n,"LinearTransferOETF"];case A:case P:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[n,"LinearTransferOETF"]}}(n);return`vec4 ${e}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(i3).join("\n")),p=i5(p=i4(p=i7(p),i),i),f=i5(f=i4(f=i7(f),i),i),p=rt(p),f=rt(f),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(S="#version 300 es\n",a="precision mediump sampler2DArray;\n#define attribute in\n#define varying out\n#define texture2D texture\n"+a,s=["precision mediump sampler2DArray;","#define varying in",i.glslVersion===D?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===D?"":"#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"+s);let E=S+a+p,T=S+s+f,w=i0(h,h.VERTEX_SHADER,E),L=i0(h,h.FRAGMENT_SHADER,T);function O(n){if(e.debug.checkShaderErrors){let i=h.getProgramInfoLog(M).trim(),r=h.getShaderInfoLog(w).trim(),o=h.getShaderInfoLog(L).trim(),l=!0,u=!0;if(!1===h.getProgramParameter(M,h.LINK_STATUS)){if(l=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(h,M,w,L);else{let e=i2(h,w,"vertex"),n=i2(h,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+h.getError()+" - VALIDATE_STATUS "+h.getProgramParameter(M,h.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+e+"\n"+n)}}else""!==i?console.warn("THREE.WebGLProgram: Program Info Log:",i):(""===r||""===o)&&(u=!1);u&&(n.diagnostics={runnable:l,programLog:i,vertexShader:{log:r,prefix:a},fragmentShader:{log:o,prefix:s}})}h.deleteShader(w),h.deleteShader(L),o=new iQ(h,M),l=function(e,n){let i={},r=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let a=0;a0,J=s.clearcoat>0,Z=s.iridescence>0,K=s.sheen>0,$=s.transmission>0,Q=Y&&!!s.anisotropyMap,ee=J&&!!s.clearcoatMap,et=J&&!!s.clearcoatNormalMap,en=J&&!!s.clearcoatRoughnessMap,ei=Z&&!!s.iridescenceMap,er=Z&&!!s.iridescenceThicknessMap,ea=K&&!!s.sheenColorMap,es=K&&!!s.sheenRoughnessMap,el=!!s.specularMap,eu=!!s.specularColorMap,ec=!!s.specularIntensityMap,eh=$&&!!s.transmissionMap,ed=$&&!!s.thicknessMap,ep=!!s.gradientMap,ef=!!s.alphaMap,em=s.alphaTest>0,eg=!!s.alphaHash,ev=!!s.extensions,e_=!!T.attributes.uv1,ey=!!T.attributes.uv2,ex=!!T.attributes.uv3,eb=0;s.toneMapped&&(null===U||!0===U.isXRRenderTarget)&&(eb=e.toneMapping);let eM={isWebGL2:d,shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:x,fragmentShader:b,defines:s.defines,customVertexShaderID:M,customFragmentShaderID:S,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:m,instancing:N,instancingColor:N&&null!==y.instanceColor,supportsVertexTextures:f,outputColorSpace:null===U?e.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:R,map:F,matcap:z,envMap:B,envMapMode:B&&A.mapping,envMapCubeUVHeight:P,aoMap:k,lightMap:H,bumpMap:V,normalMap:G,displacementMap:f&&W,emissiveMap:j,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:X,roughnessMap:q,anisotropy:Y,anisotropyMap:Q,clearcoat:J,clearcoatMap:ee,clearcoatNormalMap:et,clearcoatRoughnessMap:en,iridescence:Z,iridescenceMap:ei,iridescenceThicknessMap:er,sheen:K,sheenColorMap:ea,sheenRoughnessMap:es,specularMap:el,specularColorMap:eu,specularIntensityMap:ec,transmission:$,transmissionMap:eh,thicknessMap:ed,gradientMap:ep,opaque:!1===s.transparent&&1===s.blending,alphaMap:ef,alphaTest:em,alphaHash:eg,combine:s.combine,mapUv:F&&v(s.map.channel),aoMapUv:k&&v(s.aoMap.channel),lightMapUv:H&&v(s.lightMap.channel),bumpMapUv:V&&v(s.bumpMap.channel),normalMapUv:G&&v(s.normalMap.channel),displacementMapUv:W&&v(s.displacementMap.channel),emissiveMapUv:j&&v(s.emissiveMap.channel),metalnessMapUv:X&&v(s.metalnessMap.channel),roughnessMapUv:q&&v(s.roughnessMap.channel),anisotropyMapUv:Q&&v(s.anisotropyMap.channel),clearcoatMapUv:ee&&v(s.clearcoatMap.channel),clearcoatNormalMapUv:et&&v(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:en&&v(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ei&&v(s.iridescenceMap.channel),iridescenceThicknessMapUv:er&&v(s.iridescenceThicknessMap.channel),sheenColorMapUv:ea&&v(s.sheenColorMap.channel),sheenRoughnessMapUv:es&&v(s.sheenRoughnessMap.channel),specularMapUv:el&&v(s.specularMap.channel),specularColorMapUv:eu&&v(s.specularColorMap.channel),specularIntensityMapUv:ec&&v(s.specularIntensityMap.channel),transmissionMapUv:eh&&v(s.transmissionMap.channel),thicknessMapUv:ed&&v(s.thicknessMap.channel),alphaMapUv:ef&&v(s.alphaMap.channel),vertexTangents:!!T.attributes.tangent&&(G||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!T.attributes.color&&4===T.attributes.color.itemSize,vertexUv1s:e_,vertexUv2s:ey,vertexUv3s:ex,pointsUvs:!0===y.isPoints&&!!T.attributes.uv&&(F||ef),fog:!!E,useFog:!0===s.fog,fogExp2:E&&E.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:p,skinning:!0===y.isSkinnedMesh,morphTargets:void 0!==T.morphAttributes.position,morphNormals:void 0!==T.morphAttributes.normal,morphColors:void 0!==T.morphAttributes.color,morphTargetsCount:I,morphTextureStride:D,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:eb,useLegacyLights:e._useLegacyLights,decodeVideoTexture:F&&!0===s.map.isVideoTexture&&eo.getTransfer(s.map.colorSpace)===O,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===u,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:ev&&!0===s.extensions.derivatives,extensionFragDepth:ev&&!0===s.extensions.fragDepth,extensionDrawBuffers:ev&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:ev&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return eM},getProgramCacheKey:function(n){let i=[];if(n.shaderID?i.push(n.shaderID):(i.push(n.customVertexShaderID),i.push(n.customFragmentShaderID)),void 0!==n.defines)for(let e in n.defines)i.push(e),i.push(n.defines[e]);return!1===n.isRawShaderMaterial&&(i.push(n.precision),i.push(n.outputColorSpace),i.push(n.envMapMode),i.push(n.envMapCubeUVHeight),i.push(n.mapUv),i.push(n.alphaMapUv),i.push(n.lightMapUv),i.push(n.aoMapUv),i.push(n.bumpMapUv),i.push(n.normalMapUv),i.push(n.displacementMapUv),i.push(n.emissiveMapUv),i.push(n.metalnessMapUv),i.push(n.roughnessMapUv),i.push(n.anisotropyMapUv),i.push(n.clearcoatMapUv),i.push(n.clearcoatNormalMapUv),i.push(n.clearcoatRoughnessMapUv),i.push(n.iridescenceMapUv),i.push(n.iridescenceThicknessMapUv),i.push(n.sheenColorMapUv),i.push(n.sheenRoughnessMapUv),i.push(n.specularMapUv),i.push(n.specularColorMapUv),i.push(n.specularIntensityMapUv),i.push(n.transmissionMapUv),i.push(n.thicknessMapUv),i.push(n.combine),i.push(n.fogExp2),i.push(n.sizeAttenuation),i.push(n.morphTargetsCount),i.push(n.morphAttributeCount),i.push(n.numDirLights),i.push(n.numPointLights),i.push(n.numSpotLights),i.push(n.numSpotLightMaps),i.push(n.numHemiLights),i.push(n.numRectAreaLights),i.push(n.numDirLightShadows),i.push(n.numPointLightShadows),i.push(n.numSpotLightShadows),i.push(n.numSpotLightShadowsWithMaps),i.push(n.numLightProbes),i.push(n.shadowMapType),i.push(n.toneMapping),i.push(n.numClippingPlanes),i.push(n.numClipIntersection),i.push(n.depthPacking),l.disableAll(),n.isWebGL2&&l.enable(0),n.supportsVertexTextures&&l.enable(1),n.instancing&&l.enable(2),n.instancingColor&&l.enable(3),n.matcap&&l.enable(4),n.envMap&&l.enable(5),n.normalMapObjectSpace&&l.enable(6),n.normalMapTangentSpace&&l.enable(7),n.clearcoat&&l.enable(8),n.iridescence&&l.enable(9),n.alphaTest&&l.enable(10),n.vertexColors&&l.enable(11),n.vertexAlphas&&l.enable(12),n.vertexUv1s&&l.enable(13),n.vertexUv2s&&l.enable(14),n.vertexUv3s&&l.enable(15),n.vertexTangents&&l.enable(16),n.anisotropy&&l.enable(17),n.alphaHash&&l.enable(18),i.push(l.mask),l.disableAll(),n.fog&&l.enable(0),n.useFog&&l.enable(1),n.flatShading&&l.enable(2),n.logarithmicDepthBuffer&&l.enable(3),n.skinning&&l.enable(4),n.morphTargets&&l.enable(5),n.morphNormals&&l.enable(6),n.morphColors&&l.enable(7),n.premultipliedAlpha&&l.enable(8),n.shadowMapEnabled&&l.enable(9),n.useLegacyLights&&l.enable(10),n.doubleSided&&l.enable(11),n.flipSided&&l.enable(12),n.useDepthPacking&&l.enable(13),n.dithering&&l.enable(14),n.transmission&&l.enable(15),n.sheen&&l.enable(16),n.opaque&&l.enable(17),n.pointsUvs&&l.enable(18),n.decodeVideoTexture&&l.enable(19),i.push(l.mask),i.push(e.outputColorSpace)),i.push(n.customProgramCacheKey),i.join()},getUniforms:function(e){let n;let i=g[e.type];if(i){let e=nw[i];n=no.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(n,i){let r;for(let e=0,n=h.length;e0?r.push(h):!0===o.transparent?a.push(h):i.push(h)},unshift:function(e,n,o,l,u,c){let h=s(e,n,o,l,u,c);o.transmission>0?r.unshift(h):!0===o.transparent?a.unshift(h):i.unshift(h)},finish:function(){for(let i=n,r=e.length;i1&&i.sort(e||rc),r.length>1&&r.sort(n||rh),a.length>1&&a.sort(n||rh)}}}function rp(){let e=new WeakMap;return{get:function(n,i){let r;let a=e.get(n);return void 0===a?(r=new rd,e.set(n,[r])):i>=a.length?(r=new rd,a.push(r)):r=a[i],r},dispose:function(){e=new WeakMap}}}function rf(){let e={};return{get:function(n){let i;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":i={direction:new eb,color:new tP};break;case"SpotLight":i={position:new eb,direction:new eb,color:new tP,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new eb,color:new tP,distance:0,decay:0};break;case"HemisphereLight":i={direction:new eb,skyColor:new tP,groundColor:new tP};break;case"RectAreaLight":i={color:new tP,position:new eb,halfWidth:new eb,halfHeight:new eb}}return e[n.id]=i,i}}}let rm=0;function rg(e,n){return(n.castShadow?2:0)-(e.castShadow?2:0)+(n.map?1:0)-(e.map?1:0)}function rv(e,n){let i=new rf,r=function(){let e={};return{get:function(n){let i;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z,shadowCameraNear:1,shadowCameraFar:1e3}}return e[n.id]=i,i}}}(),a={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 e=0;e<9;e++)a.probe.push(new eb);let s=new eb,o=new eK,l=new eK;return{setup:function(s,o){let l=0,u=0,c=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let h=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0,y=0,x=0,b=0;s.sort(rg);let M=!0===o?Math.PI:1;for(let e=0,n=s.length;e0&&(n.isWebGL2?(a.rectAreaLTC1=nT.LTC_FLOAT_1,a.rectAreaLTC2=nT.LTC_FLOAT_2):!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=nT.LTC_FLOAT_1,a.rectAreaLTC2=nT.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(a.rectAreaLTC1=nT.LTC_HALF_1,a.rectAreaLTC2=nT.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),a.ambient[0]=l,a.ambient[1]=u,a.ambient[2]=c;let S=a.hash;(S.directionalLength!==h||S.pointLength!==d||S.spotLength!==p||S.rectAreaLength!==f||S.hemiLength!==m||S.numDirectionalShadows!==g||S.numPointShadows!==v||S.numSpotShadows!==_||S.numSpotMaps!==y||S.numLightProbes!==b)&&(a.directional.length=h,a.spot.length=p,a.rectArea.length=f,a.point.length=d,a.hemi.length=m,a.directionalShadow.length=g,a.directionalShadowMap.length=g,a.pointShadow.length=v,a.pointShadowMap.length=v,a.spotShadow.length=_,a.spotShadowMap.length=_,a.directionalShadowMatrix.length=g,a.pointShadowMatrix.length=v,a.spotLightMatrix.length=_+y-x,a.spotLightMap.length=y,a.numSpotLightShadowsWithMaps=x,a.numLightProbes=b,S.directionalLength=h,S.pointLength=d,S.spotLength=p,S.rectAreaLength=f,S.hemiLength=m,S.numDirectionalShadows=g,S.numPointShadows=v,S.numSpotShadows=_,S.numSpotMaps=y,S.numLightProbes=b,a.version=rm++)},setupView:function(e,n){let i=0,r=0,u=0,c=0,h=0,d=n.matrixWorldInverse;for(let n=0,p=e.length;n=o.length?(s=new r_(e,n),o.push(s)):s=o[a],s},dispose:function(){i=new WeakMap}}}class rx extends tO{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class rb extends tO{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function rM(e,n,i){let r=new nx,a=new Z,s=new Z,o=new eg,c=new rx({depthPacking:3201}),h=new rb,d={},p=i.maxTextureSize,m={[l]:1,1:l,[u]:u},g=new nl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Z},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),v=g.clone();v.defines.HORIZONTAL_PASS=1;let _=new tq;_.setAttribute("position",new tN(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new nt(_,g),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let b=this.type;function M(n,i,r,a){let s=null,o=!0===r.isPointLight?n.customDistanceMaterial:n.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===r.isPointLight?h:c,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){let e=s.uuid,n=i.uuid,r=d[e];void 0===r&&(r={},d[e]=r);let a=r[n];void 0===a&&(a=s.clone(),r[n]=a),s=a}if(s.visible=i.visible,s.wireframe=i.wireframe,3===a?s.side=null!==i.shadowSide?i.shadowSide:i.side:s.side=null!==i.shadowSide?i.shadowSide:m[i.side],s.alphaMap=i.alphaMap,s.alphaTest=i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===r.isPointLight&&!0===s.isMeshDistanceMaterial){let n=e.properties.get(s);n.light=r}return s}this.render=function(i,l,u){if(!1===x.enabled||!1===x.autoUpdate&&!1===x.needsUpdate||0===i.length)return;let c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),m=e.state;m.setBlending(0),m.buffers.color.setClear(1,1,1,1),m.buffers.depth.setTest(!0),m.setScissorTest(!1);let _=3!==b&&3===this.type,S=3===b&&3!==this.type;for(let c=0,h=i.length;cp||a.y>p)&&(a.x>p&&(s.x=Math.floor(p/x.x),a.x=s.x*x.x,d.mapSize.x=s.x),a.y>p&&(s.y=Math.floor(p/x.y),a.y=s.y*x.y,d.mapSize.y=s.y)),null===d.map||!0===_||!0===S){let e=3!==this.type?{minFilter:f,magFilter:f}:{};null!==d.map&&d.map.dispose(),d.map=new e_(a.x,a.y,e),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let b=d.getViewportCount();for(let i=0;i=1:-1!==D.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(D)[1])>=2);let U=null,N={},F=e.getParameter(e.SCISSOR_BOX),z=e.getParameter(e.VIEWPORT),B=new eg().fromArray(F),k=new eg().fromArray(z);function H(n,i,a,s){let o=new Uint8Array(4),l=e.createTexture();e.bindTexture(n,l),e.texParameteri(n,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(n,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;lr||e.height>r)&&(a=r/Math.max(e.width,e.height)),a<1||!0===n){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let r=n?X:Math.floor,s=r(a*e.width),o=r(a*e.height);void 0===l&&(l=I(s,o));let u=i?I(s,o):l;u.width=s,u.height=o;let c=u.getContext("2d");return c.drawImage(e,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+o+")."),u}"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+").")}return e}function U(e){return W(e.width)&&W(e.height)}function N(e,n){return e.generateMipmaps&&n&&e.minFilter!==f&&e.minFilter!==v}function F(n){e.generateMipmap(n)}function z(i,r,a,s,o=!1){if(!1===u)return r;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=r;if(r===e.RED&&(a===e.FLOAT&&(l=e.R32F),a===e.HALF_FLOAT&&(l=e.R16F),a===e.UNSIGNED_BYTE&&(l=e.R8)),r===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.R8UI),a===e.UNSIGNED_SHORT&&(l=e.R16UI),a===e.UNSIGNED_INT&&(l=e.R32UI),a===e.BYTE&&(l=e.R8I),a===e.SHORT&&(l=e.R16I),a===e.INT&&(l=e.R32I)),r===e.RG&&(a===e.FLOAT&&(l=e.RG32F),a===e.HALF_FLOAT&&(l=e.RG16F),a===e.UNSIGNED_BYTE&&(l=e.RG8)),r===e.RGBA){let n=o?L:eo.getTransfer(s);a===e.FLOAT&&(l=e.RGBA32F),a===e.HALF_FLOAT&&(l=e.RGBA16F),a===e.UNSIGNED_BYTE&&(l=n===O?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&n.get("EXT_color_buffer_float"),l}function B(e,n,i){return!0===N(e,i)||e.isFramebufferTexture&&e.minFilter!==f&&e.minFilter!==v?Math.log2(Math.max(n.width,n.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?n.mipmaps.length:1}function k(n){return n===f||n===m||n===g?e.NEAREST:e.LINEAR}function H(e){let n=e.target;n.removeEventListener("dispose",H),function(e){let n=r.get(e);if(void 0===n.__webglInit)return;let i=e.source,a=P.get(i);if(a){let r=a[n.__cacheKey];r.usedTimes--,0===r.usedTimes&&G(e),0===Object.keys(a).length&&P.delete(i)}r.remove(e)}(n),n.isVideoTexture&&A.delete(n)}function V(n){let i=n.target;i.removeEventListener("dispose",V),function(n){let i=n.texture,a=r.get(n),s=r.get(i);if(void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),o.memory.textures--),n.depthTexture&&n.depthTexture.dispose(),n.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(a.__webglFramebuffer[n]))for(let i=0;i0&&s.__version!==n.version){let e=n.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(s,n,a);return}}i.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+a)}let Y={[h]:e.REPEAT,[d]:e.CLAMP_TO_EDGE,[p]:e.MIRRORED_REPEAT},J={[f]:e.NEAREST,[m]:e.NEAREST_MIPMAP_NEAREST,[g]:e.NEAREST_MIPMAP_LINEAR,[v]:e.LINEAR,[_]:e.LINEAR_MIPMAP_NEAREST,[y]:e.LINEAR_MIPMAP_LINEAR},Z={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function K(i,s,o){if(o?(e.texParameteri(i,e.TEXTURE_WRAP_S,Y[s.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,Y[s.wrapT]),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,Y[s.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,J[s.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,J[s.minFilter])):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(s.wrapS!==d||s.wrapT!==d)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,e.TEXTURE_MAG_FILTER,k(s.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,k(s.minFilter)),s.minFilter!==f&&s.minFilter!==v&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(i,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(i,e.TEXTURE_COMPARE_FUNC,Z[s.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")){let o=n.get("EXT_texture_filter_anisotropic");s.magFilter!==f&&(s.minFilter===g||s.minFilter===y)&&(1015!==s.type||!1!==n.has("OES_texture_float_linear"))&&(!1!==u||1016!==s.type||!1!==n.has("OES_texture_half_float_linear"))&&(s.anisotropy>1||r.get(s).__currentAnisotropy)&&(e.texParameterf(i,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,a.getMaxAnisotropy())),r.get(s).__currentAnisotropy=s.anisotropy)}}function $(n,i){let r=!1;void 0===n.__webglInit&&(n.__webglInit=!0,i.addEventListener("dispose",H));let a=i.source,s=P.get(a);void 0===s&&(s={},P.set(a,s));let l=function(e){let n=[];return n.push(e.wrapS),n.push(e.wrapT),n.push(e.wrapR||0),n.push(e.magFilter),n.push(e.minFilter),n.push(e.anisotropy),n.push(e.internalFormat),n.push(e.format),n.push(e.type),n.push(e.generateMipmaps),n.push(e.premultiplyAlpha),n.push(e.flipY),n.push(e.unpackAlignment),n.push(e.colorSpace),n.join()}(i);if(l!==n.__cacheKey){void 0===s[l]&&(s[l]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),s[l].usedTimes++;let a=s[n.__cacheKey];void 0!==a&&(s[n.__cacheKey].usedTimes--,0===a.usedTimes&&G(i)),n.__cacheKey=l,n.__webglTexture=s[l].texture}return r}function Q(n,a,o){let l=e.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=e.TEXTURE_3D);let c=$(n,a),h=a.source;i.bindTexture(l,n.__webglTexture,e.TEXTURE0+o);let p=r.get(h);if(h.version!==p.__version||!0===c){let n;i.activeTexture(e.TEXTURE0+o);let r=eo.getPrimaries(eo.workingColorSpace),m=a.colorSpace===w?null:eo.getPrimaries(a.colorSpace),g=a.colorSpace===w||r===m?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,g);let _=!u&&(a.wrapS!==d||a.wrapT!==d||a.minFilter!==f&&a.minFilter!==v)&&!1===U(a.image),y=D(a.image,_,!1,M);y=es(a,y);let b=U(y)||u,S=s.convert(a.format,a.colorSpace),E=s.convert(a.type),T=z(a.internalFormat,S,E,a.colorSpace,a.isVideoTexture);K(l,a,b);let A=a.mipmaps,R=u&&!0!==a.isVideoTexture,P=void 0===p.__version||!0===c,C=B(a,y,b);if(a.isDepthTexture)T=e.DEPTH_COMPONENT,u?T=1015===a.type?e.DEPTH_COMPONENT32F:1014===a.type?e.DEPTH_COMPONENT24:1020===a.type?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:1015===a.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===a.format&&T===e.DEPTH_COMPONENT&&1012!==a.type&&1014!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),a.type=1014,E=s.convert(a.type)),1027===a.format&&T===e.DEPTH_COMPONENT&&(T=e.DEPTH_STENCIL,1020!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),a.type=1020,E=s.convert(a.type))),P&&(R?i.texStorage2D(e.TEXTURE_2D,1,T,y.width,y.height):i.texImage2D(e.TEXTURE_2D,0,T,y.width,y.height,0,S,E,null));else if(a.isDataTexture){if(A.length>0&&b){R&&P&&i.texStorage2D(e.TEXTURE_2D,C,T,A[0].width,A[0].height);for(let r=0,a=A.length;r>=1,r>>=1}}}else if(A.length>0&&b){R&&P&&i.texStorage2D(e.TEXTURE_2D,C,T,A[0].width,A[0].height);for(let r=0,a=A.length;r>c),r=Math.max(1,a.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?i.texImage3D(u,c,p,n,r,a.depth,0,h,d,null):i.texImage2D(u,c,p,n,r,0,h,d,null)}i.bindFramebuffer(e.FRAMEBUFFER,n),ea(a)?E.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,r.get(o).__webglTexture,0,er(a)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,r.get(o).__webglTexture,c),i.bindFramebuffer(e.FRAMEBUFFER,null)}function en(n,i,r){if(e.bindRenderbuffer(e.RENDERBUFFER,n),i.depthBuffer&&!i.stencilBuffer){let a=!0===u?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(r||ea(i)){let n=i.depthTexture;n&&n.isDepthTexture&&(1015===n.type?a=e.DEPTH_COMPONENT32F:1014===n.type&&(a=e.DEPTH_COMPONENT24));let r=er(i);ea(i)?E.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,a,i.width,i.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,a,i.width,i.height)}else e.renderbufferStorage(e.RENDERBUFFER,a,i.width,i.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n)}else if(i.depthBuffer&&i.stencilBuffer){let a=er(i);r&&!1===ea(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,a,e.DEPTH24_STENCIL8,i.width,i.height):ea(i)?E.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,a,e.DEPTH24_STENCIL8,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n)}else{let n=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let a=0;a0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function es(e,i){let r=e.colorSpace,a=e.format,s=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||1035===e.format||r!==R&&r!==w&&(eo.getTransfer(r)===O?!1===u?!0===n.has("EXT_sRGB")&&a===x?(e.format=1035,e.minFilter=v,e.generateMipmaps=!1):i=ec.sRGBToLinear(i):(a!==x||1009!==s)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",r)),i}this.allocateTextureUnit=function(){let e=j;return e>=c&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+c),j+=1,e},this.resetTextureUnits=function(){j=0},this.setTexture2D=q,this.setTexture2DArray=function(n,a){let s=r.get(n);if(n.version>0&&s.__version!==n.version){Q(s,n,a);return}i.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+a)},this.setTexture3D=function(n,a){let s=r.get(n);if(n.version>0&&s.__version!==n.version){Q(s,n,a);return}i.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(n,a){let o=r.get(n);if(n.version>0&&o.__version!==n.version){(function(n,a,o){if(6!==a.image.length)return;let l=$(n,a),c=a.source;i.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture,e.TEXTURE0+o);let h=r.get(c);if(c.version!==h.__version||!0===l){let n;i.activeTexture(e.TEXTURE0+o);let r=eo.getPrimaries(eo.workingColorSpace),d=a.colorSpace===w?null:eo.getPrimaries(a.colorSpace),p=a.colorSpace===w||r===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let f=a.isCompressedTexture||a.image[0].isCompressedTexture,m=a.image[0]&&a.image[0].isDataTexture,g=[];for(let e=0;e<6;e++)f||m?g[e]=m?a.image[e].image:a.image[e]:g[e]=D(a.image[e],!1,!0,b),g[e]=es(a,g[e]);let v=g[0],_=U(v)||u,y=s.convert(a.format,a.colorSpace),M=s.convert(a.type),S=z(a.internalFormat,y,M,a.colorSpace),E=u&&!0!==a.isVideoTexture,T=void 0===h.__version||!0===l,A=B(a,v,_);if(K(e.TEXTURE_CUBE_MAP,a,_),f){E&&T&&i.texStorage2D(e.TEXTURE_CUBE_MAP,A,S,v.width,v.height);for(let r=0;r<6;r++){n=g[r].mipmaps;for(let s=0;s0&&A++,i.texStorage2D(e.TEXTURE_CUBE_MAP,A,S,g[0].width,g[0].height));for(let r=0;r<6;r++)if(m){E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,0,0,g[r].width,g[r].height,y,M,g[r].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,S,g[r].width,g[r].height,0,y,M,g[r].data);for(let a=0;a0){c.__webglFramebuffer[n]=[];for(let i=0;i0){c.__webglFramebuffer=[];for(let n=0;n0&&!1===ea(n)){let r=p?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let i=0;i0)for(let r=0;r0)for(let i=0;i0&&!1===ea(n)){let a=n.isWebGLMultipleRenderTargets?n.texture:[n.texture],s=n.width,o=n.height,l=e.COLOR_BUFFER_BIT,u=[],c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=r.get(n),d=!0===n.isWebGLMultipleRenderTargets;if(d)for(let n=0;n.025?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&o<=.015&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==l&&e.gripSpace&&null!==(a=n.getPose(e.gripSpace,i))&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1);null!==o&&(null===(r=n.getPose(e.targetRaySpace,i))&&null!==a&&(r=a),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,this.dispatchEvent(rR)))}return null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),null!==u&&(u.visible=null!==s),this}_getHandJoint(e,n){if(void 0===e.joints[n.jointName]){let i=new rA;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}class rC extends em{constructor(e,n,i,r,a,s,o,l,u,c){if(1026!==(c=void 0!==c?c:1026)&&1027!==c)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&1026===c&&(i=1014),void 0===i&&1027===c&&(i=1020),super(null,r,a,s,o,l,c,i,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=void 0!==o?o:f,this.minFilter=void 0!==l?l:f,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let n=super.toJSON(e);return null!==this.compareFunction&&(n.compareFunction=this.compareFunction),n}}class rL extends U{constructor(e,n){super();let i=this,r=null,a=1,s=null,o="local-floor",l=1,u=null,c=null,h=null,d=null,p=null,f=null,m=n.getContextAttributes(),g=null,v=null,_=[],y=[],b=new nc;b.layers.enable(1),b.viewport=new eg;let M=new nc;M.layers.enable(2),M.viewport=new eg;let S=[b,M],E=new rw;E.layers.enable(1),E.layers.enable(2);let T=null,w=null;function A(e){let n=y.indexOf(e.inputSource);if(-1===n)return;let i=_[n];void 0!==i&&(i.update(e.inputSource,e.frame,u||s),i.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){r.removeEventListener("select",A),r.removeEventListener("selectstart",A),r.removeEventListener("selectend",A),r.removeEventListener("squeeze",A),r.removeEventListener("squeezestart",A),r.removeEventListener("squeezeend",A),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",P);for(let e=0;e<_.length;e++){let n=y[e];null!==n&&(y[e]=null,_[e].disconnect(n))}T=null,w=null,e.setRenderTarget(g),p=null,d=null,h=null,r=null,v=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function P(e){for(let n=0;n=0&&(y[r]=null,_[r].disconnect(i))}for(let n=0;n=y.length){y.push(i),r=e;break}if(null===y[e]){y[e]=i,r=e;break}}if(-1===r)break}let a=_[r];a&&a.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let n=_[e];return void 0===n&&(n=new rP,_[e]=n),n.getTargetRaySpace()},this.getControllerGrip=function(e){let n=_[e];return void 0===n&&(n=new rP,_[e]=n),n.getGripSpace()},this.getHand=function(e){let n=_[e];return void 0===n&&(n=new rP,_[e]=n),n.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(e){u=e},this.getBaseLayer=function(){return null!==d?d:p},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(c){if(null!==(r=c)){if(g=e.getRenderTarget(),r.addEventListener("select",A),r.addEventListener("selectstart",A),r.addEventListener("selectend",A),r.addEventListener("squeeze",A),r.addEventListener("squeezestart",A),r.addEventListener("squeezeend",A),r.addEventListener("end",R),r.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await n.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){let i={antialias:void 0!==r.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(r,n,i),r.updateRenderState({baseLayer:p}),v=new e_(p.framebufferWidth,p.framebufferHeight,{format:x,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let i=null,s=null,o=null;m.depth&&(o=m.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,i=m.stencil?1027:1026,s=m.stencil?1020:1014);let l={colorFormat:n.RGBA8,depthFormat:o,scaleFactor:a};d=(h=new XRWebGLBinding(r,n)).createProjectionLayer(l),r.updateRenderState({layers:[d]}),v=new e_(d.textureWidth,d.textureHeight,{format:x,type:1009,depthTexture:new rC(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let u=e.properties.get(v);u.__ignoreDepthValues=d.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(l),u=null,s=await r.requestReferenceSpace(o),D.setContext(r),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode};let C=new eb,L=new eb;function O(e,n){null===n?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(n.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;E.near=M.near=b.near=e.near,E.far=M.far=b.far=e.far,(T!==E.near||w!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,w=E.far);let n=e.parent,i=E.cameras;O(E,n);for(let e=0;e0&&(r.alphaTest.value=a.alphaTest);let s=n.get(a).envMap;if(s&&(r.envMap.value=s,r.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,r.reflectivity.value=a.reflectivity,r.ior.value=a.ior,r.refractionRatio.value=a.refractionRatio),a.lightMap){r.lightMap.value=a.lightMap;let n=!0===e._useLegacyLights?Math.PI:1;r.lightMapIntensity.value=a.lightMapIntensity*n,i(a.lightMap,r.lightMapTransform)}a.aoMap&&(r.aoMap.value=a.aoMap,r.aoMapIntensity.value=a.aoMapIntensity,i(a.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(n,i){i.color.getRGB(n.fogColor.value,ns(e)),i.isFog?(n.fogNear.value=i.near,n.fogFar.value=i.far):i.isFogExp2&&(n.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,a,s,o,l){a.isMeshBasicMaterial?r(e,a):a.isMeshLambertMaterial?r(e,a):a.isMeshToonMaterial?(r(e,a),a.gradientMap&&(e.gradientMap.value=a.gradientMap)):a.isMeshPhongMaterial?(r(e,a),e.specular.value.copy(a.specular),e.shininess.value=Math.max(a.shininess,1e-4)):a.isMeshStandardMaterial?(r(e,a),function(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,i(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,i(r.roughnessMap,e.roughnessMapTransform));let a=n.get(r).envMap;a&&(e.envMapIntensity.value=r.envMapIntensity)}(e,a),a.isMeshPhysicalMaterial&&(e.ior.value=a.ior,a.sheen>0&&(e.sheenColor.value.copy(a.sheenColor).multiplyScalar(a.sheen),e.sheenRoughness.value=a.sheenRoughness,a.sheenColorMap&&(e.sheenColorMap.value=a.sheenColorMap,i(a.sheenColorMap,e.sheenColorMapTransform)),a.sheenRoughnessMap&&(e.sheenRoughnessMap.value=a.sheenRoughnessMap,i(a.sheenRoughnessMap,e.sheenRoughnessMapTransform))),a.clearcoat>0&&(e.clearcoat.value=a.clearcoat,e.clearcoatRoughness.value=a.clearcoatRoughness,a.clearcoatMap&&(e.clearcoatMap.value=a.clearcoatMap,i(a.clearcoatMap,e.clearcoatMapTransform)),a.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=a.clearcoatRoughnessMap,i(a.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),a.clearcoatNormalMap&&(e.clearcoatNormalMap.value=a.clearcoatNormalMap,i(a.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(a.clearcoatNormalScale),1===a.side&&e.clearcoatNormalScale.value.negate())),a.iridescence>0&&(e.iridescence.value=a.iridescence,e.iridescenceIOR.value=a.iridescenceIOR,e.iridescenceThicknessMinimum.value=a.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=a.iridescenceThicknessRange[1],a.iridescenceMap&&(e.iridescenceMap.value=a.iridescenceMap,i(a.iridescenceMap,e.iridescenceMapTransform)),a.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=a.iridescenceThicknessMap,i(a.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),a.transmission>0&&(e.transmission.value=a.transmission,e.transmissionSamplerMap.value=l.texture,e.transmissionSamplerSize.value.set(l.width,l.height),a.transmissionMap&&(e.transmissionMap.value=a.transmissionMap,i(a.transmissionMap,e.transmissionMapTransform)),e.thickness.value=a.thickness,a.thicknessMap&&(e.thicknessMap.value=a.thicknessMap,i(a.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=a.attenuationDistance,e.attenuationColor.value.copy(a.attenuationColor)),a.anisotropy>0&&(e.anisotropyVector.value.set(a.anisotropy*Math.cos(a.anisotropyRotation),a.anisotropy*Math.sin(a.anisotropyRotation)),a.anisotropyMap&&(e.anisotropyMap.value=a.anisotropyMap,i(a.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=a.specularIntensity,e.specularColor.value.copy(a.specularColor),a.specularColorMap&&(e.specularColorMap.value=a.specularColorMap,i(a.specularColorMap,e.specularColorMapTransform)),a.specularIntensityMap&&(e.specularIntensityMap.value=a.specularIntensityMap,i(a.specularIntensityMap,e.specularIntensityMapTransform)))):a.isMeshMatcapMaterial?(r(e,a),a.matcap&&(e.matcap.value=a.matcap)):a.isMeshDepthMaterial?r(e,a):a.isMeshDistanceMaterial?(r(e,a),function(e,i){let r=n.get(i).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,a)):a.isMeshNormalMaterial?r(e,a):a.isLineBasicMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,a.map&&(e.map.value=a.map,i(a.map,e.mapTransform)),a.isLineDashedMaterial&&(e.dashSize.value=a.dashSize,e.totalSize.value=a.dashSize+a.gapSize,e.scale.value=a.scale)):a.isPointsMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,e.size.value=a.size*s,e.scale.value=.5*o,a.map&&(e.map.value=a.map,i(a.map,e.uvTransform)),a.alphaMap&&(e.alphaMap.value=a.alphaMap,i(a.alphaMap,e.alphaMapTransform)),a.alphaTest>0&&(e.alphaTest.value=a.alphaTest)):a.isSpriteMaterial?(e.diffuse.value.copy(a.color),e.opacity.value=a.opacity,e.rotation.value=a.rotation,a.map&&(e.map.value=a.map,i(a.map,e.mapTransform)),a.alphaMap&&(e.alphaMap.value=a.alphaMap,i(a.alphaMap,e.alphaMapTransform)),a.alphaTest>0&&(e.alphaTest.value=a.alphaTest)):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}function rI(e,n,i,r){let a={},s={},o=[],l=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(e){let n={boundary:0,storage:0};return"number"==typeof e?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=48,n.storage=48):e.isMatrix4?(n.boundary=64,n.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),n}function c(n){let i=n.target;i.removeEventListener("dispose",c);let r=o.indexOf(i.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(a[i.id]),delete a[i.id],delete s[i.id]}return{bind:function(e,n){let i=n.program;r.uniformBlockBinding(e,i)},update:function(i,h){let d=a[i.id];void 0===d&&(function(e){let n=e.uniforms,i=0,r=0;for(let e=0,a=n.length;e0){r=i%16;let e=16-r;0!==r&&e-s.boundary<0&&(i+=16-r,a.__offset=i)}i+=s.storage}(r=i%16)>0&&(i+=16-r),e.__size=i,e.__cache={}}(i),d=function(n){let i=function(){for(let e=0;el.matrixWorld.determinant(),_=function(e,n,i,s,l){var u;!0!==n.isScene&&(n=eR),c.resetTextureUnits();let p=n.fog,f=s.isMeshStandardMaterial?n.environment:null,m=null===en?K.outputColorSpace:!0===en.isXRRenderTarget?en.texture.colorSpace:R,g=(s.isMeshStandardMaterial?d:h).get(s.envMap||f),_=!0===s.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,y=!!i.attributes.tangent&&(!!s.normalMap||s.anisotropy>0),x=!!i.morphAttributes.position,b=!!i.morphAttributes.normal,S=!!i.morphAttributes.color,E=0;s.toneMapped&&(null===en||!0===en.isXRRenderTarget)&&(E=K.toneMapping);let w=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,A=void 0!==w?w.length:0,P=o.get(s),C=q.state.lights;if(!0===eM&&(!0===eS||e!==er)){let n=e===er&&s.id===ei;M.setState(s,e,n)}let L=!1;s.version===P.__version?P.needsLights&&P.lightsStateVersion!==C.state.version?L=!0:P.outputColorSpace!==m?L=!0:l.isInstancedMesh&&!1===P.instancing?L=!0:l.isInstancedMesh||!0!==P.instancing?l.isSkinnedMesh&&!1===P.skinning?L=!0:l.isSkinnedMesh||!0!==P.skinning?l.isInstancedMesh&&!0===P.instancingColor&&null===l.instanceColor?L=!0:l.isInstancedMesh&&!1===P.instancingColor&&null!==l.instanceColor?L=!0:P.envMap!==g?L=!0:!0===s.fog&&P.fog!==p?L=!0:void 0!==P.numClippingPlanes&&(P.numClippingPlanes!==M.numPlanes||P.numIntersection!==M.numIntersection)?L=!0:P.vertexAlphas!==_?L=!0:P.vertexTangents!==y?L=!0:P.morphTargets!==x?L=!0:P.morphNormals!==b?L=!0:P.morphColors!==S?L=!0:P.toneMapping!==E?L=!0:!0===r.isWebGL2&&P.morphTargetsCount!==A&&(L=!0):L=!0:L=!0:(L=!0,P.__version=s.version);let I=P.currentProgram;!0===L&&(I=eX(s,n,l));let D=!1,U=!1,N=!1,F=I.getUniforms(),z=P.uniforms;if(a.useProgram(I.program)&&(D=!0,U=!0,N=!0),s.id!==ei&&(ei=s.id,U=!0),D||er!==e){F.setValue(eC,"projectionMatrix",e.projectionMatrix),F.setValue(eC,"viewMatrix",e.matrixWorldInverse);let n=F.map.cameraPosition;void 0!==n&&n.setValue(eC,eA.setFromMatrixPosition(e.matrixWorld)),r.logarithmicDepthBuffer&&F.setValue(eC,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(s.isMeshPhongMaterial||s.isMeshToonMaterial||s.isMeshLambertMaterial||s.isMeshBasicMaterial||s.isMeshStandardMaterial||s.isShaderMaterial)&&F.setValue(eC,"isOrthographic",!0===e.isOrthographicCamera),er!==e&&(er=e,U=!0,N=!0)}if(l.isSkinnedMesh){F.setOptional(eC,l,"bindMatrix"),F.setOptional(eC,l,"bindMatrixInverse");let e=l.skeleton;e&&(r.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),F.setValue(eC,"boneTexture",e.boneTexture,c),F.setValue(eC,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let B=i.morphAttributes;if((void 0!==B.position||void 0!==B.normal||void 0!==B.color&&!0===r.isWebGL2)&&T.update(l,i,I),(U||P.receiveShadow!==l.receiveShadow)&&(P.receiveShadow=l.receiveShadow,F.setValue(eC,"receiveShadow",l.receiveShadow)),s.isMeshGouraudMaterial&&null!==s.envMap&&(z.envMap.value=g,z.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1),U&&(F.setValue(eC,"toneMappingExposure",K.toneMappingExposure),P.needsLights&&(u=N,z.ambientLightColor.needsUpdate=u,z.lightProbe.needsUpdate=u,z.directionalLights.needsUpdate=u,z.directionalLightShadows.needsUpdate=u,z.pointLights.needsUpdate=u,z.pointLightShadows.needsUpdate=u,z.spotLights.needsUpdate=u,z.spotLightShadows.needsUpdate=u,z.rectAreaLights.needsUpdate=u,z.hemisphereLights.needsUpdate=u),p&&!0===s.fog&&v.refreshFogUniforms(z,p),v.refreshMaterialUniforms(z,s,ed,eh,eE),iQ.upload(eC,eq(P),z,c)),s.isShaderMaterial&&!0===s.uniformsNeedUpdate&&(iQ.upload(eC,eq(P),z,c),s.uniformsNeedUpdate=!1),s.isSpriteMaterial&&F.setValue(eC,"center",l.center),F.setValue(eC,"modelViewMatrix",l.modelViewMatrix),F.setValue(eC,"normalMatrix",l.normalMatrix),F.setValue(eC,"modelMatrix",l.matrixWorld),s.isShaderMaterial||s.isRawShaderMaterial){let e=s.uniformsGroups;for(let n=0,i=e.length;n{function r(){if(a.forEach(function(e){let n=o.get(e),i=n.currentProgram;i.isReady()&&a.delete(e)}),0===a.size){n(e);return}setTimeout(r,10)}null!==i.get("KHR_parallel_shader_compile")?r():setTimeout(r,10)})};let eB=null;function ek(){eV.stop()}function eH(){eV.start()}let eV=new nb;function eG(e,n,s,o){let l=e.opaque,h=e.transmissive,d=e.transparent;q.setupLightsView(s),!0===eM&&M.setGlobalState(K.clippingPlanes,s),h.length>0&&function(e,n,a,s){let o=!0===a.isScene?a.overrideMaterial:null;if(null!==o)return;let l=r.isWebGL2;null===eE&&(eE=new e_(1,1,{generateMipmaps:!0,type:i.has("EXT_color_buffer_half_float")?1016:1009,minFilter:y,samples:l?4:0})),K.getDrawingBufferSize(ew),l?eE.setSize(ew.x,ew.y):eE.setSize(X(ew.x),X(ew.y));let h=K.getRenderTarget();K.setRenderTarget(eE),K.getClearColor(el),(eu=K.getClearAlpha())<1&&K.setClearColor(16777215,.5),K.clear();let d=K.toneMapping;K.toneMapping=0,eW(e,a,s),c.updateMultisampleRenderTarget(eE),c.updateRenderTargetMipmap(eE);let p=!1;for(let e=0,i=n.length;e0&&eW(l,n,s),h.length>0&&eW(h,n,s),d.length>0&&eW(d,n,s),a.buffers.depth.setTest(!0),a.buffers.depth.setMask(!0),a.buffers.color.setMask(!0),a.setPolygonOffset(!1)}function eW(e,n,i){let r=!0===n.isScene?n.overrideMaterial:null;for(let a=0,s=e.length;a0?J[J.length-1]:null,Y.pop(),j=Y.length>0?Y[Y.length-1]:null},this.getActiveCubeFace=function(){return Q},this.getActiveMipmapLevel=function(){return et},this.getRenderTarget=function(){return en},this.setRenderTargetTextures=function(e,n,r){o.get(e.texture).__webglTexture=n,o.get(e.depthTexture).__webglTexture=r;let a=o.get(e);a.__hasExternalTextures=!0,a.__hasExternalTextures&&(a.__autoAllocateDepthBuffer=void 0===r,a.__autoAllocateDepthBuffer||!0!==i.has("WEBGL_multisampled_render_to_texture")||(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),a.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,n){let i=o.get(e);i.__webglFramebuffer=n,i.__useDefaultFramebuffer=void 0===n},this.setRenderTarget=function(e,n=0,i=0){en=e,Q=n,et=i;let s=!0,l=null,u=!1,h=!1;if(e){let d=o.get(e);void 0!==d.__useDefaultFramebuffer?(a.bindFramebuffer(eC.FRAMEBUFFER,null),s=!1):void 0===d.__webglFramebuffer?c.setupRenderTarget(e):d.__hasExternalTextures&&c.rebindTextures(e,o.get(e.texture).__webglTexture,o.get(e.depthTexture).__webglTexture);let p=e.texture;(p.isData3DTexture||p.isDataArrayTexture||p.isCompressedArrayTexture)&&(h=!0);let f=o.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(l=Array.isArray(f[n])?f[n][i]:f[n],u=!0):l=r.isWebGL2&&e.samples>0&&!1===c.useMultisampledRTT(e)?o.get(e).__webglMultisampledFramebuffer:Array.isArray(f)?f[i]:f,ea.copy(e.viewport),es.copy(e.scissor),eo=e.scissorTest}else ea.copy(em).multiplyScalar(ed).floor(),es.copy(ev).multiplyScalar(ed).floor(),eo=ey;let d=a.bindFramebuffer(eC.FRAMEBUFFER,l);if(d&&r.drawBuffers&&s&&a.drawBuffers(e,l),a.viewport(ea),a.scissor(es),a.setScissorTest(eo),u){let r=o.get(e.texture);eC.framebufferTexture2D(eC.FRAMEBUFFER,eC.COLOR_ATTACHMENT0,eC.TEXTURE_CUBE_MAP_POSITIVE_X+n,r.__webglTexture,i)}else if(h){let r=o.get(e.texture),a=n||0;eC.framebufferTextureLayer(eC.FRAMEBUFFER,eC.COLOR_ATTACHMENT0,r.__webglTexture,i||0,a)}ei=-1},this.readRenderTargetPixels=function(e,n,s,l,u,c,h){if(!(e&&e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let d=o.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==h&&(d=d[h]),d){a.bindFramebuffer(eC.FRAMEBUFFER,d);try{let a=e.texture,o=a.format,h=a.type;if(o!==x&&C.convert(o)!==eC.getParameter(eC.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let d=1016===h&&(i.has("EXT_color_buffer_half_float")||r.isWebGL2&&i.has("EXT_color_buffer_float"));if(1009!==h&&C.convert(h)!==eC.getParameter(eC.IMPLEMENTATION_COLOR_READ_TYPE)&&!(1015===h&&(r.isWebGL2||i.has("OES_texture_float")||i.has("WEBGL_color_buffer_float")))&&!d){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}n>=0&&n<=e.width-l&&s>=0&&s<=e.height-u&&eC.readPixels(n,s,l,u,C.convert(o),C.convert(h),c)}finally{let e=null!==en?o.get(en).__webglFramebuffer:null;a.bindFramebuffer(eC.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,n,i=0){let r=Math.pow(2,-i),s=Math.floor(n.image.width*r),o=Math.floor(n.image.height*r);c.setTexture2D(n,0),eC.copyTexSubImage2D(eC.TEXTURE_2D,i,0,0,e.x,e.y,s,o),a.unbindTexture()},this.copyTextureToTexture=function(e,n,i,r=0){let s=n.image.width,o=n.image.height,l=C.convert(i.format),u=C.convert(i.type);c.setTexture2D(i,0),eC.pixelStorei(eC.UNPACK_FLIP_Y_WEBGL,i.flipY),eC.pixelStorei(eC.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),eC.pixelStorei(eC.UNPACK_ALIGNMENT,i.unpackAlignment),n.isDataTexture?eC.texSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,s,o,l,u,n.image.data):n.isCompressedTexture?eC.compressedTexSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,n.mipmaps[0].width,n.mipmaps[0].height,l,n.mipmaps[0].data):eC.texSubImage2D(eC.TEXTURE_2D,r,e.x,e.y,l,u,n.image),0===r&&i.generateMipmaps&&eC.generateMipmap(eC.TEXTURE_2D),a.unbindTexture()},this.copyTextureToTexture3D=function(e,n,i,r,s=0){let o;if(K.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let l=e.max.x-e.min.x+1,u=e.max.y-e.min.y+1,h=e.max.z-e.min.z+1,d=C.convert(r.format),p=C.convert(r.type);if(r.isData3DTexture)c.setTexture3D(r,0),o=eC.TEXTURE_3D;else if(r.isDataArrayTexture)c.setTexture2DArray(r,0),o=eC.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}eC.pixelStorei(eC.UNPACK_FLIP_Y_WEBGL,r.flipY),eC.pixelStorei(eC.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),eC.pixelStorei(eC.UNPACK_ALIGNMENT,r.unpackAlignment);let f=eC.getParameter(eC.UNPACK_ROW_LENGTH),m=eC.getParameter(eC.UNPACK_IMAGE_HEIGHT),g=eC.getParameter(eC.UNPACK_SKIP_PIXELS),v=eC.getParameter(eC.UNPACK_SKIP_ROWS),_=eC.getParameter(eC.UNPACK_SKIP_IMAGES),y=i.isCompressedTexture?i.mipmaps[0]:i.image;eC.pixelStorei(eC.UNPACK_ROW_LENGTH,y.width),eC.pixelStorei(eC.UNPACK_IMAGE_HEIGHT,y.height),eC.pixelStorei(eC.UNPACK_SKIP_PIXELS,e.min.x),eC.pixelStorei(eC.UNPACK_SKIP_ROWS,e.min.y),eC.pixelStorei(eC.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?eC.texSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,p,y.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),eC.compressedTexSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,y.data)):eC.texSubImage3D(o,s,n.x,n.y,n.z,l,u,h,d,p,y),eC.pixelStorei(eC.UNPACK_ROW_LENGTH,f),eC.pixelStorei(eC.UNPACK_IMAGE_HEIGHT,m),eC.pixelStorei(eC.UNPACK_SKIP_PIXELS,g),eC.pixelStorei(eC.UNPACK_SKIP_ROWS,v),eC.pixelStorei(eC.UNPACK_SKIP_IMAGES,_),0===s&&r.generateMipmaps&&eC.generateMipmap(o),a.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?c.setTextureCube(e,0):e.isData3DTexture?c.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?c.setTexture2DArray(e,0):c.setTexture2D(e,0),a.unbindTexture()},this.resetState=function(){Q=0,et=0,en=null,a.reset(),L.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let n=this.getContext();n.drawingBufferColorSpace=e===P?"display-p3":"srgb",n.unpackColorSpace=eo.workingColorSpace===C?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===A?3001:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=3001===e?A:R}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}(class extends rD{}).prototype.isWebGL1Renderer=!0;class rU extends td{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let n=super.toJSON(e);return null!==this.fog&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class rN{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=void 0!==e?e.length/n:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=k()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,i){e*=this.stride,i*=n.stride;for(let r=0,a=this.stride;rl)continue;d.applyMatrix4(this.matrixWorld);let o=e.ray.origin.distanceTo(d);oe.far||n.push({distance:o,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}else{let i=Math.max(0,s.start),r=Math.min(g.count,s.start+s.count);for(let a=i,s=r-1;al)continue;d.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(d);re.far||n.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry,n=e.morphAttributes,i=Object.keys(n);if(i.length>0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;n0){let e=n[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,i=e.length;na.far)return;s.push({distance:u,distanceToRay:Math.sqrt(l),point:i,index:n,face:null,object:o})}}class av extends em{constructor(e,n,i,r,a,s,o,l,u,c,h,d){super(null,s,o,l,u,c,r,a,h,d),this.isCompressedTexture=!0,this.image={width:n,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class a_{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,n){let i=this.getUtoTmapping(e);return this.getPoint(i,n)}getPoints(e=5){let n=[];for(let i=0;i<=e;i++)n.push(this.getPoint(i/e));return n}getSpacedPoints(e=5){let n=[];for(let i=0;i<=e;i++)n.push(this.getPointAt(i/e));return n}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let n=[],i,r=this.getPoint(0),a=0;n.push(0);for(let s=1;s<=e;s++)n.push(a+=(i=this.getPoint(s/e)).distanceTo(r)),r=i;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,n){let i;let r=this.getLengths(),a=0,s=r.length;i=n||e*r[s-1];let o=0,l=s-1,u;for(;o<=l;)if((u=r[a=Math.floor(o+(l-o)/2)]-i)<0)o=a+1;else if(u>0)l=a-1;else{l=a;break}if(r[a=l]===i)return a/(s-1);let c=r[a],h=r[a+1],d=(a+(i-c)/(h-c))/(s-1);return d}getTangent(e,n){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),o=n||(a.isVector2?new Z:new eb);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,n){let i=this.getUtoTmapping(e);return this.getTangent(i,n)}computeFrenetFrames(e,n){let i=new eb,r=[],a=[],s=[],o=new eb,l=new eK;for(let n=0;n<=e;n++){let i=n/e;r[n]=this.getTangentAt(i,new eb)}a[0]=new eb,s[0]=new eb;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=u&&(u=c,i.set(1,0,0)),h<=u&&(u=h,i.set(0,1,0)),d<=u&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let n=1;n<=e;n++){if(a[n]=a[n-1].clone(),s[n]=s[n-1].clone(),o.crossVectors(r[n-1],r[n]),o.length()>Number.EPSILON){o.normalize();let e=Math.acos(H(r[n-1].dot(r[n]),-1,1));a[n].applyMatrix4(l.makeRotationAxis(o,e))}s[n].crossVectors(r[n],a[n])}if(!0===n){let n=Math.acos(H(a[0].dot(a[e]),-1,1));n/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(n=-n);for(let i=1;i<=e;i++)a[i].applyMatrix4(l.makeRotationAxis(r[i],n*i)),s[i].crossVectors(r[i],a[i])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ay extends a_{constructor(e=0,n=0,i=1,r=1,a=0,s=2*Math.PI,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=n,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=l}getPoint(e,n){let i=n||new Z,r=2*Math.PI,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)r;)a-=r;ai.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(aT(s,o.x,l.x,u.x,c.x),aT(s,o.y,l.y,u.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let n=0,i=e.points.length;n0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===u&&l===s-1&&(l=s-2,u=1),this.closed||l>0?i=a[(l-1)%s]:(ab.subVectors(a[0],a[1]).add(a[0]),i=ab);let c=a[l%s],h=a[(l+1)%s];if(this.closed||l+2=i){let e=r[a]-i,s=this.curves[a],o=s.getLength(),l=0===o?0:1-e/o;return s.getPointAt(l,n)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],n=0;for(let i=0,r=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(e){super.copy(e),this.curves=[];for(let n=0,i=e.curves.length;n0){let e=u.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class aN extends tq{constructor(e=[new Z(0,-.5),new Z(.5,0),new Z(0,.5)],n=12,i=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:n,phiStart:i,phiLength:r},n=Math.floor(n),r=H(r,0,2*Math.PI);let a=[],s=[],o=[],l=[],u=[],c=1/n,h=new eb,d=new Z,p=new eb,f=new eb,m=new eb,g=0,v=0;for(let n=0;n<=e.length-1;n++)switch(n){case 0:g=e[n+1].x-e[n].x,v=e[n+1].y-e[n].y,p.x=1*v,p.y=-g,p.z=0*v,m.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(m.x,m.y,m.z);break;default:g=e[n+1].x-e[n].x,v=e[n+1].y-e[n].y,p.x=1*v,p.y=-g,p.z=0*v,f.copy(p),p.x+=m.x,p.y+=m.y,p.z+=m.z,p.normalize(),l.push(p.x,p.y,p.z),m.copy(f)}for(let a=0;a<=n;a++){let p=i+a*c*r,f=Math.sin(p),m=Math.cos(p);for(let i=0;i<=e.length-1;i++){h.x=e[i].x*f,h.y=e[i].y,h.z=e[i].x*m,s.push(h.x,h.y,h.z),d.x=a/n,d.y=i/(e.length-1),o.push(d.x,d.y);let r=l[3*i+0]*f,c=l[3*i+1],p=l[3*i+0]*m;u.push(r,c,p)}}for(let i=0;i0&&_(!0),n>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new tB(h,3)),this.setAttribute("normal",new tB(d,3)),this.setAttribute("uv",new tB(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aB(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ak extends aB{constructor(e=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(0,e,n,i,r,a,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o}}static fromJSON(e){return new ak(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class aH extends tq{constructor(e=[],n=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:n,radius:i,detail:r};let a=[],s=[];function o(e){a.push(e.x,e.y,e.z)}function l(n,i){let r=3*n;i.x=e[r+0],i.y=e[r+1],i.z=e[r+2]}function u(e,n,i,r){r<0&&1===e.x&&(s[n]=e.x-1),0===i.x&&0===i.z&&(s[n]=r/2/Math.PI+.5)}function c(e){return Math.atan2(e.z,-e.x)}(function(e){let i=new eb,r=new eb,a=new eb;for(let s=0;s.9&&o<.1&&(n<.2&&(s[e+0]+=1),i<.2&&(s[e+2]+=1),r<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new tB(a,3)),this.setAttribute("normal",new tB(a.slice(),3)),this.setAttribute("uv",new tB(s,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aH(e.vertices,e.indices,e.radius,e.details)}}class aV extends aH{constructor(e=1,n=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];super(a,[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],e,n),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new aV(e.radius,e.detail)}}class aG extends aU{constructor(e){super(e),this.uuid=k(),this.type="Shape",this.holes=[]}getPointsHoles(e){let n=[];for(let i=0,r=this.holes.length;i=i.next.y&&i.next.y!==i.y){let e=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,a=i.x=i.x&&i.x>=u&&s!==i.x&&aJ(oa.x||i.x===a.x&&(p=a,f=i,0>aZ(p.prev,p,f.prev)&&0>aZ(f.next,p,p.next))))&&(a=i,h=d)),i=i.next}while(i!==l)return a}(e,n);if(!i)return n;let r=a2(i,e);return aX(r,r.next),aX(i,i.next)}(c[a],i);return i}(e,n,p,i)),e.length>80*i){r=s=e[0],a=o=e[1];for(let n=i;ns&&(s=l),u>o&&(o=u);c=0!==(c=Math.max(s-r,o-a))?32767/c:0}return function e(n,i,r,a,s,o,l){if(!n)return;!l&&o&&function(e,n,i,r){let a=e;do 0===a.z&&(a.z=aY(a.x,a.y,n,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e)a.prevZ.nextZ=null,a.prevZ=null,function(e){let n,i,r,a,s,o,l,u,c=1;do{for(i=e,e=null,s=null,o=0;i;){for(o++,r=i,l=0,n=0;n0||u>0&&r;)0!==l&&(0===u||!r||i.z<=r.z)?(a=i,i=i.nextZ,l--):(a=r,r=r.nextZ,u--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,c*=2}while(o>1)}(a)}(n,a,s,o);let u=n,c,h;for(;n.prev!==n.next;){if(c=n.prev,h=n.next,o?function(e,n,i,r){let a=e.prev,s=e.next;if(aZ(a,e,s)>=0)return!1;let o=a.x,l=e.x,u=s.x,c=a.y,h=e.y,d=s.y,p=ol?o>u?o:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,v=aY(p,f,n,i,r),_=aY(m,g,n,i,r),y=e.prevZ,x=e.nextZ;for(;y&&y.z>=v&&x&&x.z<=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==a&&y!==s&&aJ(o,c,l,h,u,d,y.x,y.y)&&aZ(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==a&&x!==s&&aJ(o,c,l,h,u,d,x.x,x.y)&&aZ(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==a&&y!==s&&aJ(o,c,l,h,u,d,y.x,y.y)&&aZ(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==a&&x!==s&&aJ(o,c,l,h,u,d,x.x,x.y)&&aZ(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}(n,a,s,o):function(e){let n=e.prev,i=e.next;if(aZ(n,e,i)>=0)return!1;let r=n.x,a=e.x,s=i.x,o=n.y,l=e.y,u=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>u?o:u:l>u?l:u,f=i.next;for(;f!==n;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&aJ(r,o,a,l,s,u,f.x,f.y)&&aZ(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}(n)){i.push(c.i/r|0),i.push(n.i/r|0),i.push(h.i/r|0),a4(n),n=h.next,u=h.next;continue}if((n=h)===u){l?1===l?e(n=function(e,n,i){let r=e;do{let a=r.prev,s=r.next.next;!aK(a,s)&&a$(a,r,r.next,s)&&a1(a,s)&&a1(s,a)&&(n.push(a.i/i|0),n.push(r.i/i|0),n.push(s.i/i|0),a4(r),a4(r.next),r=e=s),r=r.next}while(r!==e)return aX(r)}(aX(n),i,r),i,r,a,s,o,2):2===l&&function(n,i,r,a,s,o){let l=n;do{let n=l.next.next;for(;n!==l.prev;){var u,c;if(l.i!==n.i&&(u=l,c=n,u.next.i!==c.i&&u.prev.i!==c.i&&!function(e,n){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==n.i&&i.next.i!==n.i&&a$(i,i.next,e,n))return!0;i=i.next}while(i!==e)return!1}(u,c)&&(a1(u,c)&&a1(c,u)&&function(e,n){let i=e,r=!1,a=(e.x+n.x)/2,s=(e.y+n.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e)return r}(u,c)&&(aZ(u.prev,u,c.prev)||aZ(u,c.prev,c))||aK(u,c)&&aZ(u.prev,u,u.next)>0&&aZ(c.prev,c,c.next)>0))){let u=a2(l,n);l=aX(l,l.next),u=aX(u,u.next),e(l,i,r,a,s,o,0),e(u,i,r,a,s,o,0);return}n=n.next}l=l.next}while(l!==n)}(n,i,r,a,s,o):e(aX(n),i,r,a,s,o,1);break}}}(p,f,i,r,a,c,0),f}};function aj(e,n,i,r,a){let s,o;if(a===function(e,n,i,r){let a=0;for(let s=n,o=i-r;s0)for(s=n;s=n;s-=r)o=a3(s,e[s],e[s+1],o);return o&&aK(o,o.next)&&(a4(o),o=o.next),o}function aX(e,n){if(!e)return e;n||(n=e);let i=e,r;do if(r=!1,!i.steiner&&(aK(i,i.next)||0===aZ(i.prev,i,i.next))){if(a4(i),(i=n=i.prev)===i.next)break;r=!0}else i=i.next;while(r||i!==n)return n}function aq(e,n){return e.x-n.x}function aY(e,n,i,r,a){return(e=((e=((e=((e=((e=(e-i)*a|0)|e<<8)&16711935)|e<<4)&252645135)|e<<2)&858993459)|e<<1)&1431655765)|(n=((n=((n=((n=((n=(n-r)*a|0)|n<<8)&16711935)|n<<4)&252645135)|n<<2)&858993459)|n<<1)&1431655765)<<1}function aJ(e,n,i,r,a,s,o,l){return(a-o)*(n-l)>=(e-o)*(s-l)&&(e-o)*(r-l)>=(i-o)*(n-l)&&(i-o)*(s-l)>=(a-o)*(r-l)}function aZ(e,n,i){return(n.y-e.y)*(i.x-n.x)-(n.x-e.x)*(i.y-n.y)}function aK(e,n){return e.x===n.x&&e.y===n.y}function a$(e,n,i,r){let a=a0(aZ(e,n,i)),s=a0(aZ(e,n,r)),o=a0(aZ(i,r,e)),l=a0(aZ(i,r,n));return!!(a!==s&&o!==l||0===a&&aQ(e,i,n)||0===s&&aQ(e,r,n)||0===o&&aQ(i,e,r)||0===l&&aQ(i,n,r))}function aQ(e,n,i){return n.x<=Math.max(e.x,i.x)&&n.x>=Math.min(e.x,i.x)&&n.y<=Math.max(e.y,i.y)&&n.y>=Math.min(e.y,i.y)}function a0(e){return e>0?1:e<0?-1:0}function a1(e,n){return 0>aZ(e.prev,e,e.next)?aZ(e,n,e.next)>=0&&aZ(e,e.prev,n)>=0:0>aZ(e,n,e.prev)||0>aZ(e,e.next,n)}function a2(e,n){let i=new a5(e.i,e.x,e.y),r=new a5(n.i,n.x,n.y),a=e.next,s=n.prev;return e.next=n,n.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function a3(e,n,i,r){let a=new a5(e,n,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function a4(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function a5(e,n,i){this.i=e,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class a6{static area(e){let n=e.length,i=0;for(let r=n-1,a=0;aa6.area(e)}static triangulateShape(e,n){let i=[],r=[],a=[];a7(e),a8(i,e);let s=e.length;n.forEach(a7);for(let e=0;e2&&e[n-1].equals(e[0])&&e.pop()}function a8(e,n){for(let i=0;iNumber.EPSILON){let d=Math.sqrt(h),p=Math.sqrt(u*u+c*c),f=n.x-l/d,m=n.y+o/d,g=i.x-c/p,v=i.y+u/p,_=((g-f)*c-(v-m)*u)/(o*c-l*u);r=f+o*_-e.x,a=m+l*_-e.y;let y=r*r+a*a;if(y<=2)return new Z(r,a);s=Math.sqrt(y/2)}else{let e=!1;o>Number.EPSILON?u>Number.EPSILON&&(e=!0):o<-Number.EPSILON?u<-Number.EPSILON&&(e=!0):Math.sign(l)===Math.sign(c)&&(e=!0),e?(r=-l,a=o,s=Math.sqrt(h)):(r=o,a=l,s=Math.sqrt(h/2))}return new Z(r/s,a/s)}let I=[];for(let e=0,n=R.length,i=n-1,r=e+1;e=0;e--){let n=e/_,i=m*Math.cos(n*Math.PI/2),r=g*Math.sin(n*Math.PI/2)+v;for(let e=0,n=R.length;e=0;){let s=a,o=a-1;o<0&&(o=e.length-1);for(let e=0,a=d+2*_;e0)&&p.push(n,a,u),(e!==i-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class sd extends tO{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new tP(16777215),this.specular=new tP(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tP(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function sp(e,n,i){return e&&(i||e.constructor!==n)?"number"==typeof n.BYTES_PER_ELEMENT?new n(e):Array.prototype.slice.call(e):e}function sf(e,n,i){let r=e.length,a=new e.constructor(r);for(let s=0,o=0;o!==r;++s){let r=i[s]*n;for(let i=0;i!==n;++i)a[o++]=e[r+i]}return a}function sm(e,n,i,r){let a=1,s=e[0];for(;void 0!==s&&void 0===s[r];)s=e[a++];if(void 0===s)return;let o=s[r];if(void 0!==o){if(Array.isArray(o))do void 0!==(o=s[r])&&(n.push(s.time),i.push.apply(i,o)),s=e[a++];while(void 0!==s)else if(void 0!==o.toArray)do void 0!==(o=s[r])&&(n.push(s.time),o.toArray(i,i.length)),s=e[a++];while(void 0!==s)else do void 0!==(o=s[r])&&(n.push(s.time),i.push(o)),s=e[a++];while(void 0!==s)}}class sg{constructor(e,n,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let n=this.parameterPositions,i=this._cachedIndex,r=n[i],a=n[i-1];e:{t:{let s;n:{i:if(!(e=a)){let o=n[1];e=(a=n[--i-1]))break t}s=i,i=0;break n}break e}for(;i>>1;en;)--s;if(++s,0!==a||s!==r){a>=s&&(a=(s=Math.max(s,1))-1);let e=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*e,s*e)}return this}validate(){let e=!0,n=this.getValueSize();n-Math.floor(n)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;0===a&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let r=i[n];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,r),e=!1;break}if(null!==s&&s>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,r,s),e=!1;break}s=r}if(void 0!==r&&ArrayBuffer.isView(r)&&!(r instanceof DataView))for(let n=0,i=r.length;n!==i;++n){let i=r[n];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,i),e=!1;break}}return e}optimize(){let e=this.times.slice(),n=this.values.slice(),i=this.getValueSize(),r=2302===this.getInterpolation(),a=e.length-1,s=1;for(let o=1;o0){e[s]=e[a];for(let e=a*i,r=s*i,o=0;o!==i;++o)n[r+o]=n[e+o];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=n.slice(0,s*i)):(this.times=e,this.values=n),this}clone(){let e=this.times.slice(),n=this.values.slice(),i=this.constructor,r=new i(this.name,e,n);return r.createInterpolant=this.createInterpolant,r}}sx.prototype.TimeBufferType=Float32Array,sx.prototype.ValueBufferType=Float32Array,sx.prototype.DefaultInterpolation=M;class sb extends sx{}sb.prototype.ValueTypeName="bool",sb.prototype.ValueBufferType=Array,sb.prototype.DefaultInterpolation=b,sb.prototype.InterpolantFactoryMethodLinear=void 0,sb.prototype.InterpolantFactoryMethodSmooth=void 0;class sM extends sx{}sM.prototype.ValueTypeName="color";class sS extends sx{}sS.prototype.ValueTypeName="number";class sE extends sg{constructor(e,n,i,r){super(e,n,i,r)}interpolate_(e,n,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=(i-n)/(r-n),u=e*o;for(let e=u+o;u!==e;u+=4)ex.slerpFlat(a,0,s,u-o,s,u,l);return a}}class sT extends sx{InterpolantFactoryMethodLinear(e){return new sE(this.times,this.values,this.getValueSize(),e)}}sT.prototype.ValueTypeName="quaternion",sT.prototype.DefaultInterpolation=M,sT.prototype.InterpolantFactoryMethodSmooth=void 0;class sw extends sx{}sw.prototype.ValueTypeName="string",sw.prototype.ValueBufferType=Array,sw.prototype.DefaultInterpolation=b,sw.prototype.InterpolantFactoryMethodLinear=void 0,sw.prototype.InterpolantFactoryMethodSmooth=void 0;class sA extends sx{}sA.prototype.ValueTypeName="vector";class sR{constructor(e,n=-1,i,r=2500){this.name=e,this.tracks=i,this.duration=n,this.blendMode=r,this.uuid=k(),this.duration<0&&this.resetDuration()}static parse(e){let n=[],i=e.tracks,r=1/(e.fps||1);for(let e=0,a=i.length;e!==a;++e)n.push((function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let n=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sS;case"vector":case"vector2":case"vector3":case"vector4":return sA;case"color":return sM;case"quaternion":return sT;case"bool":case"boolean":return sb;case"string":return sw}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let n=[],i=[];sm(e.keys,n,i,"value"),e.times=n,e.values=i}return void 0!==n.parse?n.parse(e):new n(e.name,e.times,e.values,e.interpolation)})(i[e]).scale(r));let a=new this(e.name,e.duration,n,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let n=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=i.length;e!==r;++e)n.push(sx.toJSON(i[e]));return r}static CreateFromMorphTargetSequence(e,n,i,r){let a=n.length,s=[];for(let e=0;e1){let e=s[1],n=r[e];n||(r[e]=n=[]),n.push(i)}}let s=[];for(let e in r)s.push(this.CreateFromMorphTargetSequence(e,r[e],n,i));return s}static parseAnimation(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(e,n,i,r,a){if(0!==i.length){let s=[],o=[];sm(i,s,o,r),0!==s.length&&a.push(new e(n,s,o))}},r=[],a=e.name||"default",s=e.fps||30,o=e.blendMode,l=e.length||-1,u=e.hierarchy||[];for(let e=0;e{n&&n(a),this.manager.itemEnd(e)},0),a;if(void 0!==sO[e]){sO[e].push({onLoad:n,onProgress:i,onError:r});return}sO[e]=[],sO[e].push({onLoad:n,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(s).then(n=>{if(200===n.status||0===n.status){if(0===n.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===n.body||void 0===n.body.getReader)return n;let i=sO[e],r=n.body.getReader(),a=n.headers.get("Content-Length")||n.headers.get("X-File-Size"),s=a?parseInt(a):0,o=0!==s,l=0,u=new ReadableStream({start(e){(function n(){r.read().then(({done:r,value:a})=>{if(r)e.close();else{l+=a.byteLength;let r=new ProgressEvent("progress",{lengthComputable:o,loaded:l,total:s});for(let e=0,n=i.length;e{switch(l){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>{let n=new DOMParser;return n.parseFromString(e,o)});case"json":return e.json();default:if(void 0===o)return e.text();{let n=/charset="?([^;"\s]*)"?/i.exec(o),i=n&&n[1]?n[1].toLowerCase():void 0,r=new TextDecoder(i);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(n=>{sP.add(e,n);let i=sO[e];delete sO[e];for(let e=0,r=i.length;e{let i=sO[e];if(void 0===i)throw this.manager.itemError(e),n;delete sO[e];for(let e=0,r=i.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class sU extends sL{constructor(e){super(e)}load(e,n,i,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=sP.get(e);if(void 0!==s)return a.manager.itemStart(e),setTimeout(function(){n&&n(s),a.manager.itemEnd(e)},0),s;let o=ee("img");function l(){c(),sP.add(e,this),n&&n(this),a.manager.itemEnd(e)}function u(n){c(),r&&r(n),a.manager.itemError(e),a.manager.itemEnd(e)}function c(){o.removeEventListener("load",l,!1),o.removeEventListener("error",u,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",u,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),a.manager.itemStart(e),o.src=e,o}}class sN extends sL{constructor(e){super(e)}load(e,n,i,r){let a=new em,s=new sU(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){a.image=e,a.needsUpdate=!0,void 0!==n&&n(a)},i,r),a}}class sF extends td{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new tP(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,void 0!==this.groundColor&&(n.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(n.object.distance=this.distance),void 0!==this.angle&&(n.object.angle=this.angle),void 0!==this.decay&&(n.object.decay=this.decay),void 0!==this.penumbra&&(n.object.penumbra=this.penumbra),void 0!==this.shadow&&(n.object.shadow=this.shadow.toJSON()),n}}let sz=new eK,sB=new eb,sk=new eb;class sH{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Z(512,512),this.map=null,this.mapPass=null,this.matrix=new eK,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nx,this._frameExtents=new Z(1,1),this._viewportCount=1,this._viewports=[new eg(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let n=this.camera,i=this.matrix;sB.setFromMatrixPosition(e.matrixWorld),n.position.copy(sB),sk.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(sk),n.updateMatrixWorld(),sz.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sz),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(sz)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class sV extends sH{constructor(){super(new nc(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let n=this.camera,i=2*B*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||n.far;(i!==n.fov||r!==n.aspect||a!==n.far)&&(n.fov=i,n.aspect=r,n.far=a,n.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sG extends sF{constructor(e,n,i=0,r=Math.PI/3,a=0,s=2){super(e,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(td.DEFAULT_UP),this.updateMatrix(),this.target=new td,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new sV}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let sW=new eK,sj=new eb,sX=new eb;class sq extends sH{constructor(){super(new nc(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Z(4,2),this._viewportCount=6,this._viewports=[new eg(2,1,1,1),new eg(0,1,1,1),new eg(3,1,1,1),new eg(1,1,1,1),new eg(3,0,1,1),new eg(1,0,1,1)],this._cubeDirections=[new eb(1,0,0),new eb(-1,0,0),new eb(0,0,1),new eb(0,0,-1),new eb(0,1,0),new eb(0,-1,0)],this._cubeUps=[new eb(0,1,0),new eb(0,1,0),new eb(0,1,0),new eb(0,1,0),new eb(0,0,1),new eb(0,0,-1)]}updateMatrices(e,n=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),sj.setFromMatrixPosition(e.matrixWorld),i.position.copy(sj),sX.copy(i.position),sX.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(sX),i.updateMatrixWorld(),r.makeTranslation(-sj.x,-sj.y,-sj.z),sW.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sW)}}class sY extends sF{constructor(e,n,i=0,r=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new sq}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class sJ extends sH{constructor(){super(new nD(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sZ extends sF{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(td.DEFAULT_UP),this.updateMatrix(),this.target=new td,this.shadow=new sJ}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class sK extends sF{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class s${static decodeText(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);let n="";for(let i=0,r=e.length;i0){this.source.connect(this.filters[0]);for(let e=1,n=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,n=this.filters.length;e.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{o_.set(e.z,0,-e.x).normalize();let n=Math.acos(e.y);this.quaternion.setFromAxisAngle(o_,n)}}setLength(e,n=.2*e,i=.2*n){this.line.scale.set(1,Math.max(1e-4,e-n),1),this.line.updateMatrix(),this.cone.scale.set(i,n,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"158"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="158")}},n={};function i(r){var a=n[r];if(void 0!==a)return a.exports;var s=n[r]={exports:{}};return e[r](s,s.exports,i),s.exports}i.m=e,(()=>{var e=[];i.O=(n,r,a,s)=>{if(r){s=s||0;for(var o=e.length;o>0&&e[o-1][2]>s;o--)e[o]=e[o-1];e[o]=[r,a,s];return}for(var l=1/0,o=0;o=s&&Object.keys(i.O).every(e=>i.O[e](r[c]))?r.splice(c--,1):(u=!1,s{var n=e&&e.__esModule?()=>e.default:()=>e;return i.d(n,{a:n}),n},i.d=(e,n)=>{for(var r in n)i.o(n,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={736:0};i.O.j=n=>0===e[n];var n=(n,r)=>{var a,s,[o,l,u]=r,c=0;if(o.some(n=>0!==e[n])){for(a in l)i.o(l,a)&&(i.m[a]=l[a]);if(u)var h=u(i)}for(n&&n(r);c