@inweb/viewer-three 25.11.0 → 25.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ODA=e.ODA||{},e.ODA.Three=e.ODA.Three||{}))}(this,(function(e){"use strict";class t{constructor(){this._commands=new Map}registerCommand(e,t,n,i){this._commands.set(e,{id:e,handler:t,thisArg:i,description:n})}registerCommandAlias(e,t){this.registerCommand(t,((t,...n)=>this.executeCommand(e,t,...n)))}getCommand(e){return this._commands.get(e)}getCommands(){const e=new Map;return this._commands.forEach(((t,n)=>e.set(n,t))),e}executeCommand(e,t,...n){const i=this._commands.get(e);if(!i){if(t){if(t.draggers.includes(e))return t.setActiveDragger(e)}return void console.warn(`Command '${e}' not found`)}const{handler:r,thisArg:s}=i,a=r.apply(s,[t,...n]);return null==t||t.emit({type:"command",data:e,args:n}),a}}const n=new Map;function i(e=""){let i=n.get(e);return i||(i=new t,n.set(e,i)),i}function r(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}i("").registerCommand("noop",(()=>{})),i("VisualizeJS").registerCommand("noop",(()=>{})),i("ThreeJS").registerCommand("noop",(()=>{}));class s{constructor(e){this._emitter=e,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(e){console.error("Cannot save client settings.",e)}}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem("od-client-settings");if(e){const t=JSON.parse(e);this.data={...t}}}catch(e){console.error("Cannot load client settings.",e)}}resetToDefaults(e){if(void 0!==e){const t=s.defaults(),n=e.reduce(((e,n)=>(e[n]=t[n],e)),{});this.data={...this.data,...n}}else this.data={...this.data,...s.defaults()}}get data(){return this._data}set data(e){const t=!!e.enableStreamingMode&&e.enablePartialMode,n=!t&&e.sceneGraph;this._data={...s.defaults(),...this._data,...e,enablePartialMode:t,sceneGraph:n},this.change()}get showWCS(){return this._data.showWCS}set showWCS(e){this._data.showWCS=e,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(e){this._data.cameraAnimation=e,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(e){this._data.antialiasing=e,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(e){this._data.groundShadow=e,this.change()}get shadows(){return this._data.shadows}set shadows(e){this._data.shadows=e,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(e){this._data.cameraAxisXSpeed=e,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(e){this.cameraAxisYSpeed=e,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(e){this._data.ambientOcclusion=e,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(e){this._data.enableStreamingMode=e,e||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(e){this._data.enablePartialMode=e,e&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(e){this._data.memoryLimit=e,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(e){this._data.cuttingPlaneFillColor=e,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(e){this._data.edgesColor=e,this.change()}get facesColor(){return this._data.facesColor}set facesColor(e){this._data.facesColor=e,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(e){this._data.edgesVisibility=e,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(e){this._data.edgesOverlap=e,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(e){this._data.facesOverlap=e,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(e){this._data.facesTransparancy=e,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(e){this._data.enableCustomHighlight=e,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(e){this._data.sceneGraph=e,e&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(e){this._data.edgeModel=Boolean(e),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(e){this._data.reverseZoomWheel=!!e,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(e){this._data.enableZoomWheel=!!e,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(e){this._data.enableGestures=!!e,this.change()}get geometryType(){return this._data.geometryType}set geometryType(e){this._data.geometryType=e,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(e){this._data.rulerUnit=e,this.change()}}const a=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],o=a;i("ThreeJS").registerCommand("applyModelTransform",(function(e,t){console.warn("applyModelTransform not implemented")})),i("ThreeJS").registerCommand("clearMarkup",(e=>console.warn("clearMarkup not implemented"))),i("ThreeJS").registerCommandAlias("clearMarkup","clearOverlay");
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Three=t.ODA.Three||{}))}(this,(function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,n){this._commands.set(t,{id:t,handler:e,thisArg:n,description:i})}registerCommandAlias(t,e){this.registerCommand(e,((e,...i)=>this.executeCommand(t,e,...i)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,i)=>t.set(i,e))),t}executeCommand(t,e,...i){const n=this._commands.get(t);if(!n){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:a}=n,s=r.apply(a,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),s}}const i=new Map;function n(t=""){let n=i.get(t);return n||(n=new e,i.set(t,n)),n}function r(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}n("").registerCommand("noop",(()=>{})),n("VisualizeJS").registerCommand("noop",(()=>{})),n("ThreeJS").registerCommand("noop",(()=>{}));class a{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=a.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...a.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...a.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}}const s=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],o=s;n("ThreeJS").registerCommand("applyModelTransform",(function(t,e){console.warn("applyModelTransform not implemented")})),n("ThreeJS").registerCommand("clearMarkup",(t=>t.clearOverlay())),n("ThreeJS").registerCommandAlias("clearMarkup","clearOverlay");
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2023 Three.js Authors
5
5
  * SPDX-License-Identifier: MIT
6
6
  */
7
- const l="153",c=0,h=1,u=2,d=0,p=1,m=2,f=3,g=1,_=2,v=3,x=0,y=1,M=2,S=100,E=101,T=102,w=200,b=201,A=202,R=203,C=204,P=205,L=206,I=207,U=208,D=209,N=210,O=0,F=1,B=2,z=0,H=1,k=2,G=3,V=4,W=5,X=301,j=302,Y=306,q=1e3,K=1001,Z=1002,J=1003,Q=1004,$=1005,ee=1006,te=1007,ne=1008,ie=1009,re=1012,se=1013,ae=1014,oe=1015,le=1016,ce=1020,he=1023,ue=1026,de=1027,pe=33776,me=33777,fe=33778,ge=33779,_e=36492,ve=2300,xe=2301,ye=2302,Me=3001,Se="",Ee="srgb",Te="srgb-linear",we="display-p3",be=7680,Ae=512,Re=513,Ce=514,Pe=515,Le=516,Ie=517,Ue=518,De=519,Ne=35044,Oe="300 es",Fe=1035,Be=2e3,ze=2001;class He{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e);e.target=null}}}const ke=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Ge=1234567;const Ve=Math.PI/180,We=180/Math.PI;function Xe(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(ke[255&e]+ke[e>>8&255]+ke[e>>16&255]+ke[e>>24&255]+"-"+ke[255&t]+ke[t>>8&255]+"-"+ke[t>>16&15|64]+ke[t>>24&255]+"-"+ke[63&n|128]+ke[n>>8&255]+"-"+ke[n>>16&255]+ke[n>>24&255]+ke[255&i]+ke[i>>8&255]+ke[i>>16&255]+ke[i>>24&255]).toLowerCase()}function je(e,t,n){return Math.max(t,Math.min(n,e))}function Ye(e,t){return(e%t+t)%t}function qe(e,t,n){return(1-n)*e+n*t}function Ke(e){return!(e&e-1)&&0!==e}function Ze(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Je(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Qe(e,t){switch(t.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 new Error("Invalid component type.")}}function $e(e,t){switch(t.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 new Error("Invalid component type.")}}const et={DEG2RAD:Ve,RAD2DEG:We,generateUUID:Xe,clamp:je,euclideanModulo:Ye,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:qe,damp:function(e,t,n,i){return qe(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(Ye(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(Ge=e);let t=Ge+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Ve},radToDeg:function(e){return e*We},isPowerOfTwo:Ke,ceilPowerOfTwo:Ze,floorPowerOfTwo:Je,setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),m=a((i-t)/2);switch(r){case"XYX":e.set(o*h,l*u,l*d,o*c);break;case"YZY":e.set(l*d,o*h,l*u,o*c);break;case"ZXZ":e.set(l*u,l*d,o*h,o*c);break;case"XZX":e.set(o*h,l*m,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*m,o*c);break;case"ZYZ":e.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:$e,denormalize:Qe};class tt{constructor(e=0,t=0){tt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new 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 new 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.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){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){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(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class nt{constructor(e,t,n,i,r,s,a,o,l){nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],_=i[1],v=i[4],x=i[7],y=i[2],M=i[5],S=i[8];return r[0]=s*m+a*_+o*y,r[3]=s*f+a*v+o*M,r[6]=s*g+a*x+o*S,r[1]=l*m+c*_+h*y,r[4]=l*f+c*v+h*M,r[7]=l*g+c*x+h*S,r[2]=u*m+d*_+p*y,r[5]=u*f+d*v+p*M,r[8]=u*g+d*x+p*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-c*n)*m,e[2]=(a*n-i*s)*m,e[3]=u*m,e[4]=(c*t-i*o)*m,e[5]=(i*r-a*t)*m,e[6]=d*m,e[7]=(n*o-l*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(it.makeScale(e,t)),this}rotate(e){return this.premultiply(it.makeRotation(-e)),this}translate(e,t){return this.premultiply(it.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const it=new nt;function rt(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function st(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const at={};function ot(e){e in at||(at[e]=!0,console.warn(e))}function lt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ct(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const ht=(new nt).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),ut=(new nt).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const dt={[Te]:e=>e,[Ee]:e=>e.convertSRGBToLinear(),[we]:function(e){return e.convertSRGBToLinear().applyMatrix3(ut)}},pt={[Te]:e=>e,[Ee]:e=>e.convertLinearToSRGB(),[we]:function(e){return e.applyMatrix3(ht).convertLinearToSRGB()}},mt={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Te},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=dt[t],r=pt[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let ft;class gt{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ft&&(ft=st("canvas")),ft.width=e.width,ft.height=e.height;const n=ft.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ft}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.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){const t=st("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*lt(r[e]/255);return n.putImageData(i,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*lt(t[e]/255)):t[e]=lt(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let _t=0;class vt{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_t++}),this.uuid=Xe(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(xt(i[t].image)):e.push(xt(i[t]))}else e=xt(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function xt(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?gt.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let yt=0;class Mt extends He{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,l=Mt.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:yt++}),this.uuid=Xe(),this.name="",this.source=new vt(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new nt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof c?this.colorSpace=c:(ot("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=c===Me?Ee:Se),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}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 q:e.x=e.x-Math.floor(e.x);break;case K:e.x=e.x<0?0:1;break;case Z: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 q:e.y=e.y-Math.floor(e.y);break;case K:e.y=e.y<0?0:1;break;case Z: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 ot("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ee?Me:3e3}set encoding(e){ot("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Me?Ee:Se}}Mt.DEFAULT_IMAGE=null,Mt.DEFAULT_MAPPING=300,Mt.DEFAULT_ANISOTROPY=1;class St{constructor(e=0,t=0,n=0,i=1){St.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new 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 new 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.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){const t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(h-m)<s&&Math.abs(p-f)<s){if(Math.abs(c+u)<a&&Math.abs(h+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,o=(d+1)/2,_=(g+1)/2,v=(c+u)/4,x=(h+m)/4,y=(p+f)/4;return e>o&&e>_?e<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=v/n,r=x/n):o>_?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=v/i,r=y/i):_<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=x/r,i=y/r),this.set(n,i,r,t),this}let _=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(u-c)*(u-c));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(h-m)/_,this.z=(u-c)/_,this.w=Math.acos((l+d+g-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,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 Et extends He{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new St(0,0,e,t),this.scissorTest=!1,this.viewport=new St(0,0,e,t);const i={width:e,height:t,depth:1};void 0!==n.encoding&&(ot("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Me?Ee:Se),this.texture=new Mt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:ee,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}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;const t=Object.assign({},e.texture.image);return this.texture.source=new vt(t),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 Tt extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=J,this.minFilter=J,this.wrapR=K,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wt extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=J,this.minFilter=J,this.wrapR=K,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,a){let o=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return e[t+0]=o,e[t+1]=l,e[t+2]=c,void(e[t+3]=h);if(1===a)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=m);if(h!==m||o!==u||l!==d||c!==p){let e=1-a;const t=o*u+l*d+c*p+h*m,n=t>=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,t*n);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+m*r,e===1-a){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*h+o*d-l*u,e[t+1]=o*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-o*h,e[t+3]=c*p-a*h-o*u-l*d,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,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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,t){const n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,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,t){const n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),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 At{constructor(e=0,t=0,n=0){At.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new 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 new 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.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,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ct.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ct.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=o*t+s*i-a*n,c=o*n+a*t-r*i,h=o*i+r*n-s*t,u=-r*t-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Rt.copy(this).projectOnVector(e),this.sub(Rt)}reflect(e){return this.sub(Rt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Rt=new At,Ct=new bt;class Pt{constructor(e=new At(1/0,1/0,1/0),t=new At(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(It.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(It.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=It.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),Ut.copy(e.boundingBox),Ut.applyMatrix4(e.matrixWorld),this.union(Ut);else{const n=e.geometry;if(void 0!==n)if(t&&void 0!==n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,i=t.count;n<i;n++)It.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(It)}else null===n.boundingBox&&n.computeBoundingBox(),Ut.copy(n.boundingBox),Ut.applyMatrix4(e.matrixWorld),this.union(Ut)}const n=e.children;for(let e=0,i=n.length;e<i;e++)this.expandByObject(n[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.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,t){return t.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,It),It.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ht),kt.subVectors(this.max,Ht),Dt.subVectors(e.a,Ht),Nt.subVectors(e.b,Ht),Ot.subVectors(e.c,Ht),Ft.subVectors(Nt,Dt),Bt.subVectors(Ot,Nt),zt.subVectors(Dt,Ot);let t=[0,-Ft.z,Ft.y,0,-Bt.z,Bt.y,0,-zt.z,zt.y,Ft.z,0,-Ft.x,Bt.z,0,-Bt.x,zt.z,0,-zt.x,-Ft.y,Ft.x,0,-Bt.y,Bt.x,0,-zt.y,zt.x,0];return!!Wt(t,Dt,Nt,Ot,kt)&&(t=[1,0,0,0,1,0,0,0,1],!!Wt(t,Dt,Nt,Ot,kt)&&(Gt.crossVectors(Ft,Bt),t=[Gt.x,Gt.y,Gt.z],Wt(t,Dt,Nt,Ot,kt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,It).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(It).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()||(Lt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lt)),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)}}const Lt=[new At,new At,new At,new At,new At,new At,new At,new At],It=new At,Ut=new Pt,Dt=new At,Nt=new At,Ot=new At,Ft=new At,Bt=new At,zt=new At,Ht=new At,kt=new At,Gt=new At,Vt=new At;function Wt(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){Vt.fromArray(e,s);const a=r.x*Math.abs(Vt.x)+r.y*Math.abs(Vt.y)+r.z*Math.abs(Vt.z),o=t.dot(Vt),l=n.dot(Vt),c=i.dot(Vt);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Xt=new Pt,jt=new At,Yt=new At;class qt{constructor(e=new At,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Xt.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(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;jt.subVectors(e,this.center);const t=jt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(jt,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Yt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jt.copy(e.center).add(Yt)),this.expandByPoint(jt.copy(e.center).sub(Yt))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Kt=new At,Zt=new At,Jt=new At,Qt=new At,$t=new At,en=new At,tn=new At;class nn{constructor(e=new At,t=new At(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.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,Kt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Kt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kt.copy(this.origin).addScaledVector(this.direction,t),Kt.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Zt.copy(e).add(t).multiplyScalar(.5),Jt.copy(t).sub(e).normalize(),Qt.copy(this.origin).sub(Zt);const r=.5*e.distanceTo(t),s=-this.direction.dot(Jt),a=Qt.dot(this.direction),o=-Qt.dot(Jt),l=Qt.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Zt).addScaledVector(Jt,u),d}intersectSphere(e,t){Kt.subVectors(e.center,this.origin);const n=Kt.dot(this.direction),i=Kt.dot(Kt)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),h>=0?(a=(e.min.z-u.z)*h,o=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,o=(e.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Kt)}intersectTriangle(e,t,n,i,r){$t.subVectors(t,e),en.subVectors(n,e),tn.crossVectors($t,en);let s,a=this.direction.dot(tn);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Qt.subVectors(this.origin,e);const o=s*this.direction.dot(en.crossVectors(Qt,en));if(o<0)return null;const l=s*this.direction.dot($t.cross(Qt));if(l<0)return null;if(o+l>a)return null;const c=-s*Qt.dot(tn);return c<0?null:this.at(c/a,r)}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 rn{constructor(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){rn.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,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f)}set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 rn).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/sn.setFromMatrixColumn(e,0).length(),r=1/sn.setFromMatrixColumn(e,1).length(),s=1/sn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*h,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-s*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=s*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(on,e,ln)}lookAt(e,t,n){const i=this.elements;return un.subVectors(e,t),0===un.lengthSq()&&(un.z=1),un.normalize(),cn.crossVectors(n,un),0===cn.lengthSq()&&(1===Math.abs(n.z)?un.x+=1e-4:un.z+=1e-4,un.normalize(),cn.crossVectors(n,un)),cn.normalize(),hn.crossVectors(un,cn),i[0]=cn.x,i[4]=hn.x,i[8]=un.x,i[1]=cn.y,i[5]=hn.y,i[9]=un.y,i[2]=cn.z,i[6]=hn.z,i[10]=un.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],_=n[3],v=n[7],x=n[11],y=n[15],M=i[0],S=i[4],E=i[8],T=i[12],w=i[1],b=i[5],A=i[9],R=i[13],C=i[2],P=i[6],L=i[10],I=i[14],U=i[3],D=i[7],N=i[11],O=i[15];return r[0]=s*M+a*w+o*C+l*U,r[4]=s*S+a*b+o*P+l*D,r[8]=s*E+a*A+o*L+l*N,r[12]=s*T+a*R+o*I+l*O,r[1]=c*M+h*w+u*C+d*U,r[5]=c*S+h*b+u*P+d*D,r[9]=c*E+h*A+u*L+d*N,r[13]=c*T+h*R+u*I+d*O,r[2]=p*M+m*w+f*C+g*U,r[6]=p*S+m*b+f*P+g*D,r[10]=p*E+m*A+f*L+g*N,r[14]=p*T+m*R+f*I+g*O,r[3]=_*M+v*w+x*C+y*U,r[7]=_*S+v*b+x*P+y*D,r[11]=_*E+v*A+x*L+y*N,r[15]=_*T+v*R+x*I+y*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+e[11]*(+t*l*h-t*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*o*h+t*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],_=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,v=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,x=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,y=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,M=t*_+n*v+i*x+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/M;return e[0]=_*S,e[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*S,e[2]=(a*f*r-m*o*r+m*i*l-n*f*l-a*i*g+n*o*g)*S,e[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*S,e[4]=v*S,e[5]=(c*f*r-p*u*r+p*i*d-t*f*d-c*i*g+t*u*g)*S,e[6]=(p*o*r-s*f*r-p*i*l+t*f*l+s*i*g-t*o*g)*S,e[7]=(s*u*r-c*o*r+c*i*l-t*u*l-s*i*d+t*o*d)*S,e[8]=x*S,e[9]=(p*h*r-c*m*r-p*n*d+t*m*d+c*n*g-t*h*g)*S,e[10]=(s*m*r-p*a*r+p*n*l-t*m*l-s*n*g+t*a*g)*S,e[11]=(c*a*r-s*h*r-c*n*l+t*h*l+s*n*d-t*a*d)*S,e[12]=y*S,e[13]=(c*m*i-p*h*i+p*n*u-t*m*u-c*n*f+t*h*f)*S,e[14]=(p*a*i-s*m*i-p*n*o+t*m*o+s*n*f-t*a*f)*S,e[15]=(s*h*i-c*a*i+c*n*o-t*h*o-s*n*u+t*a*u)*S,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,_=o*l,v=o*c,x=o*h,y=n.x,M=n.y,S=n.z;return i[0]=(1-(m+g))*y,i[1]=(d+x)*y,i[2]=(p-v)*y,i[3]=0,i[4]=(d-x)*M,i[5]=(1-(u+g))*M,i[6]=(f+_)*M,i[7]=0,i[8]=(p+v)*S,i[9]=(f-_)*S,i[10]=(1-(u+m))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=sn.set(i[0],i[1],i[2]).length();const s=sn.set(i[4],i[5],i[6]).length(),a=sn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],an.copy(this);const o=1/r,l=1/s,c=1/a;return an.elements[0]*=o,an.elements[1]*=o,an.elements[2]*=o,an.elements[4]*=l,an.elements[5]*=l,an.elements[6]*=l,an.elements[8]*=c,an.elements[9]*=c,an.elements[10]*=c,t.setFromRotationMatrix(an),n.x=r,n.y=s,n.z=a,this}makePerspective(e,t,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let d,p;if(a===Be)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==ze)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(s-r),u=(t+e)*l,d=(n+i)*c;let p,m;if(a===Be)p=(s+r)*h,m=-2*h;else{if(a!==ze)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,m=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sn=new At,an=new rn,on=new At(0,0,0),ln=new At(1,1,1),cn=new At,hn=new At,un=new At,dn=new rn,pn=new bt;class mn{constructor(e=0,t=0,n=0,i=mn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,t=this._order,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-je(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(je(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-je(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-je(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return dn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(dn,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pn.setFromEuler(this),this.setFromQuaternion(pn,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=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+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}}mn.DEFAULT_ORDER="XYZ";class fn{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return!!(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let gn=0;const _n=new At,vn=new bt,xn=new rn,yn=new At,Mn=new At,Sn=new At,En=new bt,Tn=new At(1,0,0),wn=new At(0,1,0),bn=new At(0,0,1),An={type:"added"},Rn={type:"removed"};class Cn extends He{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gn++}),this.uuid=Xe(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Cn.DEFAULT_UP.clone();const e=new At,t=new mn,n=new bt,i=new At(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new rn},normalMatrix:{value:new nt}}),this.matrix=new rn,this.matrixWorld=new rn,this.matrixAutoUpdate=Cn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new fn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.multiply(vn),this}rotateOnWorldAxis(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.premultiply(vn),this}rotateX(e){return this.rotateOnAxis(Tn,e)}rotateY(e){return this.rotateOnAxis(wn,e)}rotateZ(e){return this.rotateOnAxis(bn,e)}translateOnAxis(e,t){return _n.copy(e).applyQuaternion(this.quaternion),this.position.add(_n.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Tn,e)}translateY(e){return this.translateOnAxis(wn,e)}translateZ(e){return this.translateOnAxis(bn,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?yn.copy(e):yn.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Mn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xn.lookAt(Mn,yn,this.up):xn.lookAt(yn,Mn,this.up),this.quaternion.setFromRotationMatrix(xn),i&&(xn.extractRotation(i.matrixWorld),vn.setFromRotationMatrix(xn),this.quaternion.premultiply(vn.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(An)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Rn)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Rn)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),xn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),xn.multiply(e.parent.matrixWorld)),e.applyMatrix4(xn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,r=this.children.length;i<r;i++){const r=this.children[i].getObjectsByProperty(e,t);r.length>0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Mn,e,Sn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Mn,En,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const i=t[n];!0!==i.matrixWorldAutoUpdate&&!0!==e||i.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){const t=s(e.geometries),i=s(e.materials),r=s(e.textures),a=s(e.images),o=s(e.shapes),l=s(e.skeletons),c=s(e.animations),h=s(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!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,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}Cn.DEFAULT_UP=new At(0,1,0),Cn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Pn=new At,Ln=new At,In=new At,Un=new At,Dn=new At,Nn=new At,On=new At,Fn=new At,Bn=new At,zn=new At;let Hn=!1;class kn{constructor(e=new At,t=new At,n=new At){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Pn.subVectors(e,t),i.cross(Pn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Pn.subVectors(i,t),Ln.subVectors(n,t),In.subVectors(e,t);const s=Pn.dot(Pn),a=Pn.dot(Ln),o=Pn.dot(In),l=Ln.dot(Ln),c=Ln.dot(In),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Un),Un.x>=0&&Un.y>=0&&Un.x+Un.y<=1}static getUV(e,t,n,i,r,s,a,o){return!1===Hn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Hn=!0),this.getInterpolation(e,t,n,i,r,s,a,o)}static getInterpolation(e,t,n,i,r,s,a,o){return this.getBarycoord(e,t,n,i,Un),o.setScalar(0),o.addScaledVector(r,Un.x),o.addScaledVector(s,Un.y),o.addScaledVector(a,Un.z),o}static isFrontFacing(e,t,n,i){return Pn.subVectors(n,t),Ln.subVectors(e,t),Pn.cross(Ln).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Pn.subVectors(this.c,this.b),Ln.subVectors(this.a,this.b),.5*Pn.cross(Ln).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===Hn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Hn=!0),kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return kn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Dn.subVectors(i,n),Nn.subVectors(r,n),Fn.subVectors(e,n);const o=Dn.dot(Fn),l=Nn.dot(Fn);if(o<=0&&l<=0)return t.copy(n);Bn.subVectors(e,i);const c=Dn.dot(Bn),h=Nn.dot(Bn);if(c>=0&&h<=c)return t.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Dn,s);zn.subVectors(e,r);const d=Dn.dot(zn),p=Nn.dot(zn);if(p>=0&&d<=p)return t.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Nn,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return On.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(On,a);const g=1/(f+m+u);return s=m*g,a=u*g,t.copy(n).addScaledVector(Dn,s).addScaledVector(Nn,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Gn=0;class Vn extends He{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gn++}),this.uuid=Xe(),this.name="",this.type="Material",this.blending=1,this.side=x,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=S,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=be,this.stencilZFail=be,this.stencilZPass=be,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(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==x&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}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;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,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.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++}}const Wn={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},Xn={h:0,s:0,l:0},jn={h:0,s:0,l:0};function Yn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class qn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ee){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,mt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=mt.workingColorSpace){return this.r=e,this.g=t,this.b=n,mt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=mt.workingColorSpace){if(e=Ye(e,1),t=je(t,0,1),n=je(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=Yn(r,i,e+1/3),this.g=Yn(r,i,e),this.b=Yn(r,i,e-1/3)}return mt.toWorkingColorSpace(this,i),this}setStyle(e,t=Ee){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ee){const n=Wn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):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=lt(e.r),this.g=lt(e.g),this.b=lt(e.b),this}copyLinearToSRGB(e){return this.r=ct(e.r),this.g=ct(e.g),this.b=ct(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ee){return mt.fromWorkingColorSpace(Kn.copy(this),e),65536*Math.round(je(255*Kn.r,0,255))+256*Math.round(je(255*Kn.g,0,255))+Math.round(je(255*Kn.b,0,255))}getHexString(e=Ee){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mt.workingColorSpace){mt.fromWorkingColorSpace(Kn.copy(this),t);const n=Kn.r,i=Kn.g,r=Kn.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i<r?6:0);break;case i:o=(r-n)/e+2;break;case r:o=(n-i)/e+4}o/=6}return e.h=o,e.s=l,e.l=c,e}getRGB(e,t=mt.workingColorSpace){return mt.fromWorkingColorSpace(Kn.copy(this),t),e.r=Kn.r,e.g=Kn.g,e.b=Kn.b,e}getStyle(e=Ee){mt.fromWorkingColorSpace(Kn.copy(this),e);const t=Kn.r,n=Kn.g,i=Kn.b;return e!==Ee?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(e,t,n){return this.getHSL(Xn),Xn.h+=e,Xn.s+=t,Xn.l+=n,this.setHSL(Xn.h,Xn.s,Xn.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Xn),e.getHSL(jn);const n=qe(Xn.h,jn.h,t),i=qe(Xn.s,jn.s,t),r=qe(Xn.l,jn.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Kn=new qn;qn.NAMES=Wn;class Zn extends Vn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qn(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=O,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}}const Jn=new At,Qn=new tt;class $n{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Ne,this.updateRange={offset:0,count:-1},this.gpuType=oe,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,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyMatrix3(e),this.setXY(t,Qn.x,Qn.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyMatrix3(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyMatrix4(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyNormalMatrix(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.transformDirection(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Qe(t,this.array)),t}setX(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Qe(t,this.array)),t}setY(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Qe(t,this.array)),t}setZ(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Qe(t,this.array)),t}setW(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),i=$e(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),i=$e(i,this.array),r=$e(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Ne&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class ei extends $n{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ti extends $n{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class ni extends $n{constructor(e,t,n){super(new Float32Array(e),t,n)}}let ii=0;const ri=new rn,si=new Cn,ai=new At,oi=new Pt,li=new Pt,ci=new At;class hi extends He{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ii++}),this.uuid=Xe(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rt(e)?ti:ei)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new nt).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return ri.makeRotationFromQuaternion(e),this.applyMatrix4(ri),this}rotateX(e){return ri.makeRotationX(e),this.applyMatrix4(ri),this}rotateY(e){return ri.makeRotationY(e),this.applyMatrix4(ri),this}rotateZ(e){return ri.makeRotationZ(e),this.applyMatrix4(ri),this}translate(e,t,n){return ri.makeTranslation(e,t,n),this.applyMatrix4(ri),this}scale(e,t,n){return ri.makeScale(e,t,n),this.applyMatrix4(ri),this}lookAt(e){return si.lookAt(e),si.updateMatrix(),this.applyMatrix4(si.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ai).negate(),this.translate(ai.x,ai.y,ai.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new ni(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new At(-1/0,-1/0,-1/0),new At(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];oi.setFromBufferAttribute(n),this.morphTargetsRelative?(ci.addVectors(this.boundingBox.min,oi.min),this.boundingBox.expandByPoint(ci),ci.addVectors(this.boundingBox.max,oi.max),this.boundingBox.expandByPoint(ci)):(this.boundingBox.expandByPoint(oi.min),this.boundingBox.expandByPoint(oi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new qt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new At,1/0);if(e){const n=this.boundingSphere.center;if(oi.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];li.setFromBufferAttribute(n),this.morphTargetsRelative?(ci.addVectors(oi.min,li.min),oi.expandByPoint(ci),ci.addVectors(oi.max,li.max),oi.expandByPoint(ci)):(oi.expandByPoint(li.min),oi.expandByPoint(li.max))}oi.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)ci.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(ci));if(t)for(let r=0,s=t.length;r<s;r++){const s=t[r],a=this.morphTargetsRelative;for(let t=0,r=s.count;t<r;t++)ci.fromBufferAttribute(s,t),a&&(ai.fromBufferAttribute(e,t),ci.add(ai)),i=Math.max(i,n.distanceToSquared(ci))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,i=t.position.array,r=t.normal.array,s=t.uv.array,a=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new $n(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new At,c[e]=new At;const h=new At,u=new At,d=new At,p=new tt,m=new tt,f=new tt,g=new At,_=new At;function v(e,t,n){h.fromArray(i,3*e),u.fromArray(i,3*t),d.fromArray(i,3*n),p.fromArray(s,2*e),m.fromArray(s,2*t),f.fromArray(s,2*n),u.sub(h),d.sub(h),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(_),c[t].add(_),c[n].add(_))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let e=0,t=x.length;e<t;++e){const t=x[e],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)v(n[e+0],n[e+1],n[e+2])}const y=new At,M=new At,S=new At,E=new At;function T(e){S.fromArray(r,3*e),E.copy(S);const t=l[e];y.copy(t),y.sub(S.multiplyScalar(S.dot(t))).normalize(),M.crossVectors(E,t);const n=M.dot(c[e])<0?-1:1;o[4*e]=y.x,o[4*e+1]=y.y,o[4*e+2]=y.z,o[4*e+3]=n}for(let e=0,t=x.length;e<t;++e){const t=x[e],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)T(n[e+0]),T(n[e+1]),T(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new $n(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const i=new At,r=new At,s=new At,a=new At,o=new At,l=new At,c=new At,h=new At;if(e)for(let u=0,d=e.count;u<d;u+=3){const d=e.getX(u+0),p=e.getX(u+1),m=e.getX(u+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,m),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),a.add(c),o.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ci.fromBufferAttribute(e,t),ci.normalize(),e.setXYZ(t,ci.x,ci.y,ci.z)}toNonIndexed(){function e(e,t){const n=e.array,i=e.itemSize,r=e.normalized,s=new n.constructor(t.length*i);let a=0,o=0;for(let r=0,l=t.length;r<l;r++){a=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*i;for(let e=0;e<i;e++)s[o++]=n[a++]}return new $n(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new hi,n=this.index.array,i=this.attributes;for(const r in i){const s=e(i[r],n);t.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],a=r[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],n);s.push(i)}t.morphAttributes[i]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,n=s.length;e<n;e++){const n=s[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];s.push(i.toJSON(e.data))}s.length>0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.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;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ui=new rn,di=new nn,pi=new qt,mi=new At,fi=new At,gi=new At,_i=new At,vi=new At,xi=new At,yi=new tt,Mi=new tt,Si=new tt,Ei=new At,Ti=new At,wi=new At,bi=new At,Ai=new At;class Ri extends Cn{constructor(e=new hi,t=new Zn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){xi.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(vi.fromBufferAttribute(o,e),s?xi.addScaledVector(vi,i):xi.addScaledVector(vi.sub(t),i))}t.add(xi)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),pi.copy(n.boundingSphere),pi.applyMatrix4(r),di.copy(e.ray).recast(e.near),!1===pi.containsPoint(di.origin)){if(null===di.intersectSphere(pi,mi))return;if(di.origin.distanceToSquared(mi)>(e.far-e.near)**2)return}ui.copy(r).invert(),di.copy(e.ray).applyMatrix4(ui),null!==n.boundingBox&&!1===di.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,di)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){i=Ci(this,p,e,n,l,c,h,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,t.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=Ci(this,s,e,n,l,c,h,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){i=Ci(this,p,e,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,t.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=Ci(this,s,e,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}}}function Ci(e,t,n,i,r,s,a,o,l,c){e.getVertexPosition(o,fi),e.getVertexPosition(l,gi),e.getVertexPosition(c,_i);const h=function(e,t,n,i,r,s,a,o){let l;if(l=t.side===y?i.intersectTriangle(a,s,r,!0,o):i.intersectTriangle(r,s,a,t.side===x,o),null===l)return null;Ai.copy(o),Ai.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(Ai);return c<n.near||c>n.far?null:{distance:c,point:Ai.clone(),object:e}}(e,t,n,i,fi,gi,_i,bi);if(h){r&&(yi.fromBufferAttribute(r,o),Mi.fromBufferAttribute(r,l),Si.fromBufferAttribute(r,c),h.uv=kn.getInterpolation(bi,fi,gi,_i,yi,Mi,Si,new tt)),s&&(yi.fromBufferAttribute(s,o),Mi.fromBufferAttribute(s,l),Si.fromBufferAttribute(s,c),h.uv1=kn.getInterpolation(bi,fi,gi,_i,yi,Mi,Si,new tt),h.uv2=h.uv1),a&&(Ei.fromBufferAttribute(a,o),Ti.fromBufferAttribute(a,l),wi.fromBufferAttribute(a,c),h.normal=kn.getInterpolation(bi,fi,gi,_i,Ei,Ti,wi,new At),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c:c,normal:new At,materialIndex:0};kn.getNormal(fi,gi,_i,e.normal),h.face=e}return h}class Pi extends hi{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,s,p,m,f,g,_){const v=s/f,x=p/g,y=s/2,M=p/2,S=m/2,E=f+1,T=g+1;let w=0,b=0;const A=new At;for(let s=0;s<T;s++){const a=s*x-M;for(let o=0;o<E;o++){const u=o*v-y;A[e]=u*i,A[t]=a*r,A[n]=S,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=m>0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-s/g),w+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const n=u+t+E*e,i=u+t+E*(e+1),r=u+(t+1)+E*(e+1),s=u+(t+1)+E*e;o.push(n,i,s),o.push(i,r,s),b+=6}a.addGroup(d,b,_),d+=b,u+=w}p("z","y","x",-1,-1,n,t,e,s,r,0),p("z","y","x",1,-1,n,t,-e,s,r,1),p("x","z","y",1,1,e,n,t,i,s,2),p("x","z","y",1,-1,e,n,-t,i,s,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new ni(l,3)),this.setAttribute("normal",new ni(c,3)),this.setAttribute("uv",new ni(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Li(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}}return t}function Ii(e){const t={};for(let n=0;n<e.length;n++){const i=Li(e[n]);for(const e in i)t[e]=i[e]}return t}function Ui(e){return null===e.getRenderTarget()?e.outputColorSpace:Te}const Di={clone:Li,merge:Ii};class Ni extends Vn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Li(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Oi extends Cn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rn,this.projectionMatrix=new rn,this.projectionMatrixInverse=new rn,this.coordinateSystem=Be}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class Fi extends Oi{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),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){const t=.5*this.getFilmHeight()/e;this.fov=2*We*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ve*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*We*Math.atan(Math.tan(.5*Ve*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,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=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ve*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Bi=-90;class zi extends Cn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new Fi(Bi,1,e,t);i.layers=this.layers,this.add(i);const r=new Fi(Bi,1,e,t);r.layers=this.layers,this.add(r);const s=new Fi(Bi,1,e,t);s.layers=this.layers,this.add(s);const a=new Fi(Bi,1,e,t);a.layers=this.layers,this.add(a);const o=new Fi(Bi,1,e,t);o.layers=this.layers,this.add(o);const l=new Fi(Bi,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Be)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==ze)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,r,s,a,o,l]=this.children,c=e.getRenderTarget(),h=e.toneMapping,u=e.xr.enabled;e.toneMapping=z,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=h,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}}class Hi extends Mt{constructor(e,t,n,i,r,s,a,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:X,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ki extends Et{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(ot("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Me?Ee:Se),this.texture=new Hi(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:ee}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Pi(5,5,5),r=new Ni({name:"CubemapFromEquirect",uniforms:Li(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:y,blending:0});r.uniforms.tEquirect.value=t;const s=new Ri(i,r),a=t.minFilter;t.minFilter===ne&&(t.minFilter=ee);return new zi(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const Gi=new At,Vi=new At,Wi=new nt;class Xi{constructor(e=new At(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Gi.subVectors(n,t).cross(Vi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Gi),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>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,t){const n=t||Wi.getNormalMatrix(e),i=this.coplanarPoint(Gi).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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)}}const ji=new qt,Yi=new At;class qi{constructor(e=new Xi,t=new Xi,n=new Xi,i=new Xi,r=new Xi,s=new Xi){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],m=i[10],f=i[11],g=i[12],_=i[13],v=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,f-d,x-g).normalize(),n[1].setComponents(o+r,u+l,f+d,x+g).normalize(),n[2].setComponents(o+s,u+c,f+p,x+_).normalize(),n[3].setComponents(o-s,u-c,f-p,x-_).normalize(),n[4].setComponents(o-a,u-h,f-m,x-v).normalize(),t===Be)n[5].setComponents(o+a,u+h,f+m,x+v).normalize();else{if(t!==ze)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,m,v).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),ji.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),ji.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ji)}intersectsSprite(e){return ji.center.set(0,0,0),ji.radius=.7071067811865476,ji.applyMatrix4(e.matrixWorld),this.intersectsSphere(ji)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Yi.x=i.normal.x>0?e.max.x:e.min.x,Yi.y=i.normal.y>0?e.max.y:e.min.y,Yi.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Yi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Ki(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Zi(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const s=i.get(t);void 0===s?i.set(t,function(t,i){const r=t.array,s=t.usage,a=e.createBuffer();let o;if(e.bindBuffer(i,a),e.bufferData(i,r,s),t.onUploadCallback(),r instanceof Float32Array)o=e.FLOAT;else if(r instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");o=e.HALF_FLOAT}else o=e.UNSIGNED_SHORT;else if(r instanceof Int16Array)o=e.SHORT;else if(r instanceof Uint32Array)o=e.UNSIGNED_INT;else if(r instanceof Int32Array)o=e.INT;else if(r instanceof Int8Array)o=e.BYTE;else if(r instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);o=e.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):s.version<t.version&&(!function(t,i,r){const s=i.array,a=i.updateRange;e.bindBuffer(r,t),-1===a.count?e.bufferSubData(r,0,s):(n?e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s,a.offset,a.count):e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1),i.onUploadCallback()}(s.buffer,t,r),s.version=t.version)}}}class Ji extends hi{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,s=t/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,h=e/a,u=t/o,d=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*u-s;for(let n=0;n<l;n++){const i=n*h-r;p.push(i,-t,0),m.push(0,0,1),f.push(n/a),f.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<a;t++){const n=t+l*e,i=t+l*(e+1),r=t+1+l*(e+1),s=t+1+l*e;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new ni(p,3)),this.setAttribute("normal",new ni(m,3)),this.setAttribute("uv",new ni(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ji(e.width,e.height,e.widthSegments,e.heightSegments)}}const Qi={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 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\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_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\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\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\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},$i={common:{diffuse:{value:new qn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new nt},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new nt}},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 nt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new nt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new nt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new nt},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new nt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new nt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new nt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new nt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qn(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 qn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0},uvTransform:{value:new nt}},sprite:{diffuse:{value:new qn(16777215)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new nt},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0}}},er={basic:{uniforms:Ii([$i.common,$i.specularmap,$i.envmap,$i.aomap,$i.lightmap,$i.fog]),vertexShader:Qi.meshbasic_vert,fragmentShader:Qi.meshbasic_frag},lambert:{uniforms:Ii([$i.common,$i.specularmap,$i.envmap,$i.aomap,$i.lightmap,$i.emissivemap,$i.bumpmap,$i.normalmap,$i.displacementmap,$i.fog,$i.lights,{emissive:{value:new qn(0)}}]),vertexShader:Qi.meshlambert_vert,fragmentShader:Qi.meshlambert_frag},phong:{uniforms:Ii([$i.common,$i.specularmap,$i.envmap,$i.aomap,$i.lightmap,$i.emissivemap,$i.bumpmap,$i.normalmap,$i.displacementmap,$i.fog,$i.lights,{emissive:{value:new qn(0)},specular:{value:new qn(1118481)},shininess:{value:30}}]),vertexShader:Qi.meshphong_vert,fragmentShader:Qi.meshphong_frag},standard:{uniforms:Ii([$i.common,$i.envmap,$i.aomap,$i.lightmap,$i.emissivemap,$i.bumpmap,$i.normalmap,$i.displacementmap,$i.roughnessmap,$i.metalnessmap,$i.fog,$i.lights,{emissive:{value:new qn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qi.meshphysical_vert,fragmentShader:Qi.meshphysical_frag},toon:{uniforms:Ii([$i.common,$i.aomap,$i.lightmap,$i.emissivemap,$i.bumpmap,$i.normalmap,$i.displacementmap,$i.gradientmap,$i.fog,$i.lights,{emissive:{value:new qn(0)}}]),vertexShader:Qi.meshtoon_vert,fragmentShader:Qi.meshtoon_frag},matcap:{uniforms:Ii([$i.common,$i.bumpmap,$i.normalmap,$i.displacementmap,$i.fog,{matcap:{value:null}}]),vertexShader:Qi.meshmatcap_vert,fragmentShader:Qi.meshmatcap_frag},points:{uniforms:Ii([$i.points,$i.fog]),vertexShader:Qi.points_vert,fragmentShader:Qi.points_frag},dashed:{uniforms:Ii([$i.common,$i.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qi.linedashed_vert,fragmentShader:Qi.linedashed_frag},depth:{uniforms:Ii([$i.common,$i.displacementmap]),vertexShader:Qi.depth_vert,fragmentShader:Qi.depth_frag},normal:{uniforms:Ii([$i.common,$i.bumpmap,$i.normalmap,$i.displacementmap,{opacity:{value:1}}]),vertexShader:Qi.meshnormal_vert,fragmentShader:Qi.meshnormal_frag},sprite:{uniforms:Ii([$i.sprite,$i.fog]),vertexShader:Qi.sprite_vert,fragmentShader:Qi.sprite_frag},background:{uniforms:{uvTransform:{value:new nt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qi.background_vert,fragmentShader:Qi.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Qi.backgroundCube_vert,fragmentShader:Qi.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qi.cube_vert,fragmentShader:Qi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qi.equirect_vert,fragmentShader:Qi.equirect_frag},distanceRGBA:{uniforms:Ii([$i.common,$i.displacementmap,{referencePosition:{value:new At},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qi.distanceRGBA_vert,fragmentShader:Qi.distanceRGBA_frag},shadow:{uniforms:Ii([$i.lights,$i.fog,{color:{value:new qn(0)},opacity:{value:1}}]),vertexShader:Qi.shadow_vert,fragmentShader:Qi.shadow_frag}};er.physical={uniforms:Ii([er.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new nt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new nt},clearcoatNormalScale:{value:new tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new nt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new nt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new nt},sheen:{value:0},sheenColor:{value:new qn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new nt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new nt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new nt},transmissionSamplerSize:{value:new tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new nt},attenuationDistance:{value:0},attenuationColor:{value:new qn(0)},specularColor:{value:new qn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new nt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new nt},anisotropyVector:{value:new tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new nt}}]),vertexShader:Qi.meshphysical_vert,fragmentShader:Qi.meshphysical_frag};const tr={r:0,b:0,g:0};function nr(e,t,n,i,r,s,a){const o=new qn(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function m(t,n){t.getRGB(tr,Ui(e)),i.buffers.color.setClear(tr.r,tr.g,tr.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,m(o,h)},render:function(s,f){let g=!1,_=!0===f.isScene?f.background:null;if(_&&_.isTexture){_=(f.backgroundBlurriness>0?n:t).get(_)}switch(null===_?m(o,h):_&&_.isColor&&(m(_,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,a),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,a),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),_&&(_.isCubeTexture||_.mapping===Y)?(void 0===c&&(c=new Ri(new Pi(1,1,1),new Ni({name:"BackgroundCubeMaterial",uniforms:Li(er.backgroundCube.uniforms),vertexShader:er.backgroundCube.vertexShader,fragmentShader:er.backgroundCube.fragmentShader,side:y,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=_,c.material.uniforms.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,c.material.toneMapped=_.colorSpace!==Ee,u===_&&d===_.version&&p===e.toneMapping||(c.material.needsUpdate=!0,u=_,d=_.version,p=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):_&&_.isTexture&&(void 0===l&&(l=new Ri(new Ji(2,2),new Ni({name:"BackgroundMaterial",uniforms:Li(er.background.uniforms),vertexShader:er.background.vertexShader,fragmentShader:er.background.fragmentShader,side:x,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Ee,!0===_.matrixAutoUpdate&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),u===_&&d===_.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=_,d=_.version,p=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function ir(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e<r;e++)t[e]=0,n[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,object:e,attributes:{},index:null}}function m(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function f(e){g(e,0)}function g(n,r){const s=c.newAttributes,a=c.enabledAttributes,o=c.attributeDivisors;if(s[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),o[n]!==r){(i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),o[n]=r}}function _(){const t=c.newAttributes,n=c.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function v(t,n,i,r,s,a,o){!0===o?e.vertexAttribIPointer(t,n,i,s,a):e.vertexAttribPointer(t,n,i,r,s,a)}function x(){y(),h=!0,c!==l&&(c=l,u(c.object))}function y(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,x,y){let M=!1;if(a){const t=function(t,n,r){const a=!0===r.wireframe;let l=o[t.id];void 0===l&&(l={},o[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let h=c[a];void 0===h&&(h=p(i.isWebGL2?e.createVertexArray():s.createVertexArrayOES()),c[a]=h);return h}(x,d,l);c!==t&&(c=t,u(c.object)),M=function(e,t,n,i){const r=c.attributes,s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o){if(o[t].location>=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(r,x,d,y),M&&function(e,t,n,i){const r={},s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o){if(o[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}}c.attributes=r,c.attributesNum=a,c.index=i}(r,x,d,y)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===e||(c.geometry=x.id,c.program=d.id,c.wireframe=e,M=!0)}null!==y&&n.update(y,e.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const t in c){const s=c[t];if(s.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||a.gpuType===se);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<s.locationSize;e++)g(s.location+e,n.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<s.locationSize;e++)f(s.location+e);e.bindBuffer(e.ARRAY_BUFFER,h);for(let e=0;e<s.locationSize;e++)v(s.location+e,l/s.locationSize,u,t,i*d,(c+l/s.locationSize*e)*d,p)}else{if(a.isInstancedBufferAttribute){for(let e=0;e<s.locationSize;e++)g(s.location+e,a.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let e=0;e<s.locationSize;e++)f(s.location+e);e.bindBuffer(e.ARRAY_BUFFER,h);for(let e=0;e<s.locationSize;e++)v(s.location+e,l/s.locationSize,u,t,l*d,l/s.locationSize*e*d,p)}}else if(void 0!==h){const n=h[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(s.location,n);break;case 3:e.vertexAttrib3fv(s.location,n);break;case 4:e.vertexAttrib4fv(s.location,n);break;default:e.vertexAttrib1fv(s.location,n)}}}}_()}(r,l,d,x),null!==y&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(y).buffer))},reset:x,resetDefaultState:y,dispose:function(){x();for(const e in o){const t=o[e];for(const e in t){const n=t[e];for(const e in n)d(n[e].object),delete n[e];delete t[e]}delete o[e]}},releaseStatesOfGeometry:function(e){if(void 0===o[e.id])return;const t=o[e.id];for(const e in t){const n=t[e];for(const e in n)d(n[e].object),delete n[e];delete t[e]}delete o[e.id]},releaseStatesOfProgram:function(e){for(const t in o){const n=o[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)d(i[e].object),delete i[e];delete n[e.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:_}}function rr(e,t,n,i){const r=i.isWebGL2;let s;this.setMode=function(e){s=e},this.render=function(t,i){e.drawArrays(s,t,i),n.update(i,s,1)},this.renderInstances=function(i,a,o){if(0===o)return;let l,c;if(r)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](s,i,a,o),n.update(a,s,o)}}function sr(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),_=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,x=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:x,floatVertexTextures:v&&x,maxSamples:s?e.getParameter(e.MAX_SAMPLES):0}}function ar(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new Xi,o=new nt,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==s;++t,n+=4)a.copy(e[t]).applyMatrix4(r,o),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(a,o,h){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=e.get(a);if(!r||null===u||0===u.length||s&&!p)s?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{const e=s?0:i,t=4*e;let r=m.clippingState||null;l.value=r,r=c(u,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function or(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=X:304===t&&(e.mapping=j),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(303===s||304===s){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new ki(s.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class lr extends Oi{constructor(e=-1,t=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const cr=[.125,.215,.35,.446,.526,.582],hr=20,ur=new lr,dr=new qn;let pr=null;const mr=(1+Math.sqrt(5))/2,fr=1/mr,gr=[new At(1,1,1),new At(-1,1,1),new At(1,1,-1),new At(-1,1,-1),new At(0,mr,fr),new At(0,mr,-fr),new At(fr,0,mr),new At(-fr,0,mr),new At(mr,fr,0),new At(-mr,fr,0)];class _r{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){pr=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Mr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=yr(),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;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(pr),e.scissorTest=!1,xr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===X||e.mapping===j?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),pr=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:ee,minFilter:ee,generateMipmaps:!1,type:le,format:he,colorSpace:Te,depthBuffer:!1},i=vr(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=vr(e,t,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const s=e-4+1+cr.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);n.push(s);let o=1/s;a>e-4?o=cr[a-e+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,_=new Float32Array(m*p*d),v=new Float32Array(f*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];_.set(i,m*p*e),v.set(u,f*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new hi;y.setAttribute("position",new $n(_,m)),y.setAttribute("uv",new $n(v,f)),y.setAttribute("faceIndex",new $n(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(hr),r=new At(0,1,0),s=new Ni({name:"SphericalGaussianBlur",defines:{n:hr,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Sr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,e,t)}return i}_compileMaterial(e){const t=new Ri(this._lodPlanes[0],e);this._renderer.compile(t,ur)}_sceneToCubeUV(e,t,n,i){const r=new Fi(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(dr),o.toneMapping=z,o.autoClear=!1;const h=new Zn({name:"PMREM.Background",side:y,depthWrite:!1,depthTest:!1}),u=new Ri(new Pi,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(dr),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;xr(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===X||e.mapping===j;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Mr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=yr());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ri(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;xr(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,ur)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=gr[(t-1)%gr.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,n,i,"latitudinal",r),this._halfBlur(s,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Ri(this._lodPlanes[i],l),h=l.uniforms,u=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):hr;m>hr&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;e<hr;++e){const t=e/p,n=Math.exp(-t*t/2);f.push(n),0===e?g+=n:e<m&&(g+=2*n)}for(let e=0;e<f.length;e++)f[e]=f[e]/g;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===s,a&&(h.poleAxis.value=a);const{_lodMax:_}=this;h.dTheta.value=d,h.mipInt.value=_-n;const v=this._sizeLods[i];xr(t,3*v*(i>_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(t),o.render(c,ur)}}function vr(e,t,n){const i=new Et(e,t,n);return i.texture.mapping=Y,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xr(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function yr(){return new Ni({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Sr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Mr(){return new Ni({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Sr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Sr(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Er(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=303===s||304===s,o=s===X||s===j;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new _r(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(s)){null===n&&(n=new _r(e));const s=a?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,s),r.addEventListener("dispose",i),s.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Tr(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function wr(e,t,n,i){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);for(const e in o.morphAttributes){const n=o.morphAttributes[e];for(let e=0,i=n.length;e<i;e++)t.remove(n[e])}o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(t.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let a=0;if(null!==i){const e=i.array;a=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],s=e[t+2];n.push(i,r,r,s,s,i)}}else{const e=r.array;a=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}const o=new(rt(n)?ti:ei)(n,1);o.version=a;const l=s.get(e);l&&t.remove(l),s.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER);const r=n.morphAttributes;for(const n in r){const i=r[n];for(let n=0,r=i.length;n<r;n++)t.update(i[n],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){const t=s.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return s.get(e)}}}function br(e,t,n,i){const r=i.isWebGL2;let s,a,o;this.setMode=function(e){s=e},this.setIndex=function(e){a=e.type,o=e.bytesPerElement},this.render=function(t,i){e.drawElements(s,i,a,t*o),n.update(i,s,1)},this.renderInstances=function(i,l,c){if(0===c)return;let h,u;if(r)h=e,u="drawElementsInstanced";else if(h=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](s,l,a,i*o,c),n.update(l,s,c)}}function Ar(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Rr(e,t){return e[0]-t[0]}function Cr(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Pr(e,t,n){const i={},r=new Float32Array(8),s=new WeakMap,a=new St,o=[];for(let e=0;e<8;e++)o[e]=[e,0];return{update:function(l,c,h){const u=l.morphTargetInfluences;if(!0===t.isWebGL2){const d=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,p=void 0!==d?d.length:0;let m=s.get(c);if(void 0===m||m.count!==p){void 0!==m&&m.texture.dispose();const _=void 0!==c.morphAttributes.position,v=void 0!==c.morphAttributes.normal,x=void 0!==c.morphAttributes.color,y=c.morphAttributes.position||[],M=c.morphAttributes.normal||[],S=c.morphAttributes.color||[];let E=0;!0===_&&(E=1),!0===v&&(E=2),!0===x&&(E=3);let T=c.attributes.position.count*E,w=1;T>t.maxTextureSize&&(w=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);const b=new Float32Array(T*w*4*p),A=new Tt(b,T,w,p);A.type=oe,A.needsUpdate=!0;const R=4*E;for(let P=0;P<p;P++){const L=y[P],I=M[P],U=S[P],D=T*w*4*P;for(let N=0;N<L.count;N++){const O=N*R;!0===_&&(a.fromBufferAttribute(L,N),b[D+O+0]=a.x,b[D+O+1]=a.y,b[D+O+2]=a.z,b[D+O+3]=0),!0===v&&(a.fromBufferAttribute(I,N),b[D+O+4]=a.x,b[D+O+5]=a.y,b[D+O+6]=a.z,b[D+O+7]=0),!0===x&&(a.fromBufferAttribute(U,N),b[D+O+8]=a.x,b[D+O+9]=a.y,b[D+O+10]=a.z,b[D+O+11]=4===U.itemSize?a.w:1)}}function C(){A.dispose(),s.delete(c),c.removeEventListener("dispose",C)}m={count:p,texture:A,size:new tt(T,w)},s.set(c,m),c.addEventListener("dispose",C)}let f=0;for(let F=0;F<u.length;F++)f+=u[F];const g=c.morphTargetsRelative?1:1-f;h.getUniforms().setValue(e,"morphTargetBaseInfluence",g),h.getUniforms().setValue(e,"morphTargetInfluences",u),h.getUniforms().setValue(e,"morphTargetsTexture",m.texture,n),h.getUniforms().setValue(e,"morphTargetsTextureSize",m.size)}else{const B=void 0===u?0:u.length;let z=i[c.id];if(void 0===z||z.length!==B){z=[];for(let W=0;W<B;W++)z[W]=[W,0];i[c.id]=z}for(let X=0;X<B;X++){const j=z[X];j[0]=X,j[1]=u[X]}z.sort(Cr);for(let Y=0;Y<8;Y++)Y<B&&z[Y][1]?(o[Y][0]=z[Y][0],o[Y][1]=z[Y][1]):(o[Y][0]=Number.MAX_SAFE_INTEGER,o[Y][1]=0);o.sort(Rr);const H=c.morphAttributes.position,k=c.morphAttributes.normal;let G=0;for(let q=0;q<8;q++){const K=o[q],Z=K[0],J=K[1];Z!==Number.MAX_SAFE_INTEGER&&J?(H&&c.getAttribute("morphTarget"+q)!==H[Z]&&c.setAttribute("morphTarget"+q,H[Z]),k&&c.getAttribute("morphNormal"+q)!==k[Z]&&c.setAttribute("morphNormal"+q,k[Z]),r[q]=J,G+=J):(H&&!0===c.hasAttribute("morphTarget"+q)&&c.deleteAttribute("morphTarget"+q),k&&!0===c.hasAttribute("morphNormal"+q)&&c.deleteAttribute("morphNormal"+q),r[q]=0)}const V=c.morphTargetsRelative?1:1-G;h.getUniforms().setValue(e,"morphTargetBaseInfluence",V),h.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function Lr(e,t,n,i){let r=new WeakMap;function s(e){const t=e.target;t.removeEventListener("dispose",s),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,c=t.get(a,l);return r.get(c)!==o&&(t.update(c),r.set(c,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),n.update(a.instanceMatrix,e.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,e.ARRAY_BUFFER)),c},dispose:function(){r=new WeakMap}}}const Ir=new Mt,Ur=new Tt,Dr=new wt,Nr=new Hi,Or=[],Fr=[],Br=new Float32Array(16),zr=new Float32Array(9),Hr=new Float32Array(4);function kr(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let s=Or[r];if(void 0===s&&(s=new Float32Array(r),Or[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function Gr(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Vr(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Wr(e,t){let n=Fr[t];void 0===n&&(n=new Int32Array(t),Fr[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Xr(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function jr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Gr(n,t))return;e.uniform2fv(this.addr,t),Vr(n,t)}}function Yr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Gr(n,t))return;e.uniform3fv(this.addr,t),Vr(n,t)}}function qr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Gr(n,t))return;e.uniform4fv(this.addr,t),Vr(n,t)}}function Kr(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Gr(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Vr(n,t)}else{if(Gr(n,i))return;Hr.set(i),e.uniformMatrix2fv(this.addr,!1,Hr),Vr(n,i)}}function Zr(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Gr(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Vr(n,t)}else{if(Gr(n,i))return;zr.set(i),e.uniformMatrix3fv(this.addr,!1,zr),Vr(n,i)}}function Jr(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Gr(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Vr(n,t)}else{if(Gr(n,i))return;Br.set(i),e.uniformMatrix4fv(this.addr,!1,Br),Vr(n,i)}}function Qr(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function $r(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Gr(n,t))return;e.uniform2iv(this.addr,t),Vr(n,t)}}function es(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Gr(n,t))return;e.uniform3iv(this.addr,t),Vr(n,t)}}function ts(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Gr(n,t))return;e.uniform4iv(this.addr,t),Vr(n,t)}}function ns(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function is(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Gr(n,t))return;e.uniform2uiv(this.addr,t),Vr(n,t)}}function rs(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Gr(n,t))return;e.uniform3uiv(this.addr,t),Vr(n,t)}}function ss(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Gr(n,t))return;e.uniform4uiv(this.addr,t),Vr(n,t)}}function as(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2D(t||Ir,r)}function os(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Dr,r)}function ls(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||Nr,r)}function cs(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||Ur,r)}function hs(e,t){e.uniform1fv(this.addr,t)}function us(e,t){const n=kr(t,this.size,2);e.uniform2fv(this.addr,n)}function ds(e,t){const n=kr(t,this.size,3);e.uniform3fv(this.addr,n)}function ps(e,t){const n=kr(t,this.size,4);e.uniform4fv(this.addr,n)}function ms(e,t){const n=kr(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function fs(e,t){const n=kr(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function gs(e,t){const n=kr(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function _s(e,t){e.uniform1iv(this.addr,t)}function vs(e,t){e.uniform2iv(this.addr,t)}function xs(e,t){e.uniform3iv(this.addr,t)}function ys(e,t){e.uniform4iv(this.addr,t)}function Ms(e,t){e.uniform1uiv(this.addr,t)}function Ss(e,t){e.uniform2uiv(this.addr,t)}function Es(e,t){e.uniform3uiv(this.addr,t)}function Ts(e,t){e.uniform4uiv(this.addr,t)}function ws(e,t,n){const i=this.cache,r=t.length,s=Wr(n,r);Gr(i,s)||(e.uniform1iv(this.addr,s),Vr(i,s));for(let e=0;e!==r;++e)n.setTexture2D(t[e]||Ir,s[e])}function bs(e,t,n){const i=this.cache,r=t.length,s=Wr(n,r);Gr(i,s)||(e.uniform1iv(this.addr,s),Vr(i,s));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||Dr,s[e])}function As(e,t,n){const i=this.cache,r=t.length,s=Wr(n,r);Gr(i,s)||(e.uniform1iv(this.addr,s),Vr(i,s));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||Nr,s[e])}function Rs(e,t,n){const i=this.cache,r=t.length,s=Wr(n,r);Gr(i,s)||(e.uniform1iv(this.addr,s),Vr(i,s));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||Ur,s[e])}class Cs{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Xr;case 35664:return jr;case 35665:return Yr;case 35666:return qr;case 35674:return Kr;case 35675:return Zr;case 35676:return Jr;case 5124:case 35670:return Qr;case 35667:case 35671:return $r;case 35668:case 35672:return es;case 35669:case 35673:return ts;case 5125:return ns;case 36294:return is;case 36295:return rs;case 36296:return ss;case 35678:case 36198:case 36298:case 36306:case 35682:return as;case 35679:case 36299:case 36307:return os;case 35680:case 36300:case 36308:case 36293:return ls;case 36289:case 36303:case 36311:case 36292:return cs}}(t.type)}}class Ps{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return hs;case 35664:return us;case 35665:return ds;case 35666:return ps;case 35674:return ms;case 35675:return fs;case 35676:return gs;case 5124:case 35670:return _s;case 35667:case 35671:return vs;case 35668:case 35672:return xs;case 35669:case 35673:return ys;case 5125:return Ms;case 36294:return Ss;case 36295:return Es;case 36296:return Ts;case 35678:case 36198:case 36298:case 36306:case 35682:return ws;case 35679:case 36299:case 36307:return bs;case 35680:case 36300:case 36308:case 36293:return As;case 36289:case 36303:case 36311:case 36292:return Rs}}(t.type)}}class Ls{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(e,t[s.id],n)}}}const Is=/(\w+)(\])?(\[|\.)?/g;function Us(e,t){e.seq.push(t),e.map[t.id]=t}function Ds(e,t,n){const i=e.name,r=i.length;for(Is.lastIndex=0;;){const s=Is.exec(i),a=Is.lastIndex;let o=s[1];const l="]"===s[2],c=s[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===r){Us(n,void 0===c?new Cs(o,e,t):new Ps(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new Ls(o),Us(n,e)),n=e}}}class Ns{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);Ds(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){const s=t[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function Os(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let Fs=0;function Bs(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let e=r;e<s;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function zs(e,t){const n=function(e){switch(e){case Te:return["Linear","( value )"];case Ee:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Hs(e,t){let n;switch(t){case H:n="Linear";break;case k:n="Reinhard";break;case G:n="OptimizedCineon";break;case V:n="ACESFilmic";break;case W:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ks(e){return""!==e}function Gs(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Vs(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ws=/^[ \t]*#include +<([\w\d./]+)>/gm;function Xs(e){return e.replace(Ws,js)}function js(e,t){const n=Qi[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Xs(n)}const Ys=/#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 qs(e){return e.replace(Ys,Ks)}function Ks(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function Zs(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Js(e,t,n,i){const r=e.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===g?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===_?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===v&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case X:case j:t="ENVMAP_TYPE_CUBE";break;case Y:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),h=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===j&&(t="ENVMAP_MODE_REFRACTION");return t}(n),u=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case O:t="ENVMAP_BLENDING_MULTIPLY";break;case F:t="ENVMAP_BLENDING_MIX";break;case B:t="ENVMAP_BLENDING_ADD"}return t}(n),d=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ks).join("\n")}(n),m=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),f=r.createProgram();let x,y,M=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ks).join("\n"),x.length>0&&(x+="\n"),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ks).join("\n"),y.length>0&&(y+="\n")):(x=[Zs(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ks).join("\n"),y=[p,Zs(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==z?"#define TONE_MAPPING":"",n.toneMapping!==z?Qi.tonemapping_pars_fragment:"",n.toneMapping!==z?Hs("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Qi.encodings_pars_fragment,zs("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ks).join("\n")),a=Xs(a),a=Gs(a,n),a=Vs(a,n),o=Xs(o),o=Gs(o,n),o=Vs(o,n),a=qs(a),o=qs(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(M="#version 300 es\n",x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,y=["#define varying in",n.glslVersion===Oe?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Oe?"":"#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"+y);const S=M+x+a,E=M+y+o,T=Os(r,r.VERTEX_SHADER,S),w=Os(r,r.FRAGMENT_SHADER,E);if(r.attachShader(f,T),r.attachShader(f,w),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(f).trim(),n=r.getShaderInfoLog(T).trim(),i=r.getShaderInfoLog(w).trim();let s=!0,a=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,f,T,w);else{const e=Bs(r,T,"vertex"),n=Bs(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==i||(a=!1);a&&(this.diagnostics={runnable:s,programLog:t,vertexShader:{log:n,prefix:x},fragmentShader:{log:i,prefix:y}})}let b,A;return r.deleteShader(T),r.deleteShader(w),this.getUniforms=function(){return void 0===b&&(b=new Ns(r,f)),b},this.getAttributes=function(){return void 0===A&&(A=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),s=i.name;let a=1;i.type===e.FLOAT_MAT2&&(a=2),i.type===e.FLOAT_MAT3&&(a=3),i.type===e.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:e.getAttribLocation(t,s),locationSize:a}}return n}(r,f)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Fs++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=T,this.fragmentShader=w,this}let Qs=0;class $s{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),s=this._getShaderCacheForMaterial(e);return!1===s.has(i)&&(s.add(i),i.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new ea(e),t.set(e,n)),n}}class ea{constructor(e){this.id=Qs++,this.code=e,this.usedTimes=0}}function ta(e,t,n,i,r,s,a){const o=new fn,l=new $s,c=[],h=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(e){return 0===e?"uv":`uv${e}`}return{getParameters:function(s,o,c,g,_){const v=g.fog,x=_.geometry,M=s.isMeshStandardMaterial?g.environment:null,S=(s.isMeshStandardMaterial?n:t).get(s.envMap||M),E=S&&S.mapping===Y?S.image.height:null,T=m[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const w=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,b=void 0!==w?w.length:0;let A,R,C,P,L=0;if(void 0!==x.morphAttributes.position&&(L=1),void 0!==x.morphAttributes.normal&&(L=2),void 0!==x.morphAttributes.color&&(L=3),T){const e=er[T];A=e.vertexShader,R=e.fragmentShader}else A=s.vertexShader,R=s.fragmentShader,l.update(s),C=l.getVertexShaderID(s),P=l.getFragmentShaderID(s);const I=e.getRenderTarget(),U=!0===_.isInstancedMesh,D=!!s.map,N=!!s.matcap,O=!!S,F=!!s.aoMap,B=!!s.lightMap,H=!!s.bumpMap,k=!!s.normalMap,G=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,X=!!s.roughnessMap,j=s.anisotropy>0,q=s.clearcoat>0,K=s.iridescence>0,Z=s.sheen>0,J=s.transmission>0,Q=j&&!!s.anisotropyMap,$=q&&!!s.clearcoatMap,ee=q&&!!s.clearcoatNormalMap,te=q&&!!s.clearcoatRoughnessMap,ne=K&&!!s.iridescenceMap,ie=K&&!!s.iridescenceThicknessMap,re=Z&&!!s.sheenColorMap,se=Z&&!!s.sheenRoughnessMap,ae=!!s.specularMap,oe=!!s.specularColorMap,le=!!s.specularIntensityMap,ce=J&&!!s.transmissionMap,he=J&&!!s.thicknessMap,ue=!!s.gradientMap,de=!!s.alphaMap,pe=s.alphaTest>0,me=!!s.extensions,fe=!!x.attributes.uv1,ge=!!x.attributes.uv2,_e=!!x.attributes.uv3;return{isWebGL2:h,shaderID:T,shaderType:s.type,shaderName:s.name,vertexShader:A,fragmentShader:R,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:P,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:U,instancingColor:U&&null!==_.instanceColor,supportsVertexTextures:d,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Te,map:D,matcap:N,envMap:O,envMapMode:O&&S.mapping,envMapCubeUVHeight:E,aoMap:F,lightMap:B,bumpMap:H,normalMap:k,displacementMap:d&&G,emissiveMap:V,normalMapObjectSpace:k&&1===s.normalMapType,normalMapTangentSpace:k&&0===s.normalMapType,metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:Q,clearcoat:q,clearcoatMap:$,clearcoatNormalMap:ee,clearcoatRoughnessMap:te,iridescence:K,iridescenceMap:ne,iridescenceThicknessMap:ie,sheen:Z,sheenColorMap:re,sheenRoughnessMap:se,specularMap:ae,specularColorMap:oe,specularIntensityMap:le,transmission:J,transmissionMap:ce,thicknessMap:he,gradientMap:ue,opaque:!1===s.transparent&&1===s.blending,alphaMap:de,alphaTest:pe,combine:s.combine,mapUv:D&&f(s.map.channel),aoMapUv:F&&f(s.aoMap.channel),lightMapUv:B&&f(s.lightMap.channel),bumpMapUv:H&&f(s.bumpMap.channel),normalMapUv:k&&f(s.normalMap.channel),displacementMapUv:G&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:W&&f(s.metalnessMap.channel),roughnessMapUv:X&&f(s.roughnessMap.channel),anisotropyMapUv:Q&&f(s.anisotropyMap.channel),clearcoatMapUv:$&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:ee&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:re&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:se&&f(s.sheenRoughnessMap.channel),specularMapUv:ae&&f(s.specularMap.channel),specularColorMapUv:oe&&f(s.specularColorMap.channel),specularIntensityMapUv:le&&f(s.specularIntensityMap.channel),transmissionMapUv:ce&&f(s.transmissionMap.channel),thicknessMapUv:he&&f(s.thicknessMap.channel),alphaMapUv:de&&f(s.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(k||j),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:fe,vertexUv2s:ge,vertexUv3s:_e,pointsUvs:!0===_.isPoints&&!!x.attributes.uv&&(D||de),fog:!!v,useFog:!0===s.fog,fogExp2:v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:b,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:s.toneMapped?e.toneMapping:z,useLegacyLights:e.useLegacyLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:s.side===y,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:me&&!0===s.extensions.derivatives,extensionFragDepth:me&&!0===s.extensions.fragDepth,extensionDrawBuffers:me&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:me&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0);t.supportsVertexTextures&&o.enable(1);t.instancing&&o.enable(2);t.instancingColor&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.skinning&&o.enable(4);t.morphTargets&&o.enable(5);t.morphNormals&&o.enable(6);t.morphColors&&o.enable(7);t.premultipliedAlpha&&o.enable(8);t.shadowMapEnabled&&o.enable(9);t.useLegacyLights&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=er[t];n=Di.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new Js(e,n,t,s),c.push(i)),i},releaseProgram:function(e){if(0==--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function na(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function ia(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function ra(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function sa(){const e=[];let t=0;const n=[],i=[],r=[];function s(n,i,r,s,a,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||ia),i.length>1&&i.sort(t||ra),r.length>1&&r.sort(t||ra)}}}function aa(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new sa,e.set(t,[r])):n>=i.length?(r=new sa,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function oa(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new At,color:new qn};break;case"SpotLight":n={position:new At,direction:new At,color:new qn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new At,color:new qn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new At,skyColor:new qn,groundColor:new qn};break;case"RectAreaLight":n={color:new qn,position:new At,halfWidth:new At,halfHeight:new At}}return e[t.id]=n,n}}}let la=0;function ca(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ha(e,t){const n=new oa,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let e=0;e<9;e++)r.probe.push(new At);const s=new At,a=new rn,o=new rn;return{setup:function(s,a){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0,v=0,x=0;s.sort(ca);const y=!0===a?Math.PI:1;for(let e=0,t=s.length;e<t;e++){const t=s[e],a=t.color,M=t.intensity,S=t.distance,E=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)o+=a.r*M*y,l+=a.g*M*y,c+=a.b*M*y;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],M);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,r.directionalShadow[h]=n,r.directionalShadowMap[h]=E,r.directionalShadowMatrix[h]=t.shadow.matrix,f++}r.directional[h]=e,h++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(M*y),e.distance=S,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,r.spot[d]=e;const s=t.shadow;if(t.map&&(r.spotLightMap[v]=t.map,v++,s.updateMatrices(t),t.castShadow&&x++),r.spotLightMatrix[d]=s.matrix,t.castShadow){const e=i.get(t);e.shadowBias=s.bias,e.shadowNormalBias=s.normalBias,e.shadowRadius=s.radius,e.shadowMapSize=s.mapSize,r.spotShadow[d]=e,r.spotShadowMap[d]=E,_++}d++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(a).multiplyScalar(M),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,r.pointShadow[u]=n,r.pointShadowMap[u]=E,r.pointShadowMatrix[u]=t.shadow.matrix,g++}r.point[u]=e,u++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(M*y),e.groundColor.copy(t.groundColor).multiplyScalar(M*y),r.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=$i.LTC_FLOAT_1,r.rectAreaLTC2=$i.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=$i.LTC_HALF_1,r.rectAreaLTC2=$i.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const M=r.hash;M.directionalLength===h&&M.pointLength===u&&M.spotLength===d&&M.rectAreaLength===p&&M.hemiLength===m&&M.numDirectionalShadows===f&&M.numPointShadows===g&&M.numSpotShadows===_&&M.numSpotMaps===v||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=_+v-x,r.spotLightMap.length=v,r.numSpotLightShadowsWithMaps=x,M.directionalLength=h,M.pointLength=u,M.spotLength=d,M.rectAreaLength=p,M.hemiLength=m,M.numDirectionalShadows=f,M.numPointShadows=g,M.numSpotShadows=_,M.numSpotMaps=v,r.version=la++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=r.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),n++}else if(d.isSpotLight){const e=r.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const e=r.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),o.identity(),a.copy(d.matrixWorld),a.premultiply(u),o.extractRotation(a),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const e=r.point[i];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),i++}else if(d.isHemisphereLight){const e=r.hemi[h];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(u),h++}}},state:r}}function ua(e,t){const n=new ha(e,t),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(e){n.setup(i,e)},setupLightsView:function(e){n.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){r.push(e)}}}function da(e,t){let n=new WeakMap;return{get:function(i,r=0){const s=n.get(i);let a;return void 0===s?(a=new ua(e,t),n.set(i,[a])):r>=s.length?(a=new ua(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class pa extends Vn{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 ma extends Vn{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 fa(e,t,n){let i=new qi;const r=new tt,s=new tt,a=new St,o=new pa({depthPacking:3201}),l=new ma,c={},h=n.maxTextureSize,u={[x]:y,[y]:x,[M]:2},d=new Ni({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tt},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new hi;m.setAttribute("position",new $n(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Ri(m,d),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=g;let S=this.type;function E(n,i){const s=t.update(f);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Et(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,d,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,p,f,null)}function T(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===v?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=i}return s}function w(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===v)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],h=r[c.materialIndex];if(h&&h.visible){const t=T(n,h,a,o);e.renderBufferDirect(s,null,i,t,n,c)}}}else if(r.visible){const t=T(n,r,a,o);e.renderBufferDirect(s,null,i,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)w(l[e],r,s,a,o)}this.render=function(t,n,o){if(!1===_.enabled)return;if(!1===_.autoUpdate&&!1===_.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=S!==v&&this.type===v,m=S===v&&this.type!==v;for(let l=0,c=t.length;l<c;l++){const c=t[l],u=c.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const f=u.getFrameExtents();if(r.multiply(f),s.copy(u.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/f.x),r.x=s.x*f.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/f.y),r.y=s.y*f.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===m){const e=this.type!==v?{minFilter:J,magFilter:J}:{};null!==u.map&&u.map.dispose(),u.map=new Et(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const g=u.getViewportCount();for(let e=0;e<g;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(c,e),i=u.getFrustum(),w(n,o,u.camera,c,this.type)}!0!==u.isPointLightShadow&&this.type===v&&E(u,o),u.needsUpdate=!1}S=this.type,_.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function ga(e,t,n){const i=n.isWebGL2;const r=new function(){let t=!1;const n=new St;let i=null;const r=new St(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,s,a,o){!0===o&&(t*=a,i*=a,s*=a),n.set(t,i,s,a),!1===r.equals(n)&&(e.clearColor(t,i,s,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,n=null,i=null,r=null;return{setTest:function(t){t?te(e.DEPTH_TEST):ne(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},a=new function(){let t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?te(e.STENCIL_TEST):ne(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&s===a||(e.stencilFunc(t,n,a),i=t,r=n,s=a)},setOp:function(t,n,i){a===t&&o===n&&l===i||(e.stencilOp(t,n,i),a=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,x=null,M=null,O=null,F=!1,B=null,z=null,H=null,k=null,G=null;const V=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,X=0;const j=e.getParameter(e.VERSION);-1!==j.indexOf("WebGL")?(X=parseFloat(/^WebGL (\d)/.exec(j)[1]),W=X>=1):-1!==j.indexOf("OpenGL ES")&&(X=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),W=X>=2);let Y=null,q={};const K=e.getParameter(e.SCISSOR_BOX),Z=e.getParameter(e.VIEWPORT),J=(new St).fromArray(K),Q=(new St).fromArray(Z);function $(t,n,r,s){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)!i||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage3D(n,0,e.RGBA,1,1,s,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}const ee={};function te(t){!0!==c[t]&&(e.enable(t),c[t]=!0)}function ne(t){!1!==c[t]&&(e.disable(t),c[t]=!1)}ee[e.TEXTURE_2D]=$(e.TEXTURE_2D,e.TEXTURE_2D,1),ee[e.TEXTURE_CUBE_MAP]=$(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(ee[e.TEXTURE_2D_ARRAY]=$(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),ee[e.TEXTURE_3D]=$(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),te(e.DEPTH_TEST),s.setFunc(3),ae(!1),oe(1),te(e.CULL_FACE),se(0);const ie={[S]:e.FUNC_ADD,[E]:e.FUNC_SUBTRACT,[T]:e.FUNC_REVERSE_SUBTRACT};if(i)ie[103]=e.MIN,ie[104]=e.MAX;else{const e=t.get("EXT_blend_minmax");null!==e&&(ie[103]=e.MIN_EXT,ie[104]=e.MAX_EXT)}const re={[w]:e.ZERO,[b]:e.ONE,[A]:e.SRC_COLOR,[C]:e.SRC_ALPHA,[N]:e.SRC_ALPHA_SATURATE,[U]:e.DST_COLOR,[L]:e.DST_ALPHA,[R]:e.ONE_MINUS_SRC_COLOR,[P]:e.ONE_MINUS_SRC_ALPHA,[D]:e.ONE_MINUS_DST_COLOR,[I]:e.ONE_MINUS_DST_ALPHA};function se(t,n,i,r,s,a,o,l){if(0!==t){if(!1===m&&(te(e.BLEND),m=!0),5===t)s=s||n,a=a||i,o=o||r,n===g&&s===x||(e.blendEquationSeparate(ie[n],ie[s]),g=n,x=s),i===_&&r===v&&a===M&&o===O||(e.blendFuncSeparate(re[i],re[r],re[a],re[o]),_=i,v=r,M=a,O=o),f=t,F=!1;else if(t!==f||l!==F){if(g===S&&x===S||(e.blendEquation(e.FUNC_ADD),g=S,x=S),l)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}_=null,v=null,M=null,O=null,f=t,F=l}}else!0===m&&(ne(e.BLEND),m=!1)}function ae(t){B!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),B=t)}function oe(t){0!==t?(te(e.CULL_FACE),t!==z&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):ne(e.CULL_FACE),z=t}function le(t,n,i){t?(te(e.POLYGON_OFFSET_FILL),k===n&&G===i||(e.polygonOffset(n,i),k=n,G=i)):ne(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:s,stencil:a},enable:te,disable:ne,bindFramebuffer:function(t,n){return h[t]!==n&&(e.bindFramebuffer(t,n),h[t]=n,i&&(t===e.DRAW_FRAMEBUFFER&&(h[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(h[e.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(i,r){let s=d,a=!1;if(i)if(s=u.get(r),void 0===s&&(s=[],u.set(r,s)),i.isWebGLMultipleRenderTargets){const t=i.texture;if(s.length!==t.length||s[0]!==e.COLOR_ATTACHMENT0){for(let n=0,i=t.length;n<i;n++)s[n]=e.COLOR_ATTACHMENT0+n;s.length=t.length,a=!0}}else s[0]!==e.COLOR_ATTACHMENT0&&(s[0]=e.COLOR_ATTACHMENT0,a=!0);else s[0]!==e.BACK&&(s[0]=e.BACK,a=!0);a&&(n.isWebGL2?e.drawBuffers(s):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(s))},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:se,setMaterial:function(t,n){2===t.side?ne(e.CULL_FACE):te(e.CULL_FACE);let i=t.side===y;n&&(i=!i),ae(i),1===t.blending&&!1===t.transparent?se(0):se(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),r.setMask(t.colorWrite);const o=t.stencilWrite;a.setTest(o),o&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),le(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?te(e.SAMPLE_ALPHA_TO_COVERAGE):ne(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ae,setCullFace:oe,setLineWidth:function(t){t!==H&&(W&&e.lineWidth(t),H=t)},setPolygonOffset:le,setScissorTest:function(t){t?te(e.SCISSOR_TEST):ne(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+V-1),Y!==t&&(e.activeTexture(t),Y=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===Y?e.TEXTURE0+V-1:Y);let r=q[i];void 0===r&&(r={type:void 0,texture:void 0},q[i]=r),r.type===t&&r.texture===n||(Y!==i&&(e.activeTexture(i),Y=i),e.bindTexture(t,n||ee[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=q[Y];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let i=l.get(n);void 0===i&&(i=new WeakMap,l.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=l.get(n).get(t);o.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),o.set(n,i))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===J.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),J.copy(t))},viewport:function(t){!1===Q.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),Q.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===i&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),c={},Y=null,q={},h={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,x=null,M=null,O=null,F=!1,B=null,z=null,H=null,k=null,G=null,J.set(0,0,e.canvas.width,e.canvas.height),Q.set(0,0,e.canvas.width,e.canvas.height),r.reset(),s.reset(),a.reset()}}}function _a(e,t,n,i,r,s,a){const o=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,h=r.maxTextureSize,u=r.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let f;const g=new WeakMap;let _=!1;try{_="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function v(e,t){return _?new OffscreenCanvas(e,t):st("canvas")}function x(e,t,n,i){let r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?Je:Math.floor,s=i(r*e.width),a=i(r*e.height);void 0===f&&(f=v(s,a));const o=n?v(s,a):f;o.width=s,o.height=a;return o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function y(e){return Ke(e.width)&&Ke(e.height)}function M(e,t){return e.generateMipmaps&&t&&e.minFilter!==J&&e.minFilter!==ee}function S(t){e.generateMipmap(t)}function E(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=s===Ee&&!1===a?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function T(e,t,n){return!0===M(e,n)||e.isFramebufferTexture&&e.minFilter!==J&&e.minFilter!==ee?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(t){return t===J||t===Q||t===$?e.NEAREST:e.LINEAR}function b(e){const t=e.target;t.removeEventListener("dispose",b),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&R(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=t.texture,r=i.get(t),s=i.get(n);void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t<r.__webglColorRenderbuffer.length;t++)r.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(r.__webglColorRenderbuffer[t]);r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,r=n.length;t<r;t++){const r=i.get(n[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),a.memory.textures--),i.remove(n[t])}i.remove(n),i.remove(t)}(n)}function R(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete g.get(r)[n.__cacheKey],a.memory.textures--}let C=0;function P(t,r){const s=i.get(t);if(t.isVideoTexture&&function(e){const t=a.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void O(s,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const L={[q]:e.REPEAT,[K]:e.CLAMP_TO_EDGE,[Z]:e.MIRRORED_REPEAT},I={[J]:e.NEAREST,[Q]:e.NEAREST_MIPMAP_NEAREST,[$]:e.NEAREST_MIPMAP_LINEAR,[ee]:e.LINEAR,[te]:e.LINEAR_MIPMAP_NEAREST,[ne]:e.LINEAR_MIPMAP_LINEAR},U={[Ae]:e.NEVER,[De]:e.ALWAYS,[Re]:e.LESS,[Pe]:e.LEQUAL,[Ce]:e.EQUAL,[Ue]:e.GEQUAL,[Le]:e.GREATER,[Ie]:e.NOTEQUAL};function D(n,s,a){if(a?(e.texParameteri(n,e.TEXTURE_WRAP_S,L[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[s.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),s.wrapS===K&&s.wrapT===K||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,w(s.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,w(s.minFilter)),s.minFilter!==J&&s.minFilter!==ee&&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(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,U[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.magFilter===J)return;if(s.minFilter!==$&&s.minFilter!==ne)return;if(s.type===oe&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===le&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function N(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",b));const r=n.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&R(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function O(t,r,a){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=N(t,r),u=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!o&&(e.wrapS!==K||e.wrapT!==K||e.minFilter!==J&&e.minFilter!==ee)}(r)&&!1===y(r.image);let i=x(r.image,t,!1,h);i=G(r,i);const p=y(i)||o,m=s.convert(r.format,r.colorSpace);let f,g=s.convert(r.type),_=E(r.internalFormat,m,g,r.colorSpace);D(l,r,p);const v=r.mipmaps,w=o&&!0!==r.isVideoTexture,b=void 0===d.__version||!0===c,A=T(r,i,p);if(r.isDepthTexture)_=e.DEPTH_COMPONENT,o?_=r.type===oe?e.DEPTH_COMPONENT32F:r.type===ae?e.DEPTH_COMPONENT24:r.type===ce?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===oe&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===ue&&_===e.DEPTH_COMPONENT&&r.type!==re&&r.type!==ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=ae,g=s.convert(r.type)),r.format===de&&_===e.DEPTH_COMPONENT&&(_=e.DEPTH_STENCIL,r.type!==ce&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ce,g=s.convert(r.type))),b&&(w?n.texStorage2D(e.TEXTURE_2D,1,_,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,_,i.width,i.height,0,m,g,null));else if(r.isDataTexture)if(v.length>0&&p){w&&b&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t<i;t++)f=v[t],w?n.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,m,g,f.data):n.texImage2D(e.TEXTURE_2D,t,_,f.width,f.height,0,m,g,f.data);r.generateMipmaps=!1}else w?(b&&n.texStorage2D(e.TEXTURE_2D,A,_,i.width,i.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,m,g,i.data)):n.texImage2D(e.TEXTURE_2D,0,_,i.width,i.height,0,m,g,i.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){w&&b&&n.texStorage3D(e.TEXTURE_2D_ARRAY,A,_,v[0].width,v[0].height,i.depth);for(let t=0,s=v.length;t<s;t++)f=v[t],r.format!==he?null!==m?w?n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,f.width,f.height,i.depth,m,f.data,0,0):n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,_,f.width,f.height,i.depth,0,f.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,f.width,f.height,i.depth,m,g,f.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,_,f.width,f.height,i.depth,0,m,g,f.data)}else{w&&b&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t<i;t++)f=v[t],r.format!==he?null!==m?w?n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,m,f.data):n.compressedTexImage2D(e.TEXTURE_2D,t,_,f.width,f.height,0,f.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?n.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,m,g,f.data):n.texImage2D(e.TEXTURE_2D,t,_,f.width,f.height,0,m,g,f.data)}else if(r.isDataArrayTexture)w?(b&&n.texStorage3D(e.TEXTURE_2D_ARRAY,A,_,i.width,i.height,i.depth),n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,m,g,i.data)):n.texImage3D(e.TEXTURE_2D_ARRAY,0,_,i.width,i.height,i.depth,0,m,g,i.data);else if(r.isData3DTexture)w?(b&&n.texStorage3D(e.TEXTURE_3D,A,_,i.width,i.height,i.depth),n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,i.width,i.height,i.depth,m,g,i.data)):n.texImage3D(e.TEXTURE_3D,0,_,i.width,i.height,i.depth,0,m,g,i.data);else if(r.isFramebufferTexture){if(b)if(w)n.texStorage2D(e.TEXTURE_2D,A,_,i.width,i.height);else{let t=i.width,r=i.height;for(let i=0;i<A;i++)n.texImage2D(e.TEXTURE_2D,i,_,t,r,0,m,g,null),t>>=1,r>>=1}}else if(v.length>0&&p){w&&b&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t<i;t++)f=v[t],w?n.texSubImage2D(e.TEXTURE_2D,t,0,0,m,g,f):n.texImage2D(e.TEXTURE_2D,t,_,m,g,f);r.generateMipmaps=!1}else w?(b&&n.texStorage2D(e.TEXTURE_2D,A,_,i.width,i.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,m,g,i)):n.texImage2D(e.TEXTURE_2D,0,_,m,g,i);M(r,p)&&S(l),d.__version=u.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function F(t,r,a,o,l){const c=s.convert(a.format,a.colorSpace),h=s.convert(a.type),u=E(a.internalFormat,c,h,a.colorSpace);i.get(r).__hasExternalTextures||(l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,0,u,r.width,r.height,r.depth,0,c,h,null):n.texImage2D(l,0,u,r.width,r.height,0,c,h,null)),n.bindFramebuffer(e.FRAMEBUFFER,t),k(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0,H(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function B(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||k(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===oe?r=e.DEPTH_COMPONENT32F:t.type===ae&&(r=e.DEPTH_COMPONENT24));const i=H(n);k(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=H(n);i&&!1===k(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):k(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r<t.length;r++){const a=t[r],o=s.convert(a.format,a.colorSpace),l=s.convert(a.type),c=E(a.internalFormat,o,l,a.colorSpace),h=H(n);i&&!1===k(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,h,c,n.width,n.height):k(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,h,c,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,c,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function z(t){const r=i.get(t),s=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),P(r.depthTexture,0);const s=i.get(r.depthTexture).__webglTexture,a=H(r);if(r.depthTexture.format===ue)k(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,a):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==de)throw new Error("Unknown depthTexture format");k(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,a):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}(r.__webglFramebuffer,t)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=e.createRenderbuffer(),B(r.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),B(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(e.FRAMEBUFFER,null)}function H(e){return Math.min(u,e.samples)}function k(e){const n=i.get(e);return o&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){const i=e.colorSpace,r=e.format,s=e.type;return!0===e.isCompressedTexture||e.format===Fe||i!==Te&&i!==Se&&(i===Ee?!1===o?!0===t.has("EXT_sRGB")&&r===he?(e.format=Fe,e.minFilter=ee,e.generateMipmaps=!1):n=gt.sRGBToLinear(n):r===he&&s===ie||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=P,this.setTexture2DArray=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=i.get(h);if(h.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=G(r,d[e]);const p=d[0],m=y(p)||o,f=s.convert(r.format,r.colorSpace),g=s.convert(r.type),_=E(r.internalFormat,f,g,r.colorSpace),v=o&&!0!==r.isVideoTexture,w=void 0===u.__version||!0===l;let b,A=T(r,p,m);if(D(e.TEXTURE_CUBE_MAP,r,m),t){v&&w&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,p.width,p.height);for(let t=0;t<6;t++){b=d[t].mipmaps;for(let i=0;i<b.length;i++){const s=b[i];r.format!==he?null!==f?v?n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,s.width,s.height,f,s.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,_,s.width,s.height,0,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,s.width,s.height,f,g,s.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,_,s.width,s.height,0,f,g,s.data)}}}else{b=r.mipmaps,v&&w&&(b.length>0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,f,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,d[t].width,d[t].height,0,f,g,d[t].data);for(let i=0;i<b.length;i++){const r=b[i].image[t].image;v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,f,g,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,_,r.width,r.height,0,f,g,r.data)}}else{v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f,g,d[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,f,g,d[t]);for(let i=0;i<b.length;i++){const r=b[i];v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,f,g,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,_,f,g,r.image[t])}}}M(r,m)&&S(e.TEXTURE_CUBE_MAP),u.__version=h.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(a,t,r):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+r)},this.rebindTextures=function(t,n,r){const s=i.get(t);void 0!==n&&F(s.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==r&&z(t)},this.setupRenderTarget=function(t){const l=t.texture,c=i.get(t),h=i.get(l);t.addEventListener("dispose",A),!0!==t.isWebGLMultipleRenderTargets&&(void 0===h.__webglTexture&&(h.__webglTexture=e.createTexture()),h.__version=l.version,a.memory.textures++);const u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=y(t)||o;if(u){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),d)if(r.drawBuffers){const n=t.texture;for(let t=0,r=n.length;t<r;t++){const r=i.get(n[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&t.samples>0&&!1===k(t)){const i=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n<i.length;n++){const r=i[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,c.__webglColorRenderbuffer[n]);const a=s.convert(r.format,r.colorSpace),o=s.convert(r.type),l=E(r.internalFormat,a,o,r.colorSpace,!0===t.isXRRenderTarget),h=H(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,h,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,c.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),B(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,h.__webglTexture),D(e.TEXTURE_CUBE_MAP,l,p);for(let n=0;n<6;n++)F(c.__webglFramebuffer[n],t,l,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n);M(l,p)&&S(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){const r=t.texture;for(let s=0,a=r.length;s<a;s++){const a=r[s],o=i.get(a);n.bindTexture(e.TEXTURE_2D,o.__webglTexture),D(e.TEXTURE_2D,a,p),F(c.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+s,e.TEXTURE_2D),M(a,p)&&S(e.TEXTURE_2D)}n.unbindTexture()}else{let i=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(o?i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(i,h.__webglTexture),D(i,l,p),F(c.__webglFramebuffer,t,l,e.COLOR_ATTACHMENT0,i),M(l,p)&&S(i),n.unbindTexture()}t.depthBuffer&&z(t)},this.updateRenderTargetMipmap=function(t){const r=y(t)||o,s=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let a=0,o=s.length;a<o;a++){const o=s[a];if(M(o,r)){const r=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,s=i.get(o).__webglTexture;n.bindTexture(r,s),S(r),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(o&&t.samples>0&&!1===k(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,h.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,h.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,h.__webglFramebuffer);for(let n=0;n<r.length;n++){l.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&l.push(c);const d=void 0!==h.__ignoreDepthValues&&h.__ignoreDepthValues;if(!1===d&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),u&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,h.__webglColorRenderbuffer[n]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[c]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[c])),u){const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,s,a,0,0,s,a,o,e.NEAREST),p&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,l)}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,h.__webglColorRenderbuffer[t]);const s=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,h.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,s,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,h.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=F,this.useMultisampledRTT=k}function va(e,t,n){const i=n.isWebGL2;return{convert:function(n,r=""){let s;if(n===ie)return e.UNSIGNED_BYTE;if(1017===n)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===n)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===n)return e.BYTE;if(1011===n)return e.SHORT;if(n===re)return e.UNSIGNED_SHORT;if(n===se)return e.INT;if(n===ae)return e.UNSIGNED_INT;if(n===oe)return e.FLOAT;if(n===le)return i?e.HALF_FLOAT:(s=t.get("OES_texture_half_float"),null!==s?s.HALF_FLOAT_OES:null);if(1021===n)return e.ALPHA;if(n===he)return e.RGBA;if(1024===n)return e.LUMINANCE;if(1025===n)return e.LUMINANCE_ALPHA;if(n===ue)return e.DEPTH_COMPONENT;if(n===de)return e.DEPTH_STENCIL;if(n===Fe)return s=t.get("EXT_sRGB"),null!==s?s.SRGB_ALPHA_EXT:null;if(1028===n)return e.RED;if(1029===n)return e.RED_INTEGER;if(1030===n)return e.RG;if(1031===n)return e.RG_INTEGER;if(1033===n)return e.RGBA_INTEGER;if(n===pe||n===me||n===fe||n===ge)if(r===Ee){if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(n===pe)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===me)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===fe)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ge)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=t.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(n===pe)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===me)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===fe)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ge)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(s=t.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(35840===n)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===n)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===n)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===n)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===n)return s=t.get("WEBGL_compressed_texture_etc1"),null!==s?s.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===n||37496===n){if(s=t.get("WEBGL_compressed_texture_etc"),null===s)return null;if(37492===n)return r===Ee?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(37496===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}if(37808===n||37809===n||37810===n||37811===n||37812===n||37813===n||37814===n||37815===n||37816===n||37817===n||37818===n||37819===n||37820===n||37821===n){if(s=t.get("WEBGL_compressed_texture_astc"),null===s)return null;if(37808===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return r===Ee?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===_e){if(s=t.get("EXT_texture_compression_bptc"),null===s)return null;if(n===_e)return r===Ee?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===n||36284===n||36285===n||36286===n){if(s=t.get("EXT_texture_compression_rgtc"),null===s)return null;if(n===_e)return s.COMPRESSED_RED_RGTC1_EXT;if(36284===n)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===n)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===n)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===ce?i?e.UNSIGNED_INT_24_8:(s=t.get("WEBGL_depth_texture"),null!==s?s.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class xa extends Fi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ya extends Cn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ma={type:"move"};class Sa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ya,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new ya,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new At,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new At),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ya,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new At,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new At),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){s=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Ma)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new ya;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ea extends Mt{constructor(e,t,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:ue)!==ue&&c!==de)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===ue&&(n=ae),void 0===n&&c===de&&(n=ce),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:J,this.minFilter=void 0!==o?o:J,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Ta extends He{constructor(e,t){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const m=t.getContextAttributes();let f=null,g=null;const _=[],v=[];let x=null;const y=new Fi;y.layers.enable(1),y.viewport=new St;const M=new Fi;M.layers.enable(2),M.viewport=new St;const S=[y,M],E=new xa;E.layers.enable(1),E.layers.enable(2);let T=null,w=null;function b(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function A(){i.removeEventListener("select",b),i.removeEventListener("selectstart",b),i.removeEventListener("selectend",b),i.removeEventListener("squeeze",b),i.removeEventListener("squeezestart",b),i.removeEventListener("squeezeend",b),i.removeEventListener("end",A),i.removeEventListener("inputsourceschange",R);for(let e=0;e<_.length;e++){const t=v[e];null!==t&&(v[e]=null,_[e].disconnect(t))}T=null,w=null,e.setRenderTarget(f),d=null,u=null,h=null,i=null,g=null,U.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function R(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=v.indexOf(n);i>=0&&(v[i]=null,_[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=v.indexOf(n);if(-1===i){for(let e=0;e<_.length;e++){if(e>=v.length){v.push(n),i=e;break}if(null===v[e]){v[e]=n,i=e;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getCamera=function(){},this.setUserCamera=function(e){x=e},this.getController=function(e){let t=_[e];return void 0===t&&(t=new Sa,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new Sa,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new Sa,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(f=e.getRenderTarget(),i.addEventListener("select",b),i.addEventListener("selectstart",b),i.addEventListener("selectend",b),i.addEventListener("squeeze",b),i.addEventListener("squeezestart",b),i.addEventListener("squeezeend",b),i.addEventListener("end",A),i.addEventListener("inputsourceschange",R),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new Et(d.framebufferWidth,d.framebufferHeight,{format:he,type:ie,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?de:ue,s=m.stencil?ce:ae);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new Et(u.textureWidth,u.textureHeight,{format:he,type:ie,depthTexture:new Ea(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const C=new At,P=new At;function L(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCameraXR=function(e){if(null===i)return e;x&&(e=x),E.near=M.near=y.near=e.near,E.far=M.far=y.far=e.far,T===E.near&&w===E.far||(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,w=E.far);const t=e.parent,n=E.cameras;L(E,t);for(let e=0;e<n.length;e++)L(n[e],t);return 2===n.length?function(e,t,n){C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);const i=C.distanceTo(P),r=t.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*h,p=a*u,m=i/(-h+u),f=m*-h;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,x=p+(i-f),y=l*o/_*g,M=c*o/_*g;e.projectionMatrix.makePerspective(v,x,y,M,g,_),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(E,y,M):E.projectionMatrix.copy(y.projectionMatrix),x&&function(e,t){const n=x;null===t?n.matrix.copy(e.matrixWorld):(n.matrix.copy(t.matrixWorld),n.matrix.invert(),n.matrix.multiply(e.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0);const i=n.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(!0);n.projectionMatrix.copy(e.projectionMatrix),n.projectionMatrixInverse.copy(e.projectionMatrixInverse),n.isPerspectiveCamera&&(n.fov=2*We*Math.atan(1/n.projectionMatrix.elements[5]),n.zoom=1)}(E,t),E},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(e){o=e,null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let I=null;const U=new Ki;U.setAnimationLoop((function(t,i){if(c=i.getViewerPose(l||s),p=i,null!==c){const t=c.views;null!==d&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let n=!1;t.length!==E.cameras.length&&(E.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let s=null;if(null!==d)s=d.getViewport(r);else{const t=h.getViewSubImage(u,r);s=t.viewport,0===i&&(e.setRenderTargetTextures(g,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}let a=S[i];void 0===a&&(a=new Fi,a.layers.enable(i),a.viewport=new St,S[i]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(E.matrix.copy(a.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),!0===n&&E.cameras.push(a)}}for(let e=0;e<_.length;e++){const t=v[e],n=_[e];null!==t&&void 0!==n&&n.update(t,i,l||s)}I&&I(t,i),i.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:i}),p=null})),this.setAnimationLoop=function(e){I=e},this.dispose=function(){}}}function wa(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(i,r){i.opacity.value=r.opacity,r.color&&i.diffuse.value.copy(r.color),r.emissive&&i.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(i.map.value=r.map,n(r.map,i.mapTransform)),r.alphaMap&&(i.alphaMap.value=r.alphaMap,n(r.alphaMap,i.alphaMapTransform)),r.bumpMap&&(i.bumpMap.value=r.bumpMap,n(r.bumpMap,i.bumpMapTransform),i.bumpScale.value=r.bumpScale,r.side===y&&(i.bumpScale.value*=-1)),r.normalMap&&(i.normalMap.value=r.normalMap,n(r.normalMap,i.normalMapTransform),i.normalScale.value.copy(r.normalScale),r.side===y&&i.normalScale.value.negate()),r.displacementMap&&(i.displacementMap.value=r.displacementMap,n(r.displacementMap,i.displacementMapTransform),i.displacementScale.value=r.displacementScale,i.displacementBias.value=r.displacementBias),r.emissiveMap&&(i.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,i.emissiveMapTransform)),r.specularMap&&(i.specularMap.value=r.specularMap,n(r.specularMap,i.specularMapTransform)),r.alphaTest>0&&(i.alphaTest.value=r.alphaTest);const s=t.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Ui(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform));e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));const r=t.get(i).envMap;r&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===y&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function ba(e,t,n,i){let r={},s={},a=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t<e.length;t++)r.push(e[t].clone());n[t]=r}return!0}if("number"==typeof i){if(n[t]!==i)return n[t]=i,!0}else{const e=Array.isArray(n[t])?n[t]:[n[t]],r=Array.isArray(i)?i:[i];for(let t=0;t<e.length;t++){const n=e[t];if(!1===n.equals(r[t]))return n.copy(r[t]),!0}}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.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),t}function h(t){const n=t.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,u){let d=r[n.id];void 0===d&&(!function(e){const t=e.uniforms;let n=0;const i=16;let r=0;for(let e=0,s=t.length;e<s;e++){const s=t[e],a={boundary:0,storage:0},o=Array.isArray(s.value)?s.value:[s.value];for(let e=0,t=o.length;e<t;e++){const t=c(o[e]);a.boundary+=t.boundary,a.storage+=t.storage}if(s.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),s.__offset=n,e>0){r=n%i;0!==r&&i-r-a.boundary<0&&(n+=i-r,s.__offset=n)}n+=a.storage}r=n%i,r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,s=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,s),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",h));const p=u.program;i.updateUBOMapping(n,p);const m=t.render.frame;s[n.id]!==m&&(!function(t){const n=r[t.id],i=t.uniforms,s=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){const n=i[t];if(!0===l(n,t,s)){const t=n.__offset,i=Array.isArray(n.value)?n.value:[n.value];let r=0;for(let s=0;s<i.length;s++){const a=i[s],o=c(a);"number"==typeof a?(n.__data[0]=a,e.bufferSubData(e.UNIFORM_BUFFER,t+r,n.__data)):a.isMatrix3?(n.__data[0]=a.elements[0],n.__data[1]=a.elements[1],n.__data[2]=a.elements[2],n.__data[3]=a.elements[0],n.__data[4]=a.elements[3],n.__data[5]=a.elements[4],n.__data[6]=a.elements[5],n.__data[7]=a.elements[0],n.__data[8]=a.elements[6],n.__data[9]=a.elements[7],n.__data[10]=a.elements[8],n.__data[11]=a.elements[0]):(a.toArray(n.__data,r),r+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,n.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),s[n.id]=m)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);a=[],r={},s={}}}}function Aa(){const e=st("canvas");return e.style.display="block",e}class Ra{constructor(e={}){const{canvas:t=Aa(),context:n=null,depth:i=!0,stencil:r=!0,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;let d;this.isWebGLRenderer=!0,d=null!==n?n.getContextAttributes().alpha:s;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const _=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Ee,this.useLegacyLights=!0,this.toneMapping=z,this.toneMappingExposure=1;const M=this;let S=!1,E=0,T=0,w=null,b=-1,A=null;const R=new St,C=new St;let P=null;const L=new qn(0);let I=0,U=t.width,D=t.height,N=1,O=null,F=null;const B=new St(0,0,U,D),H=new St(0,0,U,D);let k=!1;const G=new qi;let V=!1,W=!1,X=null;const j=new rn,Y=new tt,q=new At,K={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Z(){return null===w?N:1}let J,Q,$,ee,te,se,ue,de,pe,me,fe,ge,_e,ve,xe,ye,Me,Se,we,be,Ae,Re,Ce,Pe,Le=n;function Ie(e,n){for(let i=0;i<e.length;i++){const r=e[i],s=t.getContext(r,n);if(null!==s)return s}return null}try{const e={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${l}`),t.addEventListener("webglcontextlost",Ne,!1),t.addEventListener("webglcontextrestored",Oe,!1),t.addEventListener("webglcontextcreationerror",Fe,!1),null===Le){const t=["webgl2","webgl","experimental-webgl"];if(!0===M.isWebGL1Renderer&&t.shift(),Le=Ie(t,e),null===Le)throw Ie(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Le instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Le.getShaderPrecisionFormat&&(Le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ue(){J=new Tr(Le),Q=new sr(Le,J,e),J.init(Q),Re=new va(Le,J,Q),$=new ga(Le,J,Q),ee=new Ar(Le),te=new na,se=new _a(Le,J,$,te,Q,Re,ee),ue=new or(M),de=new Er(M),pe=new Zi(Le,Q),Ce=new ir(Le,J,pe,Q),me=new wr(Le,pe,ee,Ce),fe=new Lr(Le,me,pe,ee),we=new Pr(Le,Q,se),ye=new ar(te),ge=new ta(M,ue,de,J,Q,Ce,ye),_e=new wa(M,te),ve=new aa,xe=new da(J,Q),Se=new nr(M,ue,de,$,fe,d,o),Me=new fa(M,fe,Q),Pe=new ba(Le,ee,Q,$),be=new rr(Le,J,ee,Q),Ae=new br(Le,J,ee,Q),ee.programs=ge.programs,M.capabilities=Q,M.extensions=J,M.properties=te,M.renderLists=ve,M.shadowMap=Me,M.state=$,M.info=ee}Ue();const De=new Ta(M,Le);function Ne(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Oe(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const e=ee.autoReset,t=Me.enabled,n=Me.autoUpdate,i=Me.needsUpdate,r=Me.type;Ue(),ee.autoReset=e,Me.enabled=t,Me.autoUpdate=n,Me.needsUpdate=i,Me.type=r}function Fe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Be(e){const t=e.target;t.removeEventListener("dispose",Be),function(e){(function(e){const t=te.get(e).programs;void 0!==t&&(t.forEach((function(e){ge.releaseProgram(e)})),e.isShaderMaterial&&ge.releaseShaderCache(e))})(e),te.remove(e)}(t)}this.xr=De,this.getContext=function(){return Le},this.getContextAttributes=function(){return Le.getContextAttributes()},this.forceContextLoss=function(){const e=J.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=J.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(e){void 0!==e&&(N=e,this.setSize(U,D,!1))},this.getSize=function(e){return e.set(U,D)},this.setSize=function(e,n,i=!0){De.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(U=e,D=n,t.width=Math.floor(e*N),t.height=Math.floor(n*N),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(U*N,D*N).floor()},this.setDrawingBufferSize=function(e,n,i){U=e,D=n,N=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(R)},this.getViewport=function(e){return e.copy(B)},this.setViewport=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),$.viewport(R.copy(B).multiplyScalar(N).floor())},this.getScissor=function(e){return e.copy(H)},this.setScissor=function(e,t,n,i){e.isVector4?H.set(e.x,e.y,e.z,e.w):H.set(e,t,n,i),$.scissor(C.copy(H).multiplyScalar(N).floor())},this.getScissorTest=function(){return k},this.setScissorTest=function(e){$.setScissorTest(k=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){F=e},this.getClearColor=function(e){return e.copy(Se.getClearColor())},this.setClearColor=function(){Se.setClearColor.apply(Se,arguments)},this.getClearAlpha=function(){return Se.getClearAlpha()},this.setClearAlpha=function(){Se.setClearAlpha.apply(Se,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==w){const t=w.texture.format;e=1033===t||1031===t||1029===t}if(e){const e=w.texture.type,t=e===ie||e===ae||e===re||e===ce||1017===e||1018===e,n=Se.getClearColor(),i=Se.getClearAlpha(),r=n.r,s=n.g,a=n.b,o=te.get(w).__webglFramebuffer;t?(p[0]=r,p[1]=s,p[2]=a,p[3]=i,Le.clearBufferuiv(Le.COLOR,o,p)):(m[0]=r,m[1]=s,m[2]=a,m[3]=i,Le.clearBufferiv(Le.COLOR,o,m))}else i|=Le.COLOR_BUFFER_BIT}t&&(i|=Le.DEPTH_BUFFER_BIT),n&&(i|=Le.STENCIL_BUFFER_BIT),Le.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ne,!1),t.removeEventListener("webglcontextrestored",Oe,!1),t.removeEventListener("webglcontextcreationerror",Fe,!1),ve.dispose(),xe.dispose(),te.dispose(),ue.dispose(),de.dispose(),fe.dispose(),Ce.dispose(),Pe.dispose(),ge.dispose(),De.dispose(),De.removeEventListener("sessionstart",He),De.removeEventListener("sessionend",ke),X&&(X.dispose(),X=null),Ge.stop()},this.renderBufferDirect=function(e,t,n,i,r,s){null===t&&(t=K);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=K);se.resetTextureUnits();const s=t.fog,a=i.isMeshStandardMaterial?t.environment:null,o=null===w?M.outputColorSpace:!0===w.isXRRenderTarget?w.texture.colorSpace:Te,l=(i.isMeshStandardMaterial?de:ue).get(i.envMap||a),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=i.toneMapped?M.toneMapping:z,f=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==f?f.length:0,v=te.get(i),x=g.state.lights;if(!0===V&&(!0===W||e!==A)){const t=e===A&&i.id===b;ye.setState(i,e,t)}let y=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==x.state.version||v.outputColorSpace!==o||r.isInstancedMesh&&!1===v.instancing?y=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?y=!0:r.isSkinnedMesh||!0!==v.skinning?v.envMap!==l||!0===i.fog&&v.fog!==s?y=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ye.numPlanes&&v.numIntersection===ye.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==m||!0===Q.isWebGL2&&v.morphTargetsCount!==_)&&(y=!0):y=!0:y=!0:y=!0:(y=!0,v.__version=i.version);let S=v.currentProgram;!0===y&&(S=Ye(i,t,r));let E=!1,T=!1,R=!1;const C=S.getUniforms(),P=v.uniforms;$.useProgram(S.program)&&(E=!0,T=!0,R=!0);i.id!==b&&(b=i.id,T=!0);if(E||A!==e){if(C.setValue(Le,"projectionMatrix",e.projectionMatrix),Q.logarithmicDepthBuffer&&C.setValue(Le,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),A!==e&&(A=e,T=!0,R=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=C.map.cameraPosition;void 0!==t&&t.setValue(Le,q.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&C.setValue(Le,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&C.setValue(Le,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){C.setOptional(Le,r,"bindMatrix"),C.setOptional(Le,r,"bindMatrixInverse");const e=r.skeleton;e&&(Q.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),C.setValue(Le,"boneTexture",e.boneTexture,se),C.setValue(Le,"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."))}const L=n.morphAttributes;(void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===Q.isWebGL2)&&we.update(r,n,S);(T||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,C.setValue(Le,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);T&&(C.setValue(Le,"toneMappingExposure",M.toneMappingExposure),v.needsLights&&(U=R,(I=P).ambientLightColor.needsUpdate=U,I.lightProbe.needsUpdate=U,I.directionalLights.needsUpdate=U,I.directionalLightShadows.needsUpdate=U,I.pointLights.needsUpdate=U,I.pointLightShadows.needsUpdate=U,I.spotLights.needsUpdate=U,I.spotLightShadows.needsUpdate=U,I.rectAreaLights.needsUpdate=U,I.hemisphereLights.needsUpdate=U),s&&!0===i.fog&&_e.refreshFogUniforms(P,s),_e.refreshMaterialUniforms(P,i,N,D,X),Ns.upload(Le,v.uniformsList,P,se));var I,U;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Ns.upload(Le,v.uniformsList,P,se),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&C.setValue(Le,"center",r.center);if(C.setValue(Le,"modelViewMatrix",r.modelViewMatrix),C.setValue(Le,"normalMatrix",r.normalMatrix),C.setValue(Le,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(Q.isWebGL2){const n=e[t];Pe.update(n,S),Pe.bind(n,S)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return S}(e,t,n,i,r);$.setMaterial(i,a);let l=n.index,c=1;!0===i.wireframe&&(l=me.getWireframeAttribute(n),c=2);const h=n.drawRange,u=n.attributes.position;let d=h.start*c,p=(h.start+h.count)*c;null!==s&&(d=Math.max(d,s.start*c),p=Math.min(p,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const m=p-d;if(m<0||m===1/0)return;let f;Ce.setup(r,i,o,n,l);let _=be;if(null!==l&&(f=pe.get(l),_=Ae,_.setIndex(f)),r.isMesh)!0===i.wireframe?($.setLineWidth(i.wireframeLinewidth*Z()),_.setMode(Le.LINES)):_.setMode(Le.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),$.setLineWidth(e*Z()),r.isLineSegments?_.setMode(Le.LINES):r.isLineLoop?_.setMode(Le.LINE_LOOP):_.setMode(Le.LINE_STRIP)}else r.isPoints?_.setMode(Le.POINTS):r.isSprite&&_.setMode(Le.TRIANGLES);if(r.isInstancedMesh)_.renderInstances(d,m,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);_.renderInstances(d,m,t)}else _.render(d,m)},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=y,e.needsUpdate=!0,Ye(e,t,n),e.side=x,e.needsUpdate=!0,Ye(e,t,n),e.side=2):Ye(e,t,n)}g=xe.get(e),g.init(),v.push(g),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(g.pushLight(e),e.castShadow&&g.pushShadow(e))})),g.setupLights(M.useLegacyLights),e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let r=0;r<i.length;r++){n(i[r],e,t)}else n(i,e,t)})),v.pop(),g=null};let ze=null;function He(){Ge.stop()}function ke(){Ge.start()}const Ge=new Ki;function Ve(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)g.pushLight(e),e.castShadow&&g.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||G.intersectsSprite(e)){i&&q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);const t=fe.update(e),r=e.material;r.visible&&f.push(e,t,r,n,q.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||G.intersectsObject(e))){e.isSkinnedMesh&&e.skeleton.frame!==ee.render.frame&&(e.skeleton.update(),e.skeleton.frame=ee.render.frame);const t=fe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)),q.applyMatrix4(e.matrixWorld).applyMatrix4(j)),Array.isArray(r)){const i=t.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&f.push(e,t,o,n,q.z,a)}}else r.visible&&f.push(e,t,r,n,q.z,null)}const r=e.children;for(let e=0,s=r.length;e<s;e++)Ve(r[e],t,n,i)}function We(e,t,n,i){const r=e.opaque,s=e.transmissive,o=e.transparent;g.setupLightsView(n),!0===V&&ye.setGlobalState(M.clippingPlanes,n),s.length>0&&function(e,t,n,i){const r=Q.isWebGL2;null===X&&(X=new Et(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")?le:ie,minFilter:ne,samples:r&&!0===a?4:0}));M.getDrawingBufferSize(Y),r?X.setSize(Y.x,Y.y):X.setSize(Je(Y.x),Je(Y.y));const s=M.getRenderTarget();M.setRenderTarget(X),M.getClearColor(L),I=M.getClearAlpha(),I<1&&M.setClearColor(16777215,.5);M.clear();const o=M.toneMapping;M.toneMapping=z,Xe(e,n,i),se.updateMultisampleRenderTarget(X),se.updateRenderTargetMipmap(X);let l=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e],s=r.object,a=r.geometry,o=r.material,c=r.group;if(2===o.side&&s.layers.test(i.layers)){const e=o.side;o.side=y,o.needsUpdate=!0,je(s,n,i,a,o,c),o.side=e,o.needsUpdate=!0,l=!0}}!0===l&&(se.updateMultisampleRenderTarget(X),se.updateRenderTargetMipmap(X));M.setRenderTarget(s),M.setClearColor(L,I),M.toneMapping=o}(r,s,t,n),i&&$.viewport(R.copy(i)),r.length>0&&Xe(r,t,n),s.length>0&&Xe(s,t,n),o.length>0&&Xe(o,t,n),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function Xe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,l=null===i?s.material:i,c=s.group;a.layers.test(n.layers)&&je(a,t,n,o,l,c)}}function je(e,t,n,i,r,s){e.onBeforeRender(M,t,n,i,r,s),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(M,t,n,i,e,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=y,r.needsUpdate=!0,M.renderBufferDirect(n,t,i,r,e,s),r.side=x,r.needsUpdate=!0,M.renderBufferDirect(n,t,i,r,e,s),r.side=2):M.renderBufferDirect(n,t,i,r,e,s),e.onAfterRender(M,t,n,i,r,s)}function Ye(e,t,n){!0!==t.isScene&&(t=K);const i=te.get(e),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=ge.getParameters(e,r.state,s,t,n),l=ge.getProgramCacheKey(o);let c=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?de:ue).get(e.envMap||i.environment),void 0===c&&(e.addEventListener("dispose",Be),c=new Map,i.programs=c);let h=c.get(l);if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return qe(e,o),h}else o.uniforms=ge.getUniforms(e),e.onBuild(n,o,M),e.onBeforeCompile(o,M),h=ge.acquireProgram(o,l),c.set(l,h),i.uniforms=o.uniforms;const u=i.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=ye.uniform),qe(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=a,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const d=h.getUniforms(),p=Ns.seqWithValue(d.seq,u);return i.currentProgram=h,i.uniformsList=p,h}function qe(e,t){const n=te.get(e);n.outputColorSpace=t.outputColorSpace,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Ge.setAnimationLoop((function(e){ze&&ze(e)})),"undefined"!=typeof self&&Ge.setContext(self),this.setAnimationLoop=function(e){ze=e,De.setAnimationLoop(e),null===e?Ge.stop():Ge.start()},De.addEventListener("sessionstart",He),De.addEventListener("sessionend",ke),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===S)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===De.enabled&&!0===De.isPresenting&&(t=De.updateCameraXR(t)),!0===e.isScene&&e.onBeforeRender(M,e,t,w),g=xe.get(e,v.length),g.init(),v.push(g),j.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),G.setFromProjectionMatrix(j),W=this.localClippingEnabled,V=ye.init(this.clippingPlanes,W),f=ve.get(e,_.length),f.init(),_.push(f),Ve(e,t,0,M.sortObjects),f.finish(),!0===M.sortObjects&&f.sort(O,F),!0===V&&ye.beginShadows();const n=g.state.shadowsArray;if(Me.render(n,e,t),!0===V&&ye.endShadows(),!0===this.info.autoReset&&this.info.reset(),this.info.render.frame++,Se.render(f,e),g.setupLights(M.useLegacyLights),t.isArrayCamera){const n=t.cameras;for(let t=0,i=n.length;t<i;t++){const i=n[t];We(f,e,i,i.viewport)}}else We(f,e,t);null!==w&&(se.updateMultisampleRenderTarget(w),se.updateRenderTargetMipmap(w)),!0===e.isScene&&e.onAfterRender(M,e,t),Ce.resetDefaultState(),b=-1,A=null,v.pop(),g=v.length>0?v[v.length-1]:null,_.pop(),f=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){te.get(e.texture).__webglTexture=t,te.get(e.depthTexture).__webglTexture=n;const i=te.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===J.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=te.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){w=e,E=t,T=n;let i=!0,r=null,s=!1,a=!1;if(e){const n=te.get(e);void 0!==n.__useDefaultFramebuffer?($.bindFramebuffer(Le.FRAMEBUFFER,null),i=!1):void 0===n.__webglFramebuffer?se.setupRenderTarget(e):n.__hasExternalTextures&&se.rebindTextures(e,te.get(e.texture).__webglTexture,te.get(e.depthTexture).__webglTexture);const o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(a=!0);const l=te.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],s=!0):r=Q.isWebGL2&&e.samples>0&&!1===se.useMultisampledRTT(e)?te.get(e).__webglMultisampledFramebuffer:l,R.copy(e.viewport),C.copy(e.scissor),P=e.scissorTest}else R.copy(B).multiplyScalar(N).floor(),C.copy(H).multiplyScalar(N).floor(),P=k;if($.bindFramebuffer(Le.FRAMEBUFFER,r)&&Q.drawBuffers&&i&&$.drawBuffers(e,r),$.viewport(R),$.scissor(C),$.setScissorTest(P),s){const i=te.get(e.texture);Le.framebufferTexture2D(Le.FRAMEBUFFER,Le.COLOR_ATTACHMENT0,Le.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=te.get(e.texture),r=t||0;Le.framebufferTextureLayer(Le.FRAMEBUFFER,Le.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){$.bindFramebuffer(Le.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(o!==he&&Re.convert(o)!==Le.getParameter(Le.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===le&&(J.has("EXT_color_buffer_half_float")||Q.isWebGL2&&J.has("EXT_color_buffer_float"));if(!(l===ie||Re.convert(l)===Le.getParameter(Le.IMPLEMENTATION_COLOR_READ_TYPE)||l===oe&&(Q.isWebGL2||J.has("OES_texture_float")||J.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Le.readPixels(t,n,i,r,Re.convert(o),Re.convert(l),s)}finally{const e=null!==w?te.get(w).__webglFramebuffer:null;$.bindFramebuffer(Le.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i);se.setTexture2D(t,0),Le.copyTexSubImage2D(Le.TEXTURE_2D,n,0,0,e.x,e.y,r,s),$.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,s=t.image.height,a=Re.convert(n.format),o=Re.convert(n.type);se.setTexture2D(n,0),Le.pixelStorei(Le.UNPACK_FLIP_Y_WEBGL,n.flipY),Le.pixelStorei(Le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Le.pixelStorei(Le.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Le.texSubImage2D(Le.TEXTURE_2D,i,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?Le.compressedTexSubImage2D(Le.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Le.texSubImage2D(Le.TEXTURE_2D,i,e.x,e.y,a,o,t.image),0===i&&n.generateMipmaps&&Le.generateMipmap(Le.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(M.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=Re.convert(i.format),c=Re.convert(i.type);let h;if(i.isData3DTexture)se.setTexture3D(i,0),h=Le.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");se.setTexture2DArray(i,0),h=Le.TEXTURE_2D_ARRAY}Le.pixelStorei(Le.UNPACK_FLIP_Y_WEBGL,i.flipY),Le.pixelStorei(Le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Le.pixelStorei(Le.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Le.getParameter(Le.UNPACK_ROW_LENGTH),d=Le.getParameter(Le.UNPACK_IMAGE_HEIGHT),p=Le.getParameter(Le.UNPACK_SKIP_PIXELS),m=Le.getParameter(Le.UNPACK_SKIP_ROWS),f=Le.getParameter(Le.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Le.pixelStorei(Le.UNPACK_ROW_LENGTH,g.width),Le.pixelStorei(Le.UNPACK_IMAGE_HEIGHT,g.height),Le.pixelStorei(Le.UNPACK_SKIP_PIXELS,e.min.x),Le.pixelStorei(Le.UNPACK_SKIP_ROWS,e.min.y),Le.pixelStorei(Le.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Le.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Le.compressedTexSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,g.data)):Le.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g),Le.pixelStorei(Le.UNPACK_ROW_LENGTH,u),Le.pixelStorei(Le.UNPACK_IMAGE_HEIGHT,d),Le.pixelStorei(Le.UNPACK_SKIP_PIXELS,p),Le.pixelStorei(Le.UNPACK_SKIP_ROWS,m),Le.pixelStorei(Le.UNPACK_SKIP_IMAGES,f),0===r&&i.generateMipmaps&&Le.generateMipmap(h),$.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?se.setTextureCube(e,0):e.isData3DTexture?se.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?se.setTexture2DArray(e,0):se.setTexture2D(e,0),$.unbindTexture()},this.resetState=function(){E=0,T=0,w=null,$.reset(),Ce.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Be}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===Ee?Me:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Me?Ee:Te}}(class extends Ra{}).prototype.isWebGL1Renderer=!0;class Ca extends Cn{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,t){return super.copy(e,t),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){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class Pa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Ne,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Xe()}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,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xe()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xe()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const La=new At;class Ia{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)La.fromBufferAttribute(this,t),La.applyMatrix4(e),this.setXYZ(t,La.x,La.y,La.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)La.fromBufferAttribute(this,t),La.applyNormalMatrix(e),this.setXYZ(t,La.x,La.y,La.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)La.fromBufferAttribute(this,t),La.transformDirection(e),this.setXYZ(t,La.x,La.y,La.z);return this}setX(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Qe(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Qe(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Qe(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Qe(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),i=$e(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),i=$e(i,this.array),r=$e(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new $n(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ia(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ua extends Vn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new qn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Da;const Na=new At,Oa=new At,Fa=new At,Ba=new tt,za=new tt,Ha=new rn,ka=new At,Ga=new At,Va=new At,Wa=new tt,Xa=new tt,ja=new tt;class Ya extends Cn{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Da){Da=new hi;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new Pa(e,5);Da.setIndex([0,1,2,0,2,3]),Da.setAttribute("position",new Ia(t,3,0,!1)),Da.setAttribute("uv",new Ia(t,2,3,!1))}this.geometry=Da,this.material=void 0!==e?e:new Ua,this.center=new tt(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Oa.setFromMatrixScale(this.matrixWorld),Ha.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Fa.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Oa.multiplyScalar(-Fa.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;qa(ka.set(-.5,-.5,0),Fa,s,Oa,i,r),qa(Ga.set(.5,-.5,0),Fa,s,Oa,i,r),qa(Va.set(.5,.5,0),Fa,s,Oa,i,r),Wa.set(0,0),Xa.set(1,0),ja.set(1,1);let a=e.ray.intersectTriangle(ka,Ga,Va,!1,Na);if(null===a&&(qa(Ga.set(-.5,.5,0),Fa,s,Oa,i,r),Xa.set(0,1),a=e.ray.intersectTriangle(ka,Va,Ga,!1,Na),null===a))return;const o=e.ray.origin.distanceTo(Na);o<e.near||o>e.far||t.push({distance:o,point:Na.clone(),uv:kn.getInterpolation(Na,ka,Ga,Va,Wa,Xa,ja,new tt),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function qa(e,t,n,i,r,s){Ba.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(za.x=s*Ba.x-r*Ba.y,za.y=r*Ba.x+s*Ba.y):za.copy(Ba),e.copy(t),e.x+=za.x,e.y+=za.y,e.applyMatrix4(Ha)}const Ka=new At,Za=new St,Ja=new St,Qa=new At,$a=new rn,eo=new At,to=new qt,no=new rn,io=new nn;class ro extends Ri{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new rn,this.bindMatrixInverse=new rn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Pt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)eo.fromBufferAttribute(t,e),this.applyBoneTransform(e,eo),this.boundingBox.expandByPoint(eo)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new qt),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)eo.fromBufferAttribute(t,e),this.applyBoneTransform(e,eo),this.boundingSphere.expandByPoint(eo)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),to.copy(this.boundingSphere),to.applyMatrix4(i),!1!==e.ray.intersectsSphere(to)&&(no.copy(i).invert(),io.copy(e.ray).applyMatrix4(no),null!==this.boundingBox&&!1===io.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,io)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new St,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Za.fromBufferAttribute(i.attributes.skinIndex,e),Ja.fromBufferAttribute(i.attributes.skinWeight,e),Ka.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=Ja.getComponent(e);if(0!==i){const r=Za.getComponent(e);$a.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(Qa.copy(Ka).applyMatrix4($a),i)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class so extends Cn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ao extends Mt{constructor(e=null,t=1,n=1,i,r,s,a,o,l=1003,c=1003,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const oo=new rn,lo=new rn;class co{constructor(e=[],t=[]){this.uuid=Xe(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new rn)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new rn;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=e.length;i<r;i++){const r=e[i]?e[i].matrixWorld:lo;oo.multiplyMatrices(r,t[i]),oo.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new co(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=Ze(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ao(t,e,e,he,oe);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const i=e.bones[n];let r=t[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new so),this.bones.push(r),this.boneInverses.push((new rn).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const r=t[i];e.bones.push(r.uuid);const s=n[i];e.boneInverses.push(s.toArray())}return e}}class ho extends $n{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const uo=new rn,po=new rn,mo=[],fo=new Pt,go=new rn,_o=new Ri,vo=new qt;class xo extends Ri{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ho(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,go)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Pt),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,uo),fo.copy(e.boundingBox).applyMatrix4(uo),this.boundingBox.union(fo)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new qt),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,uo),vo.copy(e.boundingSphere).applyMatrix4(uo),this.boundingSphere.union(vo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(_o.geometry=this.geometry,_o.material=this.material,void 0!==_o.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),vo.copy(this.boundingSphere),vo.applyMatrix4(n),!1!==e.ray.intersectsSphere(vo)))for(let r=0;r<i;r++){this.getMatrixAt(r,uo),po.multiplyMatrices(n,uo),_o.matrixWorld=po,_o.raycast(e,mo);for(let e=0,n=mo.length;e<n;e++){const n=mo[e];n.instanceId=r,n.object=this,t.push(n)}mo.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new ho(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class yo extends Vn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Mo=new At,So=new At,Eo=new rn,To=new nn,wo=new qt;class bo extends Cn{constructor(e=new hi,t=new yo){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)Mo.fromBufferAttribute(t,e-1),So.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Mo.distanceTo(So);e.setAttribute("lineDistance",new ni(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),wo.copy(n.boundingSphere),wo.applyMatrix4(i),wo.radius+=r,!1===e.ray.intersectsSphere(wo))return;Eo.copy(i).invert(),To.copy(e.ray).applyMatrix4(Eo);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new At,c=new At,h=new At,u=new At,d=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(null!==p){for(let n=Math.max(0,s.start),i=Math.min(p.count,s.start+s.count)-1;n<i;n+=d){const i=p.getX(n),r=p.getX(n+1);l.fromBufferAttribute(m,i),c.fromBufferAttribute(m,r);if(To.distanceSqToSegment(l,c,u,h)>o)continue;u.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(u);s<e.near||s>e.far||t.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,s.start),i=Math.min(m.count,s.start+s.count)-1;n<i;n+=d){l.fromBufferAttribute(m,n),c.fromBufferAttribute(m,n+1);if(To.distanceSqToSegment(l,c,u,h)>o)continue;u.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(u);i<e.near||i>e.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const Ao=new At,Ro=new At;class Co extends bo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)Ao.fromBufferAttribute(t,e),Ro.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Ao.distanceTo(Ro);e.setAttribute("lineDistance",new ni(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Po extends bo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Lo extends Vn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Io=new rn,Uo=new nn,Do=new qt,No=new At;class Oo extends Cn{constructor(e=new hi,t=new Lo){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Do.copy(n.boundingSphere),Do.applyMatrix4(i),Do.radius+=r,!1===e.ray.intersectsSphere(Do))return;Io.copy(i).invert(),Uo.copy(e.ray).applyMatrix4(Io);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);No.fromBufferAttribute(c,r),Fo(No,r,o,i,e,t,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);n<r;n++)No.fromBufferAttribute(c,n),Fo(No,n,o,i,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function Fo(e,t,n,i,r,s,a){const o=Uo.distanceSqToPoint(e);if(o<n){const n=new At;Uo.closestPointToPoint(e,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class Bo extends Mt{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class zo extends hi{constructor(e=1,t=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],h=[],u=[],d=[];let p=0;const m=[],f=n/2;let g=0;function _(n){const r=p,s=new tt,m=new At;let _=0;const v=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)h.push(0,f*x,0),u.push(0,x,0),d.push(.5,.5),p++;const y=p;for(let e=0;e<=i;e++){const t=e/i*o+a,n=Math.cos(t),r=Math.sin(t);m.x=v*r,m.y=f*x,m.z=v*n,h.push(m.x,m.y,m.z),u.push(0,x,0),s.x=.5*n+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let e=0;e<i;e++){const t=r+e,i=y+e;!0===n?c.push(i,i+1,t):c.push(i+1,i,t),_+=3}l.addGroup(g,_,!0===n?1:2),g+=_}!function(){const s=new At,_=new At;let v=0;const x=(t-e)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,v=g*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,r=t*o+a,l=Math.sin(r),m=Math.cos(r);_.x=v*l,_.y=-g*n+f,_.z=v*m,h.push(_.x,_.y,_.z),s.set(l,x,m).normalize(),u.push(s.x,s.y,s.z),d.push(t,1-g),c.push(p++)}m.push(c)}for(let e=0;e<i;e++)for(let t=0;t<r;t++){const n=m[t][e],i=m[t+1][e],r=m[t+1][e+1],s=m[t][e+1];c.push(n,i,s),c.push(i,r,s),v+=6}l.addGroup(g,v,0),g+=v}(),!1===s&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new ni(h,3)),this.setAttribute("normal",new ni(u,3)),this.setAttribute("uv",new ni(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ho extends hi{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const n=Math.floor(t/2);t%2==0?(o(s[e][n+1]),o(s[e+1][n]),o(s[e][n])):(o(s[e][n+1]),o(s[e+1][n+1]),o(s[e+1][n]))}}function o(e){r.push(e.x,e.y,e.z)}function l(t,n){const i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(e,t,n,i){i<0&&1===e.x&&(s[t]=e.x-1),0===n.x&&0===n.z&&(s[t]=i/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new At,i=new At,r=new At;for(let s=0;s<t.length;s+=3)l(t[s+0],n),l(t[s+1],i),l(t[s+2],r),a(n,i,r,e)}(i),function(e){const t=new At;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){const e=new At;for(let n=0;n<r.length;n+=3){e.x=r[n+0],e.y=r[n+1],e.z=r[n+2];const i=h(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);s.push(i,1-a)}var t;(function(){const e=new At,t=new At,n=new At,i=new At,a=new tt,o=new tt,l=new tt;for(let u=0,d=0;u<r.length;u+=9,d+=6){e.set(r[u+0],r[u+1],r[u+2]),t.set(r[u+3],r[u+4],r[u+5]),n.set(r[u+6],r[u+7],r[u+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),i.copy(e).add(t).add(n).divideScalar(3);const p=h(i);c(a,d+0,e,p),c(o,d+2,t,p),c(l,d+4,n,p)}})(),function(){for(let e=0;e<s.length;e+=6){const t=s[e+0],n=s[e+2],i=s[e+4],r=Math.max(t,n,i),a=Math.min(t,n,i);r>.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new ni(r,3)),this.setAttribute("normal",new ni(r.slice(),3)),this.setAttribute("uv",new ni(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ho(e.vertices,e.indices,e.radius,e.details)}}class ko extends Ho{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ko(e.radius,e.detail)}}class Go extends hi{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const c=[],h=new At,u=new At,d=[],p=[],m=[],f=[];for(let d=0;d<=n;d++){const g=[],_=d/n;let v=0;0===d&&0===s?v=.5/t:d===n&&o===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){const o=n/t;h.x=-e*Math.cos(i+o*r)*Math.sin(s+_*a),h.y=e*Math.cos(s+_*a),h.z=e*Math.sin(i+o*r)*Math.sin(s+_*a),p.push(h.x,h.y,h.z),u.copy(h).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=c[e][i+1],r=c[e][i],a=c[e+1][i],l=c[e+1][i+1];(0!==e||s>0)&&d.push(t,r,l),(e!==n-1||o<Math.PI)&&d.push(r,a,l)}this.setIndex(d),this.setAttribute("position",new ni(p,3)),this.setAttribute("normal",new ni(m,3)),this.setAttribute("uv",new ni(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Go(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Vo extends hi{constructor(e=1,t=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],o=[],l=[],c=new At,h=new At,u=new At;for(let s=0;s<=n;s++)for(let d=0;d<=i;d++){const p=d/i*r,m=s/n*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(p),h.y=(e+t*Math.cos(m))*Math.sin(p),h.z=t*Math.sin(m),a.push(h.x,h.y,h.z),c.x=e*Math.cos(p),c.y=e*Math.sin(p),u.subVectors(h,c).normalize(),o.push(u.x,u.y,u.z),l.push(d/i),l.push(s/n)}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,r=(i+1)*(e-1)+t-1,a=(i+1)*(e-1)+t,o=(i+1)*e+t;s.push(n,r,o),s.push(r,a,o)}this.setIndex(s),this.setAttribute("position",new ni(a,3)),this.setAttribute("normal",new ni(o,3)),this.setAttribute("uv",new ni(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vo(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Wo extends Vn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new qn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xo extends Wo{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new tt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qn(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new qn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qn(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function jo(e,t,n){return qo(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function Yo(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function qo(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ko(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Zo(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Jo(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}class Qo{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let s=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(e>=r)break e;{const a=t[1];e<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0}}for(;n<s;){const i=n+s>>>1;e<t[i]?s=i:n=i+1}if(i=t[n],r=t[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let e=0;e!==i;++e)t[e]=n[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class $o extends Qo{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,s=e+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case 2401:r=e,a=2*t-n;break;case 2402:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case 2401:s=e,o=2*n-t;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,x=d*f-d*m;for(let e=0;e!==a;++e)r[e]=g*s[c+e]+_*s[l+e]+v*s[o+e]+x*s[h+e];return r}}class el extends Qo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=(n-t)/(i-t),h=1-c;for(let e=0;e!==a;++e)r[e]=s[l+e]*h+s[o+e]*c;return r}}class tl extends Qo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class nl{constructor(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Yo(t,this.TimeBufferType),this.values=Yo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Yo(e.times,Array),values:Yo(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new tl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new el(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $o(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ve:t=this.InterpolantFactoryMethodDiscrete;break;case xe:t=this.InterpolantFactoryMethodLinear;break;case ye:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ve;case this.InterpolantFactoryMethodLinear:return xe;case this.InterpolantFactoryMethodSmooth:return ye}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==s&&n[s]>t;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=jo(n,r,s),this.values=jo(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&qo(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=jo(this.times),t=jo(this.values),n=this.getValueSize(),i=this.getInterpolation()===ye,r=e.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=e[a];if(o!==e[a+1]&&(1!==a||o!==e[0]))if(i)r=!0;else{const e=a*n,i=e-n,s=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[i+a]||n!==t[s+a]){r=!0;break}}}if(r){if(a!==s){e[s]=e[a];const i=a*n,r=s*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++s}}if(r>0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=jo(e,0,s),this.values=jo(t,0,s*n)):(this.times=e,this.values=t),this}clone(){const e=jo(this.times,0),t=jo(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}nl.prototype.TimeBufferType=Float32Array,nl.prototype.ValueBufferType=Float32Array,nl.prototype.DefaultInterpolation=xe;class il extends nl{}il.prototype.ValueTypeName="bool",il.prototype.ValueBufferType=Array,il.prototype.DefaultInterpolation=ve,il.prototype.InterpolantFactoryMethodLinear=void 0,il.prototype.InterpolantFactoryMethodSmooth=void 0;class rl extends nl{}rl.prototype.ValueTypeName="color";class sl extends nl{}sl.prototype.ValueTypeName="number";class al extends Qo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)bt.slerpFlat(r,0,s,l-a,s,l,o);return r}}class ol extends nl{InterpolantFactoryMethodLinear(e){return new al(this.times,this.values,this.getValueSize(),e)}}ol.prototype.ValueTypeName="quaternion",ol.prototype.DefaultInterpolation=xe,ol.prototype.InterpolantFactoryMethodSmooth=void 0;class ll extends nl{}ll.prototype.ValueTypeName="string",ll.prototype.ValueBufferType=Array,ll.prototype.DefaultInterpolation=ve,ll.prototype.InterpolantFactoryMethodLinear=void 0,ll.prototype.InterpolantFactoryMethodSmooth=void 0;class cl extends nl{}cl.prototype.ValueTypeName="vector";class hl{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Xe(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(ul(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(nl.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e<r;e++){let a=[],o=[];a.push((e+r-1)%r,e,(e+1)%r),o.push(0,1,0);const l=Ko(a);a=Zo(a,1,l),o=Zo(o,1,l),i||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new sl(".morphTargetInfluences["+t[e].name+"]",a,o).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],s=n.name.match(r);if(s&&s.length>1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const s=[],a=[];Jo(n,s,a,i),0!==s.length&&r.push(new e(t,s,a))}},i=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let n=0;n<r[t].morphTargets.length;n++)e[r[t].morphTargets[n]]=-1;for(const n in e){const e=[],s=[];for(let i=0;i!==r[t].morphTargets.length;++i){const i=r[t];e.push(i.time),s.push(i.morphTarget===n?1:0)}i.push(new sl(".morphTargetInfluence["+n+"]",e,s))}o=e.length*s}else{const s=".bones["+t[e].name+"]";n(cl,s+".position",r,"pos",i),n(ol,s+".quaternion",r,"rot",i),n(cl,s+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function ul(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sl;case"vector":case"vector2":case"vector3":case"vector4":return cl;case"color":return rl;case"quaternion":return ol;case"bool":case"boolean":return il;case"string":return ll}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Jo(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const dl={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class pl{constructor(e,t,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===s&&void 0!==i.onStart&&i.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}}const ml=new pl;class fl{constructor(e){this.manager=void 0!==e?e:ml,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(i,r){n.load(e,i,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const gl={};class _l extends Error{constructor(e,t){super(e),this.response=t}}class vl extends fl{constructor(e){super(e)}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=dl.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==gl[e])return void gl[e].push({onLoad:t,onProgress:n,onError:i});gl[e]=[],gl[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=gl[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}}))}()}});return new Response(l)}throw new _l(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{dl.add(e,t);const n=gl[e];delete gl[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{const n=gl[e];if(void 0===n)throw this.manager.itemError(e),t;delete gl[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class xl extends fl{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=dl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a=st("img");function o(){c(),dl.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class yl extends fl{constructor(e){super(e)}load(e,t,n,i){const r=new Mt,s=new xl(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class Ml extends Cn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qn(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}const Sl=new rn,El=new At,Tl=new At;class wl{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tt(512,512),this.map=null,this.mapPass=null,this.matrix=new rn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qi,this._frameExtents=new tt(1,1),this._viewportCount=1,this._viewports=[new St(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;El.setFromMatrixPosition(e.matrixWorld),t.position.copy(El),Tl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Tl),t.updateMatrixWorld(),Sl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Sl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 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 bl extends wl{constructor(){super(new Fi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*We*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Al extends Ml{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new bl}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Rl=new rn,Cl=new At,Pl=new At;class Ll extends wl{constructor(){super(new Fi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new tt(4,2),this._viewportCount=6,this._viewports=[new St(2,1,1,1),new St(0,1,1,1),new St(3,1,1,1),new St(1,1,1,1),new St(3,0,1,1),new St(1,0,1,1)],this._cubeDirections=[new At(1,0,0),new At(-1,0,0),new At(0,0,1),new At(0,0,-1),new At(0,1,0),new At(0,-1,0)],this._cubeUps=[new At(0,1,0),new At(0,1,0),new At(0,1,0),new At(0,1,0),new At(0,0,1),new At(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Cl.setFromMatrixPosition(e.matrixWorld),n.position.copy(Cl),Pl.copy(n.position),Pl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Pl),n.updateMatrixWorld(),i.makeTranslation(-Cl.x,-Cl.y,-Cl.z),Rl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Rl)}}class Il extends Ml{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Ll}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Ul extends wl{constructor(){super(new lr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Dl extends Ml{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.shadow=new Ul}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Nl extends Ml{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ol{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Fl extends fl{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=dl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){dl.add(e,n),t&&t(n),r.manager.itemEnd(e)})).catch((function(t){i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class Bl{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=zl(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=zl();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function zl(){return("undefined"==typeof performance?Date:performance).now()}const Hl="\\[\\]\\.:\\/",kl=new RegExp("["+Hl+"]","g"),Gl="[^"+Hl+"]",Vl="[^"+Hl.replace("\\.","")+"]",Wl=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Gl)+/(WCOD+)?/.source.replace("WCOD",Vl)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gl)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gl)+"$"),Xl=["material","materials","bones","map"];class jl{constructor(e,t,n){this.path=t,this.parsedPath=n||jl.parseTrackName(t),this.node=jl.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new jl.Composite(e,t,n):new jl(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(kl,"")}static parseTrackName(e){const t=Wl.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==Xl.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i<e.length;i++){const r=e[i];if(r.name===t||r.uuid===t)return r;const s=n(r.children);if(s)return s}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=jl.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}const s=e[i];if(void 0===s){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}jl.Composite=class{constructor(e,t,n){const i=n||jl.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},jl.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},jl.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},jl.prototype.GetterByBindingType=[jl.prototype._getValue_direct,jl.prototype._getValue_array,jl.prototype._getValue_arrayElement,jl.prototype._getValue_toArray],jl.prototype.SetterByBindingTypeAndVersioning=[[jl.prototype._setValue_direct,jl.prototype._setValue_direct_setNeedsUpdate,jl.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[jl.prototype._setValue_array,jl.prototype._setValue_array_setNeedsUpdate,jl.prototype._setValue_array_setMatrixWorldNeedsUpdate],[jl.prototype._setValue_arrayElement,jl.prototype._setValue_arrayElement_setNeedsUpdate,jl.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[jl.prototype._setValue_fromArray,jl.prototype._setValue_fromArray_setNeedsUpdate,jl.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Yl{constructor(e,t,n=0,i=1/0){this.ray=new nn(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new fn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Kl(e,this,n,t),n.sort(ql),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)Kl(e[i],this,n,t);return n.sort(ql),n}}function ql(e,t){return e.distance-t.distance}function Kl(e,t,n,i){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===i){const i=e.children;for(let e=0,r=i.length;e<r;e++)Kl(i[e],t,n,!0)}}class Zl{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:l}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=l);class Jl{constructor(e){this.onPointerDown=e=>{e.isPrimary&&0===e.button&&this.getMousePosition(e,this.downPosition)},this.onPointerUp=e=>{if(!e.isPrimary)return;const t=this.getMousePosition(e,new tt);if(0!==this.downPosition.distanceTo(t))return;const n=this.getPointerIntersects(t);this.clearSelection(),n.length>0&&this.select(n[0].object),this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=e=>{0===e.button&&this.viewer.executeCommand("zoomToSelected")},this.optionsChange=()=>{const{facesColor:e,facesTransparancy:t}=this.viewer.options;this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-t)/255,this.viewer.update()},this.viewer=e,this.raycaster=new Yl,this.downPosition=new tt;const{facesColor:t,facesTransparancy:n}=this.viewer.options;this.facesMaterial=new Zn,this.facesMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.facesMaterial.opacity=(255-n)/255,this.facesMaterial.transparent=!0,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("optionschange",this.optionsChange)}dispose(){this.facesMaterial.dispose(),this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("optionschange",this.optionsChange)}getMousePosition(e,t){const n=this.viewer.canvas.getBoundingClientRect();return t.setX((e.clientX-n.left)/n.width),t.setY((e.clientY-n.top)/n.height),t}getPointerIntersects(e){const t=new tt(2*e.x-1,-2*e.y+1);this.raycaster.setFromCamera(t,this.viewer.camera);const n=[];return this.viewer.scene.traverseVisible((e=>n.push(e))),this.raycaster.intersectObjects(n,!1)}select(e){e.isSelected||(e.isSelected=!0,e.originalMaterial=e.material,e.material=this.facesMaterial,this.viewer.selected.push(e))}clearSelection(){this.viewer.selected.forEach((e=>{e.isSelected=!1,e.material=e.originalMaterial})),this.viewer.selected.length=0}}function Ql(e,t){let n=t;return e.children.forEach((e=>{const i=Ql(e,t+1);n<i&&(n=i)})),e.originalPosition=e.position.clone(),n}function $l(e,t=0){t/=100,e.maxDepth||(e.maxDepth=Ql(e,1));const n=e.maxDepth;let i=t*(n-1)+1;1===n&&(i=1);!function e(n,r,s,a){const o=(new Pt).setFromObject(n).getCenter(new At),l=a.clone();if(r>0&&r<=i){const e=o.clone().sub(s).multiplyScalar(t);l.add(e)}n.children.forEach((t=>e(t,r+1,o,l)));const c=n.originalPosition;if(n.position.copy(c),t>0){const e=o.sub(s).normalize();n.position.add(e.add(l))}}(e,0,(new Pt).setFromObject(e).getCenter(new At),new At(0,0,0))}function ec(e,t=0){e.models.forEach((e=>$l(e.scene,t))),e.update(),e.emitEvent({type:"explode",data:t})}i("ThreeJS").registerCommand("clearSelected",(function(e){const t=new Jl(e);t.clearSelection(),t.dispose(),e.update(),e.emitEvent({type:"select",data:void 0,handles:[]})})),i("ThreeJS").registerCommandAlias("clearSelected","unselect"),i("ThreeJS").registerCommand("clearSlices",(function(e){e.renderer.clippingPlanes=[],e.update()})),i("ThreeJS").registerCommand("createPreview",(function(e,t="image/jpeg",n=.25){return e.update(!0),e.canvas.toDataURL(t,n)})),i("ThreeJS").registerCommand("explode",ec),i("ThreeJS").registerCommand("collect",(e=>ec(e,0)));const tc={top:new At(0,0,1),bottom:new At(0,0,-1),left:new At(-1,0,0),right:new At(1,0,0),front:new At(0,1,0),back:new At(0,-1,0),sw:new At(-.5,-.5,1).normalize(),se:new At(.5,-.5,1).normalize(),ne:new At(.5,.5,1).normalize(),nw:new At(-.5,.5,1).normalize()};function nc(e,t){const n=tc[t]||tc.sw,i=e.camera,r=e.extents.getCenter(new At),s=e.extents.getBoundingSphere(new qt),a=(new At).copy(n).multiplyScalar(s.radius);i.position.copy(r),i.position.add(a),i.rotation.set(0,0,0),i.lookAt(r),i.updateProjectionMatrix(),e.update(),e.emit({type:"viewposition",data:t}),e.executeCommand("zoomToExtents")}function ic(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(2===t)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}i("ThreeJS").registerCommand("setDefaultViewPosition",nc),i("ThreeJS").registerCommand("top",(e=>nc(e,"top"))),i("ThreeJS").registerCommand("bottom",(e=>nc(e,"bottom"))),i("ThreeJS").registerCommand("left",(e=>nc(e,"left"))),i("ThreeJS").registerCommand("right",(e=>nc(e,"right"))),i("ThreeJS").registerCommand("front",(e=>nc(e,"front"))),i("ThreeJS").registerCommand("back",(e=>nc(e,"back"))),i("ThreeJS").registerCommand("sw",(e=>nc(e,"sw"))),i("ThreeJS").registerCommand("se",(e=>nc(e,"se"))),i("ThreeJS").registerCommand("ne",(e=>nc(e,"ne"))),i("ThreeJS").registerCommand("nw",(e=>nc(e,"nw"))),i("ThreeJS").registerCommandAlias("top","k3DViewTop"),i("ThreeJS").registerCommandAlias("bottom","k3DViewBottom"),i("ThreeJS").registerCommandAlias("left","k3DViewLeft"),i("ThreeJS").registerCommandAlias("right","k3DViewRight"),i("ThreeJS").registerCommandAlias("front","k3DViewFront"),i("ThreeJS").registerCommandAlias("back","k3DViewBack"),i("ThreeJS").registerCommandAlias("se","k3DViewSE"),i("ThreeJS").registerCommandAlias("sw","k3DViewSW"),i("ThreeJS").registerCommandAlias("ne","k3DViewNE"),i("ThreeJS").registerCommandAlias("nw","k3DViewNW"),i("ThreeJS").registerCommand("getDefaultViewPositions",(function(){return Object.keys(tc)})),i("ThreeJS").registerCommand("getModels",(function(e){return e.models.map((e=>e.userData.handle||"")).filter((e=>e))})),i("ThreeJS").registerCommand("getSelected",(function(e){return e.selected.map((e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.handle})).filter((e=>e))})),i("ThreeJS").registerCommand("hideSelected",(function(e){e.selected.forEach((e=>e.visible=!1));const t=new Jl(e);t.clearSelection(),t.dispose(),e.update(),e.emitEvent({type:"hide"}),e.emitEvent({type:"select",data:void 0,handles:[]})})),i("ThreeJS").registerCommand("isolateSelected",(function(e){const t=new Set(e.selected);!function e(n,i){let r=!0;return n.children.forEach((n=>{t.has(n)?r=!1:e(n,i+1)})),r&&i>0&&(n.visible=!1),r}(e.scene,0),e.update(),e.emitEvent({type:"isolate"})})),i("ThreeJS").registerCommand("regenerateAll",(function(e){console.warn("regenerateAll not implemented"),e.emit({type:"regenerateall"})})),i("ThreeJS").registerCommand("resetView",(function(e){e.executeCommand("setActiveDragger",""),e.executeCommand("clearSlices"),e.executeCommand("clearOverlay"),e.executeCommand("setMarkupColor"),e.executeCommand("clearSelected"),e.executeCommand("showAll"),e.executeCommand("explode",0),e.executeCommand("zoomToExtents",!0),e.executeCommand("k3DViewSW"),e.emit({type:"resetview"})})),i("ThreeJS").registerCommand("selectModel",(function(e,t){console.warn("selectModel not implemented"),e.emit({type:"select",data:[]})})),i("ThreeJS").registerCommand("setActiveDragger",((e,t="")=>{e.setActiveDragger(t)})),i("ThreeJS").registerCommand("setMarkupColor",((e,t=255,n=0,i=0)=>{console.warn("setMarkupColor not implemented")})),i("ThreeJS").registerCommand("setSelected",(function(e,t=[]){const n=new Set(t),i=[];e.scene.traverseVisible((e=>{var t;n.has(null===(t=e.userData)||void 0===t?void 0:t.handle)&&i.push(e)}));const r=new Jl(e);r.clearSelection(),i.forEach((e=>r.select(e))),r.dispose(),e.update(),e.emitEvent({type:"select",data:void 0,handles:t})})),i("ThreeJS").registerCommand("showAll",(function(e){e.scene.traverse((e=>e.visible=!0)),e.update(),e.emitEvent({type:"showall"})})),i("ThreeJS").registerCommand("zoomToExtents",(function(e){if(e.extents.isEmpty())return;const t=e.extents.getCenter(new At),n=e.extents.getBoundingSphere(new qt).radius,i=new At(0,0,1);i.applyQuaternion(e.camera.quaternion),i.multiplyScalar(3*n),e.camera.position.copy(t).add(i),e.target.copy(t),e.update(),e.emitEvent({type:"zoom"})})),i("ThreeJS").registerCommandAlias("zoomToExtents","zoomExtents"),i("ThreeJS").registerCommand("zoomToObjects",(function(e,t=[]){const n=new Set(t),i=[];e.scene.traverseVisible((e=>{var t;n.has(null===(t=e.userData)||void 0===t?void 0:t.handle)&&i.push(e)}));const r=i.reduce(((e,t)=>{const n=(new Pt).setFromObject(t);return e.isEmpty()?e.copy(n):e.union(n)}),new Pt),s=r.getCenter(new At),a=r.getBoundingSphere(new qt).radius,o=new At(0,0,1);o.applyQuaternion(e.camera.quaternion),o.multiplyScalar(3*a),e.camera.position.copy(s).add(o),e.target.copy(s),e.update(),e.emitEvent({type:"zoom"})})),i("ThreeJS").registerCommand("zoomToSelected",(function(e){const t=e.selected.reduce(((e,t)=>{const n=(new Pt).setFromObject(t);return e.isEmpty()?e.copy(n):e.union(n)}),new Pt);t.isEmpty()&&t.copy(e.extents);const n=t.getCenter(new At),i=t.getBoundingSphere(new qt).radius,r=new At(0,0,1);r.applyQuaternion(e.camera.quaternion),r.multiplyScalar(3*i),e.camera.position.copy(n).add(r),e.target.copy(n),e.update(),e.emitEvent({type:"zoom"})}));class rc extends fl{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new hc(e)})),this.register((function(e){return new vc(e)})),this.register((function(e){return new xc(e)})),this.register((function(e){return new yc(e)})),this.register((function(e){return new dc(e)})),this.register((function(e){return new pc(e)})),this.register((function(e){return new mc(e)})),this.register((function(e){return new fc(e)})),this.register((function(e){return new cc(e)})),this.register((function(e){return new gc(e)})),this.register((function(e){return new uc(e)})),this.register((function(e){return new _c(e)})),this.register((function(e){return new oc(e)})),this.register((function(e){return new Mc(e)})),this.register((function(e){return new Sc(e)}))}load(e,t,n,i){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Ol.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},o=new vl(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}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,i){let r;const s={},a={},o=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(o.decode(new Uint8Array(e,0,4))===Ec){try{s[ac.KHR_BINARY_GLTF]=new bc(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[ac.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Jc(r,{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<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case ac.KHR_MATERIALS_UNLIT:s[t]=new lc;break;case ac.KHR_DRACO_MESH_COMPRESSION:s[t]=new Ac(r,this.dracoLoader);break;case ac.KHR_TEXTURE_TRANSFORM:s[t]=new Rc;break;case ac.KHR_MESH_QUANTIZATION:s[t]=new Cc;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function sc(){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={}}}}const ac={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 oc{constructor(e){this.parser=e,this.name=ac.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let a;const o=new qn(16777215);void 0!==s.color&&o.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Dl(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Il(o),a.distance=l;break;case"spot":a=new Al(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,Xc(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class lc{constructor(){this.name=ac.KHR_MATERIALS_UNLIT}getMaterialType(){return Zn}extendParams(e,t,n){const i=[];e.color=new qn(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,Ee))}return Promise.all(i)}}class cc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class hc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new tt(e,e)}return Promise.all(r)}}class uc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class dc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new qn(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,Ee)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class pc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class mc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=new qn(a[0],a[1],a[2]),Promise.all(r)}}class fc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class gc{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=new qn(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,Ee)),Promise.all(r)}}class _c{constructor(e){this.parser=e,this.name=ac.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Xo:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class vc{constructor(e){this.parser=e,this.name=ac.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class xc{constructor(e){this.parser=e,this.name=ac.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class yc{constructor(e){this.parser=e,this.name=ac.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Mc{constructor(e){this.name=ac.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class Sc{constructor(e){this.name=ac.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==Uc.TRIANGLES&&e.mode!==Uc.TRIANGLE_STRIP&&e.mode!==Uc.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then((t=>(a[e]=t,a[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new rn,n=new At,s=new bt,o=new At(1,1,1),l=new xo(e.geometry,e.material,i);for(let e=0;e<i;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,e),a.SCALE&&o.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,t.compose(n,s,o));for(const t in a)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,a[t]);Cn.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}}const Ec="glTF",Tc=1313821514,wc=5130562;class bc{constructor(e){this.name=ac.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ec)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<i;){const t=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Tc){const i=new Uint8Array(e,12+s,t);this.content=n.decode(i)}else if(i===wc){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ac{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ac.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},l={};for(const e in s){const t=Bc[e]||e.toLowerCase();a[t]=s[e]}for(const t in e.attributes){const i=Bc[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=Dc[r.componentType];l[i]=s.name,o[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=o[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class Rc{constructor(){this.name=ac.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Cc{constructor(){this.name=ac.KHR_MESH_QUANTIZATION}}class Pc extends Qo{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=i-t,h=(n-t)/c,u=h*h,d=u*h,p=e*l,m=p-l,f=-2*d+3*u,g=d-u,_=1-f,v=g-u+h;for(let e=0;e!==a;e++){const t=s[m+e+a],n=s[m+e+o]*c,i=s[p+e+a],l=s[p+e]*c;r[e]=_*t+v*n+f*i+g*l}return r}}const Lc=new bt;class Ic extends Pc{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Lc.fromArray(r).normalize().toArray(r),r}}const Uc={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Dc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Nc={9728:J,9729:ee,9984:Q,9985:1007,9986:$,9987:ne},Oc={33071:K,33648:Z,10497:q},Fc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Bc={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zc={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Hc={CUBICSPLINE:void 0,LINEAR:xe,STEP:ve},kc="OPAQUE",Gc="MASK",Vc="BLEND";function Wc(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Xc(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function jc(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Yc(e){let t;const n=e.extensions&&e.extensions[ac.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+qc(n.attributes):e.indices+":"+qc(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,i=e.targets.length;n<i;n++)t+=":"+qc(e.targets[n]);return t}function qc(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Kc(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Zc=new rn;class Jc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new sc,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new yl(this.options.manager):this.textureLoader=new Fl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new vl(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){const n=this,i=this.json,r=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){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Wc(r,s,i),Xc(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ac.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(Ol.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=Fc[i.type],t=Dc[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new $n(r,e,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=Fc[i.type],a=Dc[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,c=i.byteOffset||0,h=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,u=!0===i.normalized;let d,p;if(h&&h!==l){const e=Math.floor(c/h),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(d=new a(r,e*h,i.count*h/o),l=new Pa(d,h/o),t.cache.add(n,l)),p=new Ia(l,s,c%h/o,u)}else d=null===r?new a(i.count*s):new a(r,c,i.count*s),p=new $n(d,s,u);if(void 0!==i.sparse){const t=Fc.SCALAR,n=Dc[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],o,i.sparse.count*t),h=new a(e[2],l,i.sparse.count*s);null!==r&&(p=new $n(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=Nc[n.magFilter]||ee,t.minFilter=Nc[n.minFilter]||ne,t.wrapS=Oc[n.wrapS]||q,t.wrapT=Oc[n.wrapT]||q,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new Mt(e);t.needsUpdate=!0,n(t)}),t.load(Ol.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=s.mimeType||((t=s.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",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[ac.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[ac.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[ac.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Lo,Vn.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){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new yo,Vn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(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 Wo}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const a={},o=[];if((r.extensions||{})[ac.KHR_MATERIALS_UNLIT]){const e=i[ac.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(a,r,t))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new qn(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(a,"map",n.baseColorTexture,Ee)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===r.doubleSided&&(a.side=2);const l=r.alphaMode||kc;if(l===Vc?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===Gc&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==Zn&&(o.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new tt(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==Zn&&(o.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==Zn&&(a.emissive=(new qn).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==Zn&&o.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Ee)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),Xc(n,r),t.associations.set(n,{materials:e}),r.extensions&&Wc(i,n,r),n}))}createUniqueName(e){const t=jl.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[ac.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Qc(n,e,t)}))}const s=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],o=Yc(a),l=i[o];if(l)s.push(l.promise);else{let e;e=a.extensions&&a.extensions[ac.KHR_DRACO_MESH_COMPRESSION]?r(a):Qc(new hi,a,t),i[o]={primitive:a,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,a=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new Wo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:x})),o.DefaultMaterial):this.getDependency("material",s[e].material);a.push(t)}var o;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,c=o.length;n<c;n++){const c=o[n],h=s[n];let u;const d=a[n];if(h.mode===Uc.TRIANGLES||h.mode===Uc.TRIANGLE_STRIP||h.mode===Uc.TRIANGLE_FAN||void 0===h.mode)u=!0===r.isSkinnedMesh?new ro(c,d):new Ri(c,d),!0===u.isSkinnedMesh&&u.normalizeSkinWeights(),h.mode===Uc.TRIANGLE_STRIP?u.geometry=ic(u.geometry,1):h.mode===Uc.TRIANGLE_FAN&&(u.geometry=ic(u.geometry,2));else if(h.mode===Uc.LINES)u=new Co(c,d);else if(h.mode===Uc.LINE_STRIP)u=new bo(c,d);else if(h.mode===Uc.LINE_LOOP)u=new Po(c,d);else{if(h.mode!==Uc.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new Oo(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&jc(u,r),u.name=t.createUniqueName(r.name||"mesh_"+e),Xc(u,r),h.extensions&&Wc(i,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return r.extensions&&Wc(i,l[0],r),l[0];const c=new ya;r.extensions&&Wc(i,c,r),t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new Fi(et.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new lr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Xc(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,a=i.length;e<a;e++){const a=i[e];if(a){r.push(a);const t=new rn;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new co(r,s)}))}loadAnimation(e){const t=this.json.animations[e],n=t.name?t.name:"animation_"+e,i=[],r=[],s=[],a=[],o=[];for(let e=0,n=t.channels.length;e<n;e++){const n=t.channels[e],l=t.samplers[n.sampler],c=n.target,h=c.node,u=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;void 0!==c.node&&(i.push(this.getDependency("node",h)),r.push(this.getDependency("accessor",u)),s.push(this.getDependency("accessor",d)),a.push(l),o.push(c))}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(a),Promise.all(o)]).then((function(e){const t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],l=i[e],c=r[e],h=s[e],u=a[e];if(void 0===n)continue;let d;switch(n.updateMatrix(),zc[u.path]){case zc.weights:d=sl;break;case zc.rotation:d=ol;break;default:d=cl}const p=n.name?n.name:n.uuid,m=void 0!==h.interpolation?Hc[h.interpolation]:xe,f=[];zc[u.path]===zc.weights?n.traverse((function(e){e.morphTargetInfluences&&f.push(e.name?e.name:e.uuid)})):f.push(p);let g=c.array;if(c.normalized){const e=Kc(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=f.length;e<t;e++){const t=new d(f[e]+"."+zc[u.path],l.array,g,m);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof ol?Ic:Pc)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),o.push(t)}}return new hl(n,void 0,o)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],i=t._loadNodeShallow(e),r=[],s=n.children||[];for(let e=0,n=s.length;e<n;e++)r.push(t.getDependency("node",s[e]));const a=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),a]).then((function(e){const t=e[0],n=e[1],i=e[2];null!==i&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(i,Zc)}));for(let e=0,i=n.length;e<i;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&a.push(o),void 0!==r.camera&&a.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){a.push(e)})),this.nodeCache[e]=Promise.all(a).then((function(t){let a;if(a=!0===r.isBone?new so:t.length>1?new ya:1===t.length?t[0]:new Cn,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(r.name&&(a.userData.name=r.name,a.name=s),Xc(a,r),r.extensions&&Wc(n,a,r),void 0!==r.matrix){const e=new rn;e.fromArray(r.matrix),a.applyMatrix4(e)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new ya;n.name&&(r.name=i.createUniqueName(n.name)),Xc(r,n),n.extensions&&Wc(t,r,n);const s=n.nodes||[],a=[];for(let e=0,t=s.length;e<t;e++)a.push(i.getDependency("node",s[e]));return Promise.all(a).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof Vn||e instanceof Mt)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function Qc(e,t,n){const i=t.attributes,r=[];function s(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=Bc[t]||t.toLowerCase();n in e.attributes||r.push(s(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return Xc(e,t),function(e,t,n){const i=t.attributes,r=new Pt;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new At(t[0],t[1],t[2]),new At(s[0],s[1],s[2])),e.normalized){const t=Kc(Dc[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new At,t=new At;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,a=i.max;if(void 0!==s&&void 0!==a){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),i.normalized){const e=Kc(Dc[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const a=new qt;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const a=[],o=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(i){const t=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):e.attributes.position;a.push(t)}if(r){const t=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=a),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}class $c extends pl{constructor(e,t=new Map,n={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=n.path||"","string"==typeof e?(this.fileURL=e,this.resourcePath=Ol.extractUrlBase(e)):(t.forEach(((t,n)=>this.fileURL=t===e?n:this.fileURL)),t.set(this.fileURL,e)),t.forEach(((e,t)=>{let n;n="string"==typeof e?e:URL.createObjectURL(new Blob([e])),this.dataURLs.set(t,n)})),this.setURLModifier((e=>{const t=decodeURI(e).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),n=this.dataURLs.get(t);return null!=n?n:e}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class eh{constructor(){this._listeners={}}addEventListener(e,t){return void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t),this}removeEventListener(e,t){if(void 0===this._listeners[e])return this;const n=this._listeners[e].filter((e=>e!==t));return 0!==n.length?this._listeners[e]=n:delete this._listeners[e],this}removeAllListeners(e){return e?delete this._listeners[e]:this._listeners={},this}emitEvent(e){if(void 0===this._listeners[e.type])return!1;return this._listeners[e.type].slice().forEach((t=>t.call(this,e))),!0}on(e,t){return this.addEventListener(e,t)}off(e,t){return this.removeEventListener(e,t)}emit(e,...t){return"string"==typeof e?this.emitEvent({type:e,args:t}):"object"==typeof e&&this.emitEvent(e)}}const th={type:"change"},nh={type:"start"},ih={type:"end"},rh=-1,sh=0,ah=1,oh=2,lh=3,ch=4,hh=5,uh=6;class dh extends He{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new At,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:c,MIDDLE:h,RIGHT:u},this.touches={ONE:d,TWO:m},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",U),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",U),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(th),n.update(),n.state=rh},this.update=function(){const t=new At,a=(new bt).setFromUnitVectors(e.up,new At(0,1,0)),l=a.clone().invert(),c=new At,h=new bt,u=new At,d=2*Math.PI;return function(){const e=n.object.position;t.copy(e).sub(n.target),t.applyQuaternion(a),r.setFromVector3(t),n.autoRotate&&n.state===rh&&o(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(r.theta+=s.theta*n.dampingFactor,r.phi+=s.phi*n.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=n.minAzimuthAngle,m=n.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=d:p>Math.PI&&(p-=d),m<-Math.PI?m+=d:m>Math.PI&&(m-=d),r.theta=p<=m?Math.max(p,Math.min(m,r.theta)):r.theta>(p+m)/2?Math.max(p,r.theta):Math.min(m,r.theta)),r.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=n.scale,r.radius=Math.max(n.minDistance,Math.min(n.maxDistance,r.radius)),!0===n.enableDamping?n.target.addScaledVector(n.panOffset,n.dampingFactor):n.target.add(n.panOffset),t.setFromSpherical(r),t.applyQuaternion(l),e.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,n.panOffset.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),n.panOffset.set(0,0,0)),n.scale=1,!!(n.zoomChanged||c.distanceToSquared(n.object.position)>i||8*(1-h.dot(n.object.quaternion))>i||u.distanceToSquared(n.target)>0)&&(n.dispatchEvent(th),c.copy(n.object.position),h.copy(n.object.quaternion),u.copy(n.target),n.zoomChanged=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",D),n.domElement.removeEventListener("pointerdown",C),n.domElement.removeEventListener("pointercancel",L),n.domElement.removeEventListener("wheel",I),n.domElement.removeEventListener("pointermove",P),n.domElement.removeEventListener("pointerup",L),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",U),n._domElementKeyEvents=null)};const n=this;n.state=rh;const i=1e-6,r=new Zl,s=new Zl;function a(){return Math.pow(.95,n.zoomSpeed)}function o(e){s.theta-=e}function l(e){s.phi-=e}n.scale=1,n.panOffset=new At,n.zoomChanged=!1,n.rotateStart=new tt,n.rotateEnd=new tt,n.rotateDelta=new tt,n.panStart=new tt,n.panEnd=new tt,n.panDelta=new tt,n.dollyStart=new tt,n.dollyEnd=new tt,n.dollyDelta=new tt,n.dollyScale=0,n.pointers=[],n.pointerPositions={};const g=function(){const e=new At;return function(t,i){e.setFromMatrixColumn(i,0),e.multiplyScalar(-t),n.panOffset.add(e)}}(),_=function(){const e=new At;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),n.panOffset.add(e)}}(),v=function(){const e=new At;return function(t,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const s=n.object.position;e.copy(s).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),g(2*t*a/r.clientHeight,n.object.matrix),_(2*i*a/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(g(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),_(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function x(e){n.object.isPerspectiveCamera?n.scale/=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function y(e){n.object.isPerspectiveCamera?n.scale*=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function M(e){n.rotateStart.set(e.clientX,e.clientY)}function S(e){n.panStart.set(e.clientX,e.clientY)}function E(){if(1===n.pointers.length)n.rotateStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const e=.5*(n.pointers[0].pageX+n.pointers[1].pageX),t=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.rotateStart.set(e,t)}}function T(){if(1===n.pointers.length)n.panStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const e=.5*(n.pointers[0].pageX+n.pointers[1].pageX),t=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.panStart.set(e,t)}}function w(){const e=n.pointers[0].pageX-n.pointers[1].pageX,t=n.pointers[0].pageY-n.pointers[1].pageY,i=Math.sqrt(e*e+t*t);n.dollyStart.set(0,i)}function b(e){if(1==n.pointers.length)n.rotateEnd.set(e.pageX,e.pageY);else{const t=O(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);n.rotateEnd.set(i,r)}n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const t=n.domElement;o(2*Math.PI*n.rotateDelta.x/t.clientHeight),l(2*Math.PI*n.rotateDelta.y/t.clientHeight),n.rotateStart.copy(n.rotateEnd)}function A(e){if(1===n.pointers.length)n.panEnd.set(e.pageX,e.pageY);else{const t=O(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);n.panEnd.set(i,r)}n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),v(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd)}function R(e){const t=O(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);n.dollyEnd.set(0,s),n.dollyDelta.set(0,Math.pow(n.dollyEnd.y/n.dollyStart.y,n.zoomSpeed)),x(n.dollyDelta.y),n.dollyStart.copy(n.dollyEnd)}function C(e){!1!==n.enabled&&(0===n.pointers.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",P),n.domElement.addEventListener("pointerup",L)),function(e){n.pointers.push(e)}(e),"touch"===e.pointerType?function(e){switch(N(e),n.pointers.length){case 1:switch(n.touches.ONE){case d:if(!1===n.enableRotate)return;E(),n.state=lh;break;case p:if(!1===n.enablePan)return;T(),n.state=ch;break;default:n.state=rh}break;case 2:switch(n.touches.TWO){case m:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&w(),n.enablePan&&T(),n.state=hh;break;case f:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&w(),n.enableRotate&&E(),n.state=uh;break;default:n.state=rh}break;default:n.state=rh}n.state!==rh&&n.dispatchEvent(nh)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case h:if(!1===n.enableZoom)return;!function(e){n.dollyStart.set(e.clientX,e.clientY)}(e),n.state=ah;break;case c:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;S(e),n.state=oh}else{if(!1===n.enableRotate)return;M(e),n.state=sh}break;case u:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;M(e),n.state=sh}else{if(!1===n.enablePan)return;S(e),n.state=oh}break;default:n.state=rh}n.state!==rh&&n.dispatchEvent(nh)}(e))}function P(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(N(e),n.state){case lh:if(!1===n.enableRotate)return;b(e),n.update();break;case ch:if(!1===n.enablePan)return;A(e),n.update();break;case hh:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&R(e),n.enablePan&&A(e)}(e),n.update();break;case uh:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&R(e),n.enableRotate&&b(e)}(e),n.update();break;default:n.state=rh}}(e):function(e){switch(n.state){case sh:if(!1===n.enableRotate)return;!function(e){n.rotateEnd.set(e.clientX,e.clientY),n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const t=n.domElement;o(2*Math.PI*n.rotateDelta.x/t.clientHeight),l(2*Math.PI*n.rotateDelta.y/t.clientHeight),n.rotateStart.copy(n.rotateEnd),n.update()}(e);break;case ah:if(!1===n.enableZoom)return;!function(e){n.dollyEnd.set(e.clientX,e.clientY),n.dollyDelta.subVectors(n.dollyEnd,n.dollyStart),n.dollyDelta.y<0?(n.dollyScale=1/a(),x(a())):n.dollyDelta.y>0&&(n.dollyScale=a(),y(a())),n.dollyStart.copy(n.dollyEnd),n.update()}(e);break;case oh:if(!1===n.enablePan)return;!function(e){n.panEnd.set(e.clientX,e.clientY),n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),v(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd),n.update()}(e)}}(e))}function L(e){!function(e){delete n.pointerPositions[e.pointerId];for(let t=0;t<n.pointers.length;t++)if(n.pointers[t].pointerId==e.pointerId)return void n.pointers.splice(t,1)}(e),0===n.pointers.length&&(n.domElement.releasePointerCapture(e.pointerId),n.domElement.removeEventListener("pointermove",P),n.domElement.removeEventListener("pointerup",L)),n.dispatchEvent(ih),n.state=rh}function I(e){!1!==n.enabled&&!1!==n.enableZoom&&n.state===rh&&(e.preventDefault(),n.dispatchEvent(nh),function(e){n.dollyEnd.set(n.domElement.clientWidth/2,n.domElement.clientHeight/2),n.dollyDelta.set(e.deltaX,e.deltaY),e.deltaY<0?(n.dollyScale=1/a(),y(a())):e.deltaY>0&&(n.dollyScale=a(),x(a())),n.dollyStart.copy(n.dollyEnd),n.update(),0!==e.deltaY&&(n.state=ah,n.dispatchEvent(th),n.state=rh)}(e),n.dispatchEvent(ih))}function U(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?l(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?l(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?o(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?o(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function D(e){!1!==n.enabled&&e.preventDefault()}function N(e){let t=n.pointerPositions[e.pointerId];void 0===t&&(t=new tt,n.pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}function O(e){const t=e.pointerId===n.pointers[0].pointerId?n.pointers[1]:n.pointers[0];return n.pointerPositions[t.pointerId]}n.domElement.addEventListener("contextmenu",D),n.domElement.addEventListener("pointerdown",C),n.domElement.addEventListener("pointercancel",L),n.domElement.addEventListener("wheel",I,{passive:!1}),this.update()}}class ph{constructor(e){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case oh:case ch:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case ah:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=e=>{this.changed&&(e.preventDefault(),e.stopPropagation())},this.orbit=new dh(e.camera,e.canvas),this.orbit.mouseButtons={LEFT:c,MIDDLE:u,RIGHT:u},this.orbit.touches={ONE:d,TWO:m},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=e,this.viewer.on("geometryend",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.on("zoom",this.updateControls),this.viewer.on("contextmenu",this.stopContextMenu),this.updateControls()}dispose(){this.viewer.off("geometryend",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.off("zoom",this.updateControls),this.viewer.off("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class mh extends ph{constructor(e){super(e),this.orbit.mouseButtons={LEFT:u,MIDDLE:u,RIGHT:u}}}class fh extends ph{constructor(e){super(e),this.orbit.mouseButtons={LEFT:h,MIDDLE:u,RIGHT:u}}}const gh={type:"change"};class _h extends He{constructor(e,t){super(),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=e=>{e.isPrimary&&0===e.button&&(this.canvas.setPointerCapture(e.pointerId),this.downPosition.set(e.clientX,e.clientY),this.quaternion.copy(this.camera.quaternion),this.mouseDragOn=!0)},this.onPointerMove=e=>{if(!e.isPrimary||!this.mouseDragOn)return;const t=new tt(e.clientX,e.clientY);0!==this.downPosition.distanceTo(t)&&(this.rotateDelta.copy(this.downPosition).sub(t),this.rotateCamera(this.rotateDelta),this.dispatchEvent(gh))},this.onPointerUp=e=>{e.isPrimary&&0===e.button&&(this.canvas.releasePointerCapture(e.pointerId),this.mouseDragOn=!1)},this.onPointerCancel=e=>{this.canvas.dispatchEvent(new PointerEvent("pointerup",e))},this.onWheel=e=>{this.moveWheel=e.deltaY,this.update()},this.onKeyDown=e=>{switch(e.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(e.code),this.update()}},this.onKeyUp=e=>{switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.delete(e.code),this.update()}},this.camera=e,this.canvas=t,this.moveKeys=new Set,this.moveClock=new Bl,this.quaternion=e.quaternion.clone(),this.downPosition=new tt(0,0),this.rotateDelta=new tt(0,0),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerCancel),this.canvas.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.canvas.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)}update(){if(this.moveKeys.size>0){const e=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.camera.translateZ(-e),this.moveKeys.has("KeyS")&&this.camera.translateZ(e),this.moveKeys.has("KeyA")&&this.camera.translateX(-e),this.moveKeys.has("KeyD")&&this.camera.translateX(e),this.moveKeys.has("KeyQ")&&this.camera.translateY(e),this.moveKeys.has("KeyE")&&this.camera.translateY(-e);const t=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new tt(0,-t/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new tt(0,t/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new tt(t,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new tt(-t,0))),this.moveWheel=0,this.dispatchEvent(gh)}if(0!==this.moveWheel){const e=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.camera.translateZ(-e),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent(gh)}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(e){const t=Math.PI*e.x/this.canvas.clientWidth,n=Math.PI*e.y/this.canvas.clientHeight,i=new bt;i.setFromAxisAngle(this.camera.up,t);const r=new bt;r.setFromAxisAngle(new At(1,0,0),n);const s=this.quaternion.clone();s.premultiply(i).multiply(r).normalize(),this.camera.setRotationFromQuaternion(s)}}class vh{constructor(e){this.updateControls=()=>{const e=this.viewer.extents.getSize(new At);this.controls.movementSpeed=Math.min(e.x,e.y,e.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=e=>{this.viewer.emitEvent(e)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new _h(e.camera,e.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=e,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}const xh=new Yl,yh=new At,Mh=new At,Sh=new bt,Eh={X:new At(1,0,0),Y:new At(0,1,0),Z:new At(0,0,1)},Th={type:"change"},wh={type:"mouseDown"},bh={type:"mouseUp",mode:null},Ah={type:"objectChange"};class Rh extends Cn{constructor(e,t){super(),void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new Kh;this._gizmo=n,this.add(n);const i=new Zh;this._plane=i,this.add(i);const r=this;function s(e,t){let s=t;Object.defineProperty(r,e,{get:function(){return void 0!==s?s:t},set:function(t){s!==t&&(s=t,i[e]=t,n[e]=t,r.dispatchEvent({type:e+"-changed",value:t}),r.dispatchEvent(Th))}}),r[e]=t,i[e]=t,n[e]=t}s("camera",e),s("object",void 0),s("enabled",!0),s("axis",null),s("mode","translate"),s("translationSnap",null),s("rotationSnap",null),s("scaleSnap",null),s("space","world"),s("size",1),s("dragging",!1),s("showX",!0),s("showY",!0),s("showZ",!0);const a=new At,o=new At,l=new bt,c=new bt,h=new At,u=new bt,d=new At,p=new At,m=new At,f=new At;s("worldPosition",a),s("worldPositionStart",o),s("worldQuaternion",l),s("worldQuaternionStart",c),s("cameraPosition",h),s("cameraQuaternion",u),s("pointStart",d),s("pointEnd",p),s("rotationAxis",m),s("rotationAngle",0),s("eye",f),this._offset=new At,this._startNorm=new At,this._endNorm=new At,this._cameraScale=new At,this._parentPosition=new At,this._parentQuaternion=new bt,this._parentQuaternionInv=new bt,this._parentScale=new At,this._worldScaleStart=new At,this._worldQuaternionInv=new bt,this._worldScale=new At,this._positionStart=new At,this._quaternionStart=new bt,this._scaleStart=new At,this._getPointer=Ch.bind(this),this._onPointerDown=Lh.bind(this),this._onPointerHover=Ph.bind(this),this._onPointerMove=Ih.bind(this),this._onPointerUp=Uh.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;xh.setFromCamera(e,this.camera);const t=Dh(this._gizmo.picker[this.mode],xh);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis){xh.setFromCamera(e,this.camera);const t=Dh(this._plane,xh,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,wh.mode=this.mode,this.dispatchEvent(wh)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(r="world"),void 0===i||null===t||!1===this.dragging||-1!==e.button)return;xh.setFromCamera(e,this.camera);const s=Dh(this._plane,xh,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(Sh.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(yh.setFromMatrixPosition(i.parent.matrixWorld)),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(yh.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===n){if(-1!==t.search("XYZ")){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),Mh.set(e,e,e)}else yh.copy(this.pointStart),Mh.copy(this.pointEnd),yh.applyQuaternion(this._worldQuaternionInv),Mh.applyQuaternion(this._worldQuaternionInv),Mh.divide(yh),-1===t.search("X")&&(Mh.x=1),-1===t.search("Y")&&(Mh.y=1),-1===t.search("Z")&&(Mh.z=1);i.scale.copy(this._scaleStart).multiply(Mh),this.scaleSnap&&(-1!==t.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const e=20/this.worldPosition.distanceTo(yh.setFromMatrixPosition(this.camera.matrixWorld));"E"===t?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(yh.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Eh[t]),yh.copy(Eh[t]),"local"===r&&yh.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(yh.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==t&&"XYZE"!==t?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Sh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Sh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Th),this.dispatchEvent(Ah)}}pointerUp(e){0===e.button&&(this.dragging&&null!==this.axis&&(bh.mode=this.mode,this.dispatchEvent(bh)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Th),this.dispatchEvent(Ah),this.pointStart.copy(this.pointEnd))}getRaycaster(){return xh}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Ch(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{const t=this.domElement.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button}}}function Ph(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}function Lh(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function Ih(e){this.enabled&&this.pointerMove(this._getPointer(e))}function Uh(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}function Dh(e,t,n){const i=t.intersectObject(e,!0);for(let e=0;e<i.length;e++)if(i[e].object.visible||n)return i[e];return!1}const Nh=new mn,Oh=new At(0,1,0),Fh=new At(0,0,0),Bh=new rn,zh=new bt,Hh=new bt,kh=new At,Gh=new rn,Vh=new At(1,0,0),Wh=new At(0,1,0),Xh=new At(0,0,1),jh=new At,Yh=new At,qh=new At;class Kh extends Cn{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Zn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new yo({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const r=e.clone();r.color.setHex(16711680);const s=e.clone();s.color.setHex(65280);const a=e.clone();a.color.setHex(255);const o=e.clone();o.color.setHex(16711680),o.opacity=.5;const l=e.clone();l.color.setHex(65280),l.opacity=.5;const c=e.clone();c.color.setHex(255),c.opacity=.5;const h=e.clone();h.opacity=.25;const u=e.clone();u.color.setHex(16776960),u.opacity=.25;e.clone().color.setHex(16776960);const d=e.clone();d.color.setHex(7895160);const p=new zo(0,.04,.1,12);p.translate(0,.05,0);const m=new Pi(.08,.08,.08);m.translate(0,.04,0);const f=new hi;f.setAttribute("position",new ni([0,0,0,1,0,0],3));const g=new zo(.0075,.0075,.5,3);function _(e,t){const n=new Vo(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}g.translate(0,.25,0);const v={X:[[new Ri(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new Ri(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new Ri(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ri(p,s),[0,.5,0]],[new Ri(p,s),[0,-.5,0],[Math.PI,0,0]],[new Ri(g,s)]],Z:[[new Ri(p,a),[0,0,.5],[Math.PI/2,0,0]],[new Ri(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Ri(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new Ri(new ko(.1,0),h.clone()),[0,0,0]]],XY:[[new Ri(new Pi(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new Ri(new Pi(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ri(new Pi(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new Ri(new zo(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ri(new zo(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ri(new zo(.2,0,.6,4),n),[0,.3,0]],[new Ri(new zo(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ri(new zo(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ri(new zo(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ri(new ko(.2,0),n)]],XY:[[new Ri(new Pi(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ri(new Pi(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ri(new Pi(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},y={START:[[new Ri(new ko(.01,2),i),null,null,null,"helper"]],END:[[new Ri(new ko(.01,2),i),null,null,null,"helper"]],DELTA:[[new bo(function(){const e=new hi;return e.setAttribute("position",new ni([0,0,0,1,1,1],3)),e}(),i),null,null,null,"helper"]],X:[[new bo(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new bo(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new bo(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new Ri(_(.5,1),d),null,[0,Math.PI/2,0]]],X:[[new Ri(_(.5,.5),r)]],Y:[[new Ri(_(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Ri(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Ri(_(.75,1),u),null,[0,Math.PI/2,0]]]},S={AXIS:[[new bo(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},E={XYZE:[[new Ri(new Go(.25,10,8),n)]],X:[[new Ri(new Vo(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ri(new Vo(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ri(new Vo(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ri(new Vo(.75,.1,2,24),n)]]},T={X:[[new Ri(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new Ri(g,r),[0,0,0],[0,0,-Math.PI/2]],[new Ri(m,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ri(m,s),[0,.5,0]],[new Ri(g,s)],[new Ri(m,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ri(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Ri(g,a),[0,0,0],[Math.PI/2,0,0]],[new Ri(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ri(new Pi(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new Ri(new Pi(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ri(new Pi(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ri(new Pi(.1,.1,.1),h.clone())]]},w={X:[[new Ri(new zo(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ri(new zo(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ri(new zo(.2,0,.6,4),n),[0,.3,0]],[new Ri(new zo(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ri(new zo(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ri(new zo(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ri(new Pi(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ri(new Pi(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ri(new Pi(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ri(new Pi(.2,.2,.2),n),[0,0,0]]]},b={X:[[new bo(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new bo(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new bo(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(e){const t=new Cn;for(const n in e)for(let i=e[n].length;i--;){const r=e[n][i][0].clone(),s=e[n][i][1],a=e[n][i][2],o=e[n][i][3],l=e[n][i][4];r.name=n,r.tag=l,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const c=r.geometry.clone();c.applyMatrix4(r.matrix),r.geometry=c,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),t.add(r)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(v)),this.add(this.gizmo.rotate=A(M)),this.add(this.gizmo.scale=A(T)),this.add(this.picker.translate=A(x)),this.add(this.picker.rotate=A(E)),this.add(this.picker.scale=A(w)),this.add(this.helper.translate=A(y)),this.add(this.helper.rotate=A(S)),this.add(this.helper.scale=A(b)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Hh;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){const i=n[e];let r;if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==i.tag){if(i.quaternion.copy(t),"translate"===this.mode||"scale"===this.mode){const e=.99,n=.2;"X"===i.name&&Math.abs(Oh.copy(Vh).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(Oh.copy(Wh).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(Oh.copy(Xh).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(Oh.copy(Xh).applyQuaternion(t).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(Oh.copy(Vh).applyQuaternion(t).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(Oh.copy(Wh).applyQuaternion(t).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===this.mode&&(zh.copy(t),Oh.copy(this.eye).applyQuaternion(Sh.copy(t).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(Bh.lookAt(this.eye,Fh,Wh)),"X"===i.name&&(Sh.setFromAxisAngle(Vh,Math.atan2(-Oh.y,Oh.z)),Sh.multiplyQuaternions(zh,Sh),i.quaternion.copy(Sh)),"Y"===i.name&&(Sh.setFromAxisAngle(Wh,Math.atan2(Oh.x,Oh.z)),Sh.multiplyQuaternions(zh,Sh),i.quaternion.copy(Sh)),"Z"===i.name&&(Sh.setFromAxisAngle(Xh,Math.atan2(Oh.y,Oh.x)),Sh.multiplyQuaternions(zh,Sh),i.quaternion.copy(Sh)));i.visible=i.visible&&(-1===i.name.indexOf("X")||this.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||this.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||this.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||this.showX&&this.showY&&this.showZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some((function(e){return i.name===e})))&&(i.material.color.setHex(16776960),i.material.opacity=1)}else i.visible=!1,"AXIS"===i.name?(i.visible=!!this.axis,"X"===this.axis&&(Sh.setFromEuler(Nh.set(0,0,0)),i.quaternion.copy(t).multiply(Sh),Math.abs(Oh.copy(Vh).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Y"===this.axis&&(Sh.setFromEuler(Nh.set(0,0,Math.PI/2)),i.quaternion.copy(t).multiply(Sh),Math.abs(Oh.copy(Wh).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(Sh.setFromEuler(Nh.set(0,Math.PI/2,0)),i.quaternion.copy(t).multiply(Sh),Math.abs(Oh.copy(Xh).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(Sh.setFromEuler(Nh.set(0,Math.PI/2,0)),Oh.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Bh.lookAt(Fh,Oh,Wh)),i.quaternion.multiply(Sh),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),yh.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),yh.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(yh),i.visible=this.dragging):(i.quaternion.copy(t),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(e)}}class Zh extends Ri{constructor(){super(new Ji(1e5,1e5,2,2),new Zn({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),jh.copy(Vh).applyQuaternion("local"===t?this.worldQuaternion:Hh),Yh.copy(Wh).applyQuaternion("local"===t?this.worldQuaternion:Hh),qh.copy(Xh).applyQuaternion("local"===t?this.worldQuaternion:Hh),Oh.copy(Yh),this.mode){case"translate":case"scale":switch(this.axis){case"X":Oh.copy(this.eye).cross(jh),kh.copy(jh).cross(Oh);break;case"Y":Oh.copy(this.eye).cross(Yh),kh.copy(Yh).cross(Oh);break;case"Z":Oh.copy(this.eye).cross(qh),kh.copy(qh).cross(Oh);break;case"XY":kh.copy(qh);break;case"YZ":kh.copy(jh);break;case"XZ":Oh.copy(qh),kh.copy(Yh);break;case"XYZ":case"E":kh.set(0,0,0)}break;default:kh.set(0,0,0)}0===kh.length()?this.quaternion.copy(this.cameraQuaternion):(Gh.lookAt(yh.set(0,0,0),kh,Oh),this.quaternion.setFromRotationMatrix(Gh)),super.updateMatrixWorld(e)}}class Jh extends bo{constructor(e,t=1,n=16776960,i=new At){const r=new hi;r.setAttribute("position",new ni([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new yo({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t,this.offset=i;const s=new hi;s.setAttribute("position",new ni([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Ri(s,new Zn({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(e){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(e)}}class Qh extends ph{constructor(e,t,n){super(e),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=e=>{this.orbit.enabled=!e.value},this.viewerExplode=()=>{this.planeHelper.size=this.viewer.extents.getSize(new At).length(),this.viewer.update()},this.onDoubleClick=e=>{e.stopPropagation(),this.plane.negate(),this.viewer.update()};const i=e.extents.getSize(new At).length(),r=e.extents.getCenter(new At),s=-r.dot(t);this.plane=new Xi(t,s),e.renderer.clippingPlanes||(e.renderer.clippingPlanes=[]),e.renderer.clippingPlanes.push(this.plane),this.planeHelper=new Jh(this.plane,i,n,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new Cn,this.planeCenter.position.copy(e.extents.getCenter(new At)),this.viewer.helpers.add(this.planeCenter),this.transform=new Rh(e.camera,e.canvas),this.transform.showX=!!t.x,this.transform.showY=!!t.y,this.transform.showZ=!!t.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform),this.viewer.on("explode",this.viewerExplode),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.viewerExplode),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.removeFromParent(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class $h extends Qh{constructor(e){super(e,new At(1,0,0),16711680)}}class eu extends Qh{constructor(e){super(e,new At(0,1,0),65280)}}class tu extends Qh{constructor(e){super(e,new At(0,0,1),255)}}class nu{constructor(e){this.syncExtents=()=>{const e=this.viewer.models.reduce(((e,t)=>{const n=(new Pt).setFromObject(t.scene);return e.isEmpty()?e.copy(n):e.union(n)}),new Pt);this.viewer.extents.copy(e),this.viewer.target.copy(e.getCenter(new At))},this.viewer=e,this.viewer.addEventListener("geometryend",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents)}dispose(){this.viewer.removeEventListener("geometryend",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents)}}class iu{constructor(e){this.viewer=e,this.ambientLight=new Nl(16777215,0),this.viewer.camera.add(this.ambientLight),this.directionalLight=new Dl(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.camera.add(this.directionalLight)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight=void 0,this.directionalLight.removeFromParent(),this.directionalLight=void 0}}class ru extends Ca{constructor(){super();const e=new Pi;e.deleteAttribute("uv");const t=new Wo({side:y}),n=new Wo,i=new Il(16777215,5,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new Ri(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new Ri(e,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const a=new Ri(e,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const o=new Ri(e,n);o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),this.add(o);const l=new Ri(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const c=new Ri(e,n);c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),this.add(c);const h=new Ri(e,n);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);const u=new Ri(e,su(50));u.position.set(-16.116,14.37,8.208),u.scale.set(.1,2.428,2.739),this.add(u);const d=new Ri(e,su(50));d.position.set(-16.109,18.021,-8.207),d.scale.set(.1,2.425,2.751),this.add(d);const p=new Ri(e,su(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const m=new Ri(e,su(43));m.position.set(-.462,8.89,14.52),m.scale.set(4.38,5.441,.088),this.add(m);const f=new Ri(e,su(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);const g=new Ri(e,su(100));g.position.set(0,20,0),g.scale.set(1,.1,1),this.add(g)}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function su(e){const t=new Zn;return t.color.setScalar(e),t}class au{constructor(e){this.syncOptions=()=>{this.backgroundColor.setHex(16777215)},this.viewer=e,this.backgroundColor=new qn(16777215);const t=new ru,n=new _r(this.viewer.renderer);this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.scene.environment=n.fromScene(t).texture,this.viewer.addEventListener("optionschange",this.syncOptions),t.dispose()}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.environment=void 0,this.viewer.scene.background=void 0}}class ou{constructor(e){this.geometryEnd=e=>{const t=this.viewer.extents.getSize(new At).length();this.viewer.camera.near=t/100,this.viewer.camera.far=100*t,this.viewer.camera.updateMatrixWorld(),this.viewer.camera.updateProjectionMatrix(),this.viewer.executeCommand("zoomToExtents")},this.viewer=e,this.viewer.addEventListener("geometryend",this.geometryEnd)}dispose(){this.viewer.removeEventListener("geometryend",this.geometryEnd)}}class lu{constructor(e){this.resizeViewer=e=>{const{width:t,height:n}=e[0].contentRect;t&&n&&(this.viewer.camera.aspect=t/n,this.viewer.camera.updateProjectionMatrix(),this.viewer.renderer.setSize(t,n,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:t,height:n}))},this.viewer=e,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(e.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class cu{constructor(e){this.animate=(e=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(e)},this.viewer=e,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class hu extends Cn{constructor(e){super(),this.camera=e,this.size=160,this.orthoCamera=new lr(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const t=new Zn({toneMapped:!1,color:"#aa0000"}),n=new Zn({toneMapped:!1,color:"#00aa00"}),i=new Zn({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(t.color,"X"),s=this.getSpriteMaterial(n.color,"Y"),a=this.getSpriteMaterial(i.color,"Z"),o=new zo(.01,.01,1,3);o.translate(0,.5,0);const l=new zo(0,.1,.25,12);l.translate(0,.625,0);const c={X:[[new Ri(l,t),[.5,0,0],[0,0,-Math.PI/2]],[new Ri(o,t),[0,0,0],[0,0,-Math.PI/2]],[new Ya(r),[1.55,0,0]]],Y:[[new Ri(l,n),[0,.5,0],null],[new Ri(o,n),null,null],[new Ya(s),[0,1.55,0]]],Z:[[new Ri(l,i),[0,0,.5],[Math.PI/2,0,0]],[new Ri(o,i),null,[Math.PI/2,0,0]],[new Ya(a),[0,0,1.55]]]};Object.keys(c).forEach((e=>{c[e].forEach((t=>{const n=t[0],i=t[1],r=t[2];n.name=e,i&&n.position.set(i[0],i[1],i[2]),r&&n.rotation.set(r[0],r[1],r[2]),n.updateMatrixWorld(),this.add(n)}))}))}dispose(){this.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}getSpriteMaterial(e,t){const n=document.createElement("canvas");n.width=64,n.height=64;const i=n.getContext("2d");i.clearRect(0,0,64,64),i.font="24px Arial",i.textAlign="center",i.fillStyle=e.getStyle(),i.fillText(t,32,41);const r=new Bo(n);return r.colorSpace=Ee,new Ua({map:r,toneMapped:!1})}render(e){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const t=e.clippingPlanes,n=e.getViewport(new St);e.setViewport(this.position.x,this.position.y,this.size,this.size),e.clippingPlanes=[],e.clearDepth(),e.render(this,this.orthoCamera),e.setViewport(n),e.clippingPlanes=t}}class uu{constructor(e){this.viewerRender=()=>{this.viewer.extents.isEmpty()||this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new hu(e.camera),this.viewer=e,this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}e.CANVAS_EVENTS=o,e.CanvasEvents=a,e.Dragger=class{constructor(e){this.name=""}initialize(){}dispose(){}updatePreview(){}},e.Options=s,e.Viewer=class extends eh{constructor(e){super(),this._options=new s(this),this.client=e,this.canvasEvents=o,this.canvaseventlistener=e=>this.emit(e),this.extents=new Pt,this.target=new At,this.draggerFactory={Pan:mh,Zoom:fh,Orbit:ph,Walk:vh,CuttingPlaneXAxis:$h,CuttingPlaneYAxis:eu,CuttingPlaneZAxis:tu},this._activeDragger=null,this.models=[],this.components=[],this.selected=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this)}get options(){return this._options}get draggers(){return Object.keys(this.draggerFactory)}initialize(e,t){this.addEventListener("optionschange",(e=>this.syncOptions(e.data))),this.scene=new Ca,this.helpers=new Ca;const n=e.parentElement.getBoundingClientRect(),i=n.width||1,r=n.height||1;return this.camera=new Fi(45,i/r,.01,1e3),this.camera.up.set(0,0,1),this.renderer=new Ra({canvas:e,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(i,r),this.renderer.toneMapping=H,this.canvas=e,this.canvasEvents.forEach((t=>e.addEventListener(t,this.canvaseventlistener))),this.components.push(new nu(this)),this.components.push(new iu(this)),this.components.push(new au(this)),this.components.push(new ou(this)),this.components.push(new lu(this)),this.components.push(new cu(this)),this.components.push(new Jl(this)),this.components.push(new uu(this)),this.syncOptions(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof t&&t(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this.components.forEach((e=>e.dispose())),this.components=[],this.setActiveDragger(""),this.removeAllListeners(),this.clear(),this.canvas&&(this.canvasEvents.forEach((e=>this.canvas.removeEventListener(e,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.renderer=void 0,this.camera=void 0,this.scene=void 0,this.helpers=void 0,this}isInitialized(){return!!this.renderer}render(e){if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const t=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=t;const n=(e-this.renderTime)/1e3;this.renderTime=e,this.emitEvent({type:"render",time:e,deltaTime:n})}update(e=!1){this.renderNeeded=!0,e&&this.render(performance.now()),this.emitEvent({type:"update",data:e})}syncOptions(e=this.options){}loadReferences(e){return Promise.resolve(this)}async open(e){if(!this.renderer)return this;let t;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:e,model:e}),e){const n=await e.getModels()||[];t=n.find((e=>e.default))||n[0]}if(!t)throw new Error("No default model found");const n=t.database.split(".").pop();if("gltf"!==n)throw new Error(`Unknown geometry type: ${n}`);const i=`${t.httpClient.serverUrl}${t.path}/${t.database}`,r={requestHeader:t.httpClient.headers};return await this.loadReferences(t),await this.loadGltfFile(i,void 0,r),this}cancel(){return this.emitEvent({type:"cancel"}),this}openGltfFile(e,t=new Map,n={}){return this.renderer?(this.cancel(),this.clear(),this.emitEvent({type:"open"}),this.loadGltfFile(e,t,n)):Promise.resolve(this)}async loadGltfFile(e,t=new Map,n={}){const i=new $c(e,t,n);try{this.emitEvent({type:"geometrystart"});const e=new rc(i);e.setPath(i.path),e.setRequestHeader(n.requestHeader),e.setCrossOrigin(n.crossOrigin||e.crossOrigin),e.setWithCredentials(n.withCredentials||e.withCredentials);const t=await e.loadAsync(i.fileURL,(e=>{const{lengthComputable:t,loaded:n,total:i}=e,r=t?n/i:1;this.emitEvent({type:"geometryprogress",data:r})}));if(!this.scene)return this;if(!t.scene)throw new Error("No glTF scene found");this.models.push(t),this.scene.add(t.scene),this.update(),this.resetActiveDragger(),this.emitEvent({type:"databasechunk"}),this.emitEvent({type:"geometryend",data:t.scene})}catch(e){throw this.emitEvent({type:"geometryerror",data:e}),e}finally{i.dispose()}return this}clear(){if(!this.renderer)return this;function e(e){var t;e.geometry&&e.geometry.dispose(),e.material&&(t=e.material,(Array.isArray(t)?t:[t]).forEach((e=>{e.dispose()})))}return this.setActiveDragger(),this.selected=[],this.renderer.clippingPlanes=[],this.helpers.traverse(e),this.helpers.clear(),this.models.forEach((t=>t.scene.traverse(e))),this.models.forEach((e=>e.scene.removeFromParent())),this.models=[],this.scene.clear(),this.emitEvent({type:"clear"}),this.update(!0),this}getSelected(){return this.executeCommand("getSelected")}setSelected(e){this.executeCommand("setSelected",e)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(e=0){this.executeCommand("explode",e)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(e=""){if(!this._activeDragger||this._activeDragger.name!==e){if(this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()){const t=this.draggerFactory[e];t&&(this._activeDragger=new t(this),this._activeDragger.name=e)}const t=this.canvas;t&&(t.className=t.className.split(" ").filter((e=>!e.startsWith("oda-cursor-"))).filter((e=>e)).concat(`oda-cursor-${e.toLowerCase()}`).join(" ")),this.emitEvent({type:"changeactivedragger",data:e})}return this._activeDragger}resetActiveDragger(){const e=this._activeDragger;e&&(this.setActiveDragger(),this.setActiveDragger(e.name))}is3D(){return!0}executeCommand(e,...t){return i("ThreeJS").executeCommand(e,this,...t)}getComponent(e){return this.components.find((t=>t instanceof e))}drawViewpoint(e){}createViewpoint(){var e;const t={};return t.snapshot={data:null===(e=this.canvas)||void 0===e?void 0:e.toDataURL("image/jpeg",.25)},t.description=(new Date).toDateString(),t}},e.commands=i,e.defaultOptions=r}));
7
+ const h="153",l=0,c=1,d=2,u=0,p=1,f=2,m=3,g=1,v=2,_=3,y=0,x=1,S=2,M=100,b=101,w=102,E=200,T=201,A=202,C=203,R=204,P=205,L=206,I=207,D=208,U=209,N=210,O=0,F=1,k=2,B=0,z=1,G=2,H=3,V=4,W=5,X=301,j=302,Y=306,q=1e3,K=1001,Z=1002,J=1003,Q=1004,$=1005,tt=1006,et=1007,it=1008,nt=1009,rt=1012,at=1013,st=1014,ot=1015,ht=1016,lt=1020,ct=1023,dt=1026,ut=1027,pt=33776,ft=33777,mt=33778,gt=33779,vt=36492,_t=2300,yt=2301,xt=2302,St=3001,Mt="",bt="srgb",wt="srgb-linear",Et="display-p3",Tt=7680,At=512,Ct=513,Rt=514,Pt=515,Lt=516,It=517,Dt=518,Ut=519,Nt=35044,Ot="300 es",Ft=1035,kt=2e3,Bt=2001;class zt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t);t.target=null}}}const Gt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Ht=1234567;const Vt=Math.PI/180,Wt=180/Math.PI;function Xt(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Gt[255&t]+Gt[t>>8&255]+Gt[t>>16&255]+Gt[t>>24&255]+"-"+Gt[255&e]+Gt[e>>8&255]+"-"+Gt[e>>16&15|64]+Gt[e>>24&255]+"-"+Gt[63&i|128]+Gt[i>>8&255]+"-"+Gt[i>>16&255]+Gt[i>>24&255]+Gt[255&n]+Gt[n>>8&255]+Gt[n>>16&255]+Gt[n>>24&255]).toLowerCase()}function jt(t,e,i){return Math.max(e,Math.min(i,t))}function Yt(t,e){return(t%e+e)%e}function qt(t,e,i){return(1-i)*t+i*e}function Kt(t){return!(t&t-1)&&0!==t}function Zt(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Jt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Qt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function $t(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const te={DEG2RAD:Vt,RAD2DEG:Wt,generateUUID:Xt,clamp:jt,euclideanModulo:Yt,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:qt,damp:function(t,e,i,n){return qt(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(Yt(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Ht=t);let e=Ht+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Vt},radToDeg:function(t){return t*Wt},isPowerOfTwo:Kt,ceilPowerOfTwo:Zt,floorPowerOfTwo:Jt,setQuaternionFromProperEuler:function(t,e,i,n,r){const a=Math.cos,s=Math.sin,o=a(i/2),h=s(i/2),l=a((e+n)/2),c=s((e+n)/2),d=a((e-n)/2),u=s((e-n)/2),p=a((n-e)/2),f=s((n-e)/2);switch(r){case"XYX":t.set(o*c,h*d,h*u,o*l);break;case"YZY":t.set(h*u,o*c,h*d,o*l);break;case"ZXZ":t.set(h*d,h*u,o*c,o*l);break;case"XZX":t.set(o*c,h*f,h*p,o*l);break;case"YXY":t.set(h*p,o*c,h*f,o*l);break;case"ZYZ":t.set(h*f,h*p,o*c,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:$t,denormalize:Qt};class ee{constructor(t=0,e=0){ee.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(jt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*i-a*n+t.x,this.y=r*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ie{constructor(t,e,i,n,r,a,s,o,h){ie.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,a,s,o,h)}set(t,e,i,n,r,a,s,o,h){const l=this.elements;return l[0]=t,l[1]=n,l[2]=s,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=a,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,a=i[0],s=i[3],o=i[6],h=i[1],l=i[4],c=i[7],d=i[2],u=i[5],p=i[8],f=n[0],m=n[3],g=n[6],v=n[1],_=n[4],y=n[7],x=n[2],S=n[5],M=n[8];return r[0]=a*f+s*v+o*x,r[3]=a*m+s*_+o*S,r[6]=a*g+s*y+o*M,r[1]=h*f+l*v+c*x,r[4]=h*m+l*_+c*S,r[7]=h*g+l*y+c*M,r[2]=d*f+u*v+p*x,r[5]=d*m+u*_+p*S,r[8]=d*g+u*y+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],a=t[4],s=t[5],o=t[6],h=t[7],l=t[8];return e*a*l-e*s*h-i*r*l+i*s*o+n*r*h-n*a*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],a=t[4],s=t[5],o=t[6],h=t[7],l=t[8],c=l*a-s*h,d=s*o-l*r,u=h*r-a*o,p=e*c+i*d+n*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(n*h-l*i)*f,t[2]=(s*i-n*a)*f,t[3]=d*f,t[4]=(l*e-n*o)*f,t[5]=(n*r-s*e)*f,t[6]=u*f,t[7]=(i*o-h*e)*f,t[8]=(a*e-i*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,a,s){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*a+h*s)+a+t,-n*h,n*o,-n*(-h*a+o*s)+s+e,0,0,1),this}scale(t,e){return this.premultiply(ne.makeScale(t,e)),this}rotate(t){return this.premultiply(ne.makeRotation(-t)),this}translate(t,e){return this.premultiply(ne.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ne=new ie;function re(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function ae(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const se={};function oe(t){t in se||(se[t]=!0,console.warn(t))}function he(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function le(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const ce=(new ie).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),de=(new ie).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const ue={[wt]:t=>t,[bt]:t=>t.convertSRGBToLinear(),[Et]:function(t){return t.convertSRGBToLinear().applyMatrix3(de)}},pe={[wt]:t=>t,[bt]:t=>t.convertLinearToSRGB(),[Et]:function(t){return t.applyMatrix3(ce).convertLinearToSRGB()}},fe={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return wt},set workingColorSpace(t){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(t,e,i){if(!1===this.enabled||e===i||!e||!i)return t;const n=ue[e],r=pe[i];if(void 0===n||void 0===r)throw new Error(`Unsupported color space conversion, "${e}" to "${i}".`);return r(n(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)}};let me;class ge{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===me&&(me=ae("canvas")),me.width=t.width,me.height=t.height;const i=me.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=me}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ae("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t<r.length;t++)r[t]=255*he(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*he(e[t]/255)):e[t]=he(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ve=0;class _e{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ve++}),this.uuid=Xt(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(ye(n[e].image)):t.push(ye(n[e]))}else t=ye(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function ye(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?ge.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let xe=0;class Se extends zt{constructor(t=Se.DEFAULT_IMAGE,e=Se.DEFAULT_MAPPING,i=1001,n=1001,r=1006,a=1008,s=1023,o=1009,h=Se.DEFAULT_ANISOTROPY,l=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xe++}),this.uuid=Xt(),this.name="",this.source=new _e(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=h,this.format=s,this.internalFormat=null,this.type=o,this.offset=new ee(0,0),this.repeat=new ee(1,1),this.center=new ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ie,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof l?this.colorSpace=l:(oe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=l===St?bt:Mt),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case q:t.x=t.x-Math.floor(t.x);break;case K:t.x=t.x<0?0:1;break;case Z:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case q:t.y=t.y-Math.floor(t.y);break;case K:t.y=t.y<0?0:1;break;case Z:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return oe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===bt?St:3e3}set encoding(t){oe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===St?bt:Mt}}Se.DEFAULT_IMAGE=null,Se.DEFAULT_MAPPING=300,Se.DEFAULT_ANISOTROPY=1;class Me{constructor(t=0,e=0,i=0,n=1){Me.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const a=.01,s=.1,o=t.elements,h=o[0],l=o[4],c=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(l-d)<a&&Math.abs(c-f)<a&&Math.abs(p-m)<a){if(Math.abs(l+d)<s&&Math.abs(c+f)<s&&Math.abs(p+m)<s&&Math.abs(h+u+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,o=(u+1)/2,v=(g+1)/2,_=(l+d)/4,y=(c+f)/4,x=(p+m)/4;return t>o&&t>v?t<a?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=_/i,r=y/i):o>v?o<a?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=_/n,r=x/n):v<a?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=y/r,n=x/r),this.set(i,n,r,e),this}let v=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(d-l)*(d-l));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(c-f)/v,this.z=(d-l)/v,this.w=Math.acos((h+u+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}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 be extends zt{constructor(t=1,e=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Me(0,0,t,e),this.scissorTest=!1,this.viewport=new Me(0,0,t,e);const n={width:t,height:e,depth:1};void 0!==i.encoding&&(oe("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===St?bt:Mt),this.texture=new Se(n,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=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:tt,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(t,e,i=1){this.width===t&&this.height===e&&this.depth===i||(this.width=t,this.height=e,this.depth=i,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new _e(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class we extends Se{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=J,this.minFilter=J,this.wrapR=K,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ee extends Se{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=J,this.minFilter=J,this.wrapR=K,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Te{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,a,s){let o=i[n+0],h=i[n+1],l=i[n+2],c=i[n+3];const d=r[a+0],u=r[a+1],p=r[a+2],f=r[a+3];if(0===s)return t[e+0]=o,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===s)return t[e+0]=d,t[e+1]=u,t[e+2]=p,void(t[e+3]=f);if(c!==f||o!==d||h!==u||l!==p){let t=1-s;const e=o*d+h*u+l*p+c*f,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),a=Math.atan2(r,e*i);t=Math.sin(t*a)/r,s=Math.sin(s*a)/r}const r=s*i;if(o=o*t+d*r,h=h*t+u*r,l=l*t+p*r,c=c*t+f*r,t===1-s){const t=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=t,h*=t,l*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,a){const s=i[n],o=i[n+1],h=i[n+2],l=i[n+3],c=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return t[e]=s*p+l*c+o*u-h*d,t[e+1]=o*p+l*d+h*c-s*u,t[e+2]=h*p+l*u+s*d-o*c,t[e+3]=l*p-s*c-o*d-h*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const i=t._x,n=t._y,r=t._z,a=t._order,s=Math.cos,o=Math.sin,h=s(i/2),l=s(n/2),c=s(r/2),d=o(i/2),u=o(n/2),p=o(r/2);switch(a){case"XYZ":this._x=d*l*c+h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c-d*u*p;break;case"YXZ":this._x=d*l*c+h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c+d*u*p;break;case"ZXY":this._x=d*l*c-h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c-d*u*p;break;case"ZYX":this._x=d*l*c-h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c+d*u*p;break;case"YZX":this._x=d*l*c+h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c-d*u*p;break;case"XZY":this._x=d*l*c-h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],a=e[1],s=e[5],o=e[9],h=e[2],l=e[6],c=e[10],d=i+s+c;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(a-n)*t}else if(i>s&&i>c){const t=2*Math.sqrt(1+i-s-c);this._w=(l-o)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(r+h)/t}else if(s>c){const t=2*Math.sqrt(1+s-i-c);this._w=(r-h)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(o+l)/t}else{const t=2*Math.sqrt(1+c-i-s);this._w=(a-n)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(jt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,a=t._w,s=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+a*s+n*h-r*o,this._y=n*l+a*o+r*s-i*h,this._z=r*l+a*h+i*o-n*s,this._w=a*l-i*s-n*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,a=this._w;let s=a*t._w+i*t._x+n*t._y+r*t._z;if(s<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,s=-s):this.copy(t),s>=1)return this._w=a,this._x=i,this._y=n,this._z=r,this;const o=1-s*s;if(o<=Number.EPSILON){const t=1-e;return this._w=t*a+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const h=Math.sqrt(o),l=Math.atan2(h,s),c=Math.sin((1-e)*l)/h,d=Math.sin(e*l)/h;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=n*c+this._y*d,this._z=r*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(r),i*Math.cos(r),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ae{constructor(t=0,e=0,i=0){Ae.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Re.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Re.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,a=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,a=t.y,s=t.z,o=t.w,h=o*e+a*n-s*i,l=o*i+s*e-r*n,c=o*n+r*i-a*e,d=-r*e-a*i-s*n;return this.x=h*o+d*-r+l*-s-c*-a,this.y=l*o+d*-a+c*-r-h*-s,this.z=c*o+d*-s+h*-a-l*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,a=e.x,s=e.y,o=e.z;return this.x=n*o-r*s,this.y=r*a-i*o,this.z=i*s-n*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Ce.copy(this).projectOnVector(t),this.sub(Ce)}reflect(t){return this.sub(Ce.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(jt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ce=new Ae,Re=new Te;class Pe{constructor(t=new Ae(1/0,1/0,1/0),e=new Ae(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(Ie.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Ie.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Ie.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){if(t.updateWorldMatrix(!1,!1),void 0!==t.boundingBox)null===t.boundingBox&&t.computeBoundingBox(),De.copy(t.boundingBox),De.applyMatrix4(t.matrixWorld),this.union(De);else{const i=t.geometry;if(void 0!==i)if(e&&void 0!==i.attributes&&void 0!==i.attributes.position){const e=i.attributes.position;for(let i=0,n=e.count;i<n;i++)Ie.fromBufferAttribute(e,i).applyMatrix4(t.matrixWorld),this.expandByPoint(Ie)}else null===i.boundingBox&&i.computeBoundingBox(),De.copy(i.boundingBox),De.applyMatrix4(t.matrixWorld),this.union(De)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ie),Ie.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ze),Ge.subVectors(this.max,ze),Ue.subVectors(t.a,ze),Ne.subVectors(t.b,ze),Oe.subVectors(t.c,ze),Fe.subVectors(Ne,Ue),ke.subVectors(Oe,Ne),Be.subVectors(Ue,Oe);let e=[0,-Fe.z,Fe.y,0,-ke.z,ke.y,0,-Be.z,Be.y,Fe.z,0,-Fe.x,ke.z,0,-ke.x,Be.z,0,-Be.x,-Fe.y,Fe.x,0,-ke.y,ke.x,0,-Be.y,Be.x,0];return!!We(e,Ue,Ne,Oe,Ge)&&(e=[1,0,0,0,1,0,0,0,1],!!We(e,Ue,Ne,Oe,Ge)&&(He.crossVectors(Fe,ke),e=[He.x,He.y,He.z],We(e,Ue,Ne,Oe,Ge)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ie).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Ie).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Le[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Le[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Le[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Le[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Le[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Le[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Le[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Le[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Le)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Le=[new Ae,new Ae,new Ae,new Ae,new Ae,new Ae,new Ae,new Ae],Ie=new Ae,De=new Pe,Ue=new Ae,Ne=new Ae,Oe=new Ae,Fe=new Ae,ke=new Ae,Be=new Ae,ze=new Ae,Ge=new Ae,He=new Ae,Ve=new Ae;function We(t,e,i,n,r){for(let a=0,s=t.length-3;a<=s;a+=3){Ve.fromArray(t,a);const s=r.x*Math.abs(Ve.x)+r.y*Math.abs(Ve.y)+r.z*Math.abs(Ve.z),o=e.dot(Ve),h=i.dot(Ve),l=n.dot(Ve);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>s)return!1}return!0}const Xe=new Pe,je=new Ae,Ye=new Ae;class qe{constructor(t=new Ae,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Xe.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;je.subVectors(t,this.center);const e=je.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(je,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ye.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(je.copy(t.center).add(Ye)),this.expandByPoint(je.copy(t.center).sub(Ye))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Ke=new Ae,Ze=new Ae,Je=new Ae,Qe=new Ae,$e=new Ae,ti=new Ae,ei=new Ae;class ii{constructor(t=new Ae,e=new Ae(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ke)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ke.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ke.copy(this.origin).addScaledVector(this.direction,e),Ke.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ze.copy(t).add(e).multiplyScalar(.5),Je.copy(e).sub(t).normalize(),Qe.copy(this.origin).sub(Ze);const r=.5*t.distanceTo(e),a=-this.direction.dot(Je),s=Qe.dot(this.direction),o=-Qe.dot(Je),h=Qe.lengthSq(),l=Math.abs(1-a*a);let c,d,u,p;if(l>0)if(c=a*o-s,d=a*s-o,p=r*l,c>=0)if(d>=-p)if(d<=p){const t=1/l;c*=t,d*=t,u=c*(c+a*d+2*s)+d*(a*c+d+2*o)+h}else d=r,c=Math.max(0,-(a*d+s)),u=-c*c+d*(d+2*o)+h;else d=-r,c=Math.max(0,-(a*d+s)),u=-c*c+d*(d+2*o)+h;else d<=-p?(c=Math.max(0,-(-a*r+s)),d=c>0?-r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+h):d<=p?(c=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+h):(c=Math.max(0,-(a*r+s)),d=c>0?r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+h);else d=a>0?-r:r,c=Math.max(0,-(a*d+s)),u=-c*c+d*(d+2*o)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Ze).addScaledVector(Je,d),u}intersectSphere(t,e){Ke.subVectors(t.center,this.origin);const i=Ke.dot(this.direction),n=Ke.dot(Ke)-i*i,r=t.radius*t.radius;if(n>r)return null;const a=Math.sqrt(r-n),s=i-a,o=i+a;return o<0?null:s<0?this.at(o,e):this.at(s,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,a,s,o;const h=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,n=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,n=(t.min.x-d.x)*h),l>=0?(r=(t.min.y-d.y)*l,a=(t.max.y-d.y)*l):(r=(t.max.y-d.y)*l,a=(t.min.y-d.y)*l),i>a||r>n?null:((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),c>=0?(s=(t.min.z-d.z)*c,o=(t.max.z-d.z)*c):(s=(t.max.z-d.z)*c,o=(t.min.z-d.z)*c),i>o||s>n?null:((s>i||i!=i)&&(i=s),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Ke)}intersectTriangle(t,e,i,n,r){$e.subVectors(e,t),ti.subVectors(i,t),ei.crossVectors($e,ti);let a,s=this.direction.dot(ei);if(s>0){if(n)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}Qe.subVectors(this.origin,t);const o=a*this.direction.dot(ti.crossVectors(Qe,ti));if(o<0)return null;const h=a*this.direction.dot($e.cross(Qe));if(h<0)return null;if(o+h>s)return null;const l=-a*Qe.dot(ei);return l<0?null:this.at(l/s,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ni{constructor(t,e,i,n,r,a,s,o,h,l,c,d,u,p,f,m){ni.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,a,s,o,h,l,c,d,u,p,f,m)}set(t,e,i,n,r,a,s,o,h,l,c,d,u,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=h,g[6]=l,g[10]=c,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ni).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/ri.setFromMatrixColumn(t,0).length(),r=1/ri.setFromMatrixColumn(t,1).length(),a=1/ri.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,a=Math.cos(i),s=Math.sin(i),o=Math.cos(n),h=Math.sin(n),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=a*l,i=a*c,n=s*l,r=s*c;e[0]=o*l,e[4]=-o*c,e[8]=h,e[1]=i+n*h,e[5]=t-r*h,e[9]=-s*o,e[2]=r-t*h,e[6]=n+i*h,e[10]=a*o}else if("YXZ"===t.order){const t=o*l,i=o*c,n=h*l,r=h*c;e[0]=t+r*s,e[4]=n*s-i,e[8]=a*h,e[1]=a*c,e[5]=a*l,e[9]=-s,e[2]=i*s-n,e[6]=r+t*s,e[10]=a*o}else if("ZXY"===t.order){const t=o*l,i=o*c,n=h*l,r=h*c;e[0]=t-r*s,e[4]=-a*c,e[8]=n+i*s,e[1]=i+n*s,e[5]=a*l,e[9]=r-t*s,e[2]=-a*h,e[6]=s,e[10]=a*o}else if("ZYX"===t.order){const t=a*l,i=a*c,n=s*l,r=s*c;e[0]=o*l,e[4]=n*h-i,e[8]=t*h+r,e[1]=o*c,e[5]=r*h+t,e[9]=i*h-n,e[2]=-h,e[6]=s*o,e[10]=a*o}else if("YZX"===t.order){const t=a*o,i=a*h,n=s*o,r=s*h;e[0]=o*l,e[4]=r-t*c,e[8]=n*c+i,e[1]=c,e[5]=a*l,e[9]=-s*l,e[2]=-h*l,e[6]=i*c+n,e[10]=t-r*c}else if("XZY"===t.order){const t=a*o,i=a*h,n=s*o,r=s*h;e[0]=o*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=a*l,e[9]=i*c-n,e[2]=n*c-i,e[6]=s*l,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(si,t,oi)}lookAt(t,e,i){const n=this.elements;return ci.subVectors(t,e),0===ci.lengthSq()&&(ci.z=1),ci.normalize(),hi.crossVectors(i,ci),0===hi.lengthSq()&&(1===Math.abs(i.z)?ci.x+=1e-4:ci.z+=1e-4,ci.normalize(),hi.crossVectors(i,ci)),hi.normalize(),li.crossVectors(ci,hi),n[0]=hi.x,n[4]=li.x,n[8]=ci.x,n[1]=hi.y,n[5]=li.y,n[9]=ci.y,n[2]=hi.z,n[6]=li.z,n[10]=ci.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,a=i[0],s=i[4],o=i[8],h=i[12],l=i[1],c=i[5],d=i[9],u=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],_=i[7],y=i[11],x=i[15],S=n[0],M=n[4],b=n[8],w=n[12],E=n[1],T=n[5],A=n[9],C=n[13],R=n[2],P=n[6],L=n[10],I=n[14],D=n[3],U=n[7],N=n[11],O=n[15];return r[0]=a*S+s*E+o*R+h*D,r[4]=a*M+s*T+o*P+h*U,r[8]=a*b+s*A+o*L+h*N,r[12]=a*w+s*C+o*I+h*O,r[1]=l*S+c*E+d*R+u*D,r[5]=l*M+c*T+d*P+u*U,r[9]=l*b+c*A+d*L+u*N,r[13]=l*w+c*C+d*I+u*O,r[2]=p*S+f*E+m*R+g*D,r[6]=p*M+f*T+m*P+g*U,r[10]=p*b+f*A+m*L+g*N,r[14]=p*w+f*C+m*I+g*O,r[3]=v*S+_*E+y*R+x*D,r[7]=v*M+_*T+y*P+x*U,r[11]=v*b+_*A+y*L+x*N,r[15]=v*w+_*C+y*I+x*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],a=t[1],s=t[5],o=t[9],h=t[13],l=t[2],c=t[6],d=t[10],u=t[14];return t[3]*(+r*o*c-n*h*c-r*s*d+i*h*d+n*s*u-i*o*u)+t[7]*(+e*o*u-e*h*d+r*a*d-n*a*u+n*h*l-r*o*l)+t[11]*(+e*h*c-e*s*u-r*a*c+i*a*u+r*s*l-i*h*l)+t[15]*(-n*s*l-e*o*c+e*s*d+n*a*c-i*a*d+i*o*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],a=t[4],s=t[5],o=t[6],h=t[7],l=t[8],c=t[9],d=t[10],u=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=c*m*h-f*d*h+f*o*u-s*m*u-c*o*g+s*d*g,_=p*d*h-l*m*h-p*o*u+a*m*u+l*o*g-a*d*g,y=l*f*h-p*c*h+p*s*u-a*f*u-l*s*g+a*c*g,x=p*c*o-l*f*o-p*s*d+a*f*d+l*s*m-a*c*m,S=e*v+i*_+n*y+r*x;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/S;return t[0]=v*M,t[1]=(f*d*r-c*m*r-f*n*u+i*m*u+c*n*g-i*d*g)*M,t[2]=(s*m*r-f*o*r+f*n*h-i*m*h-s*n*g+i*o*g)*M,t[3]=(c*o*r-s*d*r-c*n*h+i*d*h+s*n*u-i*o*u)*M,t[4]=_*M,t[5]=(l*m*r-p*d*r+p*n*u-e*m*u-l*n*g+e*d*g)*M,t[6]=(p*o*r-a*m*r-p*n*h+e*m*h+a*n*g-e*o*g)*M,t[7]=(a*d*r-l*o*r+l*n*h-e*d*h-a*n*u+e*o*u)*M,t[8]=y*M,t[9]=(p*c*r-l*f*r-p*i*u+e*f*u+l*i*g-e*c*g)*M,t[10]=(a*f*r-p*s*r+p*i*h-e*f*h-a*i*g+e*s*g)*M,t[11]=(l*s*r-a*c*r-l*i*h+e*c*h+a*i*u-e*s*u)*M,t[12]=x*M,t[13]=(l*f*n-p*c*n+p*i*d-e*f*d-l*i*m+e*c*m)*M,t[14]=(p*s*n-a*f*n-p*i*o+e*f*o+a*i*m-e*s*m)*M,t[15]=(a*c*n-l*s*n+l*i*o-e*c*o-a*i*d+e*s*d)*M,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,a=t.x,s=t.y,o=t.z,h=r*a,l=r*s;return this.set(h*a+i,h*s-n*o,h*o+n*s,0,h*s+n*o,l*s+i,l*o-n*a,0,h*o-n*s,l*o+n*a,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,a){return this.set(1,i,r,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,a=e._y,s=e._z,o=e._w,h=r+r,l=a+a,c=s+s,d=r*h,u=r*l,p=r*c,f=a*l,m=a*c,g=s*c,v=o*h,_=o*l,y=o*c,x=i.x,S=i.y,M=i.z;return n[0]=(1-(f+g))*x,n[1]=(u+y)*x,n[2]=(p-_)*x,n[3]=0,n[4]=(u-y)*S,n[5]=(1-(d+g))*S,n[6]=(m+v)*S,n[7]=0,n[8]=(p+_)*M,n[9]=(m-v)*M,n[10]=(1-(d+f))*M,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=ri.set(n[0],n[1],n[2]).length();const a=ri.set(n[4],n[5],n[6]).length(),s=ri.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],ai.copy(this);const o=1/r,h=1/a,l=1/s;return ai.elements[0]*=o,ai.elements[1]*=o,ai.elements[2]*=o,ai.elements[4]*=h,ai.elements[5]*=h,ai.elements[6]*=h,ai.elements[8]*=l,ai.elements[9]*=l,ai.elements[10]*=l,e.setFromRotationMatrix(ai),i.x=r,i.y=a,i.z=s,this}makePerspective(t,e,i,n,r,a,s=2e3){const o=this.elements,h=2*r/(e-t),l=2*r/(i-n),c=(e+t)/(e-t),d=(i+n)/(i-n);let u,p;if(s===kt)u=-(a+r)/(a-r),p=-2*a*r/(a-r);else{if(s!==Bt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);u=-a/(a-r),p=-a*r/(a-r)}return o[0]=h,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,r,a,s=2e3){const o=this.elements,h=1/(e-t),l=1/(i-n),c=1/(a-r),d=(e+t)*h,u=(i+n)*l;let p,f;if(s===kt)p=(a+r)*c,f=-2*c;else{if(s!==Bt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*c,f=-1*c}return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const ri=new Ae,ai=new ni,si=new Ae(0,0,0),oi=new Ae(1,1,1),hi=new Ae,li=new Ae,ci=new Ae,di=new ni,ui=new Te;class pi{constructor(t=0,e=0,i=0,n=pi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],a=n[4],s=n[8],o=n[1],h=n[5],l=n[9],c=n[2],d=n[6],u=n[10];switch(e){case"XYZ":this._y=Math.asin(jt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-jt(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,u),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-jt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-l,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return di.makeRotationFromQuaternion(t),this.setFromRotationMatrix(di,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ui.setFromEuler(this),this.setFromQuaternion(ui,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}pi.DEFAULT_ORDER="XYZ";class fi{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let mi=0;const gi=new Ae,vi=new Te,_i=new ni,yi=new Ae,xi=new Ae,Si=new Ae,Mi=new Te,bi=new Ae(1,0,0),wi=new Ae(0,1,0),Ei=new Ae(0,0,1),Ti={type:"added"},Ai={type:"removed"};class Ci extends zt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mi++}),this.uuid=Xt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ci.DEFAULT_UP.clone();const t=new Ae,e=new pi,i=new Te,n=new Ae(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ni},normalMatrix:{value:new ie}}),this.matrix=new ni,this.matrixWorld=new ni,this.matrixAutoUpdate=Ci.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Ci.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new fi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return vi.setFromAxisAngle(t,e),this.quaternion.multiply(vi),this}rotateOnWorldAxis(t,e){return vi.setFromAxisAngle(t,e),this.quaternion.premultiply(vi),this}rotateX(t){return this.rotateOnAxis(bi,t)}rotateY(t){return this.rotateOnAxis(wi,t)}rotateZ(t){return this.rotateOnAxis(Ei,t)}translateOnAxis(t,e){return gi.copy(t).applyQuaternion(this.quaternion),this.position.add(gi.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(bi,t)}translateY(t){return this.translateOnAxis(wi,t)}translateZ(t){return this.translateOnAxis(Ei,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(_i.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?yi.copy(t):yi.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),xi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_i.lookAt(xi,yi,this.up):_i.lookAt(yi,xi,this.up),this.quaternion.setFromRotationMatrix(_i),n&&(_i.extractRotation(n.matrixWorld),vi.setFromRotationMatrix(_i),this.quaternion.premultiply(vi.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Ti)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ai)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(Ai)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),_i.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),_i.multiply(t.parent.matrixWorld)),t.applyMatrix4(_i),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e){let i=[];this[t]===e&&i.push(this);for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectsByProperty(t,e);r.length>0&&(i=i.concat(r))}return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xi,t,Si),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xi,Mi,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){const n=e[i];!0!==n.matrixWorldAutoUpdate&&!0!==t||n.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(!0===t&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){const i=t[e];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=a(t.geometries),n=a(t.materials),r=a(t.textures),s=a(t.images),o=a(t.shapes),h=a(t.skeletons),l=a(t.animations),c=a(t.nodes);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l),c.length>0&&(i.nodes=c)}return i.object=n,i;function a(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}}Ci.DEFAULT_UP=new Ae(0,1,0),Ci.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ci.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ri=new Ae,Pi=new Ae,Li=new Ae,Ii=new Ae,Di=new Ae,Ui=new Ae,Ni=new Ae,Oi=new Ae,Fi=new Ae,ki=new Ae;let Bi=!1;class zi{constructor(t=new Ae,e=new Ae,i=new Ae){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),Ri.subVectors(t,e),n.cross(Ri);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){Ri.subVectors(n,e),Pi.subVectors(i,e),Li.subVectors(t,e);const a=Ri.dot(Ri),s=Ri.dot(Pi),o=Ri.dot(Li),h=Pi.dot(Pi),l=Pi.dot(Li),c=a*h-s*s;if(0===c)return r.set(-2,-1,-1);const d=1/c,u=(h*o-s*l)*d,p=(a*l-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,Ii),Ii.x>=0&&Ii.y>=0&&Ii.x+Ii.y<=1}static getUV(t,e,i,n,r,a,s,o){return!1===Bi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Bi=!0),this.getInterpolation(t,e,i,n,r,a,s,o)}static getInterpolation(t,e,i,n,r,a,s,o){return this.getBarycoord(t,e,i,n,Ii),o.setScalar(0),o.addScaledVector(r,Ii.x),o.addScaledVector(a,Ii.y),o.addScaledVector(s,Ii.z),o}static isFrontFacing(t,e,i,n){return Ri.subVectors(i,e),Pi.subVectors(t,e),Ri.cross(Pi).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ri.subVectors(this.c,this.b),Pi.subVectors(this.a,this.b),.5*Ri.cross(Pi).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return zi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return zi.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return!1===Bi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Bi=!0),zi.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}getInterpolation(t,e,i,n,r){return zi.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return zi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return zi.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let a,s;Di.subVectors(n,i),Ui.subVectors(r,i),Oi.subVectors(t,i);const o=Di.dot(Oi),h=Ui.dot(Oi);if(o<=0&&h<=0)return e.copy(i);Fi.subVectors(t,n);const l=Di.dot(Fi),c=Ui.dot(Fi);if(l>=0&&c<=l)return e.copy(n);const d=o*c-l*h;if(d<=0&&o>=0&&l<=0)return a=o/(o-l),e.copy(i).addScaledVector(Di,a);ki.subVectors(t,r);const u=Di.dot(ki),p=Ui.dot(ki);if(p>=0&&u<=p)return e.copy(r);const f=u*h-o*p;if(f<=0&&h>=0&&p<=0)return s=h/(h-p),e.copy(i).addScaledVector(Ui,s);const m=l*p-u*c;if(m<=0&&c-l>=0&&u-p>=0)return Ni.subVectors(r,n),s=(c-l)/(c-l+(u-p)),e.copy(n).addScaledVector(Ni,s);const g=1/(m+f+d);return a=f*g,s=d*g,e.copy(i).addScaledVector(Di,a).addScaledVector(Ui,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Gi=0;class Hi extends zt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gi++}),this.uuid=Xt(),this.name="",this.type="Material",this.blending=1,this.side=y,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=M,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=Tt,this.stencilZFail=Tt,this.stencilZPass=Tt,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).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(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).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!==y&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),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.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),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=this.flatShading),!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),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const Vi={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},Wi={h:0,s:0,l:0},Xi={h:0,s:0,l:0};function ji(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class Yi{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=bt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,fe.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=fe.workingColorSpace){return this.r=t,this.g=e,this.b=i,fe.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=fe.workingColorSpace){if(t=Yt(t,1),e=jt(e,0,1),i=jt(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=ji(r,n,t+1/3),this.g=ji(r,n,t),this.b=ji(r,n,t-1/3)}return fe.toWorkingColorSpace(this,n),this}setStyle(t,e=bt){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=bt){const i=Vi[t.toLowerCase()];return void 0!==i?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=he(t.r),this.g=he(t.g),this.b=he(t.b),this}copyLinearToSRGB(t){return this.r=le(t.r),this.g=le(t.g),this.b=le(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=bt){return fe.fromWorkingColorSpace(qi.copy(this),t),65536*Math.round(jt(255*qi.r,0,255))+256*Math.round(jt(255*qi.g,0,255))+Math.round(jt(255*qi.b,0,255))}getHexString(t=bt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=fe.workingColorSpace){fe.fromWorkingColorSpace(qi.copy(this),e);const i=qi.r,n=qi.g,r=qi.b,a=Math.max(i,n,r),s=Math.min(i,n,r);let o,h;const l=(s+a)/2;if(s===a)o=0,h=0;else{const t=a-s;switch(h=l<=.5?t/(a+s):t/(2-a-s),a){case i:o=(n-r)/t+(n<r?6:0);break;case n:o=(r-i)/t+2;break;case r:o=(i-n)/t+4}o/=6}return t.h=o,t.s=h,t.l=l,t}getRGB(t,e=fe.workingColorSpace){return fe.fromWorkingColorSpace(qi.copy(this),e),t.r=qi.r,t.g=qi.g,t.b=qi.b,t}getStyle(t=bt){fe.fromWorkingColorSpace(qi.copy(this),t);const e=qi.r,i=qi.g,n=qi.b;return t!==bt?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(Wi),Wi.h+=t,Wi.s+=e,Wi.l+=i,this.setHSL(Wi.h,Wi.s,Wi.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Wi),t.getHSL(Xi);const i=qt(Wi.h,Xi.h,e),n=qt(Wi.s,Xi.s,e),r=qt(Wi.l,Xi.l,e);return this.setHSL(i,n,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,r=t.elements;return this.r=r[0]*e+r[3]*i+r[6]*n,this.g=r[1]*e+r[4]*i+r[7]*n,this.b=r[2]*e+r[5]*i+r[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qi=new Yi;Yi.NAMES=Vi;class Ki extends Hi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yi(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=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Zi=new Ae,Ji=new ee;class Qi{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=Nt,this.updateRange={offset:0,count:-1},this.gpuType=ot,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)Ji.fromBufferAttribute(this,e),Ji.applyMatrix3(t),this.setXY(e,Ji.x,Ji.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)Zi.fromBufferAttribute(this,e),Zi.applyMatrix3(t),this.setXYZ(e,Zi.x,Zi.y,Zi.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)Zi.fromBufferAttribute(this,e),Zi.applyMatrix4(t),this.setXYZ(e,Zi.x,Zi.y,Zi.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Zi.fromBufferAttribute(this,e),Zi.applyNormalMatrix(t),this.setXYZ(e,Zi.x,Zi.y,Zi.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Zi.fromBufferAttribute(this,e),Zi.transformDirection(t),this.setXYZ(e,Zi.x,Zi.y,Zi.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Qt(e,this.array)),e}setX(t,e){return this.normalized&&(e=$t(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Qt(e,this.array)),e}setY(t,e){return this.normalized&&(e=$t(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Qt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=$t(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Qt(e,this.array)),e}setW(t,e){return this.normalized&&(e=$t(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array),n=$t(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array),n=$t(n,this.array),r=$t(r,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Nt&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class $i extends Qi{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class tn extends Qi{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class en extends Qi{constructor(t,e,i){super(new Float32Array(t),e,i)}}let nn=0;const rn=new ni,an=new Ci,sn=new Ae,on=new Pe,hn=new Pe,ln=new Ae;class cn extends zt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nn++}),this.uuid=Xt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(re(t)?tn:$i)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new ie).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return rn.makeRotationFromQuaternion(t),this.applyMatrix4(rn),this}rotateX(t){return rn.makeRotationX(t),this.applyMatrix4(rn),this}rotateY(t){return rn.makeRotationY(t),this.applyMatrix4(rn),this}rotateZ(t){return rn.makeRotationZ(t),this.applyMatrix4(rn),this}translate(t,e,i){return rn.makeTranslation(t,e,i),this.applyMatrix4(rn),this}scale(t,e,i){return rn.makeScale(t,e,i),this.applyMatrix4(rn),this}lookAt(t){return an.lookAt(t),an.updateMatrix(),this.applyMatrix4(an.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sn).negate(),this.translate(sn.x,sn.y,sn.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new en(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pe);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Ae(-1/0,-1/0,-1/0),new Ae(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];on.setFromBufferAttribute(i),this.morphTargetsRelative?(ln.addVectors(this.boundingBox.min,on.min),this.boundingBox.expandByPoint(ln),ln.addVectors(this.boundingBox.max,on.max),this.boundingBox.expandByPoint(ln)):(this.boundingBox.expandByPoint(on.min),this.boundingBox.expandByPoint(on.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new qe);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Ae,1/0);if(t){const i=this.boundingSphere.center;if(on.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];hn.setFromBufferAttribute(i),this.morphTargetsRelative?(ln.addVectors(on.min,hn.min),on.expandByPoint(ln),ln.addVectors(on.max,hn.max),on.expandByPoint(ln)):(on.expandByPoint(hn.min),on.expandByPoint(hn.max))}on.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)ln.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(ln));if(e)for(let r=0,a=e.length;r<a;r++){const a=e[r],s=this.morphTargetsRelative;for(let e=0,r=a.count;e<r;e++)ln.fromBufferAttribute(a,e),s&&(sn.fromBufferAttribute(t,e),ln.add(sn)),n=Math.max(n,i.distanceToSquared(ln))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.array,n=e.position.array,r=e.normal.array,a=e.uv.array,s=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Qi(new Float32Array(4*s),4));const o=this.getAttribute("tangent").array,h=[],l=[];for(let t=0;t<s;t++)h[t]=new Ae,l[t]=new Ae;const c=new Ae,d=new Ae,u=new Ae,p=new ee,f=new ee,m=new ee,g=new Ae,v=new Ae;function _(t,e,i){c.fromArray(n,3*t),d.fromArray(n,3*e),u.fromArray(n,3*i),p.fromArray(a,2*t),f.fromArray(a,2*e),m.fromArray(a,2*i),d.sub(c),u.sub(c),f.sub(p),m.sub(p);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(d).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(r),v.copy(u).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(r),h[t].add(g),h[e].add(g),h[i].add(g),l[t].add(v),l[e].add(v),l[i].add(v))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)_(i[t+0],i[t+1],i[t+2])}const x=new Ae,S=new Ae,M=new Ae,b=new Ae;function w(t){M.fromArray(r,3*t),b.copy(M);const e=h[t];x.copy(e),x.sub(M.multiplyScalar(M.dot(e))).normalize(),S.crossVectors(b,e);const i=S.dot(l[t])<0?-1:1;o[4*t]=x.x,o[4*t+1]=x.y,o[4*t+2]=x.z,o[4*t+3]=i}for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)w(i[t+0]),w(i[t+1]),w(i[t+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new Qi(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new Ae,r=new Ae,a=new Ae,s=new Ae,o=new Ae,h=new Ae,l=new Ae,c=new Ae;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),p=t.getX(d+1),f=t.getX(d+2);n.fromBufferAttribute(e,u),r.fromBufferAttribute(e,p),a.fromBufferAttribute(e,f),l.subVectors(a,r),c.subVectors(n,r),l.cross(c),s.fromBufferAttribute(i,u),o.fromBufferAttribute(i,p),h.fromBufferAttribute(i,f),s.add(l),o.add(l),h.add(l),i.setXYZ(u,s.x,s.y,s.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(f,h.x,h.y,h.z)}else for(let t=0,s=e.count;t<s;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),a.fromBufferAttribute(e,t+2),l.subVectors(a,r),c.subVectors(n,r),l.cross(c),i.setXYZ(t+0,l.x,l.y,l.z),i.setXYZ(t+1,l.x,l.y,l.z),i.setXYZ(t+2,l.x,l.y,l.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)ln.fromBufferAttribute(t,e),ln.normalize(),t.setXYZ(e,ln.x,ln.y,ln.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,a=new i.constructor(e.length*n);let s=0,o=0;for(let r=0,h=e.length;r<h;r++){s=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*n;for(let t=0;t<n;t++)a[o++]=i[s++]}return new Qi(a,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new cn,i=this.index.array,n=this.attributes;for(const r in n){const a=t(n[r],i);e.setAttribute(r,a)}const r=this.morphAttributes;for(const n in r){const a=[],s=r[n];for(let e=0,n=s.length;e<n;e++){const n=t(s[e],i);a.push(n)}e.morphAttributes[n]=a}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let t=0,i=a.length;t<i;t++){const i=a[t];e.addGroup(i.start,i.count,i.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],a=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];a.push(n.toJSON(t.data))}a.length>0&&(n[e]=a,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let t=0,e=a.length;t<e;t++){const e=a[t];this.addGroup(e.start,e.count,e.materialIndex)}const s=t.boundingBox;null!==s&&(this.boundingBox=s.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const dn=new ni,un=new ii,pn=new qe,fn=new Ae,mn=new Ae,gn=new Ae,vn=new Ae,_n=new Ae,yn=new Ae,xn=new ee,Sn=new ee,Mn=new ee,bn=new Ae,wn=new Ae,En=new Ae,Tn=new Ae,An=new Ae;class Cn extends Ci{constructor(t=new cn,e=new Ki){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const s=this.morphTargetInfluences;if(r&&s){yn.set(0,0,0);for(let i=0,n=r.length;i<n;i++){const n=s[i],o=r[i];0!==n&&(_n.fromBufferAttribute(o,t),a?yn.addScaledVector(_n,n):yn.addScaledVector(_n.sub(e),n))}e.add(yn)}return e}raycast(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),pn.copy(i.boundingSphere),pn.applyMatrix4(r),un.copy(t.ray).recast(t.near),!1===pn.containsPoint(un.origin)){if(null===un.intersectSphere(pn,fn))return;if(un.origin.distanceToSquared(fn)>(t.far-t.near)**2)return}dn.copy(r).invert(),un.copy(t.ray).applyMatrix4(dn),null!==i.boundingBox&&!1===un.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,un)}}_computeIntersections(t,e,i){let n;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,c=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=a[o.materialIndex];for(let r=Math.max(o.start,u.start),a=Math.min(s.count,Math.min(o.start+o.count,u.start+u.count));r<a;r+=3){n=Rn(this,p,t,i,h,l,c,s.getX(r),s.getX(r+1),s.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=o.materialIndex,e.push(n))}}else{for(let r=Math.max(0,u.start),o=Math.min(s.count,u.start+u.count);r<o;r+=3){n=Rn(this,a,t,i,h,l,c,s.getX(r),s.getX(r+1),s.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}else if(void 0!==o)if(Array.isArray(a))for(let r=0,s=d.length;r<s;r++){const s=d[r],p=a[s.materialIndex];for(let r=Math.max(s.start,u.start),a=Math.min(o.count,Math.min(s.start+s.count,u.start+u.count));r<a;r+=3){n=Rn(this,p,t,i,h,l,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=s.materialIndex,e.push(n))}}else{for(let r=Math.max(0,u.start),s=Math.min(o.count,u.start+u.count);r<s;r+=3){n=Rn(this,a,t,i,h,l,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}}}function Rn(t,e,i,n,r,a,s,o,h,l){t.getVertexPosition(o,mn),t.getVertexPosition(h,gn),t.getVertexPosition(l,vn);const c=function(t,e,i,n,r,a,s,o){let h;if(h=e.side===x?n.intersectTriangle(s,a,r,!0,o):n.intersectTriangle(r,a,s,e.side===y,o),null===h)return null;An.copy(o),An.applyMatrix4(t.matrixWorld);const l=i.ray.origin.distanceTo(An);return l<i.near||l>i.far?null:{distance:l,point:An.clone(),object:t}}(t,e,i,n,mn,gn,vn,Tn);if(c){r&&(xn.fromBufferAttribute(r,o),Sn.fromBufferAttribute(r,h),Mn.fromBufferAttribute(r,l),c.uv=zi.getInterpolation(Tn,mn,gn,vn,xn,Sn,Mn,new ee)),a&&(xn.fromBufferAttribute(a,o),Sn.fromBufferAttribute(a,h),Mn.fromBufferAttribute(a,l),c.uv1=zi.getInterpolation(Tn,mn,gn,vn,xn,Sn,Mn,new ee),c.uv2=c.uv1),s&&(bn.fromBufferAttribute(s,o),wn.fromBufferAttribute(s,h),En.fromBufferAttribute(s,l),c.normal=zi.getInterpolation(Tn,mn,gn,vn,bn,wn,En,new Ae),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:h,c:l,normal:new Ae,materialIndex:0};zi.getNormal(mn,gn,vn,t.normal),c.face=t}return c}class Pn extends cn{constructor(t=1,e=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const s=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const o=[],h=[],l=[],c=[];let d=0,u=0;function p(t,e,i,n,r,a,p,f,m,g,v){const _=a/m,y=p/g,x=a/2,S=p/2,M=f/2,b=m+1,w=g+1;let E=0,T=0;const A=new Ae;for(let a=0;a<w;a++){const s=a*y-S;for(let o=0;o<b;o++){const d=o*_-x;A[t]=d*n,A[e]=s*r,A[i]=M,h.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[i]=f>0?1:-1,l.push(A.x,A.y,A.z),c.push(o/m),c.push(1-a/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const i=d+e+b*t,n=d+e+b*(t+1),r=d+(e+1)+b*(t+1),a=d+(e+1)+b*t;o.push(i,n,a),o.push(n,r,a),T+=6}s.addGroup(u,T,v),u+=T,d+=E}p("z","y","x",-1,-1,i,e,t,a,r,0),p("z","y","x",1,-1,i,e,-t,a,r,1),p("x","z","y",1,1,t,i,e,n,a,2),p("x","z","y",1,-1,t,i,-e,n,a,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new en(h,3)),this.setAttribute("normal",new en(l,3)),this.setAttribute("uv",new en(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Pn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ln(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[i][n]=null):e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}}return e}function In(t){const e={};for(let i=0;i<t.length;i++){const n=Ln(t[i]);for(const t in n)e[t]=n[t]}return e}function Dn(t){return null===t.getRenderTarget()?t.outputColorSpace:wt}const Un={clone:Ln,merge:In};class Nn extends Hi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ln(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class On extends Ci{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ni,this.projectionMatrix=new ni,this.projectionMatrixInverse=new ni,this.coordinateSystem=kt}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class Fn extends On{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Wt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Vt*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Wt*Math.atan(Math.tan(.5*Vt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,r,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Vt*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,s=a.fullHeight;r+=a.offsetX*n/t,e-=a.offsetY*i/s,n*=a.width/t,i*=a.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const kn=-90;class Bn extends Ci{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;const n=new Fn(kn,1,t,e);n.layers=this.layers,this.add(n);const r=new Fn(kn,1,t,e);r.layers=this.layers,this.add(r);const a=new Fn(kn,1,t,e);a.layers=this.layers,this.add(a);const s=new Fn(kn,1,t,e);s.layers=this.layers,this.add(s);const o=new Fn(kn,1,t,e);o.layers=this.layers,this.add(o);const h=new Fn(kn,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,r,a,s,o]=e;for(const t of e)this.remove(t);if(t===kt)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Bt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[n,r,a,s,o,h]=this.children,l=t.getRenderTarget(),c=t.toneMapping,d=t.xr.enabled;t.toneMapping=B,t.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,a),t.setRenderTarget(i,3),t.render(e,s),t.setRenderTarget(i,4),t.render(e,o),i.texture.generateMipmaps=u,t.setRenderTarget(i,5),t.render(e,h),t.setRenderTarget(l),t.toneMapping=c,t.xr.enabled=d,i.texture.needsPMREMUpdate=!0}}class zn extends Se{constructor(t,e,i,n,r,a,s,o,h,l){super(t=void 0!==t?t:[],e=void 0!==e?e:X,i,n,r,a,s,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Gn extends be{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];void 0!==e.encoding&&(oe("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===St?bt:Mt),this.texture=new zn(n,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:tt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new Pn(5,5,5),r=new Nn({name:"CubemapFromEquirect",uniforms:Ln(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:x,blending:0});r.uniforms.tEquirect.value=e;const a=new Cn(n,r),s=e.minFilter;e.minFilter===it&&(e.minFilter=tt);return new Bn(1,10,this).update(t,a),e.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}const Hn=new Ae,Vn=new Ae,Wn=new ie;class Xn{constructor(t=new Ae(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=Hn.subVectors(i,e).cross(Vn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(Hn),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||Wn.getNormalMatrix(t),n=this.coplanarPoint(Hn).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const jn=new qe,Yn=new Ae;class qn{constructor(t=new Xn,e=new Xn,i=new Xn,n=new Xn,r=new Xn,a=new Xn){this.planes=[t,e,i,n,r,a]}set(t,e,i,n,r,a){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(a),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,n=t.elements,r=n[0],a=n[1],s=n[2],o=n[3],h=n[4],l=n[5],c=n[6],d=n[7],u=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],_=n[14],y=n[15];if(i[0].setComponents(o-r,d-h,m-u,y-g).normalize(),i[1].setComponents(o+r,d+h,m+u,y+g).normalize(),i[2].setComponents(o+a,d+l,m+p,y+v).normalize(),i[3].setComponents(o-a,d-l,m-p,y-v).normalize(),i[4].setComponents(o-s,d-c,m-f,y-_).normalize(),e===kt)i[5].setComponents(o+s,d+c,m+f,y+_).normalize();else{if(e!==Bt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(s,c,f,_).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),jn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),jn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(jn)}intersectsSprite(t){return jn.center.set(0,0,0),jn.radius=.7071067811865476,jn.applyMatrix4(t.matrixWorld),this.intersectsSphere(jn)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(Yn.x=n.normal.x>0?t.max.x:t.min.x,Yn.y=n.normal.y>0?t.max.y:t.min.y,Yn.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Yn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Kn(){let t=null,e=!1,i=null,n=null;function r(e,a){i(e,a),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Zn(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const a=n.get(e);void 0===a?n.set(e,function(e,n){const r=e.array,a=e.usage,s=t.createBuffer();let o;if(t.bindBuffer(n,s),t.bufferData(n,r,a),e.onUploadCallback(),r instanceof Float32Array)o=t.FLOAT;else if(r instanceof Uint16Array)if(e.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");o=t.HALF_FLOAT}else o=t.UNSIGNED_SHORT;else if(r instanceof Int16Array)o=t.SHORT;else if(r instanceof Uint32Array)o=t.UNSIGNED_INT;else if(r instanceof Int32Array)o=t.INT;else if(r instanceof Int8Array)o=t.BYTE;else if(r instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);o=t.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):a.version<e.version&&(!function(e,n,r){const a=n.array,s=n.updateRange;t.bindBuffer(r,e),-1===s.count?t.bufferSubData(r,0,a):(i?t.bufferSubData(r,s.offset*a.BYTES_PER_ELEMENT,a,s.offset,s.count):t.bufferSubData(r,s.offset*a.BYTES_PER_ELEMENT,a.subarray(s.offset,s.offset+s.count)),s.count=-1),n.onUploadCallback()}(a.buffer,e,r),a.version=e.version)}}}class Jn extends cn{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,a=e/2,s=Math.floor(i),o=Math.floor(n),h=s+1,l=o+1,c=t/s,d=e/o,u=[],p=[],f=[],m=[];for(let t=0;t<l;t++){const e=t*d-a;for(let i=0;i<h;i++){const n=i*c-r;p.push(n,-e,0),f.push(0,0,1),m.push(i/s),m.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<s;e++){const i=e+h*t,n=e+h*(t+1),r=e+1+h*(t+1),a=e+1+h*t;u.push(i,n,a),u.push(n,r,a)}this.setIndex(u),this.setAttribute("position",new en(p,3)),this.setAttribute("normal",new en(f,3)),this.setAttribute("uv",new en(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jn(t.width,t.height,t.widthSegments,t.heightSegments)}}const Qn={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 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\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_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\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\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\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},$n={common:{diffuse:{value:new Yi(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ie},alphaMap:{value:null},alphaMapTransform:{value:new ie},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ie}},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 ie}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ie}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ie},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ie},normalScale:{value:new ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ie},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ie}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ie}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ie}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yi(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 Yi(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ie},alphaTest:{value:0},uvTransform:{value:new ie}},sprite:{diffuse:{value:new Yi(16777215)},opacity:{value:1},center:{value:new ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ie},alphaMap:{value:null},alphaMapTransform:{value:new ie},alphaTest:{value:0}}},tr={basic:{uniforms:In([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.fog]),vertexShader:Qn.meshbasic_vert,fragmentShader:Qn.meshbasic_frag},lambert:{uniforms:In([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.fog,$n.lights,{emissive:{value:new Yi(0)}}]),vertexShader:Qn.meshlambert_vert,fragmentShader:Qn.meshlambert_frag},phong:{uniforms:In([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.fog,$n.lights,{emissive:{value:new Yi(0)},specular:{value:new Yi(1118481)},shininess:{value:30}}]),vertexShader:Qn.meshphong_vert,fragmentShader:Qn.meshphong_frag},standard:{uniforms:In([$n.common,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.roughnessmap,$n.metalnessmap,$n.fog,$n.lights,{emissive:{value:new Yi(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qn.meshphysical_vert,fragmentShader:Qn.meshphysical_frag},toon:{uniforms:In([$n.common,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.gradientmap,$n.fog,$n.lights,{emissive:{value:new Yi(0)}}]),vertexShader:Qn.meshtoon_vert,fragmentShader:Qn.meshtoon_frag},matcap:{uniforms:In([$n.common,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.fog,{matcap:{value:null}}]),vertexShader:Qn.meshmatcap_vert,fragmentShader:Qn.meshmatcap_frag},points:{uniforms:In([$n.points,$n.fog]),vertexShader:Qn.points_vert,fragmentShader:Qn.points_frag},dashed:{uniforms:In([$n.common,$n.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qn.linedashed_vert,fragmentShader:Qn.linedashed_frag},depth:{uniforms:In([$n.common,$n.displacementmap]),vertexShader:Qn.depth_vert,fragmentShader:Qn.depth_frag},normal:{uniforms:In([$n.common,$n.bumpmap,$n.normalmap,$n.displacementmap,{opacity:{value:1}}]),vertexShader:Qn.meshnormal_vert,fragmentShader:Qn.meshnormal_frag},sprite:{uniforms:In([$n.sprite,$n.fog]),vertexShader:Qn.sprite_vert,fragmentShader:Qn.sprite_frag},background:{uniforms:{uvTransform:{value:new ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qn.background_vert,fragmentShader:Qn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Qn.backgroundCube_vert,fragmentShader:Qn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qn.cube_vert,fragmentShader:Qn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qn.equirect_vert,fragmentShader:Qn.equirect_frag},distanceRGBA:{uniforms:In([$n.common,$n.displacementmap,{referencePosition:{value:new Ae},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qn.distanceRGBA_vert,fragmentShader:Qn.distanceRGBA_frag},shadow:{uniforms:In([$n.lights,$n.fog,{color:{value:new Yi(0)},opacity:{value:1}}]),vertexShader:Qn.shadow_vert,fragmentShader:Qn.shadow_frag}};tr.physical={uniforms:In([tr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ie},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ie},clearcoatNormalScale:{value:new ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ie},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ie},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ie},sheen:{value:0},sheenColor:{value:new Yi(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ie},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ie},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ie},transmissionSamplerSize:{value:new ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ie},attenuationDistance:{value:0},attenuationColor:{value:new Yi(0)},specularColor:{value:new Yi(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ie},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ie},anisotropyVector:{value:new ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ie}}]),vertexShader:Qn.meshphysical_vert,fragmentShader:Qn.meshphysical_frag};const er={r:0,b:0,g:0};function ir(t,e,i,n,r,a,s){const o=new Yi(0);let h,l,c=!0===a?0:1,d=null,u=0,p=null;function f(e,i){e.getRGB(er,Dn(t)),n.buffers.color.setClear(er.r,er.g,er.b,i,s)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(a,m){let g=!1,v=!0===m.isScene?m.background:null;if(v&&v.isTexture){v=(m.backgroundBlurriness>0?i:e).get(v)}switch(null===v?f(o,c):v&&v.isColor&&(f(v,1),g=!0),t.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,s),g=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,s),g=!0}(t.autoClear||g)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),v&&(v.isCubeTexture||v.mapping===Y)?(void 0===l&&(l=new Cn(new Pn(1,1,1),new Nn({name:"BackgroundCubeMaterial",uniforms:Ln(tr.backgroundCube.uniforms),vertexShader:tr.backgroundCube.vertexShader,fragmentShader:tr.backgroundCube.fragmentShader,side:x,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=v,l.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=v.colorSpace!==bt,d===v&&u===v.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=v,u=v.version,p=t.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(void 0===h&&(h=new Cn(new Jn(2,2),new Nn({name:"BackgroundMaterial",uniforms:Ln(tr.background.uniforms),vertexShader:tr.background.vertexShader,fragmentShader:tr.background.fragmentShader,side:y,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=v,h.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,h.material.toneMapped=v.colorSpace!==bt,!0===v.matrixAutoUpdate&&v.updateMatrix(),h.material.uniforms.uvTransform.value.copy(v.matrix),d===v&&u===v.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=v,u=v.version,p=t.toneMapping),h.layers.enableAll(),a.unshift(h,h.geometry,h.material,0,0,null))}}}function nr(t,e,i,n){const r=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=n.isWebGL2?null:e.get("OES_vertex_array_object"),s=n.isWebGL2||null!==a,o={},h=p(null);let l=h,c=!1;function d(e){return n.isWebGL2?t.bindVertexArray(e):a.bindVertexArrayOES(e)}function u(e){return n.isWebGL2?t.deleteVertexArray(e):a.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let t=0;t<r;t++)e[t]=0,i[t]=0,n[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function f(){const t=l.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function m(t){g(t,0)}function g(i,r){const a=l.newAttributes,s=l.enabledAttributes,o=l.attributeDivisors;if(a[i]=1,0===s[i]&&(t.enableVertexAttribArray(i),s[i]=1),o[i]!==r){(n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),o[i]=r}}function v(){const e=l.newAttributes,i=l.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function _(e,i,n,r,a,s,o){!0===o?t.vertexAttribIPointer(e,i,n,a,s):t.vertexAttribPointer(e,i,n,r,a,s)}function y(){x(),c=!0,l!==h&&(l=h,d(l.object))}function x(){h.geometry=null,h.program=null,h.wireframe=!1}return{setup:function(r,h,u,y,x){let S=!1;if(s){const e=function(e,i,r){const s=!0===r.wireframe;let h=o[e.id];void 0===h&&(h={},o[e.id]=h);let l=h[i.id];void 0===l&&(l={},h[i.id]=l);let c=l[s];void 0===c&&(c=p(n.isWebGL2?t.createVertexArray():a.createVertexArrayOES()),l[s]=c);return c}(y,u,h);l!==e&&(l=e,d(l.object)),S=function(t,e,i,n){const r=l.attributes,a=e.attributes;let s=0;const o=i.getAttributes();for(const e in o){if(o[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;s++}}return l.attributesNum!==s||l.index!==n}(r,y,u,x),S&&function(t,e,i,n){const r={},a=e.attributes;let s=0;const o=i.getAttributes();for(const e in o){if(o[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,s++}}l.attributes=r,l.attributesNum=s,l.index=n}(r,y,u,x)}else{const t=!0===h.wireframe;l.geometry===y.id&&l.program===u.id&&l.wireframe===t||(l.geometry=y.id,l.program=u.id,l.wireframe=t,S=!0)}null!==x&&i.update(x,t.ELEMENT_ARRAY_BUFFER),(S||c)&&(c=!1,function(r,a,s,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;f();const h=o.attributes,l=s.getAttributes(),c=a.defaultAttributeValues;for(const e in l){const a=l[e];if(a.location>=0){let s=h[e];if(void 0===s&&("instanceMatrix"===e&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===e&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const e=s.normalized,h=s.itemSize,l=i.get(s);if(void 0===l)continue;const c=l.buffer,d=l.type,u=l.bytesPerElement,p=!0===n.isWebGL2&&(d===t.INT||d===t.UNSIGNED_INT||s.gpuType===at);if(s.isInterleavedBufferAttribute){const i=s.data,n=i.stride,l=s.offset;if(i.isInstancedInterleavedBuffer){for(let t=0;t<a.locationSize;t++)g(a.location+t,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let t=0;t<a.locationSize;t++)m(a.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<a.locationSize;t++)_(a.location+t,h/a.locationSize,d,e,n*u,(l+h/a.locationSize*t)*u,p)}else{if(s.isInstancedBufferAttribute){for(let t=0;t<a.locationSize;t++)g(a.location+t,s.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let t=0;t<a.locationSize;t++)m(a.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<a.locationSize;t++)_(a.location+t,h/a.locationSize,d,e,h*u,h/a.locationSize*t*u,p)}}else if(void 0!==c){const i=c[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(a.location,i);break;case 3:t.vertexAttrib3fv(a.location,i);break;case 4:t.vertexAttrib4fv(a.location,i);break;default:t.vertexAttrib1fv(a.location,i)}}}}v()}(r,h,u,y),null!==x&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){y();for(const t in o){const e=o[t];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete o[t]}},releaseStatesOfGeometry:function(t){if(void 0===o[t.id])return;const e=o[t.id];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete o[t.id]},releaseStatesOfProgram:function(t){for(const e in o){const i=o[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)u(n[t].object),delete n[t];delete i[t.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:v}}function rr(t,e,i,n){const r=n.isWebGL2;let a;this.setMode=function(t){a=t},this.render=function(e,n){t.drawArrays(a,e,n),i.update(n,a,1)},this.renderInstances=function(n,s,o){if(0===o)return;let h,l;if(r)h=t,l="drawArraysInstanced";else if(h=e.get("ANGLE_instanced_arrays"),l="drawArraysInstancedANGLE",null===h)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[l](a,n,s,o),i.update(s,a,o)}}function ar(t,e,i){let n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name;let s=void 0!==i.precision?i.precision:"highp";const o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const h=a||e.has("WEBGL_draw_buffers"),l=!0===i.logarithmicDepthBuffer,c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),f=t.getParameter(t.MAX_VERTEX_ATTRIBS),m=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),v=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),_=d>0,y=a||e.has("OES_texture_float");return{isWebGL2:a,drawBuffers:h,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:u,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:y,floatVertexTextures:_&&y,maxSamples:a?t.getParameter(t.MAX_SAMPLES):0}}function sr(t){const e=this;let i=null,n=0,r=!1,a=!1;const s=new Xn,o=new ie,h={value:null,needsUpdate:!1};function l(t,i,n,r){const a=null!==t?t.length:0;let l=null;if(0!==a){if(l=h.value,!0!==r||null===l){const e=n+4*a,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==a;++e,i+=4)s.copy(t[e]).applyMatrix4(r,o),s.normal.toArray(l,i),l[i+3]=s.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=a,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){a=!0,l(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(s,o,c){const d=s.clippingPlanes,u=s.clipIntersection,p=s.clipShadows,f=t.get(s);if(!r||null===d||0===d.length||a&&!p)a?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=a?0:n,e=4*t;let r=f.clippingState||null;h.value=r,r=l(d,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function or(t){let e=new WeakMap;function i(t,e){return 303===e?t.mapping=X:304===e&&(t.mapping=j),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const a=r.mapping;if(303===a||304===a){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const a=r.image;if(a&&a.height>0){const s=new Gn(a.height/2);return s.fromEquirectangularTexture(t,r),e.set(r,s),r.addEventListener("dispose",n),i(s.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class hr extends On{constructor(t=-1,e=1,i=1,n=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,a=i+t,s=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,a=r+t*this.view.width,s-=e*this.view.offsetY,o=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const lr=[.125,.215,.35,.446,.526,.582],cr=20,dr=new hr,ur=new Yi;let pr=null;const fr=(1+Math.sqrt(5))/2,mr=1/fr,gr=[new Ae(1,1,1),new Ae(-1,1,1),new Ae(1,1,-1),new Ae(-1,1,-1),new Ae(0,fr,mr),new Ae(0,fr,-mr),new Ae(mr,0,fr),new Ae(-mr,0,fr),new Ae(fr,mr,0),new Ae(-fr,mr,0)];class vr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){pr=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Sr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=xr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(pr),t.scissorTest=!1,yr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===X||t.mapping===j?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),pr=this._renderer.getRenderTarget();const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:tt,minFilter:tt,generateMipmaps:!1,type:ht,format:ct,colorSpace:wt,depthBuffer:!1},n=_r(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_r(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const a=t-4+1+lr.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);i.push(a);let o=1/a;s>t-4?o=lr[s-t+4-1]:0===s&&(o=0),n.push(o);const h=1/(a-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*u),_=new Float32Array(m*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,f*p*t),_.set(d,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new cn;x.setAttribute("position",new Qi(v,f)),x.setAttribute("uv",new Qi(_,m)),x.setAttribute("faceIndex",new Qi(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(cr),r=new Ae(0,1,0),a=new Nn({name:"SphericalGaussianBlur",defines:{n:cr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Mr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(n,t,e)}return n}_compileMaterial(t){const e=new Cn(this._lodPlanes[0],t);this._renderer.compile(e,dr)}_sceneToCubeUV(t,e,i,n){const r=new Fn(90,1,e,i),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,h=o.autoClear,l=o.toneMapping;o.getClearColor(ur),o.toneMapping=B,o.autoClear=!1;const c=new Ki({name:"PMREM.Background",side:x,depthWrite:!1,depthTest:!1}),d=new Cn(new Pn,c);let u=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,u=!0):(c.color.copy(ur),u=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,a[e],0),r.lookAt(s[e],0,0)):1===i?(r.up.set(0,0,a[e]),r.lookAt(0,s[e],0)):(r.up.set(0,a[e],0),r.lookAt(0,0,s[e]));const h=this._cubeSize;yr(n,i*h,e>2?h:0,h,h),o.setRenderTarget(n),u&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=l,o.autoClear=h,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===X||t.mapping===j;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Sr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=xr());const r=n?this._cubemapMaterial:this._equirectMaterial,a=new Cn(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const s=this._cubeSize;yr(e,0,0,3*s,2*s),i.setRenderTarget(e),i.render(a,dr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;e<this._lodPlanes.length;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),n=gr[(e-1)%gr.length];this._blur(t,e-1,e,i,n)}e.autoClear=i}_blur(t,e,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,i,n,"latitudinal",r),this._halfBlur(a,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,a,s){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new Cn(this._lodPlanes[n],h),c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,f=isFinite(r)?1+Math.floor(3*p):cr;f>cr&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<cr;++t){const e=t/p,i=Math.exp(-e*e/2);m.push(i),0===t?g+=i:t<f&&(g+=2*i)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===a,s&&(c.poleAxis.value=s);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const _=this._sizeLods[n];yr(e,3*_*(n>v-4?n-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(l,dr)}}function _r(t,e,i){const n=new be(t,e,i);return n.texture.mapping=Y,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function yr(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function xr(){return new Nn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Mr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Sr(){return new Nn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Mr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Mr(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function br(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===X||a===j;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let n=e.get(r);return null===i&&(i=new vr(t)),n=s?i.fromEquirectangular(r,n):i.fromCubemap(r,n),e.set(r,n),n.texture}if(e.has(r))return e.get(r).texture;{const a=r.image;if(s&&a&&a.height>0||o&&a&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(a)){null===i&&(i=new vr(t));const a=s?i.fromEquirectangular(r):i.fromCubemap(r);return e.set(r,a),r.addEventListener("dispose",n),a.texture}return null}}}return r},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function wr(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.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(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Er(t,e,i,n){const r={},a=new WeakMap;function s(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);for(const t in o.morphAttributes){const i=o.morphAttributes[t];for(let t=0,n=i.length;t<n;t++)e.remove(i[t])}o.removeEventListener("dispose",s),delete r[o.id];const h=a.get(o);h&&(e.remove(h),a.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let s=0;if(null!==n){const t=n.array;s=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],a=t[e+2];i.push(n,r,r,a,a,n)}}else{const t=r.array;s=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const o=new(re(i)?tn:$i)(i,1);o.version=s;const h=a.get(t);h&&e.remove(h),a.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER);const r=i.morphAttributes;for(const i in r){const n=r[i];for(let i=0,r=n.length;i<r;i++)e.update(n[i],t.ARRAY_BUFFER)}},getWireframeAttribute:function(t){const e=a.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return a.get(t)}}}function Tr(t,e,i,n){const r=n.isWebGL2;let a,s,o;this.setMode=function(t){a=t},this.setIndex=function(t){s=t.type,o=t.bytesPerElement},this.render=function(e,n){t.drawElements(a,n,s,e*o),i.update(n,a,1)},this.renderInstances=function(n,h,l){if(0===l)return;let c,d;if(r)c=t,d="drawElementsInstanced";else if(c=e.get("ANGLE_instanced_arrays"),d="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[d](a,h,s,n*o,l),i.update(h,a,l)}}function Ar(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Cr(t,e){return t[0]-e[0]}function Rr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Pr(t,e,i){const n={},r=new Float32Array(8),a=new WeakMap,s=new Me,o=[];for(let t=0;t<8;t++)o[t]=[t,0];return{update:function(h,l,c){const d=h.morphTargetInfluences;if(!0===e.isWebGL2){const u=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,p=void 0!==u?u.length:0;let f=a.get(l);if(void 0===f||f.count!==p){void 0!==f&&f.texture.dispose();const v=void 0!==l.morphAttributes.position,_=void 0!==l.morphAttributes.normal,y=void 0!==l.morphAttributes.color,x=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],M=l.morphAttributes.color||[];let b=0;!0===v&&(b=1),!0===_&&(b=2),!0===y&&(b=3);let w=l.attributes.position.count*b,E=1;w>e.maxTextureSize&&(E=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const T=new Float32Array(w*E*4*p),A=new we(T,w,E,p);A.type=ot,A.needsUpdate=!0;const C=4*b;for(let P=0;P<p;P++){const L=x[P],I=S[P],D=M[P],U=w*E*4*P;for(let N=0;N<L.count;N++){const O=N*C;!0===v&&(s.fromBufferAttribute(L,N),T[U+O+0]=s.x,T[U+O+1]=s.y,T[U+O+2]=s.z,T[U+O+3]=0),!0===_&&(s.fromBufferAttribute(I,N),T[U+O+4]=s.x,T[U+O+5]=s.y,T[U+O+6]=s.z,T[U+O+7]=0),!0===y&&(s.fromBufferAttribute(D,N),T[U+O+8]=s.x,T[U+O+9]=s.y,T[U+O+10]=s.z,T[U+O+11]=4===D.itemSize?s.w:1)}}function R(){A.dispose(),a.delete(l),l.removeEventListener("dispose",R)}f={count:p,texture:A,size:new ee(w,E)},a.set(l,f),l.addEventListener("dispose",R)}let m=0;for(let F=0;F<d.length;F++)m+=d[F];const g=l.morphTargetsRelative?1:1-m;c.getUniforms().setValue(t,"morphTargetBaseInfluence",g),c.getUniforms().setValue(t,"morphTargetInfluences",d),c.getUniforms().setValue(t,"morphTargetsTexture",f.texture,i),c.getUniforms().setValue(t,"morphTargetsTextureSize",f.size)}else{const k=void 0===d?0:d.length;let B=n[l.id];if(void 0===B||B.length!==k){B=[];for(let W=0;W<k;W++)B[W]=[W,0];n[l.id]=B}for(let X=0;X<k;X++){const j=B[X];j[0]=X,j[1]=d[X]}B.sort(Rr);for(let Y=0;Y<8;Y++)Y<k&&B[Y][1]?(o[Y][0]=B[Y][0],o[Y][1]=B[Y][1]):(o[Y][0]=Number.MAX_SAFE_INTEGER,o[Y][1]=0);o.sort(Cr);const z=l.morphAttributes.position,G=l.morphAttributes.normal;let H=0;for(let q=0;q<8;q++){const K=o[q],Z=K[0],J=K[1];Z!==Number.MAX_SAFE_INTEGER&&J?(z&&l.getAttribute("morphTarget"+q)!==z[Z]&&l.setAttribute("morphTarget"+q,z[Z]),G&&l.getAttribute("morphNormal"+q)!==G[Z]&&l.setAttribute("morphNormal"+q,G[Z]),r[q]=J,H+=J):(z&&!0===l.hasAttribute("morphTarget"+q)&&l.deleteAttribute("morphTarget"+q),G&&!0===l.hasAttribute("morphNormal"+q)&&l.deleteAttribute("morphNormal"+q),r[q]=0)}const V=l.morphTargetsRelative?1:1-H;c.getUniforms().setValue(t,"morphTargetBaseInfluence",V),c.getUniforms().setValue(t,"morphTargetInfluences",r)}}}}function Lr(t,e,i,n){let r=new WeakMap;function a(t){const e=t.target;e.removeEventListener("dispose",a),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(s){const o=n.render.frame,h=s.geometry,l=e.get(s,h);return r.get(l)!==o&&(e.update(l),r.set(l,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),i.update(s.instanceMatrix,t.ARRAY_BUFFER),null!==s.instanceColor&&i.update(s.instanceColor,t.ARRAY_BUFFER)),l},dispose:function(){r=new WeakMap}}}const Ir=new Se,Dr=new we,Ur=new Ee,Nr=new zn,Or=[],Fr=[],kr=new Float32Array(16),Br=new Float32Array(9),zr=new Float32Array(4);function Gr(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let a=Or[r];if(void 0===a&&(a=new Float32Array(r),Or[r]=a),0!==e){n.toArray(a,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(a,r)}return a}function Hr(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Vr(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Wr(t,e){let i=Fr[e];void 0===i&&(i=new Int32Array(e),Fr[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Xr(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function jr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Hr(i,e))return;t.uniform2fv(this.addr,e),Vr(i,e)}}function Yr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Hr(i,e))return;t.uniform3fv(this.addr,e),Vr(i,e)}}function qr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Hr(i,e))return;t.uniform4fv(this.addr,e),Vr(i,e)}}function Kr(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Hr(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Vr(i,e)}else{if(Hr(i,n))return;zr.set(n),t.uniformMatrix2fv(this.addr,!1,zr),Vr(i,n)}}function Zr(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Hr(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Vr(i,e)}else{if(Hr(i,n))return;Br.set(n),t.uniformMatrix3fv(this.addr,!1,Br),Vr(i,n)}}function Jr(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Hr(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Vr(i,e)}else{if(Hr(i,n))return;kr.set(n),t.uniformMatrix4fv(this.addr,!1,kr),Vr(i,n)}}function Qr(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function $r(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Hr(i,e))return;t.uniform2iv(this.addr,e),Vr(i,e)}}function ta(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Hr(i,e))return;t.uniform3iv(this.addr,e),Vr(i,e)}}function ea(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Hr(i,e))return;t.uniform4iv(this.addr,e),Vr(i,e)}}function ia(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function na(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Hr(i,e))return;t.uniform2uiv(this.addr,e),Vr(i,e)}}function ra(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Hr(i,e))return;t.uniform3uiv(this.addr,e),Vr(i,e)}}function aa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Hr(i,e))return;t.uniform4uiv(this.addr,e),Vr(i,e)}}function sa(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2D(e||Ir,r)}function oa(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Ur,r)}function ha(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Nr,r)}function la(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||Dr,r)}function ca(t,e){t.uniform1fv(this.addr,e)}function da(t,e){const i=Gr(e,this.size,2);t.uniform2fv(this.addr,i)}function ua(t,e){const i=Gr(e,this.size,3);t.uniform3fv(this.addr,i)}function pa(t,e){const i=Gr(e,this.size,4);t.uniform4fv(this.addr,i)}function fa(t,e){const i=Gr(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function ma(t,e){const i=Gr(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function ga(t,e){const i=Gr(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function va(t,e){t.uniform1iv(this.addr,e)}function _a(t,e){t.uniform2iv(this.addr,e)}function ya(t,e){t.uniform3iv(this.addr,e)}function xa(t,e){t.uniform4iv(this.addr,e)}function Sa(t,e){t.uniform1uiv(this.addr,e)}function Ma(t,e){t.uniform2uiv(this.addr,e)}function ba(t,e){t.uniform3uiv(this.addr,e)}function wa(t,e){t.uniform4uiv(this.addr,e)}function Ea(t,e,i){const n=this.cache,r=e.length,a=Wr(i,r);Hr(n,a)||(t.uniform1iv(this.addr,a),Vr(n,a));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||Ir,a[t])}function Ta(t,e,i){const n=this.cache,r=e.length,a=Wr(i,r);Hr(n,a)||(t.uniform1iv(this.addr,a),Vr(n,a));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||Ur,a[t])}function Aa(t,e,i){const n=this.cache,r=e.length,a=Wr(i,r);Hr(n,a)||(t.uniform1iv(this.addr,a),Vr(n,a));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Nr,a[t])}function Ca(t,e,i){const n=this.cache,r=e.length,a=Wr(i,r);Hr(n,a)||(t.uniform1iv(this.addr,a),Vr(n,a));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||Dr,a[t])}class Ra{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Xr;case 35664:return jr;case 35665:return Yr;case 35666:return qr;case 35674:return Kr;case 35675:return Zr;case 35676:return Jr;case 5124:case 35670:return Qr;case 35667:case 35671:return $r;case 35668:case 35672:return ta;case 35669:case 35673:return ea;case 5125:return ia;case 36294:return na;case 36295:return ra;case 36296:return aa;case 35678:case 36198:case 36298:case 36306:case 35682:return sa;case 35679:case 36299:case 36307:return oa;case 35680:case 36300:case 36308:case 36293:return ha;case 36289:case 36303:case 36311:case 36292:return la}}(e.type)}}class Pa{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return ca;case 35664:return da;case 35665:return ua;case 35666:return pa;case 35674:return fa;case 35675:return ma;case 35676:return ga;case 5124:case 35670:return va;case 35667:case 35671:return _a;case 35668:case 35672:return ya;case 35669:case 35673:return xa;case 5125:return Sa;case 36294:return Ma;case 36295:return ba;case 36296:return wa;case 35678:case 36198:case 36298:case 36306:case 35682:return Ea;case 35679:case 36299:case 36307:return Ta;case 35680:case 36300:case 36308:case 36293:return Aa;case 36289:case 36303:case 36311:case 36292:return Ca}}(e.type)}}class La{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,a=n.length;r!==a;++r){const a=n[r];a.setValue(t,e[a.id],i)}}}const Ia=/(\w+)(\])?(\[|\.)?/g;function Da(t,e){t.seq.push(e),t.map[e.id]=e}function Ua(t,e,i){const n=t.name,r=n.length;for(Ia.lastIndex=0;;){const a=Ia.exec(n),s=Ia.lastIndex;let o=a[1];const h="]"===a[2],l=a[3];if(h&&(o|=0),void 0===l||"["===l&&s+2===r){Da(i,void 0===l?new Ra(o,t,e):new Pa(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new La(o),Da(i,t)),i=t}}}class Na{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Ua(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,a=e.length;r!==a;++r){const a=e[r],s=i[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Oa(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Fa=0;function ka(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const n=parseInt(a[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),a=Math.min(e+6,i.length);for(let t=r;t<a;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function Ba(t,e){const i=function(t){switch(t){case wt:return["Linear","( value )"];case bt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),["Linear","( value )"]}}(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function za(t,e){let i;switch(e){case z:i="Linear";break;case G:i="Reinhard";break;case H:i="OptimizedCineon";break;case V:i="ACESFilmic";break;case W:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Ga(t){return""!==t}function Ha(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Va(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Wa=/^[ \t]*#include +<([\w\d./]+)>/gm;function Xa(t){return t.replace(Wa,ja)}function ja(t,e){const i=Qn[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return Xa(i)}const Ya=/#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 qa(t){return t.replace(Ya,Ka)}function Ka(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Za(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Ja(t,e,i,n){const r=t.getContext(),a=i.defines;let s=i.vertexShader,o=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===g?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===v?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===_&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case X:case j:e="ENVMAP_TYPE_CUBE";break;case Y:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===j&&(e="ENVMAP_MODE_REFRACTION");return e}(i),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case O:e="ENVMAP_BLENDING_MULTIPLY";break;case F:e="ENVMAP_BLENDING_MIX";break;case k:e="ENVMAP_BLENDING_ADD"}return e}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ga).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(a),m=r.createProgram();let y,x,S=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(y=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(Ga).join("\n"),y.length>0&&(y+="\n"),x=[p,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(Ga).join("\n"),x.length>0&&(x+="\n")):(y=[Za(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,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 "+c:"",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.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.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?"#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 "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ga).join("\n"),x=[p,Za(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,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 "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.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.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?"#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 "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==B?"#define TONE_MAPPING":"",i.toneMapping!==B?Qn.tonemapping_pars_fragment:"",i.toneMapping!==B?za("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Qn.encodings_pars_fragment,Ba("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Ga).join("\n")),s=Xa(s),s=Ha(s,i),s=Va(s,i),o=Xa(o),o=Ha(o,i),o=Va(o,i),s=qa(s),o=qa(o),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(S="#version 300 es\n",y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,x=["#define varying in",i.glslVersion===Ot?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ot?"":"#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"+x);const M=S+y+s,b=S+x+o,w=Oa(r,r.VERTEX_SHADER,M),E=Oa(r,r.FRAGMENT_SHADER,b);if(r.attachShader(m,w),r.attachShader(m,E),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),t.debug.checkShaderErrors){const e=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(w).trim(),n=r.getShaderInfoLog(E).trim();let a=!0,s=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,w,E);else{const t=ka(r,w,"vertex"),i=ka(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==i&&""!==n||(s=!1);s&&(this.diagnostics={runnable:a,programLog:e,vertexShader:{log:i,prefix:y},fragmentShader:{log:n,prefix:x}})}let T,A;return r.deleteShader(w),r.deleteShader(E),this.getUniforms=function(){return void 0===T&&(T=new Na(r,m)),T},this.getAttributes=function(){return void 0===A&&(A=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),a=n.name;let s=1;n.type===t.FLOAT_MAT2&&(s=2),n.type===t.FLOAT_MAT3&&(s=3),n.type===t.FLOAT_MAT4&&(s=4),i[a]={type:n.type,location:t.getAttribLocation(e,a),locationSize:s}}return i}(r,m)),A},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Fa++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=E,this}let Qa=0;class $a{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(t);return!1===a.has(n)&&(a.add(n),n.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new ts(t),e.set(t,i)),i}}class ts{constructor(t){this.id=Qa++,this.code=t,this.usedTimes=0}}function es(t,e,i,n,r,a,s){const o=new fi,h=new $a,l=[],c=r.isWebGL2,d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(t){return 0===t?"uv":`uv${t}`}return{getParameters:function(a,o,l,g,v){const _=g.fog,y=v.geometry,S=a.isMeshStandardMaterial?g.environment:null,M=(a.isMeshStandardMaterial?i:e).get(a.envMap||S),b=M&&M.mapping===Y?M.image.height:null,w=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));const E=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==E?E.length:0;let A,C,R,P,L=0;if(void 0!==y.morphAttributes.position&&(L=1),void 0!==y.morphAttributes.normal&&(L=2),void 0!==y.morphAttributes.color&&(L=3),w){const t=tr[w];A=t.vertexShader,C=t.fragmentShader}else A=a.vertexShader,C=a.fragmentShader,h.update(a),R=h.getVertexShaderID(a),P=h.getFragmentShaderID(a);const I=t.getRenderTarget(),D=!0===v.isInstancedMesh,U=!!a.map,N=!!a.matcap,O=!!M,F=!!a.aoMap,k=!!a.lightMap,z=!!a.bumpMap,G=!!a.normalMap,H=!!a.displacementMap,V=!!a.emissiveMap,W=!!a.metalnessMap,X=!!a.roughnessMap,j=a.anisotropy>0,q=a.clearcoat>0,K=a.iridescence>0,Z=a.sheen>0,J=a.transmission>0,Q=j&&!!a.anisotropyMap,$=q&&!!a.clearcoatMap,tt=q&&!!a.clearcoatNormalMap,et=q&&!!a.clearcoatRoughnessMap,it=K&&!!a.iridescenceMap,nt=K&&!!a.iridescenceThicknessMap,rt=Z&&!!a.sheenColorMap,at=Z&&!!a.sheenRoughnessMap,st=!!a.specularMap,ot=!!a.specularColorMap,ht=!!a.specularIntensityMap,lt=J&&!!a.transmissionMap,ct=J&&!!a.thicknessMap,dt=!!a.gradientMap,ut=!!a.alphaMap,pt=a.alphaTest>0,ft=!!a.extensions,mt=!!y.attributes.uv1,gt=!!y.attributes.uv2,vt=!!y.attributes.uv3;return{isWebGL2:c,shaderID:w,shaderType:a.type,shaderName:a.name,vertexShader:A,fragmentShader:C,defines:a.defines,customVertexShaderID:R,customFragmentShaderID:P,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:D,instancingColor:D&&null!==v.instanceColor,supportsVertexTextures:u,outputColorSpace:null===I?t.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:wt,map:U,matcap:N,envMap:O,envMapMode:O&&M.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:k,bumpMap:z,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===a.normalMapType,normalMapTangentSpace:G&&0===a.normalMapType,metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:Q,clearcoat:q,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,iridescence:K,iridescenceMap:it,iridescenceThicknessMap:nt,sheen:Z,sheenColorMap:rt,sheenRoughnessMap:at,specularMap:st,specularColorMap:ot,specularIntensityMap:ht,transmission:J,transmissionMap:lt,thicknessMap:ct,gradientMap:dt,opaque:!1===a.transparent&&1===a.blending,alphaMap:ut,alphaTest:pt,combine:a.combine,mapUv:U&&m(a.map.channel),aoMapUv:F&&m(a.aoMap.channel),lightMapUv:k&&m(a.lightMap.channel),bumpMapUv:z&&m(a.bumpMap.channel),normalMapUv:G&&m(a.normalMap.channel),displacementMapUv:H&&m(a.displacementMap.channel),emissiveMapUv:V&&m(a.emissiveMap.channel),metalnessMapUv:W&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:Q&&m(a.anisotropyMap.channel),clearcoatMapUv:$&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:nt&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:at&&m(a.sheenRoughnessMap.channel),specularMapUv:st&&m(a.specularMap.channel),specularColorMapUv:ot&&m(a.specularColorMap.channel),specularIntensityMapUv:ht&&m(a.specularIntensityMap.channel),transmissionMapUv:lt&&m(a.transmissionMap.channel),thicknessMapUv:ct&&m(a.thicknessMap.channel),alphaMapUv:ut&&m(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(G||j),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUv1s:mt,vertexUv2s:gt,vertexUv3s:vt,pointsUvs:!0===v.isPoints&&!!y.attributes.uv&&(U||ut),fog:!!_,useFog:!0===a.fog,fogExp2:_&&_.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:t.shadowMap.enabled&&l.length>0,shadowMapType:t.shadowMap.type,toneMapping:a.toneMapped?t.toneMapping:B,useLegacyLights:t.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:a.side===x,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ft&&!0===a.extensions.derivatives,extensionFragDepth:ft&&!0===a.extensions.fragDepth,extensionDrawBuffers:ft&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ft&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.isWebGL2&&o.enable(0);e.supportsVertexTextures&&o.enable(1);e.instancing&&o.enable(2);e.instancingColor&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.skinning&&o.enable(4);e.morphTargets&&o.enable(5);e.morphNormals&&o.enable(6);e.morphColors&&o.enable(7);e.premultipliedAlpha&&o.enable(8);e.shadowMapEnabled&&o.enable(9);e.useLegacyLights&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=f[t.type];let i;if(e){const t=tr[e];i=Un.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new Ja(t,i,e,a),l.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=l.indexOf(t);l[e]=l[l.length-1],l.pop(),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:l,dispose:function(){h.dispose()}}}function is(){let t=new WeakMap;return{get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function ns(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function rs(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function as(){const t=[];let e=0;const i=[],n=[],r=[];function a(i,n,r,a,s,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,groupOrder:a,renderOrder:i.renderOrder,z:s,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.groupOrder=a,h.renderOrder=i.renderOrder,h.z=s,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,s,o,h,l){const c=a(t,e,s,o,h,l);s.transmission>0?n.push(c):!0===s.transparent?r.push(c):i.push(c)},unshift:function(t,e,s,o,h,l){const c=a(t,e,s,o,h,l);s.transmission>0?n.unshift(c):!0===s.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||ns),n.length>1&&n.sort(e||rs),r.length>1&&r.sort(e||rs)}}}function ss(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new as,t.set(e,[r])):i>=n.length?(r=new as,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function os(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ae,color:new Yi};break;case"SpotLight":i={position:new Ae,direction:new Ae,color:new Yi,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ae,color:new Yi,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ae,skyColor:new Yi,groundColor:new Yi};break;case"RectAreaLight":i={color:new Yi,position:new Ae,halfWidth:new Ae,halfHeight:new Ae}}return t[e.id]=i,i}}}let hs=0;function ls(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function cs(t,e){const i=new os,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let t=0;t<9;t++)r.probe.push(new Ae);const a=new Ae,s=new ni,o=new ni;return{setup:function(a,s){let o=0,h=0,l=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let c=0,d=0,u=0,p=0,f=0,m=0,g=0,v=0,_=0,y=0;a.sort(ls);const x=!0===s?Math.PI:1;for(let t=0,e=a.length;t<e;t++){const e=a[t],s=e.color,S=e.intensity,M=e.distance,b=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=s.r*S*x,h+=s.g*S*x,l+=s.b*S*x;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],S);else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*x),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.directionalShadow[c]=i,r.directionalShadowMap[c]=b,r.directionalShadowMatrix[c]=e.shadow.matrix,m++}r.directional[c]=t,c++}else if(e.isSpotLight){const t=i.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(s).multiplyScalar(S*x),t.distance=M,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,r.spot[u]=t;const a=e.shadow;if(e.map&&(r.spotLightMap[_]=e.map,_++,a.updateMatrices(e),e.castShadow&&y++),r.spotLightMatrix[u]=a.matrix,e.castShadow){const t=n.get(e);t.shadowBias=a.bias,t.shadowNormalBias=a.normalBias,t.shadowRadius=a.radius,t.shadowMapSize=a.mapSize,r.spotShadow[u]=t,r.spotShadowMap[u]=b,v++}u++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(s).multiplyScalar(S),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[p]=t,p++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*x),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,r.pointShadow[d]=i,r.pointShadowMap[d]=b,r.pointShadowMatrix[d]=e.shadow.matrix,g++}r.point[d]=t,d++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(S*x),t.groundColor.copy(e.groundColor).multiplyScalar(S*x),r.hemi[f]=t,f++}}p>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=$n.LTC_FLOAT_1,r.rectAreaLTC2=$n.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=$n.LTC_HALF_1,r.rectAreaLTC2=$n.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=h,r.ambient[2]=l;const S=r.hash;S.directionalLength===c&&S.pointLength===d&&S.spotLength===u&&S.rectAreaLength===p&&S.hemiLength===f&&S.numDirectionalShadows===m&&S.numPointShadows===g&&S.numSpotShadows===v&&S.numSpotMaps===_||(r.directional.length=c,r.spot.length=u,r.rectArea.length=p,r.point.length=d,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+_-y,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=y,S.directionalLength=c,S.pointLength=d,S.spotLength=u,S.rectAreaLength=p,S.hemiLength=f,S.numDirectionalShadows=m,S.numPointShadows=g,S.numSpotShadows=v,S.numSpotMaps=_,r.version=hs++)},setupView:function(t,e){let i=0,n=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=r.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),a.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(a),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=r.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),a.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(a),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=r.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o.identity(),s.copy(u.matrixWorld),s.premultiply(d),o.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(o),t.halfHeight.applyMatrix4(o),l++}else if(u.isPointLight){const t=r.point[n];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),n++}else if(u.isHemisphereLight){const t=r.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:r}}function ds(t,e){const i=new cs(t,e),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(t){i.setup(n,t)},setupLightsView:function(t){i.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){r.push(t)}}}function us(t,e){let i=new WeakMap;return{get:function(n,r=0){const a=i.get(n);let s;return void 0===a?(s=new ds(t,e),i.set(n,[s])):r>=a.length?(s=new ds(t,e),a.push(s)):s=a[r],s},dispose:function(){i=new WeakMap}}}class ps extends Hi{constructor(t){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(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class fs extends Hi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function ms(t,e,i){let n=new qn;const r=new ee,a=new ee,s=new Me,o=new ps({depthPacking:3201}),h=new fs,l={},c=i.maxTextureSize,d={[y]:x,[x]:y,[S]:2},u=new Nn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ee},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const f=new cn;f.setAttribute("position",new Qi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Cn(f,u),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=g;let M=this.type;function b(i,n){const a=e.update(m);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new be(r.x,r.y)),u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,a,u,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,a,p,m,null)}function w(e,i,n,r){let a=null;const s=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===n.isPointLight?h:o,t.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){const t=a.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let r=n[e];void 0===r&&(r=a.clone(),n[e]=r),a=r}if(a.visible=i.visible,a.wireframe=i.wireframe,a.side=r===_?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],a.alphaMap=i.alphaMap,a.alphaTest=i.alphaTest,a.map=i.map,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.clipIntersection=i.clipIntersection,a.displacementMap=i.displacementMap,a.displacementScale=i.displacementScale,a.displacementBias=i.displacementBias,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,!0===n.isPointLight&&!0===a.isMeshDistanceMaterial){t.properties.get(a).light=n}return a}function E(i,r,a,s,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&o===_)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let h=0,l=e.length;h<l;h++){const l=e[h],c=r[l.materialIndex];if(c&&c.visible){const e=w(i,c,s,o);t.renderBufferDirect(a,null,n,e,i,l)}}}else if(r.visible){const e=w(i,r,s,o);t.renderBufferDirect(a,null,n,e,i,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)E(h[t],r,a,s,o)}this.render=function(e,i,o){if(!1===v.enabled)return;if(!1===v.autoUpdate&&!1===v.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=M!==_&&this.type===_,f=M===_&&this.type!==_;for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),a.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/m.y),r.y=a.y*m.y,d.mapSize.y=a.y)),null===d.map||!0===p||!0===f){const t=this.type!==_?{minFilter:J,magFilter:J}:{};null!==d.map&&d.map.dispose(),d.map=new be(r.x,r.y,t),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);s.set(a.x*e.x,a.y*e.y,a.x*e.z,a.y*e.w),u.viewport(s),d.updateMatrices(l,t),n=d.getFrustum(),E(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&this.type===_&&b(d,o),d.needsUpdate=!1}M=this.type,v.needsUpdate=!1,t.setRenderTarget(h,l,d)}}function gs(t,e,i){const n=i.isWebGL2;const r=new function(){let e=!1;const i=new Me;let n=null;const r=new Me(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,a,s,o){!0===o&&(e*=s,n*=s,a*=s),i.set(e,n,a,s),!1===r.equals(i)&&(t.clearColor(e,n,a,s),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},a=new function(){let e=!1,i=null,n=null,r=null;return{setTest:function(e){e?et(t.DEPTH_TEST):it(t.DEPTH_TEST)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},s=new function(){let e=!1,i=null,n=null,r=null,a=null,s=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?et(t.STENCIL_TEST):it(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,s){n===e&&r===i&&a===s||(t.stencilFunc(e,i,s),n=e,r=i,a=s)},setOp:function(e,i,n){s===e&&o===i&&h===n||(t.stencilOp(e,i,n),s=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,a=null,s=null,o=null,h=null,l=null}}},o=new WeakMap,h=new WeakMap;let l={},c={},d=new WeakMap,u=[],p=null,f=!1,m=null,g=null,v=null,_=null,y=null,S=null,O=null,F=!1,k=null,B=null,z=null,G=null,H=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,X=0;const j=t.getParameter(t.VERSION);-1!==j.indexOf("WebGL")?(X=parseFloat(/^WebGL (\d)/.exec(j)[1]),W=X>=1):-1!==j.indexOf("OpenGL ES")&&(X=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),W=X>=2);let Y=null,q={};const K=t.getParameter(t.SCISSOR_BOX),Z=t.getParameter(t.VIEWPORT),J=(new Me).fromArray(K),Q=(new Me).fromArray(Z);function $(e,i,r,a){const s=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let o=0;o<r;o++)!n||e!==t.TEXTURE_3D&&e!==t.TEXTURE_2D_ARRAY?t.texImage2D(i+o,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage3D(i,0,t.RGBA,1,1,a,0,t.RGBA,t.UNSIGNED_BYTE,s);return o}const tt={};function et(e){!0!==l[e]&&(t.enable(e),l[e]=!0)}function it(e){!1!==l[e]&&(t.disable(e),l[e]=!1)}tt[t.TEXTURE_2D]=$(t.TEXTURE_2D,t.TEXTURE_2D,1),tt[t.TEXTURE_CUBE_MAP]=$(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(tt[t.TEXTURE_2D_ARRAY]=$(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),tt[t.TEXTURE_3D]=$(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),r.setClear(0,0,0,1),a.setClear(1),s.setClear(0),et(t.DEPTH_TEST),a.setFunc(3),st(!1),ot(1),et(t.CULL_FACE),at(0);const nt={[M]:t.FUNC_ADD,[b]:t.FUNC_SUBTRACT,[w]:t.FUNC_REVERSE_SUBTRACT};if(n)nt[103]=t.MIN,nt[104]=t.MAX;else{const t=e.get("EXT_blend_minmax");null!==t&&(nt[103]=t.MIN_EXT,nt[104]=t.MAX_EXT)}const rt={[E]:t.ZERO,[T]:t.ONE,[A]:t.SRC_COLOR,[R]:t.SRC_ALPHA,[N]:t.SRC_ALPHA_SATURATE,[D]:t.DST_COLOR,[L]:t.DST_ALPHA,[C]:t.ONE_MINUS_SRC_COLOR,[P]:t.ONE_MINUS_SRC_ALPHA,[U]:t.ONE_MINUS_DST_COLOR,[I]:t.ONE_MINUS_DST_ALPHA};function at(e,i,n,r,a,s,o,h){if(0!==e){if(!1===f&&(et(t.BLEND),f=!0),5===e)a=a||i,s=s||n,o=o||r,i===g&&a===y||(t.blendEquationSeparate(nt[i],nt[a]),g=i,y=a),n===v&&r===_&&s===S&&o===O||(t.blendFuncSeparate(rt[n],rt[r],rt[s],rt[o]),v=n,_=r,S=s,O=o),m=e,F=!1;else if(e!==m||h!==F){if(g===M&&y===M||(t.blendEquation(t.FUNC_ADD),g=M,y=M),h)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}v=null,_=null,S=null,O=null,m=e,F=h}}else!0===f&&(it(t.BLEND),f=!1)}function st(e){k!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),k=e)}function ot(e){0!==e?(et(t.CULL_FACE),e!==B&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):it(t.CULL_FACE),B=e}function ht(e,i,n){e?(et(t.POLYGON_OFFSET_FILL),G===i&&H===n||(t.polygonOffset(i,n),G=i,H=n)):it(t.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:a,stencil:s},enable:et,disable:it,bindFramebuffer:function(e,i){return c[e]!==i&&(t.bindFramebuffer(e,i),c[e]=i,n&&(e===t.DRAW_FRAMEBUFFER&&(c[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(c[t.DRAW_FRAMEBUFFER]=i)),!0)},drawBuffers:function(n,r){let a=u,s=!1;if(n)if(a=d.get(r),void 0===a&&(a=[],d.set(r,a)),n.isWebGLMultipleRenderTargets){const e=n.texture;if(a.length!==e.length||a[0]!==t.COLOR_ATTACHMENT0){for(let i=0,n=e.length;i<n;i++)a[i]=t.COLOR_ATTACHMENT0+i;a.length=e.length,s=!0}}else a[0]!==t.COLOR_ATTACHMENT0&&(a[0]=t.COLOR_ATTACHMENT0,s=!0);else a[0]!==t.BACK&&(a[0]=t.BACK,s=!0);s&&(i.isWebGL2?t.drawBuffers(a):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(e){return p!==e&&(t.useProgram(e),p=e,!0)},setBlending:at,setMaterial:function(e,i){2===e.side?it(t.CULL_FACE):et(t.CULL_FACE);let n=e.side===x;i&&(n=!n),st(n),1===e.blending&&!1===e.transparent?at(0):at(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),a.setFunc(e.depthFunc),a.setTest(e.depthTest),a.setMask(e.depthWrite),r.setMask(e.colorWrite);const o=e.stencilWrite;s.setTest(o),o&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),ht(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?et(t.SAMPLE_ALPHA_TO_COVERAGE):it(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:st,setCullFace:ot,setLineWidth:function(e){e!==z&&(W&&t.lineWidth(e),z=e)},setPolygonOffset:ht,setScissorTest:function(e){e?et(t.SCISSOR_TEST):it(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+V-1),Y!==e&&(t.activeTexture(e),Y=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===Y?t.TEXTURE0+V-1:Y);let r=q[n];void 0===r&&(r={type:void 0,texture:void 0},q[n]=r),r.type===e&&r.texture===i||(Y!==n&&(t.activeTexture(n),Y=n),t.bindTexture(e,i||tt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=q[Y];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=h.get(i);void 0===n&&(n=new WeakMap,h.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=h.get(i).get(e);o.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),o.set(i,n))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===J.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),J.copy(e))},viewport:function(e){!1===Q.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),Q.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),!0===n&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),l={},Y=null,q={},c={},d=new WeakMap,u=[],p=null,f=!1,m=null,g=null,v=null,_=null,y=null,S=null,O=null,F=!1,k=null,B=null,z=null,G=null,H=null,J.set(0,0,t.canvas.width,t.canvas.height),Q.set(0,0,t.canvas.width,t.canvas.height),r.reset(),a.reset(),s.reset()}}}function vs(t,e,i,n,r,a,s){const o=r.isWebGL2,h=r.maxTextures,l=r.maxCubemapSize,c=r.maxTextureSize,d=r.maxSamples,u=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap;let m;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function _(t,e){return v?new OffscreenCanvas(t,e):ae("canvas")}function y(t,e,i,n){let r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?Jt:Math.floor,a=n(r*t.width),s=n(r*t.height);void 0===m&&(m=_(a,s));const o=i?_(a,s):m;o.width=a,o.height=s;return o.getContext("2d").drawImage(t,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+a+"x"+s+")."),o}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function x(t){return Kt(t.width)&&Kt(t.height)}function S(t,e){return t.generateMipmaps&&e&&t.minFilter!==J&&t.minFilter!==tt}function M(e){t.generateMipmap(e)}function b(i,n,r,a,s=!1){if(!1===o)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let h=n;return n===t.RED&&(r===t.FLOAT&&(h=t.R32F),r===t.HALF_FLOAT&&(h=t.R16F),r===t.UNSIGNED_BYTE&&(h=t.R8)),n===t.RG&&(r===t.FLOAT&&(h=t.RG32F),r===t.HALF_FLOAT&&(h=t.RG16F),r===t.UNSIGNED_BYTE&&(h=t.RG8)),n===t.RGBA&&(r===t.FLOAT&&(h=t.RGBA32F),r===t.HALF_FLOAT&&(h=t.RGBA16F),r===t.UNSIGNED_BYTE&&(h=a===bt&&!1===s?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(h=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(h=t.RGB5_A1)),h!==t.R16F&&h!==t.R32F&&h!==t.RG16F&&h!==t.RG32F&&h!==t.RGBA16F&&h!==t.RGBA32F||e.get("EXT_color_buffer_float"),h}function w(t,e,i){return!0===S(t,i)||t.isFramebufferTexture&&t.minFilter!==J&&t.minFilter!==tt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function E(e){return e===J||e===Q||e===$?t.NEAREST:t.LINEAR}function T(t){const e=t.target;e.removeEventListener("dispose",T),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=g.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&C(t),0===Object.keys(r).length&&g.delete(i)}n.remove(t)}(e),e.isVideoTexture&&f.delete(e)}function A(e){const i=e.target;i.removeEventListener("dispose",A),function(e){const i=e.texture,r=n.get(e),a=n.get(i);void 0!==a.__webglTexture&&(t.deleteTexture(a.__webglTexture),s.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e]);else{if(t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let e=0;e<r.__webglColorRenderbuffer.length;e++)r.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(r.__webglColorRenderbuffer[e]);r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let e=0,r=i.length;e<r;e++){const r=n.get(i[e]);r.__webglTexture&&(t.deleteTexture(r.__webglTexture),s.memory.textures--),n.remove(i[e])}n.remove(i),n.remove(e)}(i)}function C(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete g.get(r)[i.__cacheKey],s.memory.textures--}let R=0;function P(e,r){const a=n.get(e);if(e.isVideoTexture&&function(t){const e=s.render.frame;f.get(t)!==e&&(f.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&a.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void O(a,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(t.TEXTURE_2D,a.__webglTexture,t.TEXTURE0+r)}const L={[q]:t.REPEAT,[K]:t.CLAMP_TO_EDGE,[Z]:t.MIRRORED_REPEAT},I={[J]:t.NEAREST,[Q]:t.NEAREST_MIPMAP_NEAREST,[$]:t.NEAREST_MIPMAP_LINEAR,[tt]:t.LINEAR,[et]:t.LINEAR_MIPMAP_NEAREST,[it]:t.LINEAR_MIPMAP_LINEAR},D={[At]:t.NEVER,[Ut]:t.ALWAYS,[Ct]:t.LESS,[Pt]:t.LEQUAL,[Rt]:t.EQUAL,[Dt]:t.GEQUAL,[Lt]:t.GREATER,[It]:t.NOTEQUAL};function U(i,a,s){if(s?(t.texParameteri(i,t.TEXTURE_WRAP_S,L[a.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,L[a.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,L[a.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,I[a.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,I[a.minFilter])):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),a.wrapS===K&&a.wrapT===K||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,t.TEXTURE_MAG_FILTER,E(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==J&&a.minFilter!==tt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,D[a.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){const s=e.get("EXT_texture_filter_anisotropic");if(a.magFilter===J)return;if(a.minFilter!==$&&a.minFilter!==it)return;if(a.type===ot&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&a.type===ht&&!1===e.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(t.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function N(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",T));const r=i.source;let a=g.get(r);void 0===a&&(a={},g.set(r,a));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===a[o]&&(a[o]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,n=!0),a[o].usedTimes++;const r=a[e.__cacheKey];void 0!==r&&(a[e.__cacheKey].usedTimes--,0===r.usedTimes&&C(i)),e.__cacheKey=o,e.__webglTexture=a[o].texture}return n}function O(e,r,s){let h=t.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),r.isData3DTexture&&(h=t.TEXTURE_3D);const l=N(e,r),d=r.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+s);const u=n.get(d);if(d.version!==u.__version||!0===l){i.activeTexture(t.TEXTURE0+s),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE);const e=function(t){return!o&&(t.wrapS!==K||t.wrapT!==K||t.minFilter!==J&&t.minFilter!==tt)}(r)&&!1===x(r.image);let n=y(r.image,e,!1,c);n=H(r,n);const p=x(n)||o,f=a.convert(r.format,r.colorSpace);let m,g=a.convert(r.type),v=b(r.internalFormat,f,g,r.colorSpace);U(h,r,p);const _=r.mipmaps,E=o&&!0!==r.isVideoTexture,T=void 0===u.__version||!0===l,A=w(r,n,p);if(r.isDepthTexture)v=t.DEPTH_COMPONENT,o?v=r.type===ot?t.DEPTH_COMPONENT32F:r.type===st?t.DEPTH_COMPONENT24:r.type===lt?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:r.type===ot&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===dt&&v===t.DEPTH_COMPONENT&&r.type!==rt&&r.type!==st&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=st,g=a.convert(r.type)),r.format===ut&&v===t.DEPTH_COMPONENT&&(v=t.DEPTH_STENCIL,r.type!==lt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=lt,g=a.convert(r.type))),T&&(E?i.texStorage2D(t.TEXTURE_2D,1,v,n.width,n.height):i.texImage2D(t.TEXTURE_2D,0,v,n.width,n.height,0,f,g,null));else if(r.isDataTexture)if(_.length>0&&p){E&&T&&i.texStorage2D(t.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let e=0,n=_.length;e<n;e++)m=_[e],E?i.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,f,g,m.data):i.texImage2D(t.TEXTURE_2D,e,v,m.width,m.height,0,f,g,m.data);r.generateMipmaps=!1}else E?(T&&i.texStorage2D(t.TEXTURE_2D,A,v,n.width,n.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,f,g,n.data)):i.texImage2D(t.TEXTURE_2D,0,v,n.width,n.height,0,f,g,n.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){E&&T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,A,v,_[0].width,_[0].height,n.depth);for(let e=0,a=_.length;e<a;e++)m=_[e],r.format!==ct?null!==f?E?i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,m.width,m.height,n.depth,f,m.data,0,0):i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,v,m.width,m.height,n.depth,0,m.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,m.width,m.height,n.depth,f,g,m.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,v,m.width,m.height,n.depth,0,f,g,m.data)}else{E&&T&&i.texStorage2D(t.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let e=0,n=_.length;e<n;e++)m=_[e],r.format!==ct?null!==f?E?i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,f,m.data):i.compressedTexImage2D(t.TEXTURE_2D,e,v,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?i.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,f,g,m.data):i.texImage2D(t.TEXTURE_2D,e,v,m.width,m.height,0,f,g,m.data)}else if(r.isDataArrayTexture)E?(T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,A,v,n.width,n.height,n.depth),i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,n.width,n.height,n.depth,f,g,n.data)):i.texImage3D(t.TEXTURE_2D_ARRAY,0,v,n.width,n.height,n.depth,0,f,g,n.data);else if(r.isData3DTexture)E?(T&&i.texStorage3D(t.TEXTURE_3D,A,v,n.width,n.height,n.depth),i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,n.width,n.height,n.depth,f,g,n.data)):i.texImage3D(t.TEXTURE_3D,0,v,n.width,n.height,n.depth,0,f,g,n.data);else if(r.isFramebufferTexture){if(T)if(E)i.texStorage2D(t.TEXTURE_2D,A,v,n.width,n.height);else{let e=n.width,r=n.height;for(let n=0;n<A;n++)i.texImage2D(t.TEXTURE_2D,n,v,e,r,0,f,g,null),e>>=1,r>>=1}}else if(_.length>0&&p){E&&T&&i.texStorage2D(t.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let e=0,n=_.length;e<n;e++)m=_[e],E?i.texSubImage2D(t.TEXTURE_2D,e,0,0,f,g,m):i.texImage2D(t.TEXTURE_2D,e,v,f,g,m);r.generateMipmaps=!1}else E?(T&&i.texStorage2D(t.TEXTURE_2D,A,v,n.width,n.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,f,g,n)):i.texImage2D(t.TEXTURE_2D,0,v,f,g,n);S(r,p)&&M(h),u.__version=d.version,r.onUpdate&&r.onUpdate(r)}e.__version=r.version}function F(e,r,s,o,h){const l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),d=b(s.internalFormat,l,c,s.colorSpace);n.get(r).__hasExternalTextures||(h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?i.texImage3D(h,0,d,r.width,r.height,r.depth,0,l,c,null):i.texImage2D(h,0,d,r.width,r.height,0,l,c,null)),i.bindFramebuffer(t.FRAMEBUFFER,e),G(r)?u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,h,n.get(s).__webglTexture,0,z(r)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,o,h,n.get(s).__webglTexture,0),i.bindFramebuffer(t.FRAMEBUFFER,null)}function k(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer){let r=t.DEPTH_COMPONENT16;if(n||G(i)){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===ot?r=t.DEPTH_COMPONENT32F:e.type===st&&(r=t.DEPTH_COMPONENT24));const n=z(i);G(i)?u.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,n,r,i.width,i.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,n,r,i.width,i.height)}else t.renderbufferStorage(t.RENDERBUFFER,r,i.width,i.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)}else if(i.depthBuffer&&i.stencilBuffer){const r=z(i);n&&!1===G(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,i.width,i.height):G(i)?u.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)}else{const e=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let r=0;r<e.length;r++){const s=e[r],o=a.convert(s.format,s.colorSpace),h=a.convert(s.type),l=b(s.internalFormat,o,h,s.colorSpace),c=z(i);n&&!1===G(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,i.width,i.height):G(i)?u.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,l,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,l,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function B(e){const r=n.get(e),a=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),P(r.depthTexture,0);const a=n.get(r.depthTexture).__webglTexture,s=z(r);if(r.depthTexture.format===dt)G(r)?u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,s):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ut)throw new Error("Unknown depthTexture format");G(r)?u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,s):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(a){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=t.createRenderbuffer(),k(r.__webglDepthbuffer[n],e,!1)}else i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),k(r.__webglDepthbuffer,e,!1);i.bindFramebuffer(t.FRAMEBUFFER,null)}function z(t){return Math.min(d,t.samples)}function G(t){const i=n.get(t);return o&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,i){const n=t.colorSpace,r=t.format,a=t.type;return!0===t.isCompressedTexture||t.format===Ft||n!==wt&&n!==Mt&&(n===bt?!1===o?!0===e.has("EXT_sRGB")&&r===ct?(t.format=Ft,t.minFilter=tt,t.generateMipmaps=!1):i=ge.sRGBToLinear(i):r===ct&&a===nt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),i}this.allocateTextureUnit=function(){const t=R;return t>=h&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+h),R+=1,t},this.resetTextureUnits=function(){R=0},this.setTexture2D=P,this.setTexture2DArray=function(e,r){const a=n.get(e);e.version>0&&a.__version!==e.version?O(a,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,a.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const a=n.get(e);e.version>0&&a.__version!==e.version?O(a,e,r):i.bindTexture(t.TEXTURE_3D,a.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?function(e,r,s){if(6!==r.image.length)return;const h=N(e,r),c=r.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+s);const d=n.get(c);if(c.version!==d.__version||!0===h){i.activeTexture(t.TEXTURE0+s),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE);const e=r.isCompressedTexture||r.image[0].isCompressedTexture,n=r.image[0]&&r.image[0].isDataTexture,u=[];for(let t=0;t<6;t++)u[t]=e||n?n?r.image[t].image:r.image[t]:y(r.image[t],!1,!0,l),u[t]=H(r,u[t]);const p=u[0],f=x(p)||o,m=a.convert(r.format,r.colorSpace),g=a.convert(r.type),v=b(r.internalFormat,m,g,r.colorSpace),_=o&&!0!==r.isVideoTexture,E=void 0===d.__version||!0===h;let T,A=w(r,p,f);if(U(t.TEXTURE_CUBE_MAP,r,f),e){_&&E&&i.texStorage2D(t.TEXTURE_CUBE_MAP,A,v,p.width,p.height);for(let e=0;e<6;e++){T=u[e].mipmaps;for(let n=0;n<T.length;n++){const a=T[n];r.format!==ct?null!==m?_?i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,a.width,a.height,m,a.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,v,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,a.width,a.height,m,g,a.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,v,a.width,a.height,0,m,g,a.data)}}}else{T=r.mipmaps,_&&E&&(T.length>0&&A++,i.texStorage2D(t.TEXTURE_CUBE_MAP,A,v,u[0].width,u[0].height));for(let e=0;e<6;e++)if(n){_?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,u[e].width,u[e].height,m,g,u[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,v,u[e].width,u[e].height,0,m,g,u[e].data);for(let n=0;n<T.length;n++){const r=T[n].image[e].image;_?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,m,g,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,v,r.width,r.height,0,m,g,r.data)}}else{_?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m,g,u[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,v,m,g,u[e]);for(let n=0;n<T.length;n++){const r=T[n];_?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,m,g,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,v,m,g,r.image[e])}}}S(r,f)&&M(t.TEXTURE_CUBE_MAP),d.__version=c.version,r.onUpdate&&r.onUpdate(r)}e.__version=r.version}(s,e,r):i.bindTexture(t.TEXTURE_CUBE_MAP,s.__webglTexture,t.TEXTURE0+r)},this.rebindTextures=function(e,i,r){const a=n.get(e);void 0!==i&&F(a.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),void 0!==r&&B(e)},this.setupRenderTarget=function(e){const h=e.texture,l=n.get(e),c=n.get(h);e.addEventListener("dispose",A),!0!==e.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=t.createTexture()),c.__version=h.version,s.memory.textures++);const d=!0===e.isWebGLCubeRenderTarget,u=!0===e.isWebGLMultipleRenderTargets,p=x(e)||o;if(d){l.__webglFramebuffer=[];for(let e=0;e<6;e++)l.__webglFramebuffer[e]=t.createFramebuffer()}else{if(l.__webglFramebuffer=t.createFramebuffer(),u)if(r.drawBuffers){const i=e.texture;for(let e=0,r=i.length;e<r;e++){const r=n.get(i[e]);void 0===r.__webglTexture&&(r.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&e.samples>0&&!1===G(e)){const n=u?h:[h];l.__webglMultisampledFramebuffer=t.createFramebuffer(),l.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){const r=n[i];l.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,l.__webglColorRenderbuffer[i]);const s=a.convert(r.format,r.colorSpace),o=a.convert(r.type),h=b(r.internalFormat,s,o,r.colorSpace,!0===e.isXRRenderTarget),c=z(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,l.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(l.__webglDepthRenderbuffer=t.createRenderbuffer(),k(l.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(d){i.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),U(t.TEXTURE_CUBE_MAP,h,p);for(let i=0;i<6;i++)F(l.__webglFramebuffer[i],e,h,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i);S(h,p)&&M(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(u){const r=e.texture;for(let a=0,s=r.length;a<s;a++){const s=r[a],o=n.get(s);i.bindTexture(t.TEXTURE_2D,o.__webglTexture),U(t.TEXTURE_2D,s,p),F(l.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+a,t.TEXTURE_2D),S(s,p)&&M(t.TEXTURE_2D)}i.unbindTexture()}else{let n=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(o?n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(n,c.__webglTexture),U(n,h,p),F(l.__webglFramebuffer,e,h,t.COLOR_ATTACHMENT0,n),S(h,p)&&M(n),i.unbindTexture()}e.depthBuffer&&B(e)},this.updateRenderTargetMipmap=function(e){const r=x(e)||o,a=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let s=0,o=a.length;s<o;s++){const o=a[s];if(S(o,r)){const r=e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(o).__webglTexture;i.bindTexture(r,a),M(r),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(o&&e.samples>0&&!1===G(e)){const r=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],a=e.width,s=e.height;let o=t.COLOR_BUFFER_BIT;const h=[],l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=!0===e.isWebGLMultipleRenderTargets;if(d)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){h.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&h.push(l);const u=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;if(!1===u&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]),!0===u&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[l]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[l])),d){const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,a,s,0,0,a,s,o,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,h)}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const a=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,a,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=F,this.useMultisampledRTT=G}function _s(t,e,i){const n=i.isWebGL2;return{convert:function(i,r=""){let a;if(i===nt)return t.UNSIGNED_BYTE;if(1017===i)return t.UNSIGNED_SHORT_4_4_4_4;if(1018===i)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return t.BYTE;if(1011===i)return t.SHORT;if(i===rt)return t.UNSIGNED_SHORT;if(i===at)return t.INT;if(i===st)return t.UNSIGNED_INT;if(i===ot)return t.FLOAT;if(i===ht)return n?t.HALF_FLOAT:(a=e.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(1021===i)return t.ALPHA;if(i===ct)return t.RGBA;if(1024===i)return t.LUMINANCE;if(1025===i)return t.LUMINANCE_ALPHA;if(i===dt)return t.DEPTH_COMPONENT;if(i===ut)return t.DEPTH_STENCIL;if(i===Ft)return a=e.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(1028===i)return t.RED;if(1029===i)return t.RED_INTEGER;if(1030===i)return t.RG;if(1031===i)return t.RG_INTEGER;if(1033===i)return t.RGBA_INTEGER;if(i===pt||i===ft||i===mt||i===gt)if(r===bt){if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(i===pt)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ft)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===mt)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===gt)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=e.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(i===pt)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ft)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===mt)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===gt)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===i||35841===i||35842===i||35843===i){if(a=e.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(35840===i)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===i)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===i)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===i)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===i)return a=e.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===i||37496===i){if(a=e.get("WEBGL_compressed_texture_etc"),null===a)return null;if(37492===i)return r===bt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(37496===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(37808===i||37809===i||37810===i||37811===i||37812===i||37813===i||37814===i||37815===i||37816===i||37817===i||37818===i||37819===i||37820===i||37821===i){if(a=e.get("WEBGL_compressed_texture_astc"),null===a)return null;if(37808===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===i)return r===bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===vt){if(a=e.get("EXT_texture_compression_bptc"),null===a)return null;if(i===vt)return r===bt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===i||36284===i||36285===i||36286===i){if(a=e.get("EXT_texture_compression_rgtc"),null===a)return null;if(i===vt)return a.COMPRESSED_RED_RGTC1_EXT;if(36284===i)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===i)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===i)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===lt?n?t.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[i]?t[i]:null}}}class ys extends Fn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}let xs=class extends Ci{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Ss={type:"move"};class Ms{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new xs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new xs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ae,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ae),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new xs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ae,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ae),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,r=null,a=null;const s=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){a=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i),r=this._getHandJoint(h,n);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const n=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],s=n.position.distanceTo(r.position),o=.02,l=.005;h.inputState.pinching&&s>o+l?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&s<=o-l&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,n.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(n.linearVelocity)):s.hasLinearVelocity=!1,n.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(n.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Ss)))}return null!==s&&(s.visible=null!==n),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==a),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new xs;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class bs extends Se{constructor(t,e,i,n,r,a,s,o,h,l){if((l=void 0!==l?l:dt)!==dt&&l!==ut)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&l===dt&&(i=st),void 0===i&&l===ut&&(i=lt),super(null,n,r,a,s,o,l,i,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==s?s:J,this.minFilter=void 0!==o?o:J,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class ws extends zt{constructor(t,e){super();const i=this;let n=null,r=1,a=null,s="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const f=e.getContextAttributes();let m=null,g=null;const v=[],_=[];let y=null;const x=new Fn;x.layers.enable(1),x.viewport=new Me;const S=new Fn;S.layers.enable(2),S.viewport=new Me;const M=[x,S],b=new ys;b.layers.enable(1),b.layers.enable(2);let w=null,E=null;function T(t){const e=_.indexOf(t.inputSource);if(-1===e)return;const i=v[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||a),i.dispatchEvent({type:t.type,data:t.inputSource}))}function A(){n.removeEventListener("select",T),n.removeEventListener("selectstart",T),n.removeEventListener("selectend",T),n.removeEventListener("squeeze",T),n.removeEventListener("squeezestart",T),n.removeEventListener("squeezeend",T),n.removeEventListener("end",A),n.removeEventListener("inputsourceschange",C);for(let t=0;t<v.length;t++){const e=_[t];null!==e&&(_[t]=null,v[t].disconnect(e))}w=null,E=null,t.setRenderTarget(m),u=null,d=null,c=null,n=null,g=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function C(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=_.indexOf(i);n>=0&&(_[n]=null,v[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=_.indexOf(i);if(-1===n){for(let t=0;t<v.length;t++){if(t>=_.length){_.push(i),n=t;break}if(null===_[t]){_[t]=i,n=t;break}}if(-1===n)break}const r=v[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getCamera=function(){},this.setUserCamera=function(t){y=t},this.getController=function(t){let e=v[t];return void 0===e&&(e=new Ms,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new Ms,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new Ms,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){s=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){if(m=t.getRenderTarget(),n.addEventListener("select",T),n.addEventListener("selectstart",T),n.addEventListener("selectend",T),n.addEventListener("squeeze",T),n.addEventListener("squeezestart",T),n.addEventListener("squeezeend",T),n.addEventListener("end",A),n.addEventListener("inputsourceschange",C),!0!==f.xrCompatible&&await e.makeXRCompatible(),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),g=new be(u.framebufferWidth,u.framebufferHeight,{format:ct,type:nt,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil})}else{let i=null,a=null,s=null;f.depth&&(s=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=f.stencil?ut:dt,a=f.stencil?lt:st);const o={colorFormat:e.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(n,e),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),g=new be(d.textureWidth,d.textureHeight,{format:ct,type:nt,depthTexture:new bs(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0});t.properties.get(g).__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),h=null,a=await n.requestReferenceSpace(s),D.setContext(n),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};const R=new Ae,P=new Ae;function L(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCameraXR=function(t){if(null===n)return t;y&&(t=y),b.near=S.near=x.near=t.near,b.far=S.far=x.far=t.far,w===b.near&&E===b.far||(n.updateRenderState({depthNear:b.near,depthFar:b.far}),w=b.near,E=b.far);const e=t.parent,i=b.cameras;L(b,e);for(let t=0;t<i.length;t++)L(i[t],e);return 2===i.length?function(t,e,i){R.setFromMatrixPosition(e.matrixWorld),P.setFromMatrixPosition(i.matrixWorld);const n=R.distanceTo(P),r=e.projectionMatrix.elements,a=i.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(a[8]+1)/a[0],u=s*c,p=s*d,f=n/(-c+d),m=f*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=s+f,v=o+f,_=u-m,y=p+(n-m),x=h*o/v*g,S=l*o/v*g;t.projectionMatrix.makePerspective(_,y,x,S,g,v),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}(b,x,S):b.projectionMatrix.copy(x.projectionMatrix),y&&function(t,e){const i=y;null===e?i.matrix.copy(t.matrixWorld):(i.matrix.copy(e.matrixWorld),i.matrix.invert(),i.matrix.multiply(t.matrixWorld));i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0);const n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].updateMatrixWorld(!0);i.projectionMatrix.copy(t.projectionMatrix),i.projectionMatrixInverse.copy(t.projectionMatrixInverse),i.isPerspectiveCamera&&(i.fov=2*Wt*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}(b,e),b},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)};let I=null;const D=new Kn;D.setAnimationLoop((function(e,n){if(l=n.getViewerPose(h||a),p=n,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(g,u.framebuffer),t.setRenderTarget(g));let i=!1;e.length!==b.cameras.length&&(b.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const r=e[n];let a=null;if(null!==u)a=u.getViewport(r);else{const e=c.getViewSubImage(d,r);a=e.viewport,0===n&&(t.setRenderTargetTextures(g,e.colorTexture,d.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(g))}let s=M[n];void 0===s&&(s=new Fn,s.layers.enable(n),s.viewport=new Me,M[n]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===n&&(b.matrix.copy(s.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),!0===i&&b.cameras.push(s)}}for(let t=0;t<v.length;t++){const e=_[t],i=v[t];null!==e&&void 0!==i&&i.update(e,n,h||a)}I&&I(e,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),p=null})),this.setAnimationLoop=function(t){I=t},this.dispose=function(){}}}function Es(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map,i(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,i(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,i(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===x&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,i(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===x&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,i(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,i(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,i(r.specularMap,n.specularMapTransform)),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const a=e.get(r).envMap;if(a&&(n.envMap.value=a,n.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const e=!0===t.useLegacyLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*e,i(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,i(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,Dn(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,n){t.metalness.value=n.metalness,n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap,i(n.metalnessMap,t.metalnessMapTransform));t.roughness.value=n.roughness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap,i(n.roughnessMap,t.roughnessMapTransform));const r=e.get(n).envMap;r&&(t.envMapIntensity.value=n.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===x&&t.clearcoatNormalScale.value.negate()));e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,a,s):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ts(t,e,i,n){let r={},a={},s=[];const o=i.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function h(t,e,i){const n=t.value;if(void 0===i[e]){if("number"==typeof n)i[e]=n;else{const t=Array.isArray(n)?n:[n],r=[];for(let e=0;e<t.length;e++)r.push(t[e].clone());i[e]=r}return!0}if("number"==typeof n){if(i[e]!==n)return i[e]=n,!0}else{const t=Array.isArray(i[e])?i[e]:[i[e]],r=Array.isArray(n)?n:[n];for(let e=0;e<t.length;e++){const i=t[e];if(!1===i.equals(r[e]))return i.copy(r[e]),!0}}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=s.indexOf(i.__bindingPointIndex);s.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete a[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=r[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;let r=0;for(let t=0,a=e.length;t<a;t++){const a=e[t],s={boundary:0,storage:0},o=Array.isArray(a.value)?a.value:[a.value];for(let t=0,e=o.length;t<e;t++){const e=l(o[t]);s.boundary+=e.boundary,s.storage+=e.storage}if(a.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),a.__offset=i,t>0){r=i%n;0!==r&&n-r-s.boundary<0&&(i+=n-r,a.__offset=i)}i+=s.storage}r=i%n,r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===s.indexOf(t))return s.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,a=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,a),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const f=e.render.frame;a[i.id]!==f&&(!function(e){const i=r[e.id],n=e.uniforms,a=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=n[e];if(!0===h(i,e,a)){const e=i.__offset,n=Array.isArray(i.value)?i.value:[i.value];let r=0;for(let a=0;a<n.length;a++){const s=n[a],o=l(s);"number"==typeof s?(i.__data[0]=s,t.bufferSubData(t.UNIFORM_BUFFER,e+r,i.__data)):s.isMatrix3?(i.__data[0]=s.elements[0],i.__data[1]=s.elements[1],i.__data[2]=s.elements[2],i.__data[3]=s.elements[0],i.__data[4]=s.elements[3],i.__data[5]=s.elements[4],i.__data[6]=s.elements[5],i.__data[7]=s.elements[0],i.__data[8]=s.elements[6],i.__data[9]=s.elements[7],i.__data[10]=s.elements[8],i.__data[11]=s.elements[0]):(s.toArray(i.__data,r),r+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,i.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),a[i.id]=f)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);s=[],r={},a={}}}}function As(){const t=ae("canvas");return t.style.display="block",t}class Cs{constructor(t={}){const{canvas:e=As(),context:i=null,depth:n=!0,stencil:r=!0,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:d=!1}=t;let u;this.isWebGLRenderer=!0,u=null!==i?i.getContextAttributes().alpha:a;const p=new Uint32Array(4),f=new Int32Array(4);let m=null,g=null;const v=[],_=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=bt,this.useLegacyLights=!0,this.toneMapping=B,this.toneMappingExposure=1;const S=this;let M=!1,b=0,w=0,E=null,T=-1,A=null;const C=new Me,R=new Me;let P=null;const L=new Yi(0);let I=0,D=e.width,U=e.height,N=1,O=null,F=null;const k=new Me(0,0,D,U),z=new Me(0,0,D,U);let G=!1;const H=new qn;let V=!1,W=!1,X=null;const j=new ni,Y=new ee,q=new Ae,K={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Z(){return null===E?N:1}let J,Q,$,tt,et,at,dt,ut,pt,ft,mt,gt,vt,_t,yt,xt,St,Mt,Et,Tt,At,Ct,Rt,Pt,Lt=i;function It(t,i){for(let n=0;n<t.length;n++){const r=t[n],a=e.getContext(r,i);if(null!==a)return a}return null}try{const t={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${h}`),e.addEventListener("webglcontextlost",Nt,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===Lt){const e=["webgl2","webgl","experimental-webgl"];if(!0===S.isWebGL1Renderer&&e.shift(),Lt=It(e,t),null===Lt)throw It(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Lt instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Lt.getShaderPrecisionFormat&&(Lt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Dt(){J=new wr(Lt),Q=new ar(Lt,J,t),J.init(Q),Ct=new _s(Lt,J,Q),$=new gs(Lt,J,Q),tt=new Ar(Lt),et=new is,at=new vs(Lt,J,$,et,Q,Ct,tt),dt=new or(S),ut=new br(S),pt=new Zn(Lt,Q),Rt=new nr(Lt,J,pt,Q),ft=new Er(Lt,pt,tt,Rt),mt=new Lr(Lt,ft,pt,tt),Et=new Pr(Lt,Q,at),xt=new sr(et),gt=new es(S,dt,ut,J,Q,Rt,xt),vt=new Es(S,et),_t=new ss,yt=new us(J,Q),Mt=new ir(S,dt,ut,$,mt,u,o),St=new ms(S,mt,Q),Pt=new Ts(Lt,tt,Q,$),Tt=new rr(Lt,J,tt,Q),At=new Tr(Lt,J,tt,Q),tt.programs=gt.programs,S.capabilities=Q,S.extensions=J,S.properties=et,S.renderLists=_t,S.shadowMap=St,S.state=$,S.info=tt}Dt();const Ut=new ws(S,Lt);function Nt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ot(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const t=tt.autoReset,e=St.enabled,i=St.autoUpdate,n=St.needsUpdate,r=St.type;Dt(),tt.autoReset=t,St.enabled=e,St.autoUpdate=i,St.needsUpdate=n,St.type=r}function Ft(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function kt(t){const e=t.target;e.removeEventListener("dispose",kt),function(t){(function(t){const e=et.get(t).programs;void 0!==e&&(e.forEach((function(t){gt.releaseProgram(t)})),t.isShaderMaterial&&gt.releaseShaderCache(t))})(t),et.remove(t)}(e)}this.xr=Ut,this.getContext=function(){return Lt},this.getContextAttributes=function(){return Lt.getContextAttributes()},this.forceContextLoss=function(){const t=J.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=J.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(t){void 0!==t&&(N=t,this.setSize(D,U,!1))},this.getSize=function(t){return t.set(D,U)},this.setSize=function(t,i,n=!0){Ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(D=t,U=i,e.width=Math.floor(t*N),e.height=Math.floor(i*N),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(D*N,U*N).floor()},this.setDrawingBufferSize=function(t,i,n){D=t,U=i,N=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(C)},this.getViewport=function(t){return t.copy(k)},this.setViewport=function(t,e,i,n){t.isVector4?k.set(t.x,t.y,t.z,t.w):k.set(t,e,i,n),$.viewport(C.copy(k).multiplyScalar(N).floor())},this.getScissor=function(t){return t.copy(z)},this.setScissor=function(t,e,i,n){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,i,n),$.scissor(R.copy(z).multiplyScalar(N).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(t){$.setScissorTest(G=t)},this.setOpaqueSort=function(t){O=t},this.setTransparentSort=function(t){F=t},this.getClearColor=function(t){return t.copy(Mt.getClearColor())},this.setClearColor=function(){Mt.setClearColor.apply(Mt,arguments)},this.getClearAlpha=function(){return Mt.getClearAlpha()},this.setClearAlpha=function(){Mt.setClearAlpha.apply(Mt,arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==E){const e=E.texture.format;t=1033===e||1031===e||1029===e}if(t){const t=E.texture.type,e=t===nt||t===st||t===rt||t===lt||1017===t||1018===t,i=Mt.getClearColor(),n=Mt.getClearAlpha(),r=i.r,a=i.g,s=i.b,o=et.get(E).__webglFramebuffer;e?(p[0]=r,p[1]=a,p[2]=s,p[3]=n,Lt.clearBufferuiv(Lt.COLOR,o,p)):(f[0]=r,f[1]=a,f[2]=s,f[3]=n,Lt.clearBufferiv(Lt.COLOR,o,f))}else n|=Lt.COLOR_BUFFER_BIT}e&&(n|=Lt.DEPTH_BUFFER_BIT),i&&(n|=Lt.STENCIL_BUFFER_BIT),Lt.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Nt,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),_t.dispose(),yt.dispose(),et.dispose(),dt.dispose(),ut.dispose(),mt.dispose(),Rt.dispose(),Pt.dispose(),gt.dispose(),Ut.dispose(),Ut.removeEventListener("sessionstart",zt),Ut.removeEventListener("sessionend",Gt),X&&(X.dispose(),X=null),Ht.stop()},this.renderBufferDirect=function(t,e,i,n,r,a){null===e&&(e=K);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=K);at.resetTextureUnits();const a=e.fog,s=n.isMeshStandardMaterial?e.environment:null,o=null===E?S.outputColorSpace:!0===E.isXRRenderTarget?E.texture.colorSpace:wt,h=(n.isMeshStandardMaterial?ut:dt).get(n.envMap||s),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color,f=n.toneMapped?S.toneMapping:B,m=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==m?m.length:0,_=et.get(n),y=g.state.lights;if(!0===V&&(!0===W||t!==A)){const e=t===A&&n.id===T;xt.setState(n,t,e)}let x=!1;n.version===_.__version?_.needsLights&&_.lightsStateVersion!==y.state.version||_.outputColorSpace!==o||r.isInstancedMesh&&!1===_.instancing?x=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?x=!0:r.isSkinnedMesh||!0!==_.skinning?_.envMap!==h||!0===n.fog&&_.fog!==a?x=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===xt.numPlanes&&_.numIntersection===xt.numIntersection?(_.vertexAlphas!==l||_.vertexTangents!==c||_.morphTargets!==d||_.morphNormals!==u||_.morphColors!==p||_.toneMapping!==f||!0===Q.isWebGL2&&_.morphTargetsCount!==v)&&(x=!0):x=!0:x=!0:x=!0:(x=!0,_.__version=n.version);let M=_.currentProgram;!0===x&&(M=Yt(n,e,r));let b=!1,w=!1,C=!1;const R=M.getUniforms(),P=_.uniforms;$.useProgram(M.program)&&(b=!0,w=!0,C=!0);n.id!==T&&(T=n.id,w=!0);if(b||A!==t){if(R.setValue(Lt,"projectionMatrix",t.projectionMatrix),Q.logarithmicDepthBuffer&&R.setValue(Lt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),A!==t&&(A=t,w=!0,C=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const e=R.map.cameraPosition;void 0!==e&&e.setValue(Lt,q.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(Lt,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&R.setValue(Lt,"viewMatrix",t.matrixWorldInverse)}if(r.isSkinnedMesh){R.setOptional(Lt,r,"bindMatrix"),R.setOptional(Lt,r,"bindMatrixInverse");const t=r.skeleton;t&&(Q.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Lt,"boneTexture",t.boneTexture,at),R.setValue(Lt,"boneTextureSize",t.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."))}const L=i.morphAttributes;(void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===Q.isWebGL2)&&Et.update(r,i,M);(w||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Lt,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=h,P.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);w&&(R.setValue(Lt,"toneMappingExposure",S.toneMappingExposure),_.needsLights&&(D=C,(I=P).ambientLightColor.needsUpdate=D,I.lightProbe.needsUpdate=D,I.directionalLights.needsUpdate=D,I.directionalLightShadows.needsUpdate=D,I.pointLights.needsUpdate=D,I.pointLightShadows.needsUpdate=D,I.spotLights.needsUpdate=D,I.spotLightShadows.needsUpdate=D,I.rectAreaLights.needsUpdate=D,I.hemisphereLights.needsUpdate=D),a&&!0===n.fog&&vt.refreshFogUniforms(P,a),vt.refreshMaterialUniforms(P,n,N,U,X),Na.upload(Lt,_.uniformsList,P,at));var I,D;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Na.upload(Lt,_.uniformsList,P,at),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(Lt,"center",r.center);if(R.setValue(Lt,"modelViewMatrix",r.modelViewMatrix),R.setValue(Lt,"normalMatrix",r.normalMatrix),R.setValue(Lt,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++)if(Q.isWebGL2){const i=t[e];Pt.update(i,M),Pt.bind(i,M)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return M}(t,e,i,n,r);$.setMaterial(n,s);let h=i.index,l=1;!0===n.wireframe&&(h=ft.getWireframeAttribute(i),l=2);const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==a&&(u=Math.max(u,a.start*l),p=Math.min(p,(a.start+a.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const f=p-u;if(f<0||f===1/0)return;let m;Rt.setup(r,n,o,i,h);let v=Tt;if(null!==h&&(m=pt.get(h),v=At,v.setIndex(m)),r.isMesh)!0===n.wireframe?($.setLineWidth(n.wireframeLinewidth*Z()),v.setMode(Lt.LINES)):v.setMode(Lt.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),$.setLineWidth(t*Z()),r.isLineSegments?v.setMode(Lt.LINES):r.isLineLoop?v.setMode(Lt.LINE_LOOP):v.setMode(Lt.LINE_STRIP)}else r.isPoints?v.setMode(Lt.POINTS):r.isSprite&&v.setMode(Lt.TRIANGLES);if(r.isInstancedMesh)v.renderInstances(u,f,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);v.renderInstances(u,f,e)}else v.render(u,f)},this.compile=function(t,e){function i(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=x,t.needsUpdate=!0,Yt(t,e,i),t.side=y,t.needsUpdate=!0,Yt(t,e,i),t.side=2):Yt(t,e,i)}g=yt.get(t),g.init(),_.push(g),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),g.setupLights(S.useLegacyLights),t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++){i(n[r],t,e)}else i(n,t,e)})),_.pop(),g=null};let Bt=null;function zt(){Ht.stop()}function Gt(){Ht.start()}const Ht=new Kn;function Vt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){n&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(j);const e=mt.update(t),r=t.material;r.visible&&m.push(t,e,r,i,q.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){t.isSkinnedMesh&&t.skeleton.frame!==tt.render.frame&&(t.skeleton.update(),t.skeleton.frame=tt.render.frame);const e=mt.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)),q.applyMatrix4(t.matrixWorld).applyMatrix4(j)),Array.isArray(r)){const n=e.groups;for(let a=0,s=n.length;a<s;a++){const s=n[a],o=r[s.materialIndex];o&&o.visible&&m.push(t,e,o,i,q.z,s)}}else r.visible&&m.push(t,e,r,i,q.z,null)}const r=t.children;for(let t=0,a=r.length;t<a;t++)Vt(r[t],e,i,n)}function Wt(t,e,i,n){const r=t.opaque,a=t.transmissive,o=t.transparent;g.setupLightsView(i),!0===V&&xt.setGlobalState(S.clippingPlanes,i),a.length>0&&function(t,e,i,n){const r=Q.isWebGL2;null===X&&(X=new be(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")?ht:nt,minFilter:it,samples:r&&!0===s?4:0}));S.getDrawingBufferSize(Y),r?X.setSize(Y.x,Y.y):X.setSize(Jt(Y.x),Jt(Y.y));const a=S.getRenderTarget();S.setRenderTarget(X),S.getClearColor(L),I=S.getClearAlpha(),I<1&&S.setClearColor(16777215,.5);S.clear();const o=S.toneMapping;S.toneMapping=B,Xt(t,i,n),at.updateMultisampleRenderTarget(X),at.updateRenderTargetMipmap(X);let h=!1;for(let t=0,r=e.length;t<r;t++){const r=e[t],a=r.object,s=r.geometry,o=r.material,l=r.group;if(2===o.side&&a.layers.test(n.layers)){const t=o.side;o.side=x,o.needsUpdate=!0,jt(a,i,n,s,o,l),o.side=t,o.needsUpdate=!0,h=!0}}!0===h&&(at.updateMultisampleRenderTarget(X),at.updateRenderTargetMipmap(X));S.setRenderTarget(a),S.setClearColor(L,I),S.toneMapping=o}(r,a,e,i),n&&$.viewport(C.copy(n)),r.length>0&&Xt(r,e,i),a.length>0&&Xt(a,e,i),o.length>0&&Xt(o,e,i),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function Xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,a=t.length;r<a;r++){const a=t[r],s=a.object,o=a.geometry,h=null===n?a.material:n,l=a.group;s.layers.test(i.layers)&&jt(s,e,i,o,h,l)}}function jt(t,e,i,n,r,a){t.onBeforeRender(S,e,i,n,r,a),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(S,e,i,n,t,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=x,r.needsUpdate=!0,S.renderBufferDirect(i,e,n,r,t,a),r.side=y,r.needsUpdate=!0,S.renderBufferDirect(i,e,n,r,t,a),r.side=2):S.renderBufferDirect(i,e,n,r,t,a),t.onAfterRender(S,e,i,n,r,a)}function Yt(t,e,i){!0!==e.isScene&&(e=K);const n=et.get(t),r=g.state.lights,a=g.state.shadowsArray,s=r.state.version,o=gt.getParameters(t,r.state,a,e,i),h=gt.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?ut:dt).get(t.envMap||n.environment),void 0===l&&(t.addEventListener("dispose",kt),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===s)return qt(t,o),c}else o.uniforms=gt.getUniforms(t),t.onBuild(i,o,S),t.onBeforeCompile(o,S),c=gt.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=xt.uniform),qt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=s,n.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix);const u=c.getUniforms(),p=Na.seqWithValue(u.seq,d);return n.currentProgram=c,n.uniformsList=p,c}function qt(t,e){const i=et.get(t);i.outputColorSpace=e.outputColorSpace,i.instancing=e.instancing,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Ht.setAnimationLoop((function(t){Bt&&Bt(t)})),"undefined"!=typeof self&&Ht.setContext(self),this.setAnimationLoop=function(t){Bt=t,Ut.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Ut.addEventListener("sessionstart",zt),Ut.addEventListener("sessionend",Gt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===M)return;!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Ut.enabled&&!0===Ut.isPresenting&&(e=Ut.updateCameraXR(e)),!0===t.isScene&&t.onBeforeRender(S,t,e,E),g=yt.get(t,_.length),g.init(),_.push(g),j.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),H.setFromProjectionMatrix(j),W=this.localClippingEnabled,V=xt.init(this.clippingPlanes,W),m=_t.get(t,v.length),m.init(),v.push(m),Vt(t,e,0,S.sortObjects),m.finish(),!0===S.sortObjects&&m.sort(O,F),!0===V&&xt.beginShadows();const i=g.state.shadowsArray;if(St.render(i,t,e),!0===V&&xt.endShadows(),!0===this.info.autoReset&&this.info.reset(),this.info.render.frame++,Mt.render(m,t),g.setupLights(S.useLegacyLights),e.isArrayCamera){const i=e.cameras;for(let e=0,n=i.length;e<n;e++){const n=i[e];Wt(m,t,n,n.viewport)}}else Wt(m,t,e);null!==E&&(at.updateMultisampleRenderTarget(E),at.updateRenderTargetMipmap(E)),!0===t.isScene&&t.onAfterRender(S,t,e),Rt.resetDefaultState(),T=-1,A=null,_.pop(),g=_.length>0?_[_.length-1]:null,v.pop(),m=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(t,e,i){et.get(t.texture).__webglTexture=e,et.get(t.depthTexture).__webglTexture=i;const n=et.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===J.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const i=et.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){E=t,b=e,w=i;let n=!0,r=null,a=!1,s=!1;if(t){const i=et.get(t);void 0!==i.__useDefaultFramebuffer?($.bindFramebuffer(Lt.FRAMEBUFFER,null),n=!1):void 0===i.__webglFramebuffer?at.setupRenderTarget(t):i.__hasExternalTextures&&at.rebindTextures(t,et.get(t.texture).__webglTexture,et.get(t.depthTexture).__webglTexture);const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);const h=et.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=h[e],a=!0):r=Q.isWebGL2&&t.samples>0&&!1===at.useMultisampledRTT(t)?et.get(t).__webglMultisampledFramebuffer:h,C.copy(t.viewport),R.copy(t.scissor),P=t.scissorTest}else C.copy(k).multiplyScalar(N).floor(),R.copy(z).multiplyScalar(N).floor(),P=G;if($.bindFramebuffer(Lt.FRAMEBUFFER,r)&&Q.drawBuffers&&n&&$.drawBuffers(t,r),$.viewport(C),$.scissor(R),$.setScissorTest(P),a){const n=et.get(t.texture);Lt.framebufferTexture2D(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,Lt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(s){const n=et.get(t.texture),r=e||0;Lt.framebufferTextureLayer(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,n.__webglTexture,i||0,r)}T=-1},this.readRenderTargetPixels=function(t,e,i,n,r,a,s){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=et.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){$.bindFramebuffer(Lt.FRAMEBUFFER,o);try{const s=t.texture,o=s.format,h=s.type;if(o!==ct&&Ct.convert(o)!==Lt.getParameter(Lt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=h===ht&&(J.has("EXT_color_buffer_half_float")||Q.isWebGL2&&J.has("EXT_color_buffer_float"));if(!(h===nt||Ct.convert(h)===Lt.getParameter(Lt.IMPLEMENTATION_COLOR_READ_TYPE)||h===ot&&(Q.isWebGL2||J.has("OES_texture_float")||J.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&Lt.readPixels(e,i,n,r,Ct.convert(o),Ct.convert(h),a)}finally{const t=null!==E?et.get(E).__webglFramebuffer:null;$.bindFramebuffer(Lt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),a=Math.floor(e.image.height*n);at.setTexture2D(e,0),Lt.copyTexSubImage2D(Lt.TEXTURE_2D,i,0,0,t.x,t.y,r,a),$.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,a=e.image.height,s=Ct.convert(i.format),o=Ct.convert(i.type);at.setTexture2D(i,0),Lt.pixelStorei(Lt.UNPACK_FLIP_Y_WEBGL,i.flipY),Lt.pixelStorei(Lt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Lt.pixelStorei(Lt.UNPACK_ALIGNMENT,i.unpackAlignment),e.isDataTexture?Lt.texSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,r,a,s,o,e.image.data):e.isCompressedTexture?Lt.compressedTexSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,s,e.mipmaps[0].data):Lt.texSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,s,o,e.image),0===n&&i.generateMipmaps&&Lt.generateMipmap(Lt.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,r=0){if(S.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=t.max.x-t.min.x+1,s=t.max.y-t.min.y+1,o=t.max.z-t.min.z+1,h=Ct.convert(n.format),l=Ct.convert(n.type);let c;if(n.isData3DTexture)at.setTexture3D(n,0),c=Lt.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");at.setTexture2DArray(n,0),c=Lt.TEXTURE_2D_ARRAY}Lt.pixelStorei(Lt.UNPACK_FLIP_Y_WEBGL,n.flipY),Lt.pixelStorei(Lt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Lt.pixelStorei(Lt.UNPACK_ALIGNMENT,n.unpackAlignment);const d=Lt.getParameter(Lt.UNPACK_ROW_LENGTH),u=Lt.getParameter(Lt.UNPACK_IMAGE_HEIGHT),p=Lt.getParameter(Lt.UNPACK_SKIP_PIXELS),f=Lt.getParameter(Lt.UNPACK_SKIP_ROWS),m=Lt.getParameter(Lt.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[0]:i.image;Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,g.width),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,g.height),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,t.min.x),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,t.min.y),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,t.min.z),i.isDataTexture||i.isData3DTexture?Lt.texSubImage3D(c,r,e.x,e.y,e.z,a,s,o,h,l,g.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Lt.compressedTexSubImage3D(c,r,e.x,e.y,e.z,a,s,o,h,g.data)):Lt.texSubImage3D(c,r,e.x,e.y,e.z,a,s,o,h,l,g),Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,d),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,u),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,p),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,f),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,m),0===r&&n.generateMipmaps&&Lt.generateMipmap(c),$.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?at.setTextureCube(t,0):t.isData3DTexture?at.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?at.setTexture2DArray(t,0):at.setTexture2D(t,0),$.unbindTexture()},this.resetState=function(){b=0,w=0,E=null,$.reset(),Rt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kt}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===bt?St:3e3}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===St?bt:wt}}(class extends Cs{}).prototype.isWebGL1Renderer=!0;class Rs extends Ci{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(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}}class Ps{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Nt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Xt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xt()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xt()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ls=new Ae;class Is{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Ls.fromBufferAttribute(this,e),Ls.applyMatrix4(t),this.setXYZ(e,Ls.x,Ls.y,Ls.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Ls.fromBufferAttribute(this,e),Ls.applyNormalMatrix(t),this.setXYZ(e,Ls.x,Ls.y,Ls.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Ls.fromBufferAttribute(this,e),Ls.transformDirection(t),this.setXYZ(e,Ls.x,Ls.y,Ls.z);return this}setX(t,e){return this.normalized&&(e=$t(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=$t(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=$t(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=$t(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Qt(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Qt(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Qt(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Qt(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array),n=$t(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=$t(e,this.array),i=$t(i,this.array),n=$t(n,this.array),r=$t(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new Qi(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Is(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ds extends Hi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Yi(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Us;const Ns=new Ae,Os=new Ae,Fs=new Ae,ks=new ee,Bs=new ee,zs=new ni,Gs=new Ae,Hs=new Ae,Vs=new Ae,Ws=new ee,Xs=new ee,js=new ee;let Ys=class extends Ci{constructor(t){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Us){Us=new cn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Ps(t,5);Us.setIndex([0,1,2,0,2,3]),Us.setAttribute("position",new Is(e,3,0,!1)),Us.setAttribute("uv",new Is(e,2,3,!1))}this.geometry=Us,this.material=void 0!==t?t:new Ds,this.center=new ee(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Os.setFromMatrixScale(this.matrixWorld),zs.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Fs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Os.multiplyScalar(-Fs.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const a=this.center;qs(Gs.set(-.5,-.5,0),Fs,a,Os,n,r),qs(Hs.set(.5,-.5,0),Fs,a,Os,n,r),qs(Vs.set(.5,.5,0),Fs,a,Os,n,r),Ws.set(0,0),Xs.set(1,0),js.set(1,1);let s=t.ray.intersectTriangle(Gs,Hs,Vs,!1,Ns);if(null===s&&(qs(Hs.set(-.5,.5,0),Fs,a,Os,n,r),Xs.set(0,1),s=t.ray.intersectTriangle(Gs,Vs,Hs,!1,Ns),null===s))return;const o=t.ray.origin.distanceTo(Ns);o<t.near||o>t.far||e.push({distance:o,point:Ns.clone(),uv:zi.getInterpolation(Ns,Gs,Hs,Vs,Ws,Xs,js,new ee),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}};function qs(t,e,i,n,r,a){ks.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(Bs.x=a*ks.x-r*ks.y,Bs.y=r*ks.x+a*ks.y):Bs.copy(ks),t.copy(e),t.x+=Bs.x,t.y+=Bs.y,t.applyMatrix4(zs)}const Ks=new Ae,Zs=new Me,Js=new Me,Qs=new Ae,$s=new ni,to=new Ae,eo=new qe,io=new ni,no=new ii;class ro extends Cn{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ni,this.bindMatrixInverse=new ni,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Pe),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)to.fromBufferAttribute(e,t),this.applyBoneTransform(t,to),this.boundingBox.expandByPoint(to)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new qe),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)to.fromBufferAttribute(e,t),this.applyBoneTransform(t,to),this.boundingSphere.expandByPoint(to)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),eo.copy(this.boundingSphere),eo.applyMatrix4(n),!1!==t.ray.intersectsSphere(eo)&&(io.copy(n).invert(),no.copy(t.ray).applyMatrix4(io),null!==this.boundingBox&&!1===no.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,no)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Me,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;Zs.fromBufferAttribute(n.attributes.skinIndex,t),Js.fromBufferAttribute(n.attributes.skinWeight,t),Ks.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const n=Js.getComponent(t);if(0!==n){const r=Zs.getComponent(t);$s.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(Qs.copy(Ks).applyMatrix4($s),n)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(t,e)}}class ao extends Ci{constructor(){super(),this.isBone=!0,this.type="Bone"}}class so extends Se{constructor(t=null,e=1,i=1,n,r,a,s,o,h=1003,l=1003,c,d){super(null,a,s,o,h,l,n,r,c,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const oo=new ni,ho=new ni;class lo{constructor(t=[],e=[]){this.uuid=Xt(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new ni)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new ni;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const r=t[n]?t[n].matrixWorld:ho;oo.multiplyMatrices(r,e[n]),oo.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new lo(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=Zt(t),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new so(e,t,t,ct,ot);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const n=t.bones[i];let r=e[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new ao),this.bones.push(r),this.boneInverses.push((new ni).fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,r=e.length;n<r;n++){const r=e[n];t.bones.push(r.uuid);const a=i[n];t.boneInverses.push(a.toArray())}return t}}class co extends Qi{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const uo=new ni,po=new ni,fo=[],mo=new Pe,go=new ni,vo=new Cn,_o=new qe;class yo extends Cn{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new co(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<i;t++)this.setMatrixAt(t,go)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Pe),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,uo),mo.copy(t.boundingBox).applyMatrix4(uo),this.boundingBox.union(mo)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new qe),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,uo),_o.copy(t.boundingSphere).applyMatrix4(uo),this.boundingSphere.union(_o)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}raycast(t,e){const i=this.matrixWorld,n=this.count;if(vo.geometry=this.geometry,vo.material=this.material,void 0!==vo.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),_o.copy(this.boundingSphere),_o.applyMatrix4(i),!1!==t.ray.intersectsSphere(_o)))for(let r=0;r<n;r++){this.getMatrixAt(r,uo),po.multiplyMatrices(i,uo),vo.matrixWorld=po,vo.raycast(t,fo);for(let t=0,i=fo.length;t<i;t++){const i=fo[t];i.instanceId=r,i.object=this,e.push(i)}fo.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new co(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class xo extends Hi{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Yi(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const So=new Ae,Mo=new Ae,bo=new ni,wo=new ii,Eo=new qe;let To=class extends Ci{constructor(t=new cn,e=new xo){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)So.fromBufferAttribute(e,t-1),Mo.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=So.distanceTo(Mo);t.setAttribute("lineDistance",new en(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Eo.copy(i.boundingSphere),Eo.applyMatrix4(n),Eo.radius+=r,!1===t.ray.intersectsSphere(Eo))return;bo.copy(n).invert(),wo.copy(t.ray).applyMatrix4(bo);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,h=new Ae,l=new Ae,c=new Ae,d=new Ae,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(null!==p){for(let i=Math.max(0,a.start),n=Math.min(p.count,a.start+a.count)-1;i<n;i+=u){const n=p.getX(i),r=p.getX(i+1);h.fromBufferAttribute(f,n),l.fromBufferAttribute(f,r);if(wo.distanceSqToSegment(h,l,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);const a=t.ray.origin.distanceTo(d);a<t.near||a>t.far||e.push({distance:a,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,a.start),n=Math.min(f.count,a.start+a.count)-1;i<n;i+=u){h.fromBufferAttribute(f,i),l.fromBufferAttribute(f,i+1);if(wo.distanceSqToSegment(h,l,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(d);n<t.near||n>t.far||e.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}};const Ao=new Ae,Co=new Ae;class Ro extends To{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)Ao.fromBufferAttribute(e,t),Co.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+Ao.distanceTo(Co);t.setAttribute("lineDistance",new en(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Po extends To{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Lo extends Hi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Yi(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Io=new ni,Do=new ii,Uo=new qe,No=new Ae;class Oo extends Ci{constructor(t=new cn,e=new Lo){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Uo.copy(i.boundingSphere),Uo.applyMatrix4(n),Uo.radius+=r,!1===t.ray.intersectsSphere(Uo))return;Io.copy(n).invert(),Do.copy(t.ray).applyMatrix4(Io);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,h=i.index,l=i.attributes.position;if(null!==h){for(let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count);i<r;i++){const r=h.getX(i);No.fromBufferAttribute(l,r),Fo(No,r,o,n,t,e,this)}}else{for(let i=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);i<r;i++)No.fromBufferAttribute(l,i),Fo(No,i,o,n,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Fo(t,e,i,n,r,a,s){const o=Do.distanceSqToPoint(t);if(o<i){const i=new Ae;Do.closestPointToPoint(t,i),i.applyMatrix4(n);const h=r.ray.origin.distanceTo(i);if(h<r.near||h>r.far)return;a.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,object:s})}}class ko extends Se{constructor(t,e,i,n,r,a,s,o,h){super(t,e,i,n,r,a,s,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Bo extends cn{constructor(t=1,e=1,i=1,n=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const h=this;n=Math.floor(n),r=Math.floor(r);const l=[],c=[],d=[],u=[];let p=0;const f=[],m=i/2;let g=0;function v(i){const r=p,a=new ee,f=new Ae;let v=0;const _=!0===i?t:e,y=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,m*y,0),d.push(0,y,0),u.push(.5,.5),p++;const x=p;for(let t=0;t<=n;t++){const e=t/n*o+s,i=Math.cos(e),r=Math.sin(e);f.x=_*r,f.y=m*y,f.z=_*i,c.push(f.x,f.y,f.z),d.push(0,y,0),a.x=.5*i+.5,a.y=.5*r*y+.5,u.push(a.x,a.y),p++}for(let t=0;t<n;t++){const e=r+t,n=x+t;!0===i?l.push(n,n+1,e):l.push(n+1,n,e),v+=3}h.addGroup(g,v,!0===i?1:2),g+=v}!function(){const a=new Ae,v=new Ae;let _=0;const y=(e-t)/i;for(let h=0;h<=r;h++){const l=[],g=h/r,_=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,r=e*o+s,h=Math.sin(r),f=Math.cos(r);v.x=_*h,v.y=-g*i+m,v.z=_*f,c.push(v.x,v.y,v.z),a.set(h,y,f).normalize(),d.push(a.x,a.y,a.z),u.push(e,1-g),l.push(p++)}f.push(l)}for(let t=0;t<n;t++)for(let e=0;e<r;e++){const i=f[e][t],n=f[e+1][t],r=f[e+1][t+1],a=f[e][t+1];l.push(i,n,a),l.push(n,r,a),_+=6}h.addGroup(g,_,0),g+=_}(),!1===a&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(l),this.setAttribute("position",new en(c,3)),this.setAttribute("normal",new en(d,3)),this.setAttribute("uv",new en(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bo(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class zo extends cn{constructor(t=[],e=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const r=[],a=[];function s(t,e,i,n){const r=n+1,a=[];for(let n=0;n<=r;n++){a[n]=[];const s=t.clone().lerp(i,n/r),o=e.clone().lerp(i,n/r),h=r-n;for(let t=0;t<=h;t++)a[n][t]=0===t&&n===r?s:s.clone().lerp(o,t/h)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const i=Math.floor(e/2);e%2==0?(o(a[t][i+1]),o(a[t+1][i]),o(a[t][i])):(o(a[t][i+1]),o(a[t+1][i+1]),o(a[t+1][i]))}}function o(t){r.push(t.x,t.y,t.z)}function h(e,i){const n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function l(t,e,i,n){n<0&&1===t.x&&(a[e]=t.x-1),0===i.x&&0===i.z&&(a[e]=n/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}!function(t){const i=new Ae,n=new Ae,r=new Ae;for(let a=0;a<e.length;a+=3)h(e[a+0],i),h(e[a+1],n),h(e[a+2],r),s(i,n,r,t)}(n),function(t){const e=new Ae;for(let i=0;i<r.length;i+=3)e.x=r[i+0],e.y=r[i+1],e.z=r[i+2],e.normalize().multiplyScalar(t),r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z}(i),function(){const t=new Ae;for(let i=0;i<r.length;i+=3){t.x=r[i+0],t.y=r[i+1],t.z=r[i+2];const n=c(t)/2/Math.PI+.5,s=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);a.push(n,1-s)}var e;(function(){const t=new Ae,e=new Ae,i=new Ae,n=new Ae,s=new ee,o=new ee,h=new ee;for(let d=0,u=0;d<r.length;d+=9,u+=6){t.set(r[d+0],r[d+1],r[d+2]),e.set(r[d+3],r[d+4],r[d+5]),i.set(r[d+6],r[d+7],r[d+8]),s.set(a[u+0],a[u+1]),o.set(a[u+2],a[u+3]),h.set(a[u+4],a[u+5]),n.copy(t).add(e).add(i).divideScalar(3);const p=c(n);l(s,u+0,t,p),l(o,u+2,e,p),l(h,u+4,i,p)}})(),function(){for(let t=0;t<a.length;t+=6){const e=a[t+0],i=a[t+2],n=a[t+4],r=Math.max(e,i,n),s=Math.min(e,i,n);r>.9&&s<.1&&(e<.2&&(a[t+0]+=1),i<.2&&(a[t+2]+=1),n<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new en(r,3)),this.setAttribute("normal",new en(r.slice(),3)),this.setAttribute("uv",new en(a,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zo(t.vertices,t.indices,t.radius,t.details)}}class Go extends zo{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Go(t.radius,t.detail)}}class Ho extends cn{constructor(t=1,e=32,i=16,n=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:s},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(a+s,Math.PI);let h=0;const l=[],c=new Ae,d=new Ae,u=[],p=[],f=[],m=[];for(let u=0;u<=i;u++){const g=[],v=u/i;let _=0;0===u&&0===a?_=.5/e:u===i&&o===Math.PI&&(_=-.5/e);for(let i=0;i<=e;i++){const o=i/e;c.x=-t*Math.cos(n+o*r)*Math.sin(a+v*s),c.y=t*Math.cos(a+v*s),c.z=t*Math.sin(n+o*r)*Math.sin(a+v*s),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),m.push(o+_,1-v),g.push(h++)}l.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=l[t][n+1],r=l[t][n],s=l[t+1][n],h=l[t+1][n+1];(0!==t||a>0)&&u.push(e,r,h),(t!==i-1||o<Math.PI)&&u.push(r,s,h)}this.setIndex(u),this.setAttribute("position",new en(p,3)),this.setAttribute("normal",new en(f,3)),this.setAttribute("uv",new en(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ho(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Vo extends cn{constructor(t=1,e=.4,i=12,n=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);const a=[],s=[],o=[],h=[],l=new Ae,c=new Ae,d=new Ae;for(let a=0;a<=i;a++)for(let u=0;u<=n;u++){const p=u/n*r,f=a/i*Math.PI*2;c.x=(t+e*Math.cos(f))*Math.cos(p),c.y=(t+e*Math.cos(f))*Math.sin(p),c.z=e*Math.sin(f),s.push(c.x,c.y,c.z),l.x=t*Math.cos(p),l.y=t*Math.sin(p),d.subVectors(c,l).normalize(),o.push(d.x,d.y,d.z),h.push(u/n),h.push(a/i)}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*t+e-1,r=(n+1)*(t-1)+e-1,s=(n+1)*(t-1)+e,o=(n+1)*t+e;a.push(i,r,o),a.push(r,s,o)}this.setIndex(a),this.setAttribute("position",new en(s,3)),this.setAttribute("normal",new en(o,3)),this.setAttribute("uv",new en(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vo(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Wo extends Hi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Yi(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Xo extends Wo{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ee(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Yi(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Yi(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Yi(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function jo(t,e,i){return qo(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)}function Yo(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function qo(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ko(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i}function Zo(t,e,i){const n=t.length,r=new t.constructor(n);for(let a=0,s=0;s!==n;++a){const n=i[a]*e;for(let i=0;i!==e;++i)r[s++]=t[n+i]}return r}function Jo(t,e,i,n){let r=1,a=t[0];for(;void 0!==a&&void 0===a[n];)a=t[r++];if(void 0===a)return;let s=a[n];if(void 0!==s)if(Array.isArray(s))do{s=a[n],void 0!==s&&(e.push(a.time),i.push.apply(i,s)),a=t[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[n],void 0!==s&&(e.push(a.time),s.toArray(i,i.length)),a=t[r++]}while(void 0!==a);else do{s=a[n],void 0!==s&&(e.push(a.time),i.push(s)),a=t[r++]}while(void 0!==a)}class Qo{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let a;i:{n:if(!(t<n)){for(let a=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=e[++i],t<n)break e}a=e.length;break i}if(t>=r)break t;{const s=e[1];t<s&&(i=2,r=s);for(let a=i-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(n=r,r=e[--i-1],t>=r)break e}a=i,i=0}}for(;i<a;){const n=i+a>>>1;t<e[n]?a=n:i=n+1}if(n=e[i],r=e[i-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n;for(let t=0;t!==n;++t)e[t]=i[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class $o extends Qo{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,i){const n=this.parameterPositions;let r=t-2,a=t+1,s=n[r],o=n[a];if(void 0===s)switch(this.getSettings_().endingStart){case 2401:r=t,s=2*e-i;break;case 2402:r=n.length-2,s=e+n[r]-n[r+1];break;default:r=t,s=i}if(void 0===o)switch(this.getSettings_().endingEnd){case 2401:a=t,o=2*i-e;break;case 2402:a=1,o=i+n[1]-n[0];break;default:a=t-1,o=e}const h=.5*(i-e),l=this.valueSize;this._weightPrev=h/(e-s),this._weightNext=h/(o-i),this._offsetPrev=r*l,this._offsetNext=a*l}interpolate_(t,e,i,n){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,h=o-s,l=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(i-e)/(n-e),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,v=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,_=(-1-u)*m+(1.5+u)*f+.5*p,y=u*m-u*f;for(let t=0;t!==s;++t)r[t]=g*a[l+t]+v*a[h+t]+_*a[o+t]+y*a[c+t];return r}}class th extends Qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,h=o-s,l=(i-e)/(n-e),c=1-l;for(let t=0;t!==s;++t)r[t]=a[h+t]*c+a[o+t]*l;return r}}class eh extends Qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class ih{constructor(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Yo(e,this.TimeBufferType),this.values=Yo(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Yo(t.times,Array),values:Yo(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new eh(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new th(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new $o(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case _t:e=this.InterpolantFactoryMethodDiscrete;break;case yt:e=this.InterpolantFactoryMethodLinear;break;case xt:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return _t;case this.InterpolantFactoryMethodLinear:return yt;case this.InterpolantFactoryMethodSmooth:return xt}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let r=0,a=n-1;for(;r!==n&&i[r]<t;)++r;for(;-1!==a&&i[a]>e;)--a;if(++a,0!==r||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);const t=this.getValueSize();this.times=jo(i,r,a),this.values=jo(this.values,r*t,a*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==a&&a>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,a),t=!1;break}a=n}if(void 0!==n&&qo(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=jo(this.times),e=jo(this.values),i=this.getValueSize(),n=this.getInterpolation()===xt,r=t.length-1;let a=1;for(let s=1;s<r;++s){let r=!1;const o=t[s];if(o!==t[s+1]&&(1!==s||o!==t[0]))if(n)r=!0;else{const t=s*i,n=t-i,a=t+i;for(let s=0;s!==i;++s){const i=e[t+s];if(i!==e[n+s]||i!==e[a+s]){r=!0;break}}}if(r){if(s!==a){t[a]=t[s];const n=s*i,r=a*i;for(let t=0;t!==i;++t)e[r+t]=e[n+t]}++a}}if(r>0){t[a]=t[r];for(let t=r*i,n=a*i,s=0;s!==i;++s)e[n+s]=e[t+s];++a}return a!==t.length?(this.times=jo(t,0,a),this.values=jo(e,0,a*i)):(this.times=t,this.values=e),this}clone(){const t=jo(this.times,0),e=jo(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ih.prototype.TimeBufferType=Float32Array,ih.prototype.ValueBufferType=Float32Array,ih.prototype.DefaultInterpolation=yt;class nh extends ih{}nh.prototype.ValueTypeName="bool",nh.prototype.ValueBufferType=Array,nh.prototype.DefaultInterpolation=_t,nh.prototype.InterpolantFactoryMethodLinear=void 0,nh.prototype.InterpolantFactoryMethodSmooth=void 0;class rh extends ih{}rh.prototype.ValueTypeName="color";class ah extends ih{}ah.prototype.ValueTypeName="number";class sh extends Qo{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(i-e)/(n-e);let h=t*s;for(let t=h+s;h!==t;h+=4)Te.slerpFlat(r,0,a,h-s,a,h,o);return r}}class oh extends ih{InterpolantFactoryMethodLinear(t){return new sh(this.times,this.values,this.getValueSize(),t)}}oh.prototype.ValueTypeName="quaternion",oh.prototype.DefaultInterpolation=yt,oh.prototype.InterpolantFactoryMethodSmooth=void 0;class hh extends ih{}hh.prototype.ValueTypeName="string",hh.prototype.ValueBufferType=Array,hh.prototype.DefaultInterpolation=_t,hh.prototype.InterpolantFactoryMethodLinear=void 0,hh.prototype.InterpolantFactoryMethodSmooth=void 0;class lh extends ih{}lh.prototype.ValueTypeName="vector";class ch{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Xt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(dh(i[t]).scale(n));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(ih.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const r=e.length,a=[];for(let t=0;t<r;t++){let s=[],o=[];s.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const h=Ko(s);s=Zo(s,1,h),o=Zo(o,1,h),n||0!==s[0]||(s.push(r),o.push(o[0])),a.push(new ah(".morphTargetInfluences["+e[t].name+"]",s,o).scale(1/i))}return new this(t,-1,a)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<i.length;t++)if(i[t].name===e)return i[t];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,i=t.length;e<i;e++){const i=t[e],a=i.name.match(r);if(a&&a.length>1){const t=a[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const a=[];for(const t in n)a.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const a=[],s=[];Jo(i,a,s,n),0!==a.length&&r.push(new t(e,a,s))}},n=[],r=t.name||"default",a=t.fps||30,s=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let t=0;t<h.length;t++){const r=h[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let i=0;i<r[e].morphTargets.length;i++)t[r[e].morphTargets[i]]=-1;for(const i in t){const t=[],a=[];for(let n=0;n!==r[e].morphTargets.length;++n){const n=r[e];t.push(n.time),a.push(n.morphTarget===i?1:0)}n.push(new ah(".morphTargetInfluence["+i+"]",t,a))}o=t.length*a}else{const a=".bones["+e[t].name+"]";i(lh,a+".position",r,"pos",n),i(oh,a+".quaternion",r,"rot",n),i(lh,a+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,o,n,s)}resetDuration(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function dh(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ah;case"vector":case"vector2":case"vector3":case"vector4":return lh;case"color":return rh;case"quaternion":return oh;case"bool":case"boolean":return nh;case"string":return hh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];Jo(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const uh={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class ph{constructor(t,e,i){const n=this;let r,a=!1,s=0,o=0;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){o++,!1===a&&void 0!==n.onStart&&n.onStart(t,s,o),a=!0},this.itemEnd=function(t){s++,void 0!==n.onProgress&&n.onProgress(t,s,o),s===o&&(a=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return h.push(t,e),this},this.removeHandler=function(t){const e=h.indexOf(t);return-1!==e&&h.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=h.length;e<i;e+=2){const i=h[e],n=h[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}}}const fh=new ph;class mh{constructor(t){this.manager=void 0!==t?t:fh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise((function(n,r){i.load(t,n,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}const gh={};class vh extends Error{constructor(t,e){super(t),this.response=e}}class _h extends mh{constructor(t){super(t)}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=uh.get(t);if(void 0!==r)return this.manager.itemStart(t),setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==gh[t])return void gh[t].push({onLoad:e,onProgress:i,onError:n});gh[t]=[],gh[t].push({onLoad:e,onProgress:i,onError:n});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=gh[t],n=e.body.getReader(),r=e.headers.get("Content-Length")||e.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a;let o=0;const h=new ReadableStream({start(t){!function e(){n.read().then((({done:n,value:r})=>{if(n)t.close();else{o+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let t=0,e=i.length;t<e;t++){const e=i[t];e.onProgress&&e.onProgress(n)}t.enqueue(r),e()}}))}()}});return new Response(h)}throw new vh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,s)));case"json":return t.json();default:if(void 0===s)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(s),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then((t=>n.decode(t)))}}})).then((e=>{uh.add(t,e);const i=gh[t];delete gh[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}})).catch((e=>{const i=gh[t];if(void 0===i)throw this.manager.itemError(t),e;delete gh[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class yh extends mh{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=uh.get(t);if(void 0!==a)return r.manager.itemStart(t),setTimeout((function(){e&&e(a),r.manager.itemEnd(t)}),0),a;const s=ae("img");function o(){l(),uh.add(t,this),e&&e(this),r.manager.itemEnd(t)}function h(e){l(),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}function l(){s.removeEventListener("load",o,!1),s.removeEventListener("error",h,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",h,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(t),s.src=t,s}}class xh extends mh{constructor(t){super(t)}load(t,e,i,n){const r=new Se,a=new yh(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}class Sh extends Ci{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Yi(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}const Mh=new ni,bh=new Ae,wh=new Ae;class Eh{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ee(512,512),this.map=null,this.mapPass=null,this.matrix=new ni,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qn,this._frameExtents=new ee(1,1),this._viewportCount=1,this._viewports=[new Me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;bh.setFromMatrixPosition(t.matrixWorld),e.position.copy(bh),wh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(wh),e.updateMatrixWorld(),Mh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mh),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Mh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Th extends Eh{constructor(){super(new Fn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Wt*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Ah extends Sh{constructor(t,e,i=0,n=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Th}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Ch=new ni,Rh=new Ae,Ph=new Ae;class Lh extends Eh{constructor(){super(new Fn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ee(4,2),this._viewportCount=6,this._viewports=[new Me(2,1,1,1),new Me(0,1,1,1),new Me(3,1,1,1),new Me(1,1,1,1),new Me(3,0,1,1),new Me(1,0,1,1)],this._cubeDirections=[new Ae(1,0,0),new Ae(-1,0,0),new Ae(0,0,1),new Ae(0,0,-1),new Ae(0,1,0),new Ae(0,-1,0)],this._cubeUps=[new Ae(0,1,0),new Ae(0,1,0),new Ae(0,1,0),new Ae(0,1,0),new Ae(0,0,1),new Ae(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,r=t.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),Rh.setFromMatrixPosition(t.matrixWorld),i.position.copy(Rh),Ph.copy(i.position),Ph.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(Ph),i.updateMatrixWorld(),n.makeTranslation(-Rh.x,-Rh.y,-Rh.z),Ch.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ch)}}class Ih extends Sh{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Lh}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Dh extends Eh{constructor(){super(new hr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Uh extends Sh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.shadow=new Dh}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Nh extends Sh{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Oh{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let i=0,n=t.length;i<n;i++)e+=String.fromCharCode(t[i]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Fh extends mh{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=uh.get(t);if(void 0!==a)return r.manager.itemStart(t),setTimeout((function(){e&&e(a),r.manager.itemEnd(t)}),0),a;const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(t,s).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){uh.add(t,i),e&&e(i),r.manager.itemEnd(t)})).catch((function(e){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}}class kh{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Bh(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Bh();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Bh(){return("undefined"==typeof performance?Date:performance).now()}const zh="\\[\\]\\.:\\/",Gh=new RegExp("["+zh+"]","g"),Hh="[^"+zh+"]",Vh="[^"+zh.replace("\\.","")+"]",Wh=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Hh)+/(WCOD+)?/.source.replace("WCOD",Vh)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Hh)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Hh)+"$"),Xh=["material","materials","bones","map"];class jh{constructor(t,e,i){this.path=e,this.parsedPath=i||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new jh.Composite(t,e,i):new jh(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Gh,"")}static parseTrackName(t){const e=Wh.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==Xh.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.name===e||r.uuid===e)return r;const a=i(r.children);if(a)return a}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let r=e.propertyIndex;if(t||(t=jh.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==n){if(void 0===t[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[n]}}const a=t[n];if(void 0===a){const i=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",t)}let s=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}jh.Composite=class{constructor(t,e,i){const n=i||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}},jh.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},jh.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},jh.prototype.GetterByBindingType=[jh.prototype._getValue_direct,jh.prototype._getValue_array,jh.prototype._getValue_arrayElement,jh.prototype._getValue_toArray],jh.prototype.SetterByBindingTypeAndVersioning=[[jh.prototype._setValue_direct,jh.prototype._setValue_direct_setNeedsUpdate,jh.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[jh.prototype._setValue_array,jh.prototype._setValue_array_setNeedsUpdate,jh.prototype._setValue_array_setMatrixWorldNeedsUpdate],[jh.prototype._setValue_arrayElement,jh.prototype._setValue_arrayElement_setNeedsUpdate,jh.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[jh.prototype._setValue_fromArray,jh.prototype._setValue_fromArray_setNeedsUpdate,jh.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Yh{constructor(t,e,i=0,n=1/0){this.ray=new ii(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new fi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,i=[]){return Kh(t,this,i,e),i.sort(qh),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;n<r;n++)Kh(t[n],this,i,e);return i.sort(qh),i}}function qh(t,e){return t.distance-e.distance}function Kh(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)Kh(n[t],e,i,!0)}}class Zh{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(jt(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:h}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=h);class Jh{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new ee);if(0!==this.downPosition.distanceTo(e))return;const i=this.getPointerIntersects(e);this.clearSelection(),i.length>0&&this.select(i[0].object),this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.optionsChange=()=>{const{facesColor:t,facesTransparancy:e}=this.viewer.options;this.facesMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.facesMaterial.opacity=(255-e)/255,this.viewer.update()},this.viewer=t,this.raycaster=new Yh,this.downPosition=new ee;const{facesColor:e,facesTransparancy:i}=this.viewer.options;this.facesMaterial=new Ki,this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-i)/255,this.facesMaterial.transparent=!0,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("optionschange",this.optionsChange)}dispose(){this.facesMaterial.dispose(),this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("optionschange",this.optionsChange)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t){const e=this.viewer.canvas.getBoundingClientRect(),i=(t.x-e.left)/e.width*2-1,n=-(t.y-e.top)/e.height*2+1,r=new ee(i,n);this.raycaster.setFromCamera(r,this.viewer.camera);const a=[];return this.viewer.scene.traverseVisible((t=>a.push(t))),this.raycaster.intersectObjects(a,!1)}select(t){t.isSelected||(t.isSelected=!0,t.originalMaterial=t.material,t.material=this.facesMaterial,this.viewer.selected.push(t))}clearSelection(){this.viewer.selected.forEach((t=>{t.isSelected=!1,t.material=t.originalMaterial})),this.viewer.selected.length=0}}function Qh(t,e){let i=e;return t.children.forEach((t=>{const n=Qh(t,e+1);i<n&&(i=n)})),t.originalPosition=t.position.clone(),i}function $h(t,e=0){e/=100,t.maxDepth||(t.maxDepth=Qh(t,1));const i=t.maxDepth;let n=e*(i-1)+1;1===i&&(n=1);!function t(i,r,a,s){const o=(new Pe).setFromObject(i).getCenter(new Ae),h=s.clone();if(r>0&&r<=n){const t=o.clone().sub(a).multiplyScalar(e);h.add(t)}i.children.forEach((e=>t(e,r+1,o,h)));const l=i.originalPosition;if(i.position.copy(l),e>0){const t=o.sub(a).normalize();i.position.add(t.add(h))}}(t,0,(new Pe).setFromObject(t).getCenter(new Ae),new Ae(0,0,0))}function tl(t,e=0){t.models.forEach((t=>$h(t.scene,e))),t.update(),t.emitEvent({type:"explode",data:e})}n("ThreeJS").registerCommand("clearSelected",(function(t){const e=new Jh(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),n("ThreeJS").registerCommandAlias("clearSelected","unselect"),n("ThreeJS").registerCommand("clearSlices",(t=>t.clearSlices())),n("ThreeJS").registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){return t.update(!0),t.canvas.toDataURL(e,i)})),n("ThreeJS").registerCommand("explode",tl),n("ThreeJS").registerCommand("collect",(t=>tl(t,0)));const el={top:new Ae(0,0,1),bottom:new Ae(0,0,-1),left:new Ae(-1,0,0),right:new Ae(1,0,0),front:new Ae(0,-1,0),back:new Ae(0,1,0),sw:new Ae(-.5,-.5,1).normalize(),se:new Ae(.5,-.5,1).normalize(),ne:new Ae(.5,.5,1).normalize(),nw:new Ae(-.5,.5,1).normalize()};function il(t,e){const i=el[e]||el.sw,n=t.extents.getCenter(new Ae),r=t.extents.getBoundingSphere(new qe),a=i.clone().multiplyScalar(r.radius),s=t.camera;s.position.copy(n).add(a),s.lookAt(n),s.updateProjectionMatrix(),s.updateMatrixWorld(),t.target.copy(n),t.update(),t.emit({type:"viewposition",data:e}),t.executeCommand("zoomToExtents")}function nl(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),i=t.getIndex()}const n=i.count-2,r=[];if(2===e)for(let t=1;t<=n;t++)r.push(i.getX(0)),r.push(i.getX(t)),r.push(i.getX(t+1));else for(let t=0;t<n;t++)t%2==0?(r.push(i.getX(t)),r.push(i.getX(t+1)),r.push(i.getX(t+2))):(r.push(i.getX(t+2)),r.push(i.getX(t+1)),r.push(i.getX(t)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=t.clone();return a.setIndex(r),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}n("ThreeJS").registerCommand("setDefaultViewPosition",il),n("ThreeJS").registerCommand("top",(t=>il(t,"top"))),n("ThreeJS").registerCommand("bottom",(t=>il(t,"bottom"))),n("ThreeJS").registerCommand("left",(t=>il(t,"left"))),n("ThreeJS").registerCommand("right",(t=>il(t,"right"))),n("ThreeJS").registerCommand("front",(t=>il(t,"front"))),n("ThreeJS").registerCommand("back",(t=>il(t,"back"))),n("ThreeJS").registerCommand("sw",(t=>il(t,"sw"))),n("ThreeJS").registerCommand("se",(t=>il(t,"se"))),n("ThreeJS").registerCommand("ne",(t=>il(t,"ne"))),n("ThreeJS").registerCommand("nw",(t=>il(t,"nw"))),n("ThreeJS").registerCommandAlias("top","k3DViewTop"),n("ThreeJS").registerCommandAlias("bottom","k3DViewBottom"),n("ThreeJS").registerCommandAlias("left","k3DViewLeft"),n("ThreeJS").registerCommandAlias("right","k3DViewRight"),n("ThreeJS").registerCommandAlias("front","k3DViewFront"),n("ThreeJS").registerCommandAlias("back","k3DViewBack"),n("ThreeJS").registerCommandAlias("se","k3DViewSE"),n("ThreeJS").registerCommandAlias("sw","k3DViewSW"),n("ThreeJS").registerCommandAlias("ne","k3DViewNE"),n("ThreeJS").registerCommandAlias("nw","k3DViewNW"),n("ThreeJS").registerCommand("getDefaultViewPositions",(function(){return Object.keys(el)})),n("ThreeJS").registerCommand("getModels",(function(t){return t.models.map((t=>t.userData.handle||"")).filter((t=>t))})),n("ThreeJS").registerCommand("getSelected",(function(t){return t.selected.map((t=>{var e;return null===(e=t.userData)||void 0===e?void 0:e.handle})).filter((t=>t))})),n("ThreeJS").registerCommand("hideSelected",(function(t){t.selected.forEach((t=>t.visible=!1));const e=new Jh(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),n("ThreeJS").registerCommand("isolateSelected",(function(t){const e=new Set(t.selected);!function t(i,n){let r=!0;return i.children.forEach((i=>{e.has(i)?r=!1:t(i,n+1)})),r&&n>0&&(i.visible=!1),r}(t.scene,0),t.update(),t.emitEvent({type:"isolate"})})),n("ThreeJS").registerCommand("regenerateAll",(function(t){console.warn("regenerateAll not implemented"),t.emit({type:"regenerateall"})})),n("ThreeJS").registerCommand("resetView",(function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"})})),n("ThreeJS").registerCommand("selectModel",(function(t,e){console.warn("selectModel not implemented"),t.emit({type:"select",data:[]})})),n("ThreeJS").registerCommand("setActiveDragger",((t,e="")=>{t.setActiveDragger(e)})),n("ThreeJS").registerCommand("setMarkupColor",((t,e=255,i=0,n=0)=>{console.warn("setMarkupColor not implemented")})),n("ThreeJS").registerCommand("setSelected",(function(t,e=[]){const i=new Set(e),n=[];t.scene.traverseVisible((t=>{var e;i.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&n.push(t)}));const r=new Jh(t);r.clearSelection(),n.forEach((t=>r.select(t))),r.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:e})})),n("ThreeJS").registerCommand("showAll",(function(t){t.scene.traverse((t=>t.visible=!0)),t.update(),t.emitEvent({type:"showall"})})),n("ThreeJS").registerCommand("zoomToExtents",(function(t){if(t.extents.isEmpty())return;const e=t.extents.getCenter(new Ae),i=t.extents.getBoundingSphere(new qe).radius,n=new Ae(0,0,1);n.applyQuaternion(t.camera.quaternion),n.multiplyScalar(3*i),t.camera.position.copy(e).add(n),t.target.copy(e),t.update(),t.emitEvent({type:"zoom"})})),n("ThreeJS").registerCommandAlias("zoomToExtents","zoomExtents"),n("ThreeJS").registerCommand("zoomToObjects",(function(t,e=[]){const i=new Set(e),n=[];t.scene.traverseVisible((t=>{var e;i.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&n.push(t)}));const r=n.reduce(((t,e)=>{const i=(new Pe).setFromObject(e);return t.isEmpty()?t.copy(i):t.union(i)}),new Pe),a=r.getCenter(new Ae),s=r.getBoundingSphere(new qe).radius,o=new Ae(0,0,1);o.applyQuaternion(t.camera.quaternion),o.multiplyScalar(3*s),t.camera.position.copy(a).add(o),t.target.copy(a),t.update(),t.emitEvent({type:"zoom"})})),n("ThreeJS").registerCommand("zoomToSelected",(function(t){const e=t.selected.reduce(((t,e)=>{const i=(new Pe).setFromObject(e);return t.isEmpty()?t.copy(i):t.union(i)}),new Pe);e.isEmpty()&&e.copy(t.extents);const i=e.getCenter(new Ae),n=e.getBoundingSphere(new qe).radius,r=new Ae(0,0,1);r.applyQuaternion(t.camera.quaternion),r.multiplyScalar(3*n),t.camera.position.copy(i).add(r),t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}));class rl extends mh{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new cl(t)})),this.register((function(t){return new _l(t)})),this.register((function(t){return new yl(t)})),this.register((function(t){return new xl(t)})),this.register((function(t){return new ul(t)})),this.register((function(t){return new pl(t)})),this.register((function(t){return new fl(t)})),this.register((function(t){return new ml(t)})),this.register((function(t){return new ll(t)})),this.register((function(t){return new gl(t)})),this.register((function(t){return new dl(t)})),this.register((function(t){return new vl(t)})),this.register((function(t){return new ol(t)})),this.register((function(t){return new Sl(t)})),this.register((function(t){return new Ml(t)}))}load(t,e,i,n){const r=this;let a;a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Oh.extractUrlBase(t),this.manager.itemStart(t);const s=function(e){n?n(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new _h(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{r.parse(i,a,(function(i){e(i),r.manager.itemEnd(t)}),s)}catch(t){s(t)}}),i,s)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,i,n){let r;const a={},s={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===bl){try{a[sl.KHR_BINARY_GLTF]=new Tl(t)}catch(t){return void(n&&n(t))}r=JSON.parse(a[sl.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new Jl(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](h);s[e.name]=e,a[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],i=r.extensionsRequired||[];switch(e){case sl.KHR_MATERIALS_UNLIT:a[e]=new hl;break;case sl.KHR_DRACO_MESH_COMPRESSION:a[e]=new Al(r,this.dracoLoader);break;case sl.KHR_TEXTURE_TRANSFORM:a[e]=new Cl;break;case sl.KHR_MESH_QUANTIZATION:a[e]=new Rl;break;default:i.indexOf(e)>=0&&void 0===s[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}h.setExtensions(a),h.setPlugins(s),h.parse(i,n)}parseAsync(t,e){const i=this;return new Promise((function(n,r){i.parse(t,e,n,r)}))}}function al(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const sl={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 ol{constructor(t){this.parser=t,this.name=sl.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const e=this.parser,i="light:"+t;let n=e.cache.get(i);if(n)return n;const r=e.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let s;const o=new Yi(16777215);void 0!==a.color&&o.fromArray(a.color);const h=void 0!==a.range?a.range:0;switch(a.type){case"directional":s=new Uh(o),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new Ih(o),s.distance=h;break;case"spot":s=new Ah(o),s.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,s.angle=a.spot.outerConeAngle,s.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return s.position.set(0,0,0),s.decay=2,Xl(s,a),void 0!==a.intensity&&(s.intensity=a.intensity),s.name=e.createUniqueName(a.name||"light_"+t),n=Promise.resolve(s),e.cache.add(i,n),n}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,i=this.parser,n=i.json.nodes[t],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return i._getNodeRef(e.cache,r,t)}))}}class hl{constructor(){this.name=sl.KHR_MATERIALS_UNLIT}getMaterialType(){return Ki}extendParams(t,e,i){const n=[];t.color=new Yi(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(t,"map",r.baseColorTexture,bt))}return Promise.all(n)}}class ll{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(e.emissiveIntensity=n),Promise.resolve()}}class cl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];if(void 0!==a.clearcoatFactor&&(e.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&r.push(i.assignTexture(e,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(e.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(r.push(i.assignTexture(e,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){const t=a.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new ee(t,t)}return Promise.all(r)}}class dl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.iridescenceFactor&&(e.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&r.push(i.assignTexture(e,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(e.iridescenceIOR=a.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&r.push(i.assignTexture(e,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class ul{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Yi(0,0,0),e.sheenRoughness=0,e.sheen=1;const a=n.extensions[this.name];return void 0!==a.sheenColorFactor&&e.sheenColor.fromArray(a.sheenColorFactor),void 0!==a.sheenRoughnessFactor&&(e.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&r.push(i.assignTexture(e,"sheenColorMap",a.sheenColorTexture,bt)),void 0!==a.sheenRoughnessTexture&&r.push(i.assignTexture(e,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class pl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.transmissionFactor&&(e.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&r.push(i.assignTexture(e,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class fl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];e.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&r.push(i.assignTexture(e,"thicknessMap",a.thicknessTexture)),e.attenuationDistance=a.attenuationDistance||1/0;const s=a.attenuationColor||[1,1,1];return e.attenuationColor=new Yi(s[0],s[1],s[2]),Promise.all(r)}}class ml{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class gl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];e.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&r.push(i.assignTexture(e,"specularIntensityMap",a.specularTexture));const s=a.specularColorFactor||[1,1,1];return e.specularColor=new Yi(s[0],s[1],s[2]),void 0!==a.specularColorTexture&&r.push(i.assignTexture(e,"specularColorMap",a.specularColorTexture,bt)),Promise.all(r)}}class vl{constructor(t){this.parser=t,this.name=sl.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Xo:null}extendMaterialParams(t,e){const i=this.parser,n=i.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.anisotropyStrength&&(e.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(e.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&r.push(i.assignTexture(e,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class _l{constructor(t){this.parser=t,this.name=sl.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,i=e.json,n=i.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],a=e.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,a)}}class yl{constructor(t){this.parser=t,this.name=sl.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const a=r.extensions[e],s=n.images[a.source];let o=i.textureLoader;if(s.uri){const t=i.options.manager.getHandler(s.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,a.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class xl{constructor(t){this.parser=t,this.name=sl.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const a=r.extensions[e],s=n.images[a.source];let o=i.textureLoader;if(s.uri){const t=i.options.manager.getHandler(s.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,a.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Sl{constructor(t){this.name=sl.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(e){const i=t.byteOffset||0,n=t.byteLength||0,a=t.count,s=t.byteStride,o=new Uint8Array(e,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(e),a,s,o,t.mode,t.filter),e}))}))}return null}}class Ml{constructor(t){this.name=sl.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=e.meshes[i.mesh];for(const t of n.primitives)if(t.mode!==Dl.TRIANGLES&&t.mode!==Dl.TRIANGLE_STRIP&&t.mode!==Dl.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=i.extensions[this.name].attributes,a=[],s={};for(const t in r)a.push(this.parser.getDependency("accessor",r[t]).then((e=>(s[t]=e,s[t]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then((t=>{const e=t.pop(),i=e.isGroup?e.children:[e],n=t[0].count,r=[];for(const t of i){const e=new ni,i=new Ae,a=new Te,o=new Ae(1,1,1),h=new yo(t.geometry,t.material,n);for(let t=0;t<n;t++)s.TRANSLATION&&i.fromBufferAttribute(s.TRANSLATION,t),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,t),s.SCALE&&o.fromBufferAttribute(s.SCALE,t),h.setMatrixAt(t,e.compose(i,a,o));for(const e in s)"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,s[e]);Ci.prototype.copy.call(h,t),this.parser.assignFinalMaterial(h),r.push(h)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const bl="glTF",wl=1313821514,El=5130562;class Tl{constructor(t){this.name=sl.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==bl)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let a=0;for(;a<n;){const e=r.getUint32(a,!0);a+=4;const n=r.getUint32(a,!0);if(a+=4,n===wl){const n=new Uint8Array(t,12+a,e);this.content=i.decode(n)}else if(n===El){const i=12+a;this.body=t.slice(i,i+e)}a+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Al{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=sl.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,a=t.extensions[this.name].attributes,s={},o={},h={};for(const t in a){const e=kl[t]||t.toLowerCase();s[e]=a[t]}for(const e in t.attributes){const n=kl[e]||e.toLowerCase();if(void 0!==a[e]){const r=i.accessors[t.attributes[e]],a=Ul[r.componentType];h[n]=a.name,o[n]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e){n.decodeDracoFile(t,(function(t){for(const e in t.attributes){const i=t.attributes[e],n=o[e];void 0!==n&&(i.normalized=n)}e(t)}),s,h)}))}))}}class Cl{constructor(){this.name=sl.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Rl{constructor(){this.name=sl.KHR_MESH_QUANTIZATION}}class Pl extends Qo{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let t=0;t!==n;t++)e[t]=i[r+t];return e}interpolate_(t,e,i,n){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=2*s,h=3*s,l=n-e,c=(i-e)/l,d=c*c,u=d*c,p=t*h,f=p-h,m=-2*u+3*d,g=u-d,v=1-m,_=g-d+c;for(let t=0;t!==s;t++){const e=a[f+t+s],i=a[f+t+o]*l,n=a[p+t+s],h=a[p+t]*l;r[t]=v*e+_*i+m*n+g*h}return r}}const Ll=new Te;class Il extends Pl{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return Ll.fromArray(r).normalize().toArray(r),r}}const Dl={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ul={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Nl={9728:J,9729:tt,9984:Q,9985:1007,9986:$,9987:it},Ol={33071:K,33648:Z,10497:q},Fl={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},kl={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Bl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zl={CUBICSPLINE:void 0,LINEAR:yt,STEP:_t},Gl="OPAQUE",Hl="MASK",Vl="BLEND";function Wl(t,e,i){for(const n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function Xl(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function jl(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,n=e.weights.length;i<n;i++)t.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(t.morphTargetInfluences.length===i.length){t.morphTargetDictionary={};for(let e=0,n=i.length;e<n;e++)t.morphTargetDictionary[i[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Yl(t){let e;const i=t.extensions&&t.extensions[sl.KHR_DRACO_MESH_COMPRESSION];if(e=i?"draco:"+i.bufferView+":"+i.indices+":"+ql(i.attributes):t.indices+":"+ql(t.attributes)+":"+t.mode,void 0!==t.targets)for(let i=0,n=t.targets.length;i<n;i++)e+=":"+ql(t.targets[i]);return e}function ql(t){let e="";const i=Object.keys(t).sort();for(let n=0,r=i.length;n<r;n++)e+=i[n]+":"+t[i[n]]+";";return e}function Kl(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Zl=new ni;class Jl{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new al,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=!1,r=-1;"undefined"!=typeof navigator&&(i=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||i||n&&r<98?this.textureLoader=new xh(this.options.manager):this.textureLoader=new Fh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _h(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(e){const a={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};Wl(r,a,n),Xl(a,n),Promise.all(i._invokeAll((function(t){return t.afterRoot&&t.afterRoot(a)}))).then((function(){t(a)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i].joints;for(let e=0,i=n.length;e<i;e++)t[n[e]].isBone=!0}for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,i){if(t.refs[e]<=1)return i;const n=i.clone(),r=(t,e)=>{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,n]of t.children.entries())r(n,e.children[i])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i<e.length;i++){const n=t(e[i]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const i=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&i.push(r)}return i}getDependency(t,e){const i=t+":"+e;let n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":n=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":n=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)})),!n)throw new Error("Unknown type: "+t)}this.cache.add(i,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const i=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map((function(e,n){return i.getDependency(t,n)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],i=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[sl.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(t,r){i.load(Oh.resolveURL(e.uri,n.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const i=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+i)}))}loadAccessor(t){const e=this,i=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=Fl[n.type],e=Ul[n.componentType],i=!0===n.normalized,r=new e(n.count*t);return Promise.resolve(new Qi(r,t,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],a=Fl[n.type],s=Ul[n.componentType],o=s.BYTES_PER_ELEMENT,h=o*a,l=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let u,p;if(c&&c!==h){const t=Math.floor(l/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let h=e.cache.get(i);h||(u=new s(r,t*c,n.count*c/o),h=new Ps(u,c/o),e.cache.add(i,h)),p=new Is(h,a,l%c/o,d)}else u=null===r?new s(n.count*a):new s(r,l,n.count*a),p=new Qi(u,a,d);if(void 0!==n.sparse){const e=Fl.SCALAR,i=Ul[n.sparse.indices.componentType],o=n.sparse.indices.byteOffset||0,h=n.sparse.values.byteOffset||0,l=new i(t[1],o,n.sparse.count*e),c=new s(t[2],h,n.sparse.count*a);null!==r&&(p=new Qi(p.array.slice(),p.itemSize,p.normalized));for(let t=0,e=l.length;t<e;t++){const e=l[t];if(p.setX(e,c[t*a]),a>=2&&p.setY(e,c[t*a+1]),a>=3&&p.setZ(e,c[t*a+2]),a>=4&&p.setW(e,c[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t].source,r=e.images[n];let a=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(a=t)}return this.loadTextureImage(t,n,a)}loadTextureImage(t,e,i){const n=this,r=this.json,a=r.textures[t],s=r.images[e],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const h=this.loadImageSource(e,i).then((function(e){e.flipY=!1,e.name=a.name||s.name||"",""===e.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(e.name=s.uri);const i=(r.samplers||{})[a.sampler]||{};return e.magFilter=Nl[i.magFilter]||tt,e.minFilter=Nl[i.minFilter]||it,e.wrapS=Ol[i.wrapS]||q,e.wrapT=Ol[i.wrapT]||q,n.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=h,h}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const a=n.images[t],s=self.URL||self.webkitURL;let o=a.uri||"",h=!1;if(void 0!==a.bufferView)o=i.getDependency("bufferView",a.bufferView).then((function(t){h=!0;const e=new Blob([t],{type:a.mimeType});return o=s.createObjectURL(e),o}));else if(void 0===a.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then((function(t){return new Promise((function(i,n){let a=i;!0===e.isImageBitmapLoader&&(a=function(t){const e=new Se(t);e.needsUpdate=!0,i(e)}),e.load(Oh.resolveURL(t,r.path),a,void 0,n)}))})).then((function(t){var e;return!0===h&&s.revokeObjectURL(o),t.userData.mimeType=a.mimeType||((e=a.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then((function(a){if(!a)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((a=a.clone()).channel=i.texCoord),r.extensions[sl.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[sl.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(a);a=r.extensions[sl.KHR_TEXTURE_TRANSFORM].extendTexture(a,t),r.associations.set(a,e)}}return void 0!==n&&(a.colorSpace=n),t[e]=a,a}))}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new Lo,Hi.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new xo,Hi.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,this.cache.add(t,e)),i=e}if(n||r||a){let t="ClonedMaterial:"+i.uuid+":";n&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),r&&(e.vertexColors=!0),a&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}t.material=i}getMaterialType(){return Wo}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let a;const s={},o=[];if((r.extensions||{})[sl.KHR_MATERIALS_UNLIT]){const t=n[sl.KHR_MATERIALS_UNLIT];a=t.getMaterialType(),o.push(t.extendParams(s,r,e))}else{const i=r.pbrMetallicRoughness||{};if(s.color=new Yi(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;s.color.fromArray(t),s.opacity=t[3]}void 0!==i.baseColorTexture&&o.push(e.assignTexture(s,"map",i.baseColorTexture,bt)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(e.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),o.push(e.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,s)}))))}!0===r.doubleSided&&(s.side=2);const h=r.alphaMode||Gl;if(h===Vl?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,h===Hl&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==Ki&&(o.push(e.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new ee(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;s.normalScale.set(t,t)}return void 0!==r.occlusionTexture&&a!==Ki&&(o.push(e.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==Ki&&(s.emissive=(new Yi).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&a!==Ki&&o.push(e.assignTexture(s,"emissiveMap",r.emissiveTexture,bt)),Promise.all(o).then((function(){const i=new a(s);return r.name&&(i.name=r.name),Xl(i,r),e.associations.set(i,{materials:t}),r.extensions&&Wl(n,i,r),i}))}createUniqueName(t){const e=jh.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[sl.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return Ql(i,t,e)}))}const a=[];for(let i=0,s=t.length;i<s;i++){const s=t[i],o=Yl(s),h=n[o];if(h)a.push(h.promise);else{let t;t=s.extensions&&s.extensions[sl.KHR_DRACO_MESH_COMPRESSION]?r(s):Ql(new cn,s,e),n[o]={primitive:s,promise:t},a.push(t)}}return Promise.all(a)}loadMesh(t){const e=this,i=this.json,n=this.extensions,r=i.meshes[t],a=r.primitives,s=[];for(let t=0,e=a.length;t<e;t++){const e=void 0===a[t].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new Wo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:y})),o.DefaultMaterial):this.getDependency("material",a[t].material);s.push(e)}var o;return s.push(e.loadGeometries(a)),Promise.all(s).then((function(i){const s=i.slice(0,i.length-1),o=i[i.length-1],h=[];for(let i=0,l=o.length;i<l;i++){const l=o[i],c=a[i];let d;const u=s[i];if(c.mode===Dl.TRIANGLES||c.mode===Dl.TRIANGLE_STRIP||c.mode===Dl.TRIANGLE_FAN||void 0===c.mode)d=!0===r.isSkinnedMesh?new ro(l,u):new Cn(l,u),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),c.mode===Dl.TRIANGLE_STRIP?d.geometry=nl(d.geometry,1):c.mode===Dl.TRIANGLE_FAN&&(d.geometry=nl(d.geometry,2));else if(c.mode===Dl.LINES)d=new Ro(l,u);else if(c.mode===Dl.LINE_STRIP)d=new To(l,u);else if(c.mode===Dl.LINE_LOOP)d=new Po(l,u);else{if(c.mode!==Dl.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);d=new Oo(l,u)}Object.keys(d.geometry.morphAttributes).length>0&&jl(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),Xl(d,r),c.extensions&&Wl(n,d,c),e.assignFinalMaterial(d),h.push(d)}for(let i=0,n=h.length;i<n;i++)e.associations.set(h[i],{meshes:t,primitives:i});if(1===h.length)return r.extensions&&Wl(n,h[0],r),h[0];const l=new xs;r.extensions&&Wl(n,l,r),e.associations.set(l,{meshes:t});for(let t=0,e=h.length;t<e;t++)l.add(h[t]);return l}))}loadCamera(t){let e;const i=this.json.cameras[t],n=i[i.type];if(n)return"perspective"===i.type?e=new Fn(te.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(e=new hr(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(e.name=this.createUniqueName(i.name)),Xl(e,i),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],i=[];for(let t=0,n=e.joints.length;t<n;t++)i.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?i.push(this.getDependency("accessor",e.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(t){const i=t.pop(),n=t,r=[],a=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];if(s){r.push(s);const e=new ni;null!==i&&e.fromArray(i.array,16*t),a.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new lo(r,a)}))}loadAnimation(t){const e=this.json.animations[t],i=e.name?e.name:"animation_"+t,n=[],r=[],a=[],s=[],o=[];for(let t=0,i=e.channels.length;t<i;t++){const i=e.channels[t],h=e.samplers[i.sampler],l=i.target,c=l.node,d=void 0!==e.parameters?e.parameters[h.input]:h.input,u=void 0!==e.parameters?e.parameters[h.output]:h.output;void 0!==l.node&&(n.push(this.getDependency("node",c)),r.push(this.getDependency("accessor",d)),a.push(this.getDependency("accessor",u)),s.push(h),o.push(l))}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(a),Promise.all(s),Promise.all(o)]).then((function(t){const e=t[0],n=t[1],r=t[2],a=t[3],s=t[4],o=[];for(let t=0,i=e.length;t<i;t++){const i=e[t],h=n[t],l=r[t],c=a[t],d=s[t];if(void 0===i)continue;let u;switch(i.updateMatrix(),Bl[d.path]){case Bl.weights:u=ah;break;case Bl.rotation:u=oh;break;default:u=lh}const p=i.name?i.name:i.uuid,f=void 0!==c.interpolation?zl[c.interpolation]:yt,m=[];Bl[d.path]===Bl.weights?i.traverse((function(t){t.morphTargetInfluences&&m.push(t.name?t.name:t.uuid)})):m.push(p);let g=l.array;if(l.normalized){const t=Kl(g.constructor),e=new Float32Array(g.length);for(let i=0,n=g.length;i<n;i++)e[i]=g[i]*t;g=e}for(let t=0,e=m.length;t<e;t++){const e=new u(m[t]+"."+Bl[d.path],h.array,g,f);"CUBICSPLINE"===c.interpolation&&(e.createInterpolant=function(t){return new(this instanceof oh?Il:Pl)(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),o.push(e)}}return new ch(i,void 0,o)}))}createNodeMesh(t){const e=this.json,i=this,n=e.nodes[t];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(t){const e=i._getNodeRef(i.meshCache,n.mesh,t);return void 0!==n.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,i=n.weights.length;e<i;e++)t.morphTargetInfluences[e]=n.weights[e]})),e}))}loadNode(t){const e=this,i=this.json.nodes[t],n=e._loadNodeShallow(t),r=[],a=i.children||[];for(let t=0,i=a.length;t<i;t++)r.push(e.getDependency("node",a[t]));const s=void 0===i.skin?Promise.resolve(null):e.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),s]).then((function(t){const e=t[0],i=t[1],n=t[2];null!==n&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(n,Zl)}));for(let t=0,n=i.length;t<n;t++)e.add(i[t]);return e}))}_loadNodeShallow(t){const e=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],a=r.name?n.createUniqueName(r.name):"",s=[],o=n._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return o&&s.push(o),void 0!==r.camera&&s.push(n.getDependency("camera",r.camera).then((function(t){return n._getNodeRef(n.cameraCache,r.camera,t)}))),n._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){s.push(t)})),this.nodeCache[t]=Promise.all(s).then((function(e){let s;if(s=!0===r.isBone?new ao:e.length>1?new xs:1===e.length?e[0]:new Ci,s!==e[0])for(let t=0,i=e.length;t<i;t++)s.add(e[t]);if(r.name&&(s.userData.name=r.name,s.name=a),Xl(s,r),r.extensions&&Wl(i,s,r),void 0!==r.matrix){const t=new ni;t.fromArray(r.matrix),s.applyMatrix4(t)}else void 0!==r.translation&&s.position.fromArray(r.translation),void 0!==r.rotation&&s.quaternion.fromArray(r.rotation),void 0!==r.scale&&s.scale.fromArray(r.scale);return n.associations.has(s)||n.associations.set(s,{}),n.associations.get(s).nodes=t,s})),this.nodeCache[t]}loadScene(t){const e=this.extensions,i=this.json.scenes[t],n=this,r=new xs;i.name&&(r.name=n.createUniqueName(i.name)),Xl(r,i),i.extensions&&Wl(e,r,i);const a=i.nodes||[],s=[];for(let t=0,e=a.length;t<e;t++)s.push(n.getDependency("node",a[t]));return Promise.all(s).then((function(t){for(let e=0,i=t.length;e<i;e++)r.add(t[e]);return n.associations=(t=>{const e=new Map;for(const[t,i]of n.associations)(t instanceof Hi||t instanceof Se)&&e.set(t,i);return t.traverse((t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)})),e})(r),r}))}}function Ql(t,e,i){const n=e.attributes,r=[];function a(e,n){return i.getDependency("accessor",e).then((function(e){t.setAttribute(n,e)}))}for(const e in n){const i=kl[e]||e.toLowerCase();i in t.attributes||r.push(a(n[e],i))}if(void 0!==e.indices&&!t.index){const n=i.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(n)}return Xl(t,e),function(t,e,i){const n=e.attributes,r=new Pe;if(void 0===n.POSITION)return;{const t=i.json.accessors[n.POSITION],e=t.min,a=t.max;if(void 0===e||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Ae(e[0],e[1],e[2]),new Ae(a[0],a[1],a[2])),t.normalized){const e=Kl(Ul[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const a=e.targets;if(void 0!==a){const t=new Ae,e=new Ae;for(let n=0,r=a.length;n<r;n++){const r=a[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],a=n.min,s=n.max;if(void 0!==a&&void 0!==s){if(e.setX(Math.max(Math.abs(a[0]),Math.abs(s[0]))),e.setY(Math.max(Math.abs(a[1]),Math.abs(s[1]))),e.setZ(Math.max(Math.abs(a[2]),Math.abs(s[2]))),n.normalized){const t=Kl(Ul[n.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const s=new qe;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=s}(t,e,i),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,i){let n=!1,r=!1,a=!1;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(a=!0),n&&r&&a)break}if(!n&&!r&&!a)return Promise.resolve(t);const s=[],o=[],h=[];for(let l=0,c=e.length;l<c;l++){const c=e[l];if(n){const e=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):t.attributes.position;s.push(e)}if(r){const e=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(a){const e=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):t.attributes.color;h.push(e)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(h)]).then((function(e){const i=e[0],s=e[1],o=e[2];return n&&(t.morphAttributes.position=i),r&&(t.morphAttributes.normal=s),a&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,i):t}))}class $l extends ph{constructor(t,e=new Map,i={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=i.path||"","string"==typeof t?(this.fileURL=t,this.resourcePath=Oh.extractUrlBase(t)):(e.forEach(((e,i)=>this.fileURL=e===t?i:this.fileURL)),e.set(this.fileURL,t)),e.forEach(((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)})),this.setURLModifier((t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class tc{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}var ec="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ic(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nc={exports:{}},rc={},ac={},sc={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==ec?ec:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.14",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(sc);var oc={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=sc;class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){var e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,a=this.m[0]*-i+this.m[2]*e,s=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=a,this.m[3]=s,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){var i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=a,this}multiply(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],a=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],s=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=a,this.m[5]=s,this}invert(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,a=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),s=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=a,this.m[5]=s,this}getMatrix(){return this.m}decompose(){var e=this.m[0],i=this.m[1],n=this.m[2],r=this.m[3],a=e*r-i*n;let s={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var o=Math.sqrt(e*e+i*i);s.rotation=i>0?Math.acos(e/o):-Math.acos(e/o),s.scaleX=o,s.scaleY=a/o,s.skewX=(e*n+i*r)/a,s.skewY=0}else if(0!=n||0!=r){var h=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/h):-Math.acos(n/h)),s.scaleX=a/h,s.scaleY=h,s.skewX=0,s.skewY=(e*n+i*r)/a}return s.rotation=t.Util._getRotation(s.rotation),s}}t.Transform=i;var n=Math.PI/180,r=180/Math.PI,a="Konva error: ",s={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){var n=t.Util.createImageElement();n.onload=function(){i(n)},n.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){for(var t=(16777215*Math.random()|0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB(t){var e;return t in s?{r:(e=s[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){var e=s[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){var e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,r=Number(i[1])/100,a=Number(i[2])/100;let s,o,h;if(0===r)return h=255*a,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};s=a<.5?a*(1+r):a+r-a*r;const l=2*a-s,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(s-l)*o:2*o<1?s:3*o<2?l+(s-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){var e={};for(var i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*n,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(a+t)},error(t){console.error(a+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(var i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,r,a){var s,o,h,l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)s=t,o=e,h=(r-i)*(r-i)+(a-n)*(a-n);else{var c=((r-t)*(i-t)+(a-e)*(n-e))/l;c<0?(s=t,o=e,h=(t-r)*(t-r)+(e-a)*(e-a)):c>1?(s=i,o=n,h=(i-r)*(i-r)+(n-a)*(n-a)):h=((s=t+c*(i-t))-r)*(s-r)+((o=e+c*(n-e))-a)*(o-a)}return[s,o,h]},_getProjectionToLine(e,i,n){var r=t.Util.cloneObject(e),a=Number.MAX_VALUE;return i.forEach((function(s,o){if(n||o!==i.length-1){var h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(s.x,s.y,h.x,h.y,e.x,e.y),c=l[0],d=l[1],u=l[2];u<a&&(r.x=c,r.y=d,a=u)}})),r},_prepareArrayForTween(e,i,n){var r,a=[],s=[];if(e.length>i.length){var o=i;i=e,e=o}for(r=0;r<e.length;r+=2)a.push({x:e[r],y:e[r+1]});for(r=0;r<i.length;r+=2)s.push({x:i[r],y:i[r+1]});var h=[];return s.forEach((function(e){var i=t.Util._getProjectionToLine(e,a,n);h.push(i.x),h.push(i.y)})),h},_prepareToStringify(e){var i;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(i=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||t.Util._isElement(e[n])){if(!i.configurable)return null;delete e[n]}else if(null===t.Util._prepareToStringify(e[n])){if(!i.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,n){let r=0,a=0,s=0,o=0;"number"==typeof n?r=a=s=o=Math.min(n,e/2,i/2):(r=Math.min(n[0]||0,e/2,i/2),a=Math.min(n[1]||0,e/2,i/2),o=Math.min(n[2]||0,e/2,i/2),s=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(s,i),t.arc(s,i-s,s,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(oc);var hc={},lc={},cc={};Object.defineProperty(cc,"__esModule",{value:!0}),cc.getComponentValidator=cc.getBooleanValidator=cc.getNumberArrayValidator=cc.getFunctionValidator=cc.getStringOrGradientValidator=cc.getStringValidator=cc.getNumberOrAutoValidator=cc.getNumberOrArrayOfNumbersValidator=cc.getNumberValidator=cc.alphaComponent=cc.RGBComponent=void 0;const dc=sc,uc=oc;function pc(t){return uc.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||uc.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}cc.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},cc.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},cc.getNumberValidator=function(){if(dc.Konva.isUnminified)return function(t,e){return uc.Util._isNumber(t)||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},cc.getNumberOrArrayOfNumbersValidator=function(t){if(dc.Konva.isUnminified)return function(e,i){let n=uc.Util._isNumber(e),r=uc.Util._isArray(e)&&e.length==t;return n||r||uc.Util.warn(pc(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},cc.getNumberOrAutoValidator=function(){if(dc.Konva.isUnminified)return function(t,e){return uc.Util._isNumber(t)||"auto"===t||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},cc.getStringValidator=function(){if(dc.Konva.isUnminified)return function(t,e){return uc.Util._isString(t)||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},cc.getStringOrGradientValidator=function(){if(dc.Konva.isUnminified)return function(t,e){const i=uc.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},cc.getFunctionValidator=function(){if(dc.Konva.isUnminified)return function(t,e){return uc.Util._isFunction(t)||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},cc.getNumberArrayValidator=function(){if(dc.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(uc.Util._isArray(t)?t.forEach((function(t){uc.Util._isNumber(t)||uc.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},cc.getBooleanValidator=function(){if(dc.Konva.isUnminified)return function(t,e){return!0===t||!1===t||uc.Util.warn(pc(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},cc.getComponentValidator=function(t){if(dc.Konva.isUnminified)return function(e,i){return null==e||uc.Util.isObject(e)||uc.Util.warn(pc(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=oc,i=cc;var n="get",r="set";t.Factory={addGetterSetter(e,i,n,r,a){t.Factory.addGetter(e,i,n),t.Factory.addSetter(e,i,r,a),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,r){var a=n+e.Util._capitalize(i);t.prototype[a]=t.prototype[a]||function(){var t=this.attrs[i];return void 0===t?r:t}},addSetter(i,n,a,s){var o=r+e.Util._capitalize(n);i.prototype[o]||t.Factory.overWriteSetter(i,n,a,s)},overWriteSetter(t,i,n,a){var s=r+e.Util._capitalize(i);t.prototype[s]=function(t){return n&&null!=t&&(t=n.call(this,t,i)),this._setAttr(i,t),a&&a.call(this),this}},addComponentsGetterSetter(a,s,o,h,l){var c,d,u=o.length,p=e.Util._capitalize,f=n+p(s),m=r+p(s);a.prototype[f]=function(){var t={};for(c=0;c<u;c++)t[d=o[c]]=this.getAttr(s+p(d));return t};var g=(0,i.getComponentValidator)(o);a.prototype[m]=function(t){var e,i=this.attrs[s];for(e in h&&(t=h.call(this,t)),g&&g.call(this,t,s),t)t.hasOwnProperty(e)&&this._setAttr(s+p(e),t[e]);return t||o.forEach((t=>{this._setAttr(s+p(t),void 0)})),this._fireChangeEvent(s,i,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(a,s)},addOverloadedGetterSetter(t,i){var a=e.Util._capitalize(i),s=r+a,o=n+a;t.prototype[i]=function(){return arguments.length?(this[s](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,r,a,s){e.Util.error("Adding deprecated "+r);var o=n+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);var t=this.attrs[r];return void 0===t?a:t},t.Factory.addSetter(i,r,s,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,a){var s=t.prototype[a],o=n+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){s.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+a+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(lc);var fc={},mc={};Object.defineProperty(mc,"__esModule",{value:!0}),mc.HitContext=mc.SceneContext=mc.Context=void 0;const gc=oc,vc=sc;var _c=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class yc{constructor(t){this.canvas=t,vc.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){var i,n,r,a,s=this.traceArr,o=s.length,h="";for(i=0;i<o;i++)(r=(n=s[i]).method)?(a=n.args,h+=r,t?h+="()":gc.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}reset(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,r,a){this._context.arc(t,e,i,n,r,a)}arcTo(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,r,a){this._context.bezierCurveTo(t,e,i,n,r,a)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,r,a){return this._context.createRadialGradient(t,e,i,n,r,a)}drawImage(t,e,i,n,r,a,s,o,h){var l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,r):9===l.length&&c.drawImage(t,e,i,n,r,a,s,o,h)}ellipse(t,e,i,n,r,a,s,o){this._context.ellipse(t,e,i,n,r,a,s,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,r){this._context.roundRect(t,e,i,n,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,r,a){this._context.setTransform(t,e,i,n,r,a)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,r,a){this._context.transform(t,e,i,n,r,a)}translate(t,e){this._context.translate(t,e)}_enableTrace(){var t,e,i=this,n=_c.length,r=this.setAttr,a=function(t){var n,r=i[t];i[t]=function(){return e=function(t){var e,i,n=[],r=t.length,a=gc.Util;for(e=0;e<r;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),n.push(i);return n}(Array.prototype.slice.call(arguments,0)),n=r.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)a(_c[t]);i.setAttr=function(){r.apply(i,arguments);var t=arguments[0],e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}mc.Context=yc,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(yc.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));mc.SceneContext=class extends yc{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(var a=0;a<n.length;a+=2)r.addColorStop(n[a],n[a+1]);this.setAttr("strokeStyle",r)}}_stroke(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n,r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,s=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",a*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",s.x*l),this.setAttr("shadowOffsetY",s.y*c)}};mc.HitContext=class extends yc{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const r=t.getStrokeScaleEnabled();if(!r){this.save();var e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(t);var i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),r||this.restore()}}},Object.defineProperty(fc,"__esModule",{value:!0}),fc.HitCanvas=fc.SceneCanvas=fc.Canvas=void 0;const xc=oc,Sc=mc,Mc=sc,bc=lc,wc=cc;var Ec;class Tc{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||Mc.Konva.pixelRatio||function(){if(Ec)return Ec;var t=xc.Util.createCanvasElement(),e=t.getContext("2d");return Ec=(Mc.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),xc.Util.releaseCanvas(t),Ec}();this.pixelRatio=e,this._canvas=xc.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return xc.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}fc.Canvas=Tc,bc.Factory.addGetterSetter(Tc,"pixelRatio",void 0,(0,wc.getNumberValidator)());fc.SceneCanvas=class extends Tc{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new Sc.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};fc.HitCanvas=class extends Tc{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new Sc.HitContext(this),this.setSize(t.width,t.height)}};var Ac={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=sc,i=oc;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const n=[];t.DD._dragElements.forEach(((t,r)=>{const{node:a}=t,s=a.getStage();s.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=s._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){var h=a.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<h)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,t),n.push(a)}})),n.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const n=[];t.DD._dragElements.forEach((r=>{const{node:a}=r,s=a.getStage();i&&s.setPointersPositions(i);if(!s._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===n.indexOf(o)&&n.push(o)})),n.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,n)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(n)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1))}(Ac),Object.defineProperty(hc,"__esModule",{value:!0}),hc.Node=void 0;const Cc=oc,Rc=lc,Pc=fc,Lc=sc,Ic=Ac,Dc=cc;var Uc="absoluteOpacity",Nc="allEventListeners",Oc="absoluteTransform",Fc="absoluteScale",kc="canvas",Bc="listening",zc="mouseenter",Gc="mouseleave",Hc="Shape",Vc=" ",Wc="stage",Xc="transform",jc="visible",Yc=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Vc);let qc=1;class Kc{constructor(t){this._id=qc++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==Xc&&t!==Oc||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){var i=this._cache.get(t);return(void 0===i||(t===Xc||t===Oc)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(Vc);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(kc)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Oc&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(kc)){const{scene:t,filter:e,hit:i}=this._cache.get(kc);Cc.Util.releaseCanvas(t,e,i),this._cache.delete(kc)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var n=Math.ceil(e.width||i.width),r=Math.ceil(e.height||i.height),a=e.pixelRatio,s=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!r)return void Cc.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-s)>.5?1:0),r+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),s-=h,o-=h;var d=new Pc.SceneCanvas({pixelRatio:a,width:n,height:r}),u=new Pc.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),p=new Pc.HitCanvas({pixelRatio:c,width:n,height:r}),f=d.getContext(),m=p.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(kc),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),f.save(),m.save(),f.translate(-s,-o),m.translate(-s,-o),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Uc),this._clearSelfAndDescendantCache(Fc),this.drawScene(d,this),this.drawHit(p,this),this._isUnderCache=!1,f.restore(),m.restore(),l&&(f.save(),f.beginPath(),f.rect(0,0,n,r),f.closePath(),f.setAttr("strokeStyle","red"),f.setAttr("lineWidth",5),f.stroke(),f.restore()),this._cache.set(kc,{scene:d,filter:u,hit:p,x:s,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(kc)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){var i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],n=1/0,r=1/0,a=-1/0,s=-1/0,o=this.getAbsoluteTransform(e);return i.forEach((function(t){var e=o.point(t);void 0===n&&(n=a=e.x,r=s=e.y),n=Math.min(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y)})),{x:n,y:r,width:a-n,height:s-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){var t,e,i,n,r=this.filters(),a=this._getCanvasCache(),s=a.scene,o=a.filter,h=o.getContext();if(r){if(!this._filterUpToDate){var l=s.pixelRatio;o.setSize(s.width/s.pixelRatio,s.height/s.pixelRatio);try{for(t=r.length,h.clear(),h.drawImage(s._canvas,0,0,s.getWidth()/l,s.getHeight()/l),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)"function"==typeof(n=r[i])?(n.call(this,e),h.putImageData(e,0,0)):Cc.Util.error("Filter should be type of function, but got "+typeof n+" instead. Please check correct filters")}catch(t){Cc.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return o}return s}on(t,e){if(this._cache&&this._cache.delete(Nc),3===arguments.length)return this._delegate.apply(this,arguments);var i,n,r,a,s=t.split(Vc),o=s.length;for(i=0;i<o;i++)r=(n=s[i].split("."))[0],a=n[1]||"",this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:a,handler:e});return this}off(t,e){var i,n,r,a,s,o=(t||"").split(Vc),h=o.length;if(this._cache&&this._cache.delete(Nc),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<h;i++)if(a=(r=o[i].split("."))[0],s=r[1],a)this.eventListeners[a]&&this._off(a,s,e);else for(n in this.eventListeners)this._off(n,s,e);return this}dispatchEvent(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){var n=this;this.on(t,(function(t){for(var r=t.target.findAncestors(e,!0,n),a=0;a<r.length;a++)(t=Cc.Util.cloneObject(t)).currentTarget=r[a],i.call(r[a],t)}))}remove(){return this.isDragging()&&this.stopDrag(),Ic.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Oc),this._clearSelfAndDescendantCache(Uc),this._clearSelfAndDescendantCache(Fc),this._clearSelfAndDescendantCache(Wc),this._clearSelfAndDescendantCache(jc),this._clearSelfAndDescendantCache(Bc)}_remove(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){var e="get"+Cc.Util._capitalize(t);return Cc.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges((()=>{var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Cc.Util._capitalize(e),Cc.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(Bc,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(jc,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),n=!1;Ic.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));var r=!e&&!Lc.Konva.hitOnDragEnabled&&(n||Lc.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var t,e,i,n,r=this.getDepth(),a=this,s=0;const o=this.getStage();return"Stage"!==a.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],s++,n.nodeType!==Hc&&(t=t.concat(n.getChildren().slice())),n._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),s}getDepth(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Xc),this._clearSelfAndDescendantCache(Oc)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;var e=t.getPointerPosition();if(!e)return null;var i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var n=this.getAbsoluteTransform(t).getMatrix(),r=new Cc.Transform,a=this.offset();return r.m=n.slice(),r.translate(a.x,a.y),r.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(Xc);var r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(Xc),this._clearSelfAndDescendantCache(Oc),this}_setTransform(t){var e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){var t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){var e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}_eachAncestorReverse(t,e){var i,n,r=[],a=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);a&&(!e||a._id!==e._id);)r.unshift(a),a=a.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Cc.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Cc.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Cc.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Cc.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Cc.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Cc.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Uc,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t,e,i,n,r=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in r)e=r[t],Cc.Util.isObject(e)&&!Cc.Util._isPlainObject(e)&&!Cc.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(a.attrs[t]=e));return Cc.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){var n=[];e&&this._isMatch(t)&&n.push(this);for(var r=this.parent;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,n=t.replace(/ /g,"").split(","),r=n.length;for(e=0;e<r;e++)if(i=n[e],Cc.Util.isValidSelector(i)||(Cc.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Cc.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Cc.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){var t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Wc,this._getStage)}_getStage(){var t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Oc,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new Cc.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this._cache.get(Oc)||new Cc.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,r=this.attrs.offsetY||0;e.translate(t-n,i-r)}return e.dirty=!1,e}getAbsoluteScale(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Xc,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(Xc)||new Cc.Transform;i.reset();var n=this.x(),r=this.y(),a=Lc.Konva.getAngle(this.rotation()),s=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===r||i.translate(n,r),0!==a&&i.rotate(a),0===h&&0===l||i.skew(h,l),1===s&&1===o||i.scale(s,o),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){var e,i,n,r,a,s=Cc.Util.cloneObject(this.attrs);for(e in t)s[e]=t[e];var o=new this.constructor(s);for(e in this.eventListeners)for(n=(i=this.eventListeners[e]).length,r=0;r<n;r++)(a=i[r]).name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(a));return o}_toKonvaCanvas(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),r=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,s=new Pc.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),o=s.getContext();const h=new Pc.SceneCanvas({width:s.width/s.pixelRatio+Math.abs(n),height:s.height/s.pixelRatio+Math.abs(r),pixelRatio:s.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||r)&&o.translate(-1*n,-1*r),this.drawScene(s,void 0,h),o.restore(),s}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Cc.Util._urlToImage(this.toDataURL(t),(function(t){e(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Lc.Konva.dragDistance}_off(t,e,i){var n,r,a,s=this.eventListeners[t];for(n=0;n<s.length;n++)if(r=s[n].name,a=s[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==a)){if(s.splice(n,1),0===s.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){var i=this["set"+Cc.Util._capitalize(t)];return Cc.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Lc.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||Cc.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){var n;void 0!==i&&((n=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){if(e&&this.nodeType===Hc&&(e.target=this),!((t===zc||t===Gc)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var n=(t===zc||t===Gc)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,n;const r=null!==(e=this._cache.get(Nc))&&void 0!==e?e:{};let a=null==r?void 0:r[t];if(void 0===a){a=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(n=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];a.push(...r),e=Object.getPrototypeOf(e)}r[t]=a,this._cache.set(Nc,r)}return a}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var n=0;n<i.length;n++)i[n].handler.call(this,e);const r=this.eventListeners[t];if(r)for(n=0;n<r.length;n++)r[n].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){var e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(i){var r=i._getPointerById(e)||i._changedPointerPositions[0]||n;Ic.DD._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-n.x,y:r.y-n.y},dragStatus:"ready",pointerId:e})}}startDrag(t,e=!0){Ic.DD._dragElements.has(this._id)||this._createDragElement(t);Ic.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(i){var n={x:i.x-e.offset.x,y:i.y-e.offset.y},r=this.dragBoundFunc();if(void 0!==r){const e=r.call(this,n,t);e?n=e:Cc.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}stopDrag(t){const e=Ic.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),Ic.DD._endDragBefore(t),Ic.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Ic.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if((!(void 0!==t.evt.button)||Lc.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;Ic.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Ic.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&Ic.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Cc.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return Cc.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,n,r,a=Kc.prototype.getClassName.call(t),s=t.children;e&&(t.attrs.container=e),Lc.Konva[a]||(Cc.Util.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(i=new(0,Lc.Konva[a])(t.attrs),s)for(n=s.length,r=0;r<n;r++)i.add(Kc._createNode(s[r]));return i}}hc.Node=Kc,Kc.prototype.nodeType="Node",Kc.prototype._attrsAffectingSize=[],Kc.prototype.eventListeners={},Kc.prototype.on.call(Kc.prototype,Yc,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Xc),this._clearSelfAndDescendantCache(Oc))})),Kc.prototype.on.call(Kc.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(jc)})),Kc.prototype.on.call(Kc.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(Bc)})),Kc.prototype.on.call(Kc.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(Uc)}));const Zc=Rc.Factory.addGetterSetter;Zc(Kc,"zIndex"),Zc(Kc,"absolutePosition"),Zc(Kc,"position"),Zc(Kc,"x",0,(0,Dc.getNumberValidator)()),Zc(Kc,"y",0,(0,Dc.getNumberValidator)()),Zc(Kc,"globalCompositeOperation","source-over",(0,Dc.getStringValidator)()),Zc(Kc,"opacity",1,(0,Dc.getNumberValidator)()),Zc(Kc,"name","",(0,Dc.getStringValidator)()),Zc(Kc,"id","",(0,Dc.getStringValidator)()),Zc(Kc,"rotation",0,(0,Dc.getNumberValidator)()),Rc.Factory.addComponentsGetterSetter(Kc,"scale",["x","y"]),Zc(Kc,"scaleX",1,(0,Dc.getNumberValidator)()),Zc(Kc,"scaleY",1,(0,Dc.getNumberValidator)()),Rc.Factory.addComponentsGetterSetter(Kc,"skew",["x","y"]),Zc(Kc,"skewX",0,(0,Dc.getNumberValidator)()),Zc(Kc,"skewY",0,(0,Dc.getNumberValidator)()),Rc.Factory.addComponentsGetterSetter(Kc,"offset",["x","y"]),Zc(Kc,"offsetX",0,(0,Dc.getNumberValidator)()),Zc(Kc,"offsetY",0,(0,Dc.getNumberValidator)()),Zc(Kc,"dragDistance",null,(0,Dc.getNumberValidator)()),Zc(Kc,"width",0,(0,Dc.getNumberValidator)()),Zc(Kc,"height",0,(0,Dc.getNumberValidator)()),Zc(Kc,"listening",!0,(0,Dc.getBooleanValidator)()),Zc(Kc,"preventDefault",!0,(0,Dc.getBooleanValidator)()),Zc(Kc,"filters",null,(function(t){return this._filterUpToDate=!1,t})),Zc(Kc,"visible",!0,(0,Dc.getBooleanValidator)()),Zc(Kc,"transformsEnabled","all",(0,Dc.getStringValidator)()),Zc(Kc,"size"),Zc(Kc,"dragBoundFunc"),Zc(Kc,"draggable",!1,(0,Dc.getBooleanValidator)()),Rc.Factory.backCompat(Kc,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Jc={};Object.defineProperty(Jc,"__esModule",{value:!0}),Jc.Container=void 0;const Qc=lc,$c=hc,td=cc;class ed extends $c.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[];var i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(var e=0;e<t.length;e++)this.add(t[e]);return this}const i=t[0];return i.getParent()?(i.moveTo(this),this):(this._validateAdd(i),i.index=this.getChildren().length,i.parent=this,i._clearCaches(),this.getChildren().push(i),this._fire("add",{child:i}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){var i=[];return this._descendants((n=>{const r=n._isMatch(t);return r&&i.push(n),!(!r||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){var t=$c.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){var e=$c.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}getAllIntersections(t){var e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){var n=this.getLayer(),r=t||n&&n.getCanvas(),a=r&&r.getContext(),s=this._getCanvasCache(),o=s&&s.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(o){a.save();var l=this.getAbsoluteTransform(e).getMatrix();a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),a=this._getCanvasCache();if(a&&a.hit){r.save();var s=this.getAbsoluteTransform(e).getMatrix();r.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var r,a=e&&e.getContext(),s=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof s&&"number"==typeof o||h;const c=i===this;if(l){a.save();var d=this.getAbsoluteTransform(i),u=d.getMatrix();let t;if(a.transform(u[0],u[1],u[2],u[3],u[4],u[5]),a.beginPath(),h)t=h.call(this,a,this);else{var p=this.clipX(),f=this.clipY();a.rect(p||0,f||0,s,o)}a.clip.apply(a,t),u=d.copy().invert().getMatrix(),a.transform(u[0],u[1],u[2],u[3],u[4],u[5])}var m=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;m&&(a.save(),a._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,i,n)})),m&&a.restore(),l&&a.restore()}getClientRect(t={}){var e,i,n,r,a,s=t.skipTransform,o=t.relativeTo,h={x:1/0,y:1/0,width:0,height:0},l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var s=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===s.width&&0===s.height||(void 0===i?(i=s.x,n=s.y,r=s.x+s.width,a=s.y+s.height):(i=Math.min(i,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x+s.width),a=Math.max(a,s.y+s.height)))}}));for(var c=this.find("Shape"),d=!1,u=0;u<c.length;u++){if(c[u]._isVisible(this)){d=!0;break}}return h=d&&void 0!==i?{x:i,y:n,width:r-i,height:a-n}:{x:0,y:0,width:0,height:0},s?h:this._transformedRect(h,o)}}Jc.Container=ed,Qc.Factory.addComponentsGetterSetter(ed,"clip",["x","y","width","height"]),Qc.Factory.addGetterSetter(ed,"clipX",void 0,(0,td.getNumberValidator)()),Qc.Factory.addGetterSetter(ed,"clipY",void 0,(0,td.getNumberValidator)()),Qc.Factory.addGetterSetter(ed,"clipWidth",void 0,(0,td.getNumberValidator)()),Qc.Factory.addGetterSetter(ed,"clipHeight",void 0,(0,td.getNumberValidator)()),Qc.Factory.addGetterSetter(ed,"clipFunc");var id={},nd={};Object.defineProperty(nd,"__esModule",{value:!0}),nd.releaseCapture=nd.setPointerCapture=nd.hasPointerCapture=nd.createEvent=nd.getCapturedShape=void 0;const rd=sc,ad=new Map,sd=void 0!==rd.Konva._global.PointerEvent;function od(t){return{evt:t,pointerId:t.pointerId}}function hd(t,e){const i=ad.get(t);if(!i)return;const n=i.getStage();n&&n.content,ad.delete(t),sd&&i._fire("lostpointercapture",od(new PointerEvent("lostpointercapture")))}nd.getCapturedShape=function(t){return ad.get(t)},nd.createEvent=od,nd.hasPointerCapture=function(t,e){return ad.get(t)===e},nd.setPointerCapture=function(t,e){hd(t),e.getStage()&&(ad.set(t,e),sd&&e._fire("gotpointercapture",od(new PointerEvent("gotpointercapture"))))},nd.releaseCapture=hd,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=oc,i=lc,n=Jc,r=sc,a=fc,s=Ac,o=sc,h=nd;var l="mouseleave",c="mouseover",d="mouseenter",u="mousemove",p="mousedown",f="mouseup",m="pointermove",g="pointerdown",v="pointerup",_="pointercancel",y="pointerout",x="pointerleave",S="pointerover",M="pointerenter",b="contextmenu",w="touchstart",E="touchend",T="touchmove",A="touchcancel",C="wheel",R=[[d,"_pointerenter"],[p,"_pointerdown"],[u,"_pointermove"],[f,"_pointerup"],[l,"_pointerleave"],[w,"_pointerdown"],[T,"_pointermove"],[E,"_pointerup"],[A,"_pointercancel"],[c,"_pointerover"],[C,"_wheel"],[b,"_contextmenu"],[g,"_pointerdown"],[m,"_pointermove"],[v,"_pointerup"],[_,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const P={mouse:{[y]:"mouseout",[x]:l,[S]:c,[M]:d,[m]:u,[g]:p,[v]:f,[_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[x]:"touchleave",[S]:"touchover",[M]:"touchenter",[m]:T,[g]:w,[v]:E,[_]:A,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[x]:x,[S]:S,[M]:M,[m]:m,[g]:g,[v]:v,[_]:_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},L=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=L(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&P.pointer:"touch"===e?P.touch:"mouse"===e?P.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class U extends n.Container{constructor(e){super(D(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{D(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),n="FastLayer"===t.getType();i||n||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var i;i="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(i)}if(!t)throw"Can not find container in document with id "+i}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),n.Container.prototype.clone.call(this,t)}destroy(){super.destroy();var i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);var n=t.stages.indexOf(this);return n>-1&&t.stages.splice(n,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new a.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(e.isVisible()){var n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}})),e}getIntersection(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){const n=i[e].getIntersection(t);if(n)return n}return null}_resizeDOM(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(t);var a=this.children.length;return a>5&&e.Util.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&R.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),i=L(t.type);if(e){this.setPointersPositions(t);var n=this._getTargetShape(i),a=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;n&&a?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):a&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(t){const e=I(t.type),i=L(t.type);if(e){this.setPointersPositions(t);var n=!1;this._changedPointerPositions.forEach((a=>{var o=this.getIntersection(a);if(s.DD.justDragged=!1,r.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return void(this[i+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&o.setPointerCapture(a.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:a.id}),n=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(t){const e=I(t.type),i=L(t.type);if(!e)return;if(r.Konva.isDragging()&&s.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!(!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled))return;var n={};let a=!1;var o=this._getTargetShape(i);this._changedPointerPositions.forEach((r=>{const s=h.getCapturedShape(r.id)||this.getIntersection(r),l=r.id,c={evt:t,pointerId:l};var d=o!==s;if(d&&o&&(o._fireAndBubble(e.pointerout,{...c},s),o._fireAndBubble(e.pointerleave,{...c},s)),s){if(n[s._id])return;n[s._id]=!0}s&&s.isListening()?(a=!0,d&&(s._fireAndBubble(e.pointerover,{...c},o),s._fireAndBubble(e.pointerenter,{...c},o),this[i+"targetShape"]=s),s._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),a||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),i=L(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],a=this[i+"ClickEndShape"];var o={};let l=!1;this._changedPointerPositions.forEach((c=>{const d=h.getCapturedShape(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),o[d._id])return;o[d._id]=!0}const u=c.id,p={evt:t,pointerId:u};let f=!1;r.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):s.DD.justDragged||(r.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){r.Konva["_"+i+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(l=!0,this[i+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...p}),r.Konva["_"+i+"ListenClick"]&&n&&n===d&&(d._fireAndBubble(e.pointerclick,{...p}),f&&a&&a===d&&d._fireAndBubble(e.pointerdblclick,{...p}))):(this[i+"ClickEndShape"]=null,r.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(b,{evt:t}):this._fire(b,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(C,{evt:t}):this._fire(C,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(v,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){var i=this._getContentPosition(),n=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(n=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),r.Konva.isBrowser){var t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=U,U.prototype.nodeType="Stage",(0,o._registerNode)(U),i.Factory.addGetterSetter(U,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(id);var ld={},cd={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=sc,i=oc,n=lc,r=hc,a=cc,s=sc,o=nd;var h="hasShadow",l="shadowRGBA",c="patternImage",d="linearGradient",u="radialGradient";let p;function f(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class m extends r.Node{constructor(e){let n;for(super(e);n=i.Util.getRandomColor(),!n||n in t.shapes;);this.colorKey=n,t.shapes[n]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(c,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const n=new i.Transform;n.translate(this.fillPatternX(),this.fillPatternY()),n.rotate(e.Konva.getAngle(this.fillPatternRotation())),n.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),n.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=n.getMatrix(),a="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(a)}return t}}_getLinearGradient(){return this._getCache(d,this.__getLinearGradient)}__getLinearGradient(){var t=this.fillLinearGradientColorStops();if(t){for(var e=f(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){var t=this.fillRadialGradientColorStops();if(t){for(var e=f(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius()),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){var e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;const a=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(i&&n&&a&&s)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,a=this.getSelfRect(),s=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=a.width+s,h=a.height+s,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),f=l&&this.shadowBlur()||0,m={width:u+2*f,height:p+2*f,x:-(s/2+f)+Math.min(c,0)+a.x,y:-(s/2+f)+Math.min(d,0)+a.y};return n?m:this._transformedRect(m,r)}drawScene(t,e,i){var n,r,a=this.getLayer(),s=t||a.getCanvas(),o=s.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),c=this.hasShadow(),d=s.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();var p=this.getAbsoluteTransform(e).getMatrix();return o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!d){n=this.getStage();const t=i||n.bufferCanvas;(r=t.getContext()).clear(),r.save(),r._applyLineJoin(this);var f=this.getAbsoluteTransform(e).getMatrix();r.transform(f[0],f[1],f[2],f[3],f[4],f[5]),l.call(this,r,this),r.restore();var m=t.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/m,t.height/m)}else{if(o._applyLineJoin(this),!u){f=this.getAbsoluteTransform(e).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;var r=this.getLayer(),a=t||r.hitCanvas,s=a&&a.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){s.save();var c=this.getAbsoluteTransform(e).getMatrix();return s.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(s),s.restore(),this}if(!o)return this;s.save(),s._applyLineJoin(this);if(!(this===e)){var d=this.getAbsoluteTransform(e).getMatrix();s.transform(d[0],d[1],d[2],d[3],d[4],d[5])}return o.call(this,s,this),s.restore(),this}drawHitFromCache(t=0){var e,n,r,a,s,o=this._getCanvasCache(),h=this._getCachedSceneCanvas(),l=o.hit,c=l.getContext(),d=l.getWidth(),u=l.getHeight();c.clear(),c.drawImage(h._canvas,0,0,d,u);try{for(r=(n=(e=c.getImageData(0,0,d,u)).data).length,a=i.Util._hexToRgb(this.colorKey),s=0;s<r;s+=4)n[s+3]>t?(n[s]=a.r,n[s+1]=a.g,n[s+2]=a.b,n[s+3]=255):n[s+3]=0;c.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,s._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(c)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(d)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),n.Factory.addGetterSetter(m,"stroke",void 0,(0,a.getStringOrGradientValidator)()),n.Factory.addGetterSetter(m,"strokeWidth",2,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),n.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),n.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),n.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),n.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),n.Factory.addGetterSetter(m,"lineJoin"),n.Factory.addGetterSetter(m,"lineCap"),n.Factory.addGetterSetter(m,"sceneFunc"),n.Factory.addGetterSetter(m,"hitFunc"),n.Factory.addGetterSetter(m,"dash"),n.Factory.addGetterSetter(m,"dashOffset",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"shadowColor",void 0,(0,a.getStringValidator)()),n.Factory.addGetterSetter(m,"shadowBlur",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"shadowOpacity",1,(0,a.getNumberValidator)()),n.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),n.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillPatternImage"),n.Factory.addGetterSetter(m,"fill",void 0,(0,a.getStringOrGradientValidator)()),n.Factory.addGetterSetter(m,"fillPatternX",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillPatternY",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),n.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),n.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),n.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),n.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),n.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),n.Factory.addGetterSetter(m,"fillEnabled",!0),n.Factory.addGetterSetter(m,"strokeEnabled",!0),n.Factory.addGetterSetter(m,"shadowEnabled",!0),n.Factory.addGetterSetter(m,"dashEnabled",!0),n.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),n.Factory.addGetterSetter(m,"fillPriority","color"),n.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),n.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),n.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),n.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,a.getNumberValidator)()),n.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,a.getNumberValidator)()),n.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),n.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),n.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),n.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),n.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),n.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),n.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),n.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),n.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),n.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),n.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),n.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),n.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),n.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),n.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),n.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),n.Factory.addGetterSetter(m,"fillPatternRotation",0),n.Factory.addGetterSetter(m,"fillRule",void 0,(0,a.getStringValidator)()),n.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(cd),Object.defineProperty(ld,"__esModule",{value:!0}),ld.Layer=void 0;const dd=oc,ud=Jc,pd=hc,fd=lc,md=fc,gd=cc,vd=cd,_d=sc;var yd=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],xd=yd.length;class Sd extends ud.Container{constructor(t){super(t),this.canvas=new md.SceneCanvas,this.hitCanvas=new md.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){pd.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!pd.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(pd.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(pd.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var t=this.getNativeCanvasElement();return pd.Node.prototype.remove.call(this),t&&t.parentNode&&dd.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&dd.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),pd.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){dd.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){dd.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,dd.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(let n=0;n<xd;n++){const r=yd[n],a=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),s=a.shape;if(s)return s;if(i=!!a.antialiased,!a.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=dd.Util._rgbToHex(i[0],i[1],i[2]),e=vd.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e){var i=this.getLayer(),n=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),ud.Container.prototype.drawScene.call(this,n,e),this._fire("draw",{node:this}),this}drawHit(t,e){var i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),ud.Container.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){dd.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return dd.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}destroy(){return dd.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}ld.Layer=Sd,Sd.prototype.nodeType="Layer",(0,_d._registerNode)(Sd),fd.Factory.addGetterSetter(Sd,"imageSmoothingEnabled",!0),fd.Factory.addGetterSetter(Sd,"clearBeforeDraw",!0),fd.Factory.addGetterSetter(Sd,"hitGraphEnabled",!0,(0,gd.getBooleanValidator)());var Md={};Object.defineProperty(Md,"__esModule",{value:!0}),Md.FastLayer=void 0;const bd=oc,wd=ld,Ed=sc;class Td extends wd.Layer{constructor(t){super(t),this.listening(!1),bd.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Md.FastLayer=Td,Td.prototype.nodeType="FastLayer",(0,Ed._registerNode)(Td);var Ad={};Object.defineProperty(Ad,"__esModule",{value:!0}),Ad.Group=void 0;const Cd=oc,Rd=Jc,Pd=sc;class Ld extends Rd.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Cd.Util.throw("You may only add groups and shapes to groups.")}}Ad.Group=Ld,Ld.prototype.nodeType="Group",(0,Pd._registerNode)(Ld);var Id={};Object.defineProperty(Id,"__esModule",{value:!0}),Id.Animation=void 0;const Dd=sc,Ud=oc,Nd=Dd.glob.performance&&Dd.glob.performance.now?function(){return Dd.glob.performance.now()}:function(){return(new Date).getTime()};class Od{constructor(t,e){this.id=Od.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Nd(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Od.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Nd(),Od._addAnimation(this),this}stop(){return Od._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],r=n.layers,a=n.func;n._updateFrameObject(Nd());const s=r.length;let o;if(o=!a||!1!==a.call(n,n.frame),o)for(let e=0;e<s;e++){const i=r[e];void 0!==i._id&&(t[i._id]=i)}}for(let e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=Od;t.animations.length?(t._runFrames(),Ud.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ud.Util.requestAnimFrame(this._animationLoop))}}Id.Animation=Od,Od.animations=[],Od.animIdCounter=0,Od.animRunning=!1;var Fd={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=oc,i=Id,n=hc,r=sc;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},s=0,o=["fill","stroke","shadowColor"];class h{constructor(t,e,i,n,r,a,s){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){var e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(n){var o,c,d=this,u=n.node,p=u._id,f=n.easing||t.Easings.Linear,m=!!n.yoyo;o=void 0===n.duration?.3:0===n.duration?.001:n.duration,this.node=u,this._id=s++;var g=u.getLayer()||(u instanceof r.Konva.Stage?u.getLayers():null);for(c in g||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){d.tween.onEnterFrame()}),g),this.tween=new h(c,(function(t){d._tweenFunc(t)}),f,0,1,1e3*o,m),this._addListeners(),l.attrs[p]||(l.attrs[p]={}),l.attrs[p][this._id]||(l.attrs[p][this._id]={}),l.tweens[p]||(l.tweens[p]={}),n)void 0===a[c]&&this._addAttr(c,n[c]);this.reset(),this.onFinish=n.onFinish,this.onReset=n.onReset,this.onUpdate=n.onUpdate}_addAttr(t,i){var n,r,a,s,h,c,d,u,p=this.node,f=p._id;if((a=l.tweens[f][t])&&delete l.attrs[f][a][t],n=p.getAttr(t),e.Util._isArray(i))if(r=[],h=Math.max(i.length,n.length),"points"===t&&i.length!==n.length&&(i.length>n.length?(d=n,n=e.Util._prepareArrayForTween(n,i,p.closed())):(c=i,i=e.Util._prepareArrayForTween(i,n,p.closed()))),0===t.indexOf("fill"))for(s=0;s<h;s++)if(s%2==0)r.push(i[s]-n[s]);else{var m=e.Util.colorToRGBA(n[s]);u=e.Util.colorToRGBA(i[s]),n[s]=m,r.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(s=0;s<h;s++)r.push(i[s]-n[s]);else-1!==o.indexOf(t)?(n=e.Util.colorToRGBA(n),r={r:(u=e.Util.colorToRGBA(i)).r-n.r,g:u.g-n.g,b:u.b-n.b,a:u.a-n.a}):r=i-n;l.attrs[f][this._id][t]={start:n,diff:r,end:i,trueEnd:c,trueStart:d},l.tweens[f][t]=this._id}_tweenFunc(t){var i,n,r,a,s,h,c,d,u=this.node,p=l.attrs[u._id][this._id];for(i in p){if(r=(n=p[i]).start,a=n.diff,d=n.end,e.Util._isArray(r))if(s=[],c=Math.max(r.length,d.length),0===i.indexOf("fill"))for(h=0;h<c;h++)h%2==0?s.push((r[h]||0)+a[h]*t):s.push("rgba("+Math.round(r[h].r+a[h].r*t)+","+Math.round(r[h].g+a[h].g*t)+","+Math.round(r[h].b+a[h].b*t)+","+(r[h].a+a[h].a*t)+")");else for(h=0;h<c;h++)s.push((r[h]||0)+a[h]*t);else s=-1!==o.indexOf(i)?"rgba("+Math.round(r.r+a.r*t)+","+Math.round(r.g+a.g*t)+","+Math.round(r.b+a.b*t)+","+(r.a+a.a*t)+")":r+a*t;u.setAttr(i,s)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var t,e=this.node._id,i=this._id,n=l.tweens[e];for(t in this.pause(),n)delete l.tweens[e][t];delete l.attrs[e][i]}}t.Tween=l,l.attrs={},l.tweens={},n.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,n){var r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,n){var r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,n){var r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,n,r,a){var s=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,s=a/4):s=a/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-s)*(2*Math.PI)/a)+e)},ElasticEaseOut(t,e,i,n,r,a){var s=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,s=a/4):s=a/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-s)*(2*Math.PI)/a)+i+e)},ElasticEaseInOut(t,e,i,n,r,a){var s=0;return 0===t?e:2==(t/=n/2)?e+i:(a||(a=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,s=a/4):s=a/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-s)*(2*Math.PI)/a)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-s)*(2*Math.PI)/a)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,n,r)=>n-t.Easings.BounceEaseOut(r-e,0,n,r)+i,BounceEaseInOut:(e,i,n,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,n,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,n,r)+.5*n+i,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e}}(Fd),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=sc,i=oc,n=hc,r=Jc,a=id,s=ld,o=Md,h=Ad,l=Ac,c=cd,d=Id,u=Fd,p=mc,f=fc;t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:n.Node,Container:r.Container,Stage:a.Stage,stages:a.stages,Layer:s.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:c.Shape,shapes:c.shapes,Animation:d.Animation,Tween:u.Tween,Easings:u.Easings,Context:p.Context,Canvas:f.Canvas}),t.default=t.Konva}(ac);var kd={};Object.defineProperty(kd,"__esModule",{value:!0}),kd.Arc=void 0;const Bd=lc,zd=cd,Gd=sc,Hd=cc,Vd=sc;class Wd extends zd.Shape{_sceneFunc(t){var e=Gd.Konva.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=Gd.Konva.getAngle(i?360-this.angle():this.angle()),r=Math.cos(Math.min(n,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),s=Math.sin(Math.min(n,Math.PI/2)),o=r*(r>0?t:e),h=a*(a>0?t:e),l=s*(s>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}kd.Arc=Wd,Wd.prototype._centroid=!0,Wd.prototype.className="Arc",Wd.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Vd._registerNode)(Wd),Bd.Factory.addGetterSetter(Wd,"innerRadius",0,(0,Hd.getNumberValidator)()),Bd.Factory.addGetterSetter(Wd,"outerRadius",0,(0,Hd.getNumberValidator)()),Bd.Factory.addGetterSetter(Wd,"angle",0,(0,Hd.getNumberValidator)()),Bd.Factory.addGetterSetter(Wd,"clockwise",!1,(0,Hd.getBooleanValidator)());var Xd={},jd={};Object.defineProperty(jd,"__esModule",{value:!0}),jd.Line=void 0;const Yd=lc,qd=cd,Kd=cc,Zd=sc;function Jd(t,e,i,n,r,a,s){var o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(a-n,2)),l=s*o/(o+h),c=s*h/(o+h);return[i-l*(r-t),n-l*(a-e),i+c*(r-t),n+c*(a-e)]}function Qd(t,e){var i,n,r=t.length,a=[];for(i=2;i<r-2;i+=2)n=Jd(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(n[0])||(a.push(n[0]),a.push(n[1]),a.push(t[i]),a.push(t[i+1]),a.push(n[2]),a.push(n[3]));return a}class $d extends qd.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){var e,i,n,r=this.points(),a=r.length,s=this.tension(),o=this.closed(),h=this.bezier();if(a){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==s&&a>4){for(i=(e=this.getTensionPoints()).length,n=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);n<i-2;)t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);o||t.quadraticCurveTo(e[i-2],e[i-1],r[a-2],r[a-1])}else if(h)for(n=2;n<a;)t.bezierCurveTo(r[n++],r[n++],r[n++],r[n++],r[n++],r[n++]);else for(n=2;n<a;n+=2)t.lineTo(r[n],r[n+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Qd(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),n=Jd(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),r=Jd(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=Qd(t,i);return[n[2],n[3]].concat(a).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};for(var e,i,n=(t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points())[0],r=t[0],a=t[1],s=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),a=Math.min(a,i),s=Math.max(s,i);return{x:n,y:a,width:r-n,height:s-a}}}jd.Line=$d,$d.prototype.className="Line",$d.prototype._attrsAffectingSize=["points","bezier","tension"],(0,Zd._registerNode)($d),Yd.Factory.addGetterSetter($d,"closed",!1),Yd.Factory.addGetterSetter($d,"bezier",!1),Yd.Factory.addGetterSetter($d,"tension",0,(0,Kd.getNumberValidator)()),Yd.Factory.addGetterSetter($d,"points",[],(0,Kd.getNumberArrayValidator)());var tu={},eu={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];t.getCubicArcLength=(i,n,r)=>{let a,s,o;a=r/2,s=0;for(let r=0;r<20;r++)o=a*t.tValues[20][r]+a,s+=t.cValues[20][r]*e(i,n,o);return a*s};function e(t,e,n){const r=i(1,n,t),a=i(1,n,e),s=r*r+a*a;return Math.sqrt(s)}t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],a=2*t[1]-2*t[0],s=2*e[1]-2*e[0],o=4*(n*n+r*r),h=4*(n*a+r*s),l=a*a+s*s;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,f=c*c+u>0?Math.sqrt(c*c+u):0,m=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+f))):0;return Math.sqrt(o)/2*(d*p-c*f+m)};const i=(e,n,r)=>{const a=r.length-1;let s,o;if(0===a)return 0;if(0===e){o=0;for(let e=0;e<=a;e++)o+=t.binomialCoefficients[a][e]*Math.pow(1-n,a-e)*Math.pow(n,e)*r[e];return o}s=new Array(a);for(let t=0;t<a;t++)s[t]=a*(r[t+1]-r[t]);return i(e-1,n,s)};t.t2length=(t,e,i)=>{let n=1,r=t/e,a=(t-i(r))/e,s=0;for(;n>.001;){const o=i(r+a),h=Math.abs(t-o)/e;if(h<n)n=h,r+=a;else{const s=i(r-a),o=Math.abs(t-s)/e;o<n?(n=o,r-=a):a/=2}if(s++,s>500)break}return r}}(eu),Object.defineProperty(tu,"__esModule",{value:!0}),tu.Path=void 0;const iu=lc,nu=cd,ru=sc,au=eu;class su extends nu.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=su.parsePathData(this.data()),this.pathLength=su.getPathLength(this.dataArray)}_sceneFunc(t){var e=this.dataArray;t.beginPath();for(var i=!1,n=0;n<e.length;n++){var r=e[n].command,a=e[n].points;switch(r){case"L":t.lineTo(a[0],a[1]);break;case"M":t.moveTo(a[0],a[1]);break;case"C":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":t.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var s=a[0],o=a[1],h=a[2],l=a[3],c=a[4],d=a[5],u=a[6],p=a[7],f=h>l?h:l,m=h>l?1:h/l,g=h>l?l/h:1;t.translate(s,o),t.rotate(u),t.scale(m,g),t.arc(0,0,f,c,c+d,1-p),t.scale(1/m,1/g),t.rotate(-u),t.translate(-s,-o);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){var t=[];this.dataArray.forEach((function(e){if("A"===e.command){var i=e.points[4],n=e.points[5],r=e.points[4]+n,a=Math.PI/180;if(Math.abs(i-r)<a&&(a=Math.abs(i-r)),n<0)for(let n=i-a;n>r;n-=a){const i=su.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+a;n<r;n+=a){const i=su.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=su.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)}));for(var e,i,n=t[0],r=t[0],a=t[1],s=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),r=Math.max(r,e)),isNaN(i)||(a=Math.min(a,i),s=Math.max(s,i));return{x:n,y:a,width:r-n,height:s-a}}getLength(){return this.pathLength}getPointAtLength(t){return su.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(var i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){var i,n=0,r=e.length;if(!r)return null;for(;n<r&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===r)return{x:(i=e[n-1].points.slice(-2))[0],y:i[1]};if(t<.01)return{x:(i=e[n].points.slice(0,2))[0],y:i[1]};var a=e[n],s=a.points;switch(a.command){case"L":return su.getPointOnLine(t,a.start.x,a.start.y,s[0],s[1]);case"C":return su.getPointOnCubicBezier((0,au.t2length)(t,su.getPathLength(e),(t=>(0,au.getCubicArcLength)([a.start.x,s[0],s[2],s[4]],[a.start.y,s[1],s[3],s[5]],t))),a.start.x,a.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case"Q":return su.getPointOnQuadraticBezier((0,au.t2length)(t,su.getPathLength(e),(t=>(0,au.getQuadraticArcLength)([a.start.x,s[0],s[2]],[a.start.y,s[1],s[3]],t))),a.start.x,a.start.y,s[0],s[1],s[2],s[3]);case"A":var o=s[0],h=s[1],l=s[2],c=s[3],d=s[4],u=s[5],p=s[6];return d+=u*t/a.pathLength,su.getPointOnEllipticalArc(o,h,l,c,d,p)}return null}static getPointOnLine(t,e,i,n,r,a,s){a=null!=a?a:e,s=null!=s?s:i;const o=this.getLineLength(e,i,n,r);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:a,y:s+(r>i?t:-t)};const h=(r-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(s-i-h*(a-e))<1e-10)return{x:a+l,y:s+c};const d=((a-e)*(n-e)+(s-i)*(r-i))/(o*o),u=e+d*(n-e),p=i+d*(r-i),f=this.getLineLength(a,s,u,p),m=Math.sqrt(t*t-f*f),g=Math.sqrt(m*m/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,r,a,s,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+a*c(t)+n*d(t)+e*u(t),y:h*l(t)+s*c(t)+r*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,r,a,s){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:a*o(t)+n*h(t)+e*l(t),y:s*o(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,r,a){var s=Math.cos(a),o=Math.sin(a),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*s-l*o),y:e+(h*o+l*s)}}static parsePathData(t){if(!t)return[];var e=t,i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var n=0;n<i.length;n++)e=e.replace(new RegExp(i[n],"g"),"|"+i[n]);var r,a=e.split("|"),s=[],o=[],h=0,l=0,c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(n=1;n<a.length;n++){var d=a[n],u=d.charAt(0);for(d=d.slice(1),o.length=0;r=c.exec(d);)o.push(r[0]);for(var p=[],f=0,m=o.length;f<m;f++)if("00"!==o[f]){var g=parseFloat(o[f]);isNaN(g)?p.push(0):p.push(g)}else p.push(0,0);for(;p.length>0&&!isNaN(p[0]);){var v,_,y,x,S,M,b,w,E,T,A="",C=[],R=h,P=l;switch(u){case"l":h+=p.shift(),l+=p.shift(),A="L",C.push(h,l);break;case"L":h=p.shift(),l=p.shift(),C.push(h,l);break;case"m":var L=p.shift(),I=p.shift();if(h+=L,l+=I,A="M",s.length>2&&"z"===s[s.length-1].command)for(var D=s.length-2;D>=0;D--)if("M"===s[D].command){h=s[D].points[0]+L,l=s[D].points[1]+I;break}C.push(h,l),u="l";break;case"M":h=p.shift(),l=p.shift(),A="M",C.push(h,l),u="L";break;case"h":h+=p.shift(),A="L",C.push(h,l);break;case"H":h=p.shift(),A="L",C.push(h,l);break;case"v":l+=p.shift(),A="L",C.push(h,l);break;case"V":l=p.shift(),A="L",C.push(h,l);break;case"C":C.push(p.shift(),p.shift(),p.shift(),p.shift()),h=p.shift(),l=p.shift(),C.push(h,l);break;case"c":C.push(h+p.shift(),l+p.shift(),h+p.shift(),l+p.shift()),h+=p.shift(),l+=p.shift(),A="C",C.push(h,l);break;case"S":_=h,y=l,"C"===(v=s[s.length-1]).command&&(_=h+(h-v.points[2]),y=l+(l-v.points[3])),C.push(_,y,p.shift(),p.shift()),h=p.shift(),l=p.shift(),A="C",C.push(h,l);break;case"s":_=h,y=l,"C"===(v=s[s.length-1]).command&&(_=h+(h-v.points[2]),y=l+(l-v.points[3])),C.push(_,y,h+p.shift(),l+p.shift()),h+=p.shift(),l+=p.shift(),A="C",C.push(h,l);break;case"Q":C.push(p.shift(),p.shift()),h=p.shift(),l=p.shift(),C.push(h,l);break;case"q":C.push(h+p.shift(),l+p.shift()),h+=p.shift(),l+=p.shift(),A="Q",C.push(h,l);break;case"T":_=h,y=l,"Q"===(v=s[s.length-1]).command&&(_=h+(h-v.points[0]),y=l+(l-v.points[1])),h=p.shift(),l=p.shift(),A="Q",C.push(_,y,h,l);break;case"t":_=h,y=l,"Q"===(v=s[s.length-1]).command&&(_=h+(h-v.points[0]),y=l+(l-v.points[1])),h+=p.shift(),l+=p.shift(),A="Q",C.push(_,y,h,l);break;case"A":x=p.shift(),S=p.shift(),M=p.shift(),b=p.shift(),w=p.shift(),E=h,T=l,h=p.shift(),l=p.shift(),A="A",C=this.convertEndpointToCenterParameterization(E,T,h,l,b,w,x,S,M);break;case"a":x=p.shift(),S=p.shift(),M=p.shift(),b=p.shift(),w=p.shift(),E=h,T=l,h+=p.shift(),l+=p.shift(),A="A",C=this.convertEndpointToCenterParameterization(E,T,h,l,b,w,x,S,M)}s.push({command:A||u,points:C,start:{x:R,y:P},pathLength:this.calcLength(R,P,A||u,C)})}"z"!==u&&"Z"!==u||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){var r,a,s,o,h=su;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return(0,au.getCubicArcLength)([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return(0,au.getQuadraticArcLength)([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":r=0;var l=n[4],c=n[5],d=n[4]+c,u=Math.PI/180;if(Math.abs(l-d)<u&&(u=Math.abs(l-d)),a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),c<0)for(o=l-u;o>d;o-=u)s=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(a.x,a.y,s.x,s.y),a=s;else for(o=l+u;o<d;o+=u)s=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),r+=h.getLineLength(a.x,a.y,s.x,s.y),a=s;return s=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],d,0),r+=h.getLineLength(a.x,a.y,s.x,s.y)}return 0}static convertEndpointToCenterParameterization(t,e,i,n,r,a,s,o,h){var l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(s*s)+d*d/(o*o);u>1&&(s*=Math.sqrt(u),o*=Math.sqrt(u));var p=Math.sqrt((s*s*(o*o)-s*s*(d*d)-o*o*(c*c))/(s*s*(d*d)+o*o*(c*c)));r===a&&(p*=-1),isNaN(p)&&(p=0);var f=p*s*d/o,m=p*-o*c/s,g=(t+i)/2+Math.cos(l)*f-Math.sin(l)*m,v=(e+n)/2+Math.sin(l)*f+Math.cos(l)*m,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},S=x([1,0],[(c-f)/s,(d-m)/o]),M=[(c-f)/s,(d-m)/o],b=[(-1*c-f)/s,(-1*d-m)/o],w=x(M,b);return y(M,b)<=-1&&(w=Math.PI),y(M,b)>=1&&(w=0),0===a&&w>0&&(w-=2*Math.PI),1===a&&w<0&&(w+=2*Math.PI),[g,v,s,o,S,w,l,a]}}tu.Path=su,su.prototype.className="Path",su.prototype._attrsAffectingSize=["data"],(0,ru._registerNode)(su),iu.Factory.addGetterSetter(su,"data"),Object.defineProperty(Xd,"__esModule",{value:!0}),Xd.Arrow=void 0;const ou=lc,hu=jd,lu=cc,cu=sc,du=tu;class uu extends hu.Line{_sceneFunc(t){super._sceneFunc(t);var e=2*Math.PI,i=this.points(),n=i,r=0!==this.tension()&&i.length>4;r&&(n=this.getTensionPoints());var a,s,o=this.pointerLength(),h=i.length;if(r){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[h-2],i[h-1]],e=du.Path.calcLength(n[n.length-4],n[n.length-3],"C",t),r=du.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);a=i[h-2]-r.x,s=i[h-1]-r.y}else a=i[h-2]-i[h-4],s=i[h-1]-i[h-3];var l=(Math.atan2(s,a)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[h-2],i[h-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),r?(a=(n[0]+n[2])/2-i[0],s=(n[1]+n[3])/2-i[1]):(a=i[2]-i[0],s=i[3]-i[1]),t.rotate((Math.atan2(-s,-a)+e)%e),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){var e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}}Xd.Arrow=uu,uu.prototype.className="Arrow",(0,cu._registerNode)(uu),ou.Factory.addGetterSetter(uu,"pointerLength",10,(0,lu.getNumberValidator)()),ou.Factory.addGetterSetter(uu,"pointerWidth",10,(0,lu.getNumberValidator)()),ou.Factory.addGetterSetter(uu,"pointerAtBeginning",!1),ou.Factory.addGetterSetter(uu,"pointerAtEnding",!0);var pu={};Object.defineProperty(pu,"__esModule",{value:!0}),pu.Circle=void 0;const fu=lc,mu=cd,gu=cc,vu=sc;class _u extends mu.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}pu.Circle=_u,_u.prototype._centroid=!0,_u.prototype.className="Circle",_u.prototype._attrsAffectingSize=["radius"],(0,vu._registerNode)(_u),fu.Factory.addGetterSetter(_u,"radius",0,(0,gu.getNumberValidator)());var yu={};Object.defineProperty(yu,"__esModule",{value:!0}),yu.Ellipse=void 0;const xu=lc,Su=cd,Mu=cc,bu=sc;class wu extends Su.Shape{_sceneFunc(t){var e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}yu.Ellipse=wu,wu.prototype.className="Ellipse",wu.prototype._centroid=!0,wu.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,bu._registerNode)(wu),xu.Factory.addComponentsGetterSetter(wu,"radius",["x","y"]),xu.Factory.addGetterSetter(wu,"radiusX",0,(0,Mu.getNumberValidator)()),xu.Factory.addGetterSetter(wu,"radiusY",0,(0,Mu.getNumberValidator)());var Eu={};Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.Image=void 0;const Tu=oc,Au=lc,Cu=cd,Ru=sc,Pu=cc;let Lu=class t extends Cu.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),r=this.attrs.image;let a;if(r){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;a=t&&n?[r,this.cropX(),this.cropY(),t,n,0,0,e,i]:[r,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?Tu.Util.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),r&&(n&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){var e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?Tu.Util.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,n=null){var r=Tu.Util.createImageElement();r.onload=function(){var e=new t({image:r});i(e)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}};Eu.Image=Lu,Lu.prototype.className="Image",(0,Ru._registerNode)(Lu),Au.Factory.addGetterSetter(Lu,"cornerRadius",0,(0,Pu.getNumberOrArrayOfNumbersValidator)(4)),Au.Factory.addGetterSetter(Lu,"image"),Au.Factory.addComponentsGetterSetter(Lu,"crop",["x","y","width","height"]),Au.Factory.addGetterSetter(Lu,"cropX",0,(0,Pu.getNumberValidator)()),Au.Factory.addGetterSetter(Lu,"cropY",0,(0,Pu.getNumberValidator)()),Au.Factory.addGetterSetter(Lu,"cropWidth",0,(0,Pu.getNumberValidator)()),Au.Factory.addGetterSetter(Lu,"cropHeight",0,(0,Pu.getNumberValidator)());var Iu={};Object.defineProperty(Iu,"__esModule",{value:!0}),Iu.Tag=Iu.Label=void 0;const Du=lc,Uu=cd,Nu=Ad,Ou=cc,Fu=sc;var ku=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Bu="up",zu="right",Gu="down",Hu="left",Vu=ku.length;class Wu extends Nu.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){var e,i=this,n=function(){i._sync()};for(e=0;e<Vu;e++)t.on(ku[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var t,e,i,n,r,a,s,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),s=h.pointerHeight(),r=0,a=0,i){case Bu:r=t/2,a=-1*s;break;case zu:r=t+n,a=e/2;break;case Gu:r=t/2,a=e+s;break;case Hu:r=-1*n,a=e/2}h.setAttrs({x:-1*r,y:-1*a,width:t,height:e}),o.setAttrs({x:-1*r,y:-1*a})}}}Iu.Label=Wu,Wu.prototype.className="Label",(0,Fu._registerNode)(Wu);class Xu extends Uu.Shape{_sceneFunc(t){var e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),a=this.pointerHeight(),s=this.cornerRadius();let o=0,h=0,l=0,c=0;"number"==typeof s?o=h=l=c=Math.min(s,e/2,i/2):(o=Math.min(s[0]||0,e/2,i/2),h=Math.min(s[1]||0,e/2,i/2),c=Math.min(s[2]||0,e/2,i/2),l=Math.min(s[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===Bu&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*a),t.lineTo((e+r)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===zu&&(t.lineTo(e,(i-a)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+a)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===Gu&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+a),t.lineTo((e-r)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===Hu&&(t.lineTo(0,(i+a)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-a)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){var t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),a=this.width(),s=this.height();return r===Bu?(e-=n,s+=n):r===Gu?s+=n:r===Hu?(t-=1.5*i,a+=i):r===zu&&(a+=1.5*i),{x:t,y:e,width:a,height:s}}}Iu.Tag=Xu,Xu.prototype.className="Tag",(0,Fu._registerNode)(Xu),Du.Factory.addGetterSetter(Xu,"pointerDirection","none"),Du.Factory.addGetterSetter(Xu,"pointerWidth",0,(0,Ou.getNumberValidator)()),Du.Factory.addGetterSetter(Xu,"pointerHeight",0,(0,Ou.getNumberValidator)()),Du.Factory.addGetterSetter(Xu,"cornerRadius",0,(0,Ou.getNumberOrArrayOfNumbersValidator)(4));var ju={};Object.defineProperty(ju,"__esModule",{value:!0}),ju.Rect=void 0;const Yu=lc,qu=cd,Ku=sc,Zu=oc,Ju=cc;class Qu extends qu.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?Zu.Util.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}ju.Rect=Qu,Qu.prototype.className="Rect",(0,Ku._registerNode)(Qu),Yu.Factory.addGetterSetter(Qu,"cornerRadius",0,(0,Ju.getNumberOrArrayOfNumbersValidator)(4));var $u={};Object.defineProperty($u,"__esModule",{value:!0}),$u.RegularPolygon=void 0;const tp=lc,ep=cd,ip=cc,np=sc;class rp extends ep.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(var n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();var e=t[0].x,i=t[0].y,n=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),{x:e,y:n,width:i-e,height:r-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}$u.RegularPolygon=rp,rp.prototype.className="RegularPolygon",rp.prototype._centroid=!0,rp.prototype._attrsAffectingSize=["radius"],(0,np._registerNode)(rp),tp.Factory.addGetterSetter(rp,"radius",0,(0,ip.getNumberValidator)()),tp.Factory.addGetterSetter(rp,"sides",0,(0,ip.getNumberValidator)());var ap={};Object.defineProperty(ap,"__esModule",{value:!0}),ap.Ring=void 0;const sp=lc,op=cd,hp=cc,lp=sc;var cp=2*Math.PI;class dp extends op.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,cp,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),cp,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ap.Ring=dp,dp.prototype.className="Ring",dp.prototype._centroid=!0,dp.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,lp._registerNode)(dp),sp.Factory.addGetterSetter(dp,"innerRadius",0,(0,hp.getNumberValidator)()),sp.Factory.addGetterSetter(dp,"outerRadius",0,(0,hp.getNumberValidator)());var up={};Object.defineProperty(up,"__esModule",{value:!0}),up.Sprite=void 0;const pp=lc,fp=cd,mp=Id,gp=cc,vp=sc;class _p extends fp.Shape{constructor(t){super(t),this._updated=!0,this.anim=new mp.Animation((()=>{var t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){var e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],a=this.frameOffsets(),s=r[n+0],o=r[n+1],h=r[n+2],l=r[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(a){var d=a[e],u=2*i;t.drawImage(c,s,o,h,l,d[u+0],d[u+1],h,l)}else t.drawImage(c,s,o,h,l,0,0,h,l)}_hitFunc(t){var e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],a=this.frameOffsets(),s=r[n+2],o=r[n+3];if(t.beginPath(),a){var h=a[e],l=2*i;t.rect(h[l+0],h[l+1],s,o)}else t.rect(0,0,s,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}up.Sprite=_p,_p.prototype.className="Sprite",(0,vp._registerNode)(_p),pp.Factory.addGetterSetter(_p,"animation"),pp.Factory.addGetterSetter(_p,"animations"),pp.Factory.addGetterSetter(_p,"frameOffsets"),pp.Factory.addGetterSetter(_p,"image"),pp.Factory.addGetterSetter(_p,"frameIndex",0,(0,gp.getNumberValidator)()),pp.Factory.addGetterSetter(_p,"frameRate",17,(0,gp.getNumberValidator)()),pp.Factory.backCompat(_p,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var yp={};Object.defineProperty(yp,"__esModule",{value:!0}),yp.Star=void 0;const xp=lc,Sp=cd,Mp=cc,bp=sc;class wp extends Sp.Shape{_sceneFunc(t){var e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var r=1;r<2*n;r++){var a=r%2==0?i:e,s=a*Math.sin(r*Math.PI/n),o=-1*a*Math.cos(r*Math.PI/n);t.lineTo(s,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}yp.Star=wp,wp.prototype.className="Star",wp.prototype._centroid=!0,wp.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,bp._registerNode)(wp),xp.Factory.addGetterSetter(wp,"numPoints",5,(0,Mp.getNumberValidator)()),xp.Factory.addGetterSetter(wp,"innerRadius",0,(0,Mp.getNumberValidator)()),xp.Factory.addGetterSetter(wp,"outerRadius",0,(0,Mp.getNumberValidator)());var Ep={};Object.defineProperty(Ep,"__esModule",{value:!0}),Ep.Text=Ep.stringToArray=void 0;const Tp=oc,Ap=lc,Cp=cd,Rp=sc,Pp=cc,Lp=sc;function Ip(t){return Array.from(t)}Ep.stringToArray=Ip;var Dp,Up="auto",Np="inherit",Op="justify",Fp="left",kp="middle",Bp="normal",zp=" ",Gp="none",Hp=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Vp=Hp.length;function Wp(){return Dp||(Dp=Tp.Util.createCanvasElement().getContext("2d"))}class Xp extends Cp.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(var e=0;e<Vp;e++)this.on(Hp[e]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e=this.textArr,i=e.length;if(this.text()){var n,r=this.padding(),a=this.fontSize(),s=this.lineHeight()*a,o=this.verticalAlign(),h=this.direction(),l=0,c=this.align(),d=this.getWidth(),u=this.letterSpacing(),p=this.fill(),f=this.textDecoration(),m=-1!==f.indexOf("underline"),g=-1!==f.indexOf("line-through");h=h===Np?t.direction:h;var v=s/2,_=kp;if(Rp.Konva._fixTextRendering){var y=this.measureSize("M");_="alphabetic",v=(y.fontBoundingBoxAscent-y.fontBoundingBoxDescent)/2+s/2}var x=0,S=0;for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",_),t.setAttr("textAlign",Fp),o===kp?l=(this.getHeight()-i*s-2*r)/2:"bottom"===o&&(l=this.getHeight()-i*s-2*r),t.translate(r,l+r),n=0;n<i;n++){x=0,S=0;var M,b,w,E=e[n],T=E.text,A=E.width,C=E.lastInParagraph;if(t.save(),"right"===c?x+=d-A-2*r:"center"===c&&(x+=(d-A-2*r)/2),m){t.save(),t.beginPath();const e=x,i=v+S+(Rp.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i),b=0===(M=T.split(" ").length-1),w=c!==Op||C?A:d-2*r,t.lineTo(e+Math.round(w),i),t.lineWidth=a/15;const n=this._getLinearGradient();t.strokeStyle=n||p,t.stroke(),t.restore()}if(g){t.save(),t.beginPath();let e=Rp.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(x,v+S+e),b=0===(M=T.split(" ").length-1),w=c===Op&&C&&!b?d-2*r:A,t.lineTo(x+Math.round(w),v+S+e),t.lineWidth=a/15;const i=this._getLinearGradient();t.strokeStyle=i||p,t.stroke(),t.restore()}if("rtl"===h||0===u&&c!==Op)0!==u&&t.setAttr("letterSpacing",`${u}px`),this._partialTextX=x,this._partialTextY=v+S,this._partialText=T,t.fillStrokeShape(this);else{M=T.split(" ").length-1;for(var R=Ip(T),P=0;P<R.length;P++){var L=R[P];" "!==L||C||c!==Op||(x+=(d-2*r-A)/M),this._partialTextX=x,this._partialTextY=v+S,this._partialText=L,t.fillStrokeShape(this),x+=this.measureSize(L).width+u}}t.restore(),i>1&&(v+=s)}}}_hitFunc(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){var e=Tp.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Up||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Up||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Tp.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,r,a,s,o,h,l,c,d,u,p=Wp(),f=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const m=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*m,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*m,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*m,alphabeticBaseline:null!==(a=u.alphabeticBaseline)&&void 0!==a?a:0,emHeightAscent:null!==(s=u.emHeightAscent)&&void 0!==s?s:100*m,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*m,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*m,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*m,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*m,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*m,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+zp+this.fontVariant()+zp+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===Op&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){var e=this.letterSpacing(),i=t.length;return Wp().measureText(t).width+(i?e*(i-1):0)}_setTextData(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,a=this.attrs.height,s=r!==Up&&void 0!==r,o=a!==Up&&void 0!==a,h=this.padding(),l=r-2*h,c=a-2*h,d=0,u=this.wrap(),p="char"!==u&&u!==Gp,f=this.ellipsis();this.textArr=[],Wp().font=this._getContextFont();for(var m=f?this._getTextWidth("…"):0,g=0,v=t.length;g<v;++g){var _=t[g],y=this._getTextWidth(_);if(s&&y>l)for(;_.length>0;){for(var x=0,S=_.length,M="",b=0;x<S;){var w=x+S>>>1,E=_.slice(0,w+1),T=this._getTextWidth(E)+m;T<=l?(x=w+1,M=E,b=T):S=w}if(!M)break;if(p){var A,C=_[M.length];(A=(C===zp||"-"===C)&&b<=l?M.length:Math.max(M.lastIndexOf(zp),M.lastIndexOf("-"))+1)>0&&(x=A,M=M.slice(0,x),b=this._getTextWidth(M))}if(M=M.trimRight(),this._addTextLine(M),i=Math.max(i,b),d+=n,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((_=(_=_.slice(x)).trimLeft()).length>0&&(y=this._getTextWidth(_))<=l){this._addTextLine(_),d+=n,i=Math.max(i,y);break}}else this._addTextLine(_),d+=n,i=Math.max(i,y),this._shouldHandleEllipsis(d)&&g<v-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){var e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==Up&&void 0!==n,a=n-2*this.padding();return!(this.wrap()!==Gp)||r&&t+i>a}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==Up&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e)this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3));this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}Ep.Text=Xp,Xp.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},Xp.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Xp.prototype.className="Text",Xp.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,Lp._registerNode)(Xp),Ap.Factory.overWriteSetter(Xp,"width",(0,Pp.getNumberOrAutoValidator)()),Ap.Factory.overWriteSetter(Xp,"height",(0,Pp.getNumberOrAutoValidator)()),Ap.Factory.addGetterSetter(Xp,"direction",Np),Ap.Factory.addGetterSetter(Xp,"fontFamily","Arial"),Ap.Factory.addGetterSetter(Xp,"fontSize",12,(0,Pp.getNumberValidator)()),Ap.Factory.addGetterSetter(Xp,"fontStyle",Bp),Ap.Factory.addGetterSetter(Xp,"fontVariant",Bp),Ap.Factory.addGetterSetter(Xp,"padding",0,(0,Pp.getNumberValidator)()),Ap.Factory.addGetterSetter(Xp,"align",Fp),Ap.Factory.addGetterSetter(Xp,"verticalAlign","top"),Ap.Factory.addGetterSetter(Xp,"lineHeight",1,(0,Pp.getNumberValidator)()),Ap.Factory.addGetterSetter(Xp,"wrap","word"),Ap.Factory.addGetterSetter(Xp,"ellipsis",!1,(0,Pp.getBooleanValidator)()),Ap.Factory.addGetterSetter(Xp,"letterSpacing",0,(0,Pp.getNumberValidator)()),Ap.Factory.addGetterSetter(Xp,"text","",(0,Pp.getStringValidator)()),Ap.Factory.addGetterSetter(Xp,"textDecoration","");var jp={};Object.defineProperty(jp,"__esModule",{value:!0}),jp.TextPath=void 0;const Yp=oc,qp=lc,Kp=cd,Zp=tu,Jp=Ep,Qp=cc,$p=sc;var tf="normal";function ef(t){t.fillText(this.partialText,0,0)}function nf(t){t.strokeText(this.partialText,0,0)}class rf extends Kp.Shape{constructor(t){super(t),this.dummyCanvas=Yp.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Zp.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:Zp.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Zp.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(var a=0;a<r.length;a++){t.save();var s=r[a].p0;t.translate(s.x,s.y),t.rotate(r[a].rotation),this.partialText=r[a].text,t.fillStrokeShape(this),"underline"===e&&(0===a&&t.moveTo(0,n/2+1),t.lineTo(n,n/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();var e=this.glyphInfo;if(e.length>=1){var i=e[0].p0;t.moveTo(i.x,i.y)}for(var n=0;n<e.length;n++){var r=e[n].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Yp.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return Jp.Text.prototype.setText.call(this,t)}_getContextFont(){return Jp.Text.prototype._getContextFont.call(this)}_getTextSize(t){var e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();var i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),n=this.align(),r=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let s=0;"center"===n&&(s=Math.max(0,this.pathLength/2-a/2)),"right"===n&&(s=Math.max(0,this.pathLength-a));const o=(0,Jp.stringToArray)(this.text());let h=s;for(var l=0;l<o.length;l++){const t=this._getPointAtLength(h);if(!t)return;let e=this._getTextSize(o[l]).width+i;if(" "===o[l]&&"justify"===n){const t=this.text().split(" ").length-1;e+=(this.pathLength-a)/t}const s=this._getPointAtLength(h+e);if(!s)return;const c=Zp.Path.getLineLength(t.x,t.y,s.x,s.y);let d=0;if(r)try{d=r(o[l-1],o[l])*this.fontSize()}catch(t){d=0}t.x+=d,s.x+=d,this.textWidth+=d;const u=Zp.Path.getPointOnLine(d+c/2,t.x,t.y,s.x,s.y),p=Math.atan2(s.y-t.y,s.x-t.x);this.glyphInfo.push({transposeX:u.x,transposeY:u.y,text:o[l],rotation:p,p0:t,p1:s}),h+=e}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));for(var e,i,n=t[0]||0,r=t[0]||0,a=t[1]||0,s=t[1]||0,o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),r=Math.max(r,e),a=Math.min(a,i),s=Math.max(s,i);var h=this.fontSize();return{x:n-h/2,y:a-h/2,width:r-n+h,height:s-a+h}}destroy(){return Yp.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}jp.TextPath=rf,rf.prototype._fillFunc=ef,rf.prototype._strokeFunc=nf,rf.prototype._fillFuncHit=ef,rf.prototype._strokeFuncHit=nf,rf.prototype.className="TextPath",rf.prototype._attrsAffectingSize=["text","fontSize","data"],(0,$p._registerNode)(rf),qp.Factory.addGetterSetter(rf,"data"),qp.Factory.addGetterSetter(rf,"fontFamily","Arial"),qp.Factory.addGetterSetter(rf,"fontSize",12,(0,Qp.getNumberValidator)()),qp.Factory.addGetterSetter(rf,"fontStyle",tf),qp.Factory.addGetterSetter(rf,"align","left"),qp.Factory.addGetterSetter(rf,"letterSpacing",0,(0,Qp.getNumberValidator)()),qp.Factory.addGetterSetter(rf,"textBaseline","middle"),qp.Factory.addGetterSetter(rf,"fontVariant",tf),qp.Factory.addGetterSetter(rf,"text",""),qp.Factory.addGetterSetter(rf,"textDecoration",null),qp.Factory.addGetterSetter(rf,"kerningFunc",null);var af={};Object.defineProperty(af,"__esModule",{value:!0}),af.Transformer=void 0;const sf=oc,of=lc,hf=hc,lf=cd,cf=ju,df=Ad,uf=sc,pf=cc,ff=sc;var mf="tr-konva",gf=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${mf}`)).join(" "),vf="nodesRect",_f=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],yf={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const xf="ontouchstart"in uf.Konva._global;var Sf=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Mf(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:r}}function bf(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return Mf(t,e,i)}let wf=0;class Ef extends df.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(gf,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return sf.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return mf+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(sf.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(_f.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const n=t.getAbsolutePosition(),r=n.x-e.x,a=n.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+r,y:n.y+a}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(vf),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(vf,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){var n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),a=t.getAbsolutePosition(i),s=n.x*r.x-t.offsetX()*r.x,o=n.y*r.y-t.offsetY()*r.y;const h=(uf.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Mf({x:a.x+s*Math.cos(h)+o*Math.sin(-h),y:a.y+o*Math.cos(h)+s*Math.sin(h),width:n.width*r.x,height:n.height*r.y,rotation:h},-uf.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map((e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=e.getAbsoluteTransform();n.forEach((function(e){var i=r.point(e);t.push(i)}))}));const e=new sf.Transform;e.rotate(-uf.Konva.getAngle(this.rotation()));var i=1/0,n=1/0,r=-1/0,a=-1/0;t.forEach((function(t){var s=e.point(t);void 0===i&&(i=r=s.x,n=a=s.y),i=Math.min(i,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),a=Math.max(a,s.y)})),e.invert();const s=e.point({x:i,y:n});return{x:s.x,y:s.y,width:r-i,height:a-n,rotation:uf.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Sf.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new cf.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:xf?10:"auto"}),i=this;e.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),e.on("dragstart",(t=>{e.stopDrag(),t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),e.on("mouseenter",(()=>{var i=uf.Konva.getAngle(this.rotation()),n=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=sf.Util.degToRad(yf[t]||0);var n=(sf.Util.radToDeg(e)%360+360)%360;return sf.Util._inRange(n,337.5,360)||sf.Util._inRange(n,0,22.5)?"ns-resize":sf.Util._inRange(n,22.5,67.5)?"nesw-resize":sf.Util._inRange(n,67.5,112.5)?"ew-resize":sf.Util._inRange(n,112.5,157.5)?"nwse-resize":sf.Util._inRange(n,157.5,202.5)?"ns-resize":sf.Util._inRange(n,202.5,247.5)?"nesw-resize":sf.Util._inRange(n,247.5,292.5)?"ew-resize":sf.Util._inRange(n,292.5,337.5)?"nwse-resize":(sf.Util.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0})),e.on("mouseout",(()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(e)}_createBack(){var t=new lf.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){var i=e.getParent(),n=i.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.moveTo(e.width()/2,-n),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*sf.Util._sign(e.height())-n),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(this.shouldOverdrawWholeArea()){var i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}}});this.add(t),this._proxyDrag(t),t.on("dragstart",(t=>{t.cancelBubble=!0})),t.on("dragmove",(t=>{t.cancelBubble=!0})),t.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(!this._transforming){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=t.target.getAbsolutePosition(),s=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-a.x,y:s.y-a.y},wf++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}}_handleMouseMove(t){var e,i,n,r=this.findOne("."+this._movingAnchorName),a=r.getStage();a.setPointersPositions(t);const s=a.getPointerPosition();let o={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),r.setAbsolutePosition(o);const l=r.getAbsolutePosition();if(h.x!==l.x||h.y!==l.y)if("rotater"!==this._movingAnchorName){var c,d=this.shiftBehavior();c="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(c){var p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(p.x-r.x(),2)+Math.pow(p.y-r.y(),2));var f=this.findOne(".top-left").x()>p.x?-1:1,m=this.findOne(".top-left").y()>p.y?-1:1;e=n*this.cos*f,i=n*this.sin*m,this.findOne(".top-left").x(p.x-e),this.findOne(".top-left").y(p.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(c){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(r.x()-p.x,2)+Math.pow(p.y-r.y(),2));f=this.findOne(".top-right").x()<p.x?-1:1,m=this.findOne(".top-right").y()>p.y?-1:1;e=n*this.cos*f,i=n*this.sin*m,this.findOne(".top-right").x(p.x+e),this.findOne(".top-right").y(p.y-i)}var g=r.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(c){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(p.x-r.x(),2)+Math.pow(r.y()-p.y,2));f=p.x<r.x()?-1:1,m=r.y()<p.y?-1:1;e=n*this.cos*f,i=n*this.sin*m,r.x(p.x-e),r.y(p.y+i)}g=r.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(c){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(r.x()-p.x,2)+Math.pow(r.y()-p.y,2));f=this.findOne(".bottom-right").x()<p.x?-1:1,m=this.findOne(".bottom-right").y()<p.y?-1:1;e=n*this.cos*f,i=n*this.sin*m,this.findOne(".bottom-right").x(p.x+e),this.findOne(".bottom-right").y(p.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey){var v=this.findOne(".top-left"),_=this.findOne(".bottom-right"),y=v.x(),x=v.y(),S=this.getWidth()-_.x(),M=this.getHeight()-_.y();_.move({x:-y,y:-x}),v.move({x:S,y:M})}var b=this.findOne(".top-left").getAbsolutePosition();e=b.x,i=b.y;var w=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),E=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:w,height:E,rotation:uf.Konva.getAngle(this.rotation())},t)}else{var T=this._getNodeRect();e=r.x()-T.width/2,i=-r.y()+T.height/2;let n=Math.atan2(-i,e)+Math.PI/2;T.height<0&&(n-=Math.PI);const a=uf.Konva.getAngle(this.rotation())+n,s=uf.Konva.getAngle(this.rotationSnapTolerance()),o=bf(T,function(t,e,i){let n=e;for(let r=0;r<t.length;r++){const a=uf.Konva.getAngle(t[r]),s=Math.abs(a-e)%(2*Math.PI);Math.min(s,2*Math.PI-s)<i&&(n=a)}return n}(this.rotationSnaps(),a,s)-T.rotation);this._fitNodesInto(o,t)}}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var i=this.getNode();wf--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(t,e){var i=this._getNodeRect();if(sf.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(sf.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var n=new sf.Transform;if(n.rotate(uf.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:sf.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const r=1e7,a=new sf.Transform;a.translate(i.x,i.y),a.rotate(i.rotation),a.scale(i.width/r,i.height/r);const s=new sf.Transform,o=t.width/r,h=t.height/r;!1===this.flipEnabled()?(s.translate(t.x,t.y),s.rotate(t.rotation),s.translate(t.width<0?t.width:0,t.height<0?t.height:0),s.scale(Math.abs(o),Math.abs(h))):(s.translate(t.x,t.y),s.rotate(t.rotation),s.scale(o,h));const l=s.multiply(a.invert());this._nodes.forEach((t=>{var e;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const r=new sf.Transform;r.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const a=r.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()})),this.rotation(sf.Util._getRotation(t.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t,e=this._getNodeRect();this.rotation(sf.Util._getRotation(e.rotation));var i=e.width,n=e.height,r=this.enabledAnchors(),a=this.resizeEnabled(),s=this.padding(),o=this.anchorSize();const h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+s,offsetY:o/2+s,visible:a&&r.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+s,visible:a&&r.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-s,offsetY:o/2+s,visible:a&&r.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+s,visible:a&&r.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-s,visible:a&&r.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+s,offsetY:o/2-s,visible:a&&r.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-s,visible:a&&r.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-s,offsetY:o/2-s,visible:a&&r.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*sf.Util._sign(n)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach((t=>{l(t)})),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),df.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return hf.Node.prototype.toObject.call(this)}clone(t){return hf.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}af.Transformer=Ef,Ef.isTransforming=()=>wf>0,Ef.prototype.className="Transformer",(0,ff._registerNode)(Ef),of.Factory.addGetterSetter(Ef,"enabledAnchors",Sf,(function(t){return t instanceof Array||sf.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===Sf.indexOf(t)&&sf.Util.warn("Unknown anchor name: "+t+". Available names are: "+Sf.join(", "))})),t||[]})),of.Factory.addGetterSetter(Ef,"flipEnabled",!0,(0,pf.getBooleanValidator)()),of.Factory.addGetterSetter(Ef,"resizeEnabled",!0),of.Factory.addGetterSetter(Ef,"anchorSize",10,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"rotateEnabled",!0),of.Factory.addGetterSetter(Ef,"rotateLineVisible",!0),of.Factory.addGetterSetter(Ef,"rotationSnaps",[]),of.Factory.addGetterSetter(Ef,"rotateAnchorOffset",50,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"rotateAnchorCursor","crosshair"),of.Factory.addGetterSetter(Ef,"rotationSnapTolerance",5,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"borderEnabled",!0),of.Factory.addGetterSetter(Ef,"anchorStroke","rgb(0, 161, 255)"),of.Factory.addGetterSetter(Ef,"anchorStrokeWidth",1,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"anchorFill","white"),of.Factory.addGetterSetter(Ef,"anchorCornerRadius",0,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"borderStroke","rgb(0, 161, 255)"),of.Factory.addGetterSetter(Ef,"borderStrokeWidth",1,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"borderDash"),of.Factory.addGetterSetter(Ef,"keepRatio",!0),of.Factory.addGetterSetter(Ef,"shiftBehavior","default"),of.Factory.addGetterSetter(Ef,"centeredScaling",!1),of.Factory.addGetterSetter(Ef,"ignoreStroke",!1),of.Factory.addGetterSetter(Ef,"padding",0,(0,pf.getNumberValidator)()),of.Factory.addGetterSetter(Ef,"node"),of.Factory.addGetterSetter(Ef,"nodes"),of.Factory.addGetterSetter(Ef,"boundBoxFunc"),of.Factory.addGetterSetter(Ef,"anchorDragBoundFunc"),of.Factory.addGetterSetter(Ef,"anchorStyleFunc"),of.Factory.addGetterSetter(Ef,"shouldOverdrawWholeArea",!1),of.Factory.addGetterSetter(Ef,"useSingleNodeRotation",!0),of.Factory.backCompat(Ef,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Tf={};Object.defineProperty(Tf,"__esModule",{value:!0}),Tf.Wedge=void 0;const Af=lc,Cf=cd,Rf=sc,Pf=cc,Lf=sc;class If extends Cf.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Rf.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Tf.Wedge=If,If.prototype.className="Wedge",If.prototype._centroid=!0,If.prototype._attrsAffectingSize=["radius"],(0,Lf._registerNode)(If),Af.Factory.addGetterSetter(If,"radius",0,(0,Pf.getNumberValidator)()),Af.Factory.addGetterSetter(If,"angle",0,(0,Pf.getNumberValidator)()),Af.Factory.addGetterSetter(If,"clockwise",!1),Af.Factory.backCompat(If,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Df={};Object.defineProperty(Df,"__esModule",{value:!0}),Df.Blur=void 0;const Uf=lc,Nf=hc,Of=cc;function Ff(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var kf=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Bf=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];Df.Blur=function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,n,r,a,s,o,h,l,c,d,u,p,f,m,g,v,_,y,x,S,M,b,w,E,T=t.data,A=t.width,C=t.height,R=e+e+1,P=A-1,L=C-1,I=e+1,D=I*(I+1)/2,U=new Ff,N=null,O=U,F=null,k=null,B=kf[e],z=Bf[e];for(r=1;r<R;r++)O=O.next=new Ff,r===I&&(N=O);for(O.next=U,h=o=0,n=0;n<C;n++){for(v=_=y=x=l=c=d=u=0,p=I*(S=T[o]),f=I*(M=T[o+1]),m=I*(b=T[o+2]),g=I*(w=T[o+3]),l+=D*S,c+=D*M,d+=D*b,u+=D*w,O=U,r=0;r<I;r++)O.r=S,O.g=M,O.b=b,O.a=w,O=O.next;for(r=1;r<I;r++)a=o+((P<r?P:r)<<2),l+=(O.r=S=T[a])*(E=I-r),c+=(O.g=M=T[a+1])*E,d+=(O.b=b=T[a+2])*E,u+=(O.a=w=T[a+3])*E,v+=S,_+=M,y+=b,x+=w,O=O.next;for(F=U,k=N,i=0;i<A;i++)T[o+3]=w=u*B>>z,0!==w?(w=255/w,T[o]=(l*B>>z)*w,T[o+1]=(c*B>>z)*w,T[o+2]=(d*B>>z)*w):T[o]=T[o+1]=T[o+2]=0,l-=p,c-=f,d-=m,u-=g,p-=F.r,f-=F.g,m-=F.b,g-=F.a,a=h+((a=i+e+1)<P?a:P)<<2,l+=v+=F.r=T[a],c+=_+=F.g=T[a+1],d+=y+=F.b=T[a+2],u+=x+=F.a=T[a+3],F=F.next,p+=S=k.r,f+=M=k.g,m+=b=k.b,g+=w=k.a,v-=S,_-=M,y-=b,x-=w,k=k.next,o+=4;h+=A}for(i=0;i<A;i++){for(_=y=x=v=c=d=u=l=0,p=I*(S=T[o=i<<2]),f=I*(M=T[o+1]),m=I*(b=T[o+2]),g=I*(w=T[o+3]),l+=D*S,c+=D*M,d+=D*b,u+=D*w,O=U,r=0;r<I;r++)O.r=S,O.g=M,O.b=b,O.a=w,O=O.next;for(s=A,r=1;r<=e;r++)o=s+i<<2,l+=(O.r=S=T[o])*(E=I-r),c+=(O.g=M=T[o+1])*E,d+=(O.b=b=T[o+2])*E,u+=(O.a=w=T[o+3])*E,v+=S,_+=M,y+=b,x+=w,O=O.next,r<L&&(s+=A);for(o=i,F=U,k=N,n=0;n<C;n++)T[3+(a=o<<2)]=w=u*B>>z,w>0?(w=255/w,T[a]=(l*B>>z)*w,T[a+1]=(c*B>>z)*w,T[a+2]=(d*B>>z)*w):T[a]=T[a+1]=T[a+2]=0,l-=p,c-=f,d-=m,u-=g,p-=F.r,f-=F.g,m-=F.b,g-=F.a,a=i+((a=n+I)<L?a:L)*A<<2,l+=v+=F.r=T[a],c+=_+=F.g=T[a+1],d+=y+=F.b=T[a+2],u+=x+=F.a=T[a+3],F=F.next,p+=S=k.r,f+=M=k.g,m+=b=k.b,g+=w=k.a,v-=S,_-=M,y-=b,x-=w,k=k.next,o+=A}}(t,e)},Uf.Factory.addGetterSetter(Nf.Node,"blurRadius",0,(0,Of.getNumberValidator)(),Uf.Factory.afterSetFilter);var zf={};Object.defineProperty(zf,"__esModule",{value:!0}),zf.Brighten=void 0;const Gf=lc,Hf=hc,Vf=cc;zf.Brighten=function(t){var e,i=255*this.brightness(),n=t.data,r=n.length;for(e=0;e<r;e+=4)n[e]+=i,n[e+1]+=i,n[e+2]+=i},Gf.Factory.addGetterSetter(Hf.Node,"brightness",0,(0,Vf.getNumberValidator)(),Gf.Factory.afterSetFilter);var Wf={};Object.defineProperty(Wf,"__esModule",{value:!0}),Wf.Contrast=void 0;const Xf=lc,jf=hc,Yf=cc;Wf.Contrast=function(t){var e,i=Math.pow((this.contrast()+100)/100,2),n=t.data,r=n.length,a=150,s=150,o=150;for(e=0;e<r;e+=4)a=n[e],s=n[e+1],o=n[e+2],a/=255,a-=.5,a*=i,a+=.5,s/=255,s-=.5,s*=i,s+=.5,o/=255,o-=.5,o*=i,o+=.5,a=(a*=255)<0?0:a>255?255:a,s=(s*=255)<0?0:s>255?255:s,o=(o*=255)<0?0:o>255?255:o,n[e]=a,n[e+1]=s,n[e+2]=o},Xf.Factory.addGetterSetter(jf.Node,"contrast",0,(0,Yf.getNumberValidator)(),Xf.Factory.afterSetFilter);var qf={};Object.defineProperty(qf,"__esModule",{value:!0}),qf.Emboss=void 0;const Kf=lc,Zf=hc,Jf=oc,Qf=cc;qf.Emboss=function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),n=this.embossDirection(),r=this.embossBlend(),a=0,s=0,o=t.data,h=t.width,l=t.height,c=4*h,d=l;switch(n){case"top-left":a=-1,s=-1;break;case"top":a=-1,s=0;break;case"top-right":a=-1,s=1;break;case"right":a=0,s=1;break;case"bottom-right":a=1,s=1;break;case"bottom":a=1,s=0;break;case"bottom-left":a=1,s=-1;break;case"left":a=0,s=-1;break;default:Jf.Util.error("Unknown emboss direction: "+n)}do{var u=(d-1)*c,p=a;d+p<1&&(p=0),d+p>l&&(p=0);var f=(d-1+p)*h*4,m=h;do{var g=u+4*(m-1),v=s;m+v<1&&(v=0),m+v>h&&(v=0);var _=f+4*(m-1+v),y=o[g]-o[_],x=o[g+1]-o[_+1],S=o[g+2]-o[_+2],M=y,b=M>0?M:-M;if((x>0?x:-x)>b&&(M=x),(S>0?S:-S)>b&&(M=S),M*=e,r){var w=o[g]+M,E=o[g+1]+M,T=o[g+2]+M;o[g]=w>255?255:w<0?0:w,o[g+1]=E>255?255:E<0?0:E,o[g+2]=T>255?255:T<0?0:T}else{var A=i-M;A<0?A=0:A>255&&(A=255),o[g]=o[g+1]=o[g+2]=A}}while(--m)}while(--d)},Kf.Factory.addGetterSetter(Zf.Node,"embossStrength",.5,(0,Qf.getNumberValidator)(),Kf.Factory.afterSetFilter),Kf.Factory.addGetterSetter(Zf.Node,"embossWhiteLevel",.5,(0,Qf.getNumberValidator)(),Kf.Factory.afterSetFilter),Kf.Factory.addGetterSetter(Zf.Node,"embossDirection","top-left",null,Kf.Factory.afterSetFilter),Kf.Factory.addGetterSetter(Zf.Node,"embossBlend",!1,null,Kf.Factory.afterSetFilter);var $f={};Object.defineProperty($f,"__esModule",{value:!0}),$f.Enhance=void 0;const tm=lc,em=hc,im=cc;function nm(t,e,i,n,r){var a=i-e,s=r-n;return 0===a?n+s/2:0===s?n:s*((t-e)/a)+n}$f.Enhance=function(t){var e,i,n,r,a=t.data,s=a.length,o=a[0],h=o,l=a[1],c=l,d=a[2],u=d,p=this.enhance();if(0!==p){for(r=0;r<s;r+=4)(e=a[r+0])<o?o=e:e>h&&(h=e),(i=a[r+1])<l?l=i:i>c&&(c=i),(n=a[r+2])<d?d=n:n>u&&(u=n);var f,m,g,v,_,y,x,S,M;for(h===o&&(h=255,o=0),c===l&&(c=255,l=0),u===d&&(u=255,d=0),p>0?(m=h+p*(255-h),g=o-p*(o-0),_=c+p*(255-c),y=l-p*(l-0),S=u+p*(255-u),M=d-p*(d-0)):(m=h+p*(h-(f=.5*(h+o))),g=o+p*(o-f),_=c+p*(c-(v=.5*(c+l))),y=l+p*(l-v),S=u+p*(u-(x=.5*(u+d))),M=d+p*(d-x)),r=0;r<s;r+=4)a[r+0]=nm(a[r+0],o,h,g,m),a[r+1]=nm(a[r+1],l,c,y,_),a[r+2]=nm(a[r+2],d,u,M,S)}},tm.Factory.addGetterSetter(em.Node,"enhance",0,(0,im.getNumberValidator)(),tm.Factory.afterSetFilter);var rm={};Object.defineProperty(rm,"__esModule",{value:!0}),rm.Grayscale=void 0;rm.Grayscale=function(t){var e,i,n=t.data,r=n.length;for(e=0;e<r;e+=4)i=.34*n[e]+.5*n[e+1]+.16*n[e+2],n[e]=i,n[e+1]=i,n[e+2]=i};var am={};Object.defineProperty(am,"__esModule",{value:!0}),am.HSL=void 0;const sm=lc,om=hc,hm=cc;sm.Factory.addGetterSetter(om.Node,"hue",0,(0,hm.getNumberValidator)(),sm.Factory.afterSetFilter),sm.Factory.addGetterSetter(om.Node,"saturation",0,(0,hm.getNumberValidator)(),sm.Factory.afterSetFilter),sm.Factory.addGetterSetter(om.Node,"luminance",0,(0,hm.getNumberValidator)(),sm.Factory.afterSetFilter);am.HSL=function(t){var e,i,n,r,a,s=t.data,o=s.length,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,c=127*this.luminance(),d=1*h*Math.cos(l*Math.PI/180),u=1*h*Math.sin(l*Math.PI/180),p=.299+.701*d+.167*u,f=.587-.587*d+.33*u,m=.114-.114*d-.497*u,g=.299-.299*d-.328*u,v=.587+.413*d+.035*u,_=.114-.114*d+.293*u,y=.299-.3*d+1.25*u,x=.587-.586*d-1.05*u,S=.114+.886*d-.2*u;for(e=0;e<o;e+=4)i=s[e+0],n=s[e+1],r=s[e+2],a=s[e+3],s[e+0]=p*i+f*n+m*r+c,s[e+1]=g*i+v*n+_*r+c,s[e+2]=y*i+x*n+S*r+c,s[e+3]=a};var lm={};Object.defineProperty(lm,"__esModule",{value:!0}),lm.HSV=void 0;const cm=lc,dm=hc,um=cc;lm.HSV=function(t){var e,i,n,r,a,s=t.data,o=s.length,h=Math.pow(2,this.value()),l=Math.pow(2,this.saturation()),c=Math.abs(this.hue()+360)%360,d=h*l*Math.cos(c*Math.PI/180),u=h*l*Math.sin(c*Math.PI/180),p=.299*h+.701*d+.167*u,f=.587*h-.587*d+.33*u,m=.114*h-.114*d-.497*u,g=.299*h-.299*d-.328*u,v=.587*h+.413*d+.035*u,_=.114*h-.114*d+.293*u,y=.299*h-.3*d+1.25*u,x=.587*h-.586*d-1.05*u,S=.114*h+.886*d-.2*u;for(e=0;e<o;e+=4)i=s[e+0],n=s[e+1],r=s[e+2],a=s[e+3],s[e+0]=p*i+f*n+m*r,s[e+1]=g*i+v*n+_*r,s[e+2]=y*i+x*n+S*r,s[e+3]=a},cm.Factory.addGetterSetter(dm.Node,"hue",0,(0,um.getNumberValidator)(),cm.Factory.afterSetFilter),cm.Factory.addGetterSetter(dm.Node,"saturation",0,(0,um.getNumberValidator)(),cm.Factory.afterSetFilter),cm.Factory.addGetterSetter(dm.Node,"value",0,(0,um.getNumberValidator)(),cm.Factory.afterSetFilter);var pm={};Object.defineProperty(pm,"__esModule",{value:!0}),pm.Invert=void 0;pm.Invert=function(t){var e,i=t.data,n=i.length;for(e=0;e<n;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]};var fm={};Object.defineProperty(fm,"__esModule",{value:!0}),fm.Kaleidoscope=void 0;const mm=lc,gm=hc,vm=oc,_m=cc;fm.Kaleidoscope=function(t){var e,i,n,r,a,s,o,h,l,c=t.width,d=t.height,u=Math.round(this.kaleidoscopePower()),p=Math.round(this.kaleidoscopeAngle()),f=Math.floor(c*(p%360)/360);if(!(u<1)){var m=vm.Util.createCanvasElement();m.width=c,m.height=d;var g=m.getContext("2d").getImageData(0,0,c,d);vm.Util.releaseCanvas(m),function(t,e,i){var n,r,a,s,o=t.data,h=e.data,l=t.width,c=t.height,d=i.polarCenterX||l/2,u=i.polarCenterY||c/2,p=0,f=0,m=0,g=0,v=Math.sqrt(d*d+u*u);r=l-d,a=c-u,v=(s=Math.sqrt(r*r+a*a))>v?s:v;var _,y,x,S,M=c,b=l,w=360/b*Math.PI/180;for(y=0;y<b;y+=1)for(x=Math.sin(y*w),S=Math.cos(y*w),_=0;_<M;_+=1)r=Math.floor(d+v*_/M*S),p=o[0+(n=4*((a=Math.floor(u+v*_/M*x))*l+r))],f=o[n+1],m=o[n+2],g=o[n+3],h[0+(n=4*(y+_*l))]=p,h[n+1]=f,h[n+2]=m,h[n+3]=g}(t,g,{polarCenterX:c/2,polarCenterY:d/2});for(var v=c/Math.pow(2,u);v<=8;)v*=2,u-=1;var _=v=Math.ceil(v),y=0,x=_,S=1;for(f+v>c&&(y=_,x=0,S=-1),i=0;i<d;i+=1)for(e=y;e!==x;e+=S)h=4*(c*i+Math.round(e+f)%c),r=g.data[h+0],a=g.data[h+1],s=g.data[h+2],o=g.data[h+3],l=4*(c*i+e),g.data[l+0]=r,g.data[l+1]=a,g.data[l+2]=s,g.data[l+3]=o;for(i=0;i<d;i+=1)for(_=Math.floor(v),n=0;n<u;n+=1){for(e=0;e<_+1;e+=1)h=4*(c*i+e),r=g.data[h+0],a=g.data[h+1],s=g.data[h+2],o=g.data[h+3],l=4*(c*i+2*_-e-1),g.data[l+0]=r,g.data[l+1]=a,g.data[l+2]=s,g.data[l+3]=o;_*=2}!function(t,e,i){var n,r,a,s,o,h,l=t.data,c=e.data,d=t.width,u=t.height,p=i.polarCenterX||d/2,f=i.polarCenterY||u/2,m=0,g=0,v=0,_=0,y=Math.sqrt(p*p+f*f);r=d-p,a=u-f,y=(h=Math.sqrt(r*r+a*a))>y?h:y;var x,S,M,b=u,w=d;for(r=0;r<d;r+=1)for(a=0;a<u;a+=1)s=r-p,o=a-f,x=Math.sqrt(s*s+o*o)*b/y,S=(S=(180*Math.atan2(o,s)/Math.PI+360+0)%360)*w/360,M=Math.floor(S),m=l[0+(n=4*(Math.floor(x)*d+M))],g=l[n+1],v=l[n+2],_=l[n+3],c[0+(n=4*(a*d+r))]=m,c[n+1]=g,c[n+2]=v,c[n+3]=_}(g,t,{polarRotation:0})}},mm.Factory.addGetterSetter(gm.Node,"kaleidoscopePower",2,(0,_m.getNumberValidator)(),mm.Factory.afterSetFilter),mm.Factory.addGetterSetter(gm.Node,"kaleidoscopeAngle",0,(0,_m.getNumberValidator)(),mm.Factory.afterSetFilter);var ym={};Object.defineProperty(ym,"__esModule",{value:!0}),ym.Mask=void 0;const xm=lc,Sm=hc,Mm=cc;function bm(t,e,i){var n=4*(i*t.width+e),r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function wm(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}ym.Mask=function(t){var e=function(t,e){var i=bm(t,0,0),n=bm(t,t.width-1,0),r=bm(t,0,t.height-1),a=bm(t,t.width-1,t.height-1),s=e||10;if(wm(i,n)<s&&wm(n,a)<s&&wm(a,r)<s&&wm(r,i)<s){for(var o=function(t){for(var e=[0,0,0],i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,a,r]),h=[],l=0;l<t.width*t.height;l++){var c=wm(o,[t.data[4*l],t.data[4*l+1],t.data[4*l+2]]);h[l]=c<s?0:255}return h}}(t,this.threshold());return e&&function(t,e){for(var i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e=function(t,e,i){for(var n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,c=0,d=0;d<r;d++)for(var u=0;u<r;u++){var p=o+d-a,f=h+u-a;if(p>=0&&p<i&&f>=0&&f<e){var m=n[d*r+u];c+=t[p*e+f]*m}}s[l]=c}return s}(e=function(t,e,i){for(var n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,c=0,d=0;d<r;d++)for(var u=0;u<r;u++){var p=o+d-a,f=h+u-a;if(p>=0&&p<i&&f>=0&&f<e){var m=n[d*r+u];c+=t[p*e+f]*m}}s[l]=c>=1020?255:0}return s}(e=function(t,e,i){for(var n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,c=0,d=0;d<r;d++)for(var u=0;u<r;u++){var p=o+d-a,f=h+u-a;if(p>=0&&p<i&&f>=0&&f<e){var m=n[d*r+u];c+=t[p*e+f]*m}}s[l]=2040===c?255:0}return s}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},xm.Factory.addGetterSetter(Sm.Node,"threshold",0,(0,Mm.getNumberValidator)(),xm.Factory.afterSetFilter);var Em={};Object.defineProperty(Em,"__esModule",{value:!0}),Em.Noise=void 0;const Tm=lc,Am=hc,Cm=cc;Em.Noise=function(t){var e,i=255*this.noise(),n=t.data,r=n.length,a=i/2;for(e=0;e<r;e+=4)n[e+0]+=a-2*a*Math.random(),n[e+1]+=a-2*a*Math.random(),n[e+2]+=a-2*a*Math.random()},Tm.Factory.addGetterSetter(Am.Node,"noise",.2,(0,Cm.getNumberValidator)(),Tm.Factory.afterSetFilter);var Rm={};Object.defineProperty(Rm,"__esModule",{value:!0}),Rm.Pixelate=void 0;const Pm=lc,Lm=oc,Im=hc,Dm=cc;Rm.Pixelate=function(t){var e,i,n,r,a,s,o,h,l,c,d,u,p,f,m=Math.ceil(this.pixelSize()),g=t.width,v=t.height,_=Math.ceil(g/m),y=Math.ceil(v/m),x=t.data;if(m<=0)Lm.Util.error("pixelSize value can not be <= 0");else for(u=0;u<_;u+=1)for(p=0;p<y;p+=1){for(r=0,a=0,s=0,o=0,l=(h=u*m)+m,d=(c=p*m)+m,f=0,e=h;e<l;e+=1)if(!(e>=g))for(i=c;i<d;i+=1)i>=v||(r+=x[(n=4*(g*i+e))+0],a+=x[n+1],s+=x[n+2],o+=x[n+3],f+=1);for(r/=f,a/=f,s/=f,o/=f,e=h;e<l;e+=1)if(!(e>=g))for(i=c;i<d;i+=1)i>=v||(x[(n=4*(g*i+e))+0]=r,x[n+1]=a,x[n+2]=s,x[n+3]=o)}},Pm.Factory.addGetterSetter(Im.Node,"pixelSize",8,(0,Dm.getNumberValidator)(),Pm.Factory.afterSetFilter);var Um={};Object.defineProperty(Um,"__esModule",{value:!0}),Um.Posterize=void 0;const Nm=lc,Om=hc,Fm=cc;Um.Posterize=function(t){var e,i=Math.round(254*this.levels())+1,n=t.data,r=n.length,a=255/i;for(e=0;e<r;e+=1)n[e]=Math.floor(n[e]/a)*a},Nm.Factory.addGetterSetter(Om.Node,"levels",.5,(0,Fm.getNumberValidator)(),Nm.Factory.afterSetFilter);var km={};Object.defineProperty(km,"__esModule",{value:!0}),km.RGB=void 0;const Bm=lc,zm=hc,Gm=cc;km.RGB=function(t){var e,i,n=t.data,r=n.length,a=this.red(),s=this.green(),o=this.blue();for(e=0;e<r;e+=4)i=(.34*n[e]+.5*n[e+1]+.16*n[e+2])/255,n[e]=i*a,n[e+1]=i*s,n[e+2]=i*o,n[e+3]=n[e+3]},Bm.Factory.addGetterSetter(zm.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Bm.Factory.addGetterSetter(zm.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Bm.Factory.addGetterSetter(zm.Node,"blue",0,Gm.RGBComponent,Bm.Factory.afterSetFilter);var Hm={};Object.defineProperty(Hm,"__esModule",{value:!0}),Hm.RGBA=void 0;const Vm=lc,Wm=hc,Xm=cc;Hm.RGBA=function(t){var e,i,n=t.data,r=n.length,a=this.red(),s=this.green(),o=this.blue(),h=this.alpha();for(e=0;e<r;e+=4)i=1-h,n[e]=a*h+n[e]*i,n[e+1]=s*h+n[e+1]*i,n[e+2]=o*h+n[e+2]*i},Vm.Factory.addGetterSetter(Wm.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Vm.Factory.addGetterSetter(Wm.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Vm.Factory.addGetterSetter(Wm.Node,"blue",0,Xm.RGBComponent,Vm.Factory.afterSetFilter),Vm.Factory.addGetterSetter(Wm.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var jm={};Object.defineProperty(jm,"__esModule",{value:!0}),jm.Sepia=void 0;jm.Sepia=function(t){var e,i,n,r,a=t.data,s=a.length;for(e=0;e<s;e+=4)i=a[e+0],n=a[e+1],r=a[e+2],a[e+0]=Math.min(255,.393*i+.769*n+.189*r),a[e+1]=Math.min(255,.349*i+.686*n+.168*r),a[e+2]=Math.min(255,.272*i+.534*n+.131*r)};var Ym={};Object.defineProperty(Ym,"__esModule",{value:!0}),Ym.Solarize=void 0;Ym.Solarize=function(t){var e=t.data,i=t.width,n=4*i,r=t.height;do{var a=(r-1)*n,s=i;do{var o=a+4*(s-1),h=e[o],l=e[o+1],c=e[o+2];h>127&&(h=255-h),l>127&&(l=255-l),c>127&&(c=255-c),e[o]=h,e[o+1]=l,e[o+2]=c}while(--s)}while(--r)};var qm={};Object.defineProperty(qm,"__esModule",{value:!0}),qm.Threshold=void 0;const Km=lc,Zm=hc,Jm=cc;qm.Threshold=function(t){var e,i=255*this.threshold(),n=t.data,r=n.length;for(e=0;e<r;e+=1)n[e]=n[e]<i?0:255},Km.Factory.addGetterSetter(Zm.Node,"threshold",.5,(0,Jm.getNumberValidator)(),Km.Factory.afterSetFilter),Object.defineProperty(rc,"__esModule",{value:!0}),rc.Konva=void 0;const Qm=ac,$m=kd,tg=Xd,eg=pu,ig=yu,ng=Eu,rg=Iu,ag=jd,sg=tu,og=ju,hg=$u,lg=ap,cg=up,dg=yp,ug=Ep,pg=jp,fg=af,mg=Tf,gg=Df,vg=zf,_g=Wf,yg=qf,xg=$f,Sg=rm,Mg=am,bg=lm,wg=pm,Eg=fm,Tg=ym,Ag=Em,Cg=Rm,Rg=Um,Pg=km,Lg=Hm,Ig=jm,Dg=Ym,Ug=qm;rc.Konva=Qm.Konva.Util._assign(Qm.Konva,{Arc:$m.Arc,Arrow:tg.Arrow,Circle:eg.Circle,Ellipse:ig.Ellipse,Image:ng.Image,Label:rg.Label,Tag:rg.Tag,Line:ag.Line,Path:sg.Path,Rect:og.Rect,RegularPolygon:hg.RegularPolygon,Ring:lg.Ring,Sprite:cg.Sprite,Star:dg.Star,Text:ug.Text,TextPath:pg.TextPath,Transformer:fg.Transformer,Wedge:mg.Wedge,Filters:{Blur:gg.Blur,Brighten:vg.Brighten,Contrast:_g.Contrast,Emboss:yg.Emboss,Enhance:xg.Enhance,Grayscale:Sg.Grayscale,HSL:Mg.HSL,HSV:bg.HSV,Invert:wg.Invert,Kaleidoscope:Eg.Kaleidoscope,Mask:Tg.Mask,Noise:Ag.Noise,Pixelate:Cg.Pixelate,Posterize:Rg.Posterize,RGB:Pg.RGB,RGBA:Lg.RGBA,Sepia:Ig.Sepia,Solarize:Dg.Solarize,Threshold:Ug.Threshold}});var Ng=nc.exports;Object.defineProperty(Ng,"__esModule",{value:!0});const Og=rc;nc.exports=Og.Konva;var Fg=ic(nc.exports);class kg{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class Bg{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const zg=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Gg{constructor(t,e=null){var i,n;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const r=[];t.points.forEach((t=>r.push(t.x,t.y))),this._ref=new Fg.Line({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(n=t.width)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:r,draggable:!0,strokeScaleEnabled:!1,dash:zg.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case zg.get("dot"):t="dot";break;case zg.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=zg.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class Hg{constructor(t,e=null){var i,n,r;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Fg.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(i=t.fontSize)&&void 0!==i?i:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(n=t.color)&&void 0!==n?n:"#ff0000",align:"left",draggable:!0,rotation:null!==(r=t.rotation)&&void 0!==r?r:0}),this._ref.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let a=this._ref.height();n&&(a*=e.scaleY);r<50&&(r=50),a<Math.round(this.getFontSize())&&(a=Math.round(this.getFontSize())),i&&this._ref.width(r),n&&this._ref.height(a),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class Vg{constructor(t,e=null){var i,n,r,a;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Fg.Rect({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(r=t.width)&&void 0!==r?r:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let a=this._ref.height();n&&(a*=e.scaleY);r<50&&(r=50),a<50&&(a=50),i&&this._ref.width(r),n&&this._ref.height(a),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}}class Wg{constructor(t,e=null){var i,n;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Fg.Ellipse({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let a=this._ref.radiusY();n&&(a*=e.scaleY);r<25&&(r=25),a<25&&(a=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:a,y:a}):this._ref.radius({x:r,y:a}),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}}class Xg{constructor(t,e=null){var i,n;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Fg.Arrow({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",fill:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y])}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e])}}class jg{constructor(t,e=null){var i,n;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",e)return e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Fg.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(i=t.width)&&void 0!==i?i:0,height:null!==(n=t.height)&&void 0!==n?n:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let a=this._ref.height();n&&(a*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(a/this._ratio),this._ref.height(a)):(i&&this._ref.width(r),n&&this._ref.height(a)),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}}class Yg{constructor(t,e=null){var i,n,r,a;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const s=16;this._ref=new Fg.Shape({x:t.position.x,y:t.position.y,width:null!==(i=t.width)&&void 0!==i?i:200,height:null!==(n=t.height)&&void 0!==n?n:200,stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],n=(r={x:0,y:0},a=this._ref.width(),o=this._ref.height(),{x:r.x+a/2,y:r.y+o/2});var r,a,o;t.beginPath();for(let e=0;e<i.length-1;e++){let r=30;const a=i[e+1].x-i[e].x,o=i[e+1].y-i[e].y,h=Math.sqrt(a*a+o*o),l=Math.floor(h/r);r=30+l/(h%r);let c=i[e].x+a/l/2,d=i[e].y+o/l/2;const u=i[e+1].x,p=i[e+1].y,f=Math.atan((p-d)/(u-c)),m=f+Math.PI,g=c>n.x&&d>n.y;for(let e=0;e<l;e++)g?t.arc(c,d,s,f,m):t.arc(c,d,s,m,f),c+=a/l,d+=o/l}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let a=this._ref.height();n&&(a*=e.scaleY);r<100&&(r=100),a<100&&(a=100),i&&this._ref.width(r),n&&this._ref.height(a),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const qg={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Gg(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new Hg(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new Vg(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new Wg(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new Xg(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new jg(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new Yg(e,t)}};class Kg{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Bg(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i))},this.pan=t=>{const e={x:this._konvaStage.x()+t.dX,y:this._konvaStage.y()+t.dY};this._konvaStage.position(e)},this.zoomAt=t=>{const e=this._konvaStage.scaleX()*t.data;this._konvaStage.scale({x:e,y:e});const i={x:t.x-(t.x-this._konvaStage.x())*t.data,y:t.y-(t.y-this._konvaStage.y())*t.data};this._konvaStage.position(i)},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){if(!Fg)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=n?n:new kg,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";const r=this._container.parentElement;r.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(r),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this._viewer.emit({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){const n=new Bg(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}colorizeSelectedMarkups(t,e,i){const n=new Bg(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)}))}setViewpoint(t){var e,i,n,r,a,s,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(n=t.texts)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(a=t.ellipses)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,t.radius,t.line_width,t.color,t.id)})),null===(s=t.arrows)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&qg[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=qg[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(qg).forEach((e=>{const i=qg[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(qg).find((t=>t.name===e));return i?i.initializer(t):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=qg[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Fg.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Fg.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Fg.Group,e.add(this._groupImages),this._groupGeometry=new Fg.Group,e.add(this._groupGeometry),this._groupTexts=new Fg.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Fg.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,r,a,s=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const a=this.getRelativePointerPosition(t);r=a,s=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(n=this.addLine([a.x,a.y,a.x,a.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(s){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,n=i?r.x:Math.min(r.x,e.x),a=i?r.y:Math.min(r.y,e.y),s=i?200:Math.abs(r.x-e.x),o=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:a},s,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:a},{x:s/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?a:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:a},Math.max(100,s),Math.max(100,o)))}a=void 0,s=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!s)return;const i=this.getRelativePointerPosition(t),o=r&&i.x===r.x&&i.y===r.y,h=o?r.x:Math.min(r.x,i.x),l=o?r.y:Math.min(r.y,i.y),c=o?200:Math.abs(r.x-i.x),d=o?200:Math.abs(r.y-i.y);"Line"===this._markupMode?n.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?a?a.setEndPoint(i.x,i.y):a=this.addArrow({x:r.x,y:r.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?a?(a.setPosition(h,l),a.setWidth(c),a.setHeight(d)):a=this.addRectangle({x:h,y:l},c,d):"Ellipse"===this._markupMode?a?(a.setPosition(h,l),a.setRadiusX(c),a.setRadiusY(d)):a=this.addEllipse({x:h,y:l},{x:c,y:d}):"Cloud"===this._markupMode&&(a?(a.setPosition(h,l),a.setWidth(Math.max(100,c)),a.setHeight(Math.max(100,d))):a=this.addCloud({x:h,y:l},c,d))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(n||r){if(n&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.points();if(!i)return;const n=[],r=e.getAbsoluteTransform();for(let t=0;t<i.length;t+=2){const e=r.point({x:i[t],y:i[t+1]}),a=this._worldTransformer.screenToWorld(e);n.push(a)}const a=new Gg(null,e),s={id:a.id(),points:n,color:a.getColor()||"#ff0000",type:a.getLineType()||this.lineType,width:a.getLineWidth()||this.lineWidth};t.push(s)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),n=e.position(),r=this._konvaStage.getAbsoluteTransform(),a=r.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(a),o=new Hg(null,e),h={id:o.id(),position:s,text:o.getText(),text_size:.02*i.y,angle:o.getRotation(),color:o.getColor(),font_size:o.getFontSize()*r.getMatrix()[0]};t.push(h)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.position(),n=this._konvaStage.getAbsoluteTransform(),r=n.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(r),s=n.getMatrix()[0],o=new Vg(null,e),h={id:o.id(),position:a,width:o.getWidth()*s,height:o.getHeigth()*s,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.position(),n=this._konvaStage.getAbsoluteTransform(),r=n.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(r),s=n.getMatrix()[0],o=new Wg(null,e),h={id:o.id(),position:a,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAbsoluteTransform(),n=i.point({x:e.points()[0],y:e.points()[1]}),r=this._worldTransformer.screenToWorld(n),a=i.point({x:e.points()[2],y:e.points()[3]}),s=this._worldTransformer.screenToWorld(a),o=new Xg(null,e),h={id:o.id(),start:r,end:s,color:o.getColor()};t.push(h)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.position(),n=this._konvaStage.getAbsoluteTransform(),r=n.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(r),s=n.getMatrix()[0],o=new jg(null,e),h={id:o.id(),position:a,src:o.getSrc(),width:o.getWidth()*s,height:o.getHeight()*s};t.push(h)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.position(),n=this._konvaStage.getAbsoluteTransform(),r=n.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(r),s=n.getMatrix()[0],o=new Yg(null,e),h={id:o.id(),position:a,width:o.getWidth()*s,height:o.getHeigth()*s,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,n,r){if(!t||0===t.length)return;const a=[];for(let e=0;e<t.length;e+=2)a.push({x:t[e],y:t[e+1]});const s=new Gg({points:a,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:r});return this.addObject(s),s}createTextInput(t,e,i,n,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},n.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,r,a,s){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!a||a<h)){const t=.02;a=r/(this._worldTransformer.getScale().y/t)/34}const l=new Hg({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:a||this.fontSize,color:n||this._markupColor.asHex(),id:s});return this.addObject(l),l}addRectangle(t,e,i,n,r,a){if(!t)return;const s=new Vg({position:t,width:e,height:i,lineWidth:n||this.lineWidth,color:r||this._markupColor.asHex(),id:a});return this.addObject(s),s}addEllipse(t,e,i,n,r){if(!t)return;const a=new Wg({position:t,radius:e,lineWidth:i,color:n||this._markupColor.asHex(),id:r});return this.addObject(a),a}addArrow(t,e,i,n){if(!t||!e)return;const r=new Xg({start:t,end:e,color:i||this._markupColor.asHex(),id:n});return this.addObject(r),r}addCloud(t,e,i,n,r,a){if(!t||!e||!i)return;const s=new Yg({position:t,width:e,height:i,color:r||this._markupColor.asHex(),lineWidth:n||this.lineWidth,id:a});return this.addObject(s),s}addImage(t,e,i,n,r){var a;if(!t||!e)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const s=new jg({position:t,src:e,width:i,height:n,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:r});return this.addObject(s),s}}const Zg={type:"change"},Jg={type:"start"},Qg={type:"end"},$g=-1,tv=0,ev=1,iv=2,nv=3,rv=4,av=5,sv=6;class ov extends zt{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ae,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:l,MIDDLE:c,RIGHT:d},this.touches={ONE:u,TWO:f},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",D),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",D),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(Zg),i.update(),i.state=$g},this.update=function(){const e=new Ae,s=(new Te).setFromUnitVectors(t.up,new Ae(0,1,0)),h=s.clone().invert(),l=new Ae,c=new Te,d=new Ae,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(s),r.setFromVector3(e),i.autoRotate&&i.state===$g&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(r.theta+=a.theta*i.dampingFactor,r.phi+=a.phi*i.dampingFactor):(r.theta+=a.theta,r.phi+=a.phi);let p=i.minAzimuthAngle,f=i.maxAzimuthAngle;return isFinite(p)&&isFinite(f)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),f<-Math.PI?f+=u:f>Math.PI&&(f-=u),r.theta=p<=f?Math.max(p,Math.min(f,r.theta)):r.theta>(p+f)/2?Math.max(p,r.theta):Math.min(f,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=i.scale,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(r),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(a.theta*=1-i.dampingFactor,a.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(a.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent(Zg),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",U),i.domElement.removeEventListener("pointerdown",R),i.domElement.removeEventListener("pointercancel",L),i.domElement.removeEventListener("wheel",I),i.domElement.removeEventListener("pointermove",P),i.domElement.removeEventListener("pointerup",L),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",D),i._domElementKeyEvents=null)};const i=this;i.state=$g;const n=1e-6,r=new Zh,a=new Zh;function s(){return Math.pow(.95,i.zoomSpeed)}function o(t){a.theta-=t}function h(t){a.phi-=t}i.scale=1,i.panOffset=new Ae,i.zoomChanged=!1,i.rotateStart=new ee,i.rotateEnd=new ee,i.rotateDelta=new ee,i.panStart=new ee,i.panEnd=new ee,i.panDelta=new ee,i.dollyStart=new ee,i.dollyEnd=new ee,i.dollyDelta=new ee,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const g=function(){const t=new Ae;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),v=function(){const t=new Ae;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),_=function(){const t=new Ae;return function(e,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const a=i.object.position;t.copy(a).sub(i.target);let s=t.length();s*=Math.tan(i.object.fov/2*Math.PI/180),g(2*e*s/r.clientHeight,i.object.matrix),v(2*n*s/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(g(e*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),v(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function y(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function x(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function S(t){i.rotateStart.set(t.clientX,t.clientY)}function M(t){i.panStart.set(t.clientX,t.clientY)}function b(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function w(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function E(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function T(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=O(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.rotateEnd.set(n,r)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function A(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=O(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);i.panEnd.set(n,r)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),_(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function C(t){const e=O(t),n=t.pageX-e.x,r=t.pageY-e.y,a=Math.sqrt(n*n+r*r);i.dollyEnd.set(0,a),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),y(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function R(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",P),i.domElement.addEventListener("pointerup",L)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(N(t),i.pointers.length){case 1:switch(i.touches.ONE){case u:if(!1===i.enableRotate)return;b(),i.state=nv;break;case p:if(!1===i.enablePan)return;w(),i.state=rv;break;default:i.state=$g}break;case 2:switch(i.touches.TWO){case f:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&E(),i.enablePan&&w(),i.state=av;break;case m:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&E(),i.enableRotate&&b(),i.state=sv;break;default:i.state=$g}break;default:i.state=$g}i.state!==$g&&i.dispatchEvent(Jg)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case c:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=ev;break;case l:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;M(t),i.state=iv}else{if(!1===i.enableRotate)return;S(t),i.state=tv}break;case d:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;S(t),i.state=tv}else{if(!1===i.enablePan)return;M(t),i.state=iv}break;default:i.state=$g}i.state!==$g&&i.dispatchEvent(Jg)}(t))}function P(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(N(t),i.state){case nv:if(!1===i.enableRotate)return;T(t),i.update();break;case rv:if(!1===i.enablePan)return;A(t),i.update();break;case av:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&C(t),i.enablePan&&A(t)}(t),i.update();break;case sv:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&C(t),i.enableRotate&&T(t)}(t),i.update();break;default:i.state=$g}}(t):function(t){switch(i.state){case tv:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case ev:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/s(),y(s())):i.dollyDelta.y>0&&(i.dollyScale=s(),x(s())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case iv:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),_(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function L(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",P),i.domElement.removeEventListener("pointerup",L)),i.dispatchEvent(Qg),i.state=$g}function I(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===$g&&(t.preventDefault(),i.dispatchEvent(Jg),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/s(),x(s())):t.deltaY>0&&(i.dollyScale=s(),y(s())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=ev,i.dispatchEvent(Zg),i.state=$g)}(t),i.dispatchEvent(Qg))}function D(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):_(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):_(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):_(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):_(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function U(t){!1!==i.enabled&&t.preventDefault()}function N(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new ee,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function O(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",U),i.domElement.addEventListener("pointerdown",R),i.domElement.addEventListener("pointercancel",L),i.domElement.addEventListener("wheel",I,{passive:!1}),this.update()}}class hv{constructor(t){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case iv:case rv:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case ev:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new ov(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:l,MIDDLE:d,RIGHT:d},this.orbit.touches={ONE:u,TWO:f},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.on("geometryend",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.on("zoom",this.updateControls),this.viewer.on("drawviewpoint",this.updateControls),this.viewer.on("contextmenu",this.stopContextMenu),this.updateControls()}dispose(){this.viewer.off("geometryend",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.off("zoom",this.updateControls),this.viewer.off("drawviewpoint",this.updateControls),this.viewer.off("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class lv extends hv{constructor(t){super(t),this.orbit.mouseButtons={LEFT:d,MIDDLE:d,RIGHT:d}}}class cv extends hv{constructor(t){super(t),this.orbit.mouseButtons={LEFT:c,MIDDLE:d,RIGHT:d}}}const dv={type:"change"};class uv extends zt{constructor(t,e){super(),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{t.isPrimary&&0===t.button&&(this.canvas.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.camera.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!t.isPrimary||!this.mouseDragOn)return;const e=new ee(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent(dv))},this.onPointerUp=t=>{t.isPrimary&&0===t.button&&(this.canvas.releasePointerCapture(t.pointerId),this.mouseDragOn=!1)},this.onPointerCancel=t=>{this.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{switch(t.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.delete(t.code),this.update()}},this.camera=t,this.canvas=e,this.moveKeys=new Set,this.moveClock=new kh,this.quaternion=t.quaternion.clone(),this.downPosition=new ee(0,0),this.rotateDelta=new ee(0,0),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerCancel),this.canvas.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.canvas.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.camera.translateZ(-t),this.moveKeys.has("KeyS")&&this.camera.translateZ(t),this.moveKeys.has("KeyA")&&this.camera.translateX(-t),this.moveKeys.has("KeyD")&&this.camera.translateX(t),this.moveKeys.has("KeyQ")&&this.camera.translateY(t),this.moveKeys.has("KeyE")&&this.camera.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new ee(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new ee(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new ee(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new ee(-e,0))),this.moveWheel=0,this.dispatchEvent(dv)}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.camera.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent(dv)}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.canvas.clientWidth,i=Math.PI*t.y/this.canvas.clientHeight,n=new Te;n.setFromAxisAngle(this.camera.up,e);const r=new Te;r.setFromAxisAngle(new Ae(1,0,0),i);const a=this.quaternion.clone();a.premultiply(n).multiply(r).normalize(),this.camera.setRotationFromQuaternion(a)}}class pv{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Ae);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=t=>{this.viewer.emitEvent(t)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new uv(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=t,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}const fv=new Yh,mv=new Ae,gv=new Ae,vv=new Te,_v={X:new Ae(1,0,0),Y:new Ae(0,1,0),Z:new Ae(0,0,1)},yv={type:"change"},xv={type:"mouseDown"},Sv={type:"mouseUp",mode:null},Mv={type:"objectChange"};class bv extends Ci{constructor(t,e){super(),void 0===e&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const i=new Wv;this._gizmo=i,this.add(i);const n=new Xv;this._plane=n,this.add(n);const r=this;function a(t,e){let a=e;Object.defineProperty(r,t,{get:function(){return void 0!==a?a:e},set:function(e){a!==e&&(a=e,n[t]=e,i[t]=e,r.dispatchEvent({type:t+"-changed",value:e}),r.dispatchEvent(yv))}}),r[t]=e,n[t]=e,i[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const s=new Ae,o=new Ae,h=new Te,l=new Te,c=new Ae,d=new Te,u=new Ae,p=new Ae,f=new Ae,m=new Ae;a("worldPosition",s),a("worldPositionStart",o),a("worldQuaternion",h),a("worldQuaternionStart",l),a("cameraPosition",c),a("cameraQuaternion",d),a("pointStart",u),a("pointEnd",p),a("rotationAxis",f),a("rotationAngle",0),a("eye",m),this._offset=new Ae,this._startNorm=new Ae,this._endNorm=new Ae,this._cameraScale=new Ae,this._parentPosition=new Ae,this._parentQuaternion=new Te,this._parentQuaternionInv=new Te,this._parentScale=new Ae,this._worldScaleStart=new Ae,this._worldQuaternionInv=new Te,this._worldScale=new Ae,this._positionStart=new Ae,this._quaternionStart=new Te,this._scaleStart=new Ae,this._getPointer=wv.bind(this),this._onPointerDown=Tv.bind(this),this._onPointerHover=Ev.bind(this),this._onPointerMove=Av.bind(this),this._onPointerUp=Cv.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;fv.setFromCamera(t,this.camera);const e=Rv(this._gizmo.picker[this.mode],fv);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){fv.setFromCamera(t,this.camera);const e=Rv(this._plane,fv,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,xv.mode=this.mode,this.dispatchEvent(xv)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||-1!==t.button)return;fv.setFromCamera(t,this.camera);const a=Rv(this._plane,fv,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(vv.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(mv.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(mv.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),gv.set(t,t,t)}else mv.copy(this.pointStart),gv.copy(this.pointEnd),mv.applyQuaternion(this._worldQuaternionInv),gv.applyQuaternion(this._worldQuaternionInv),gv.divide(mv),-1===e.search("X")&&(gv.x=1),-1===e.search("Y")&&(gv.y=1),-1===e.search("Z")&&(gv.z=1);n.scale.copy(this._scaleStart).multiply(gv),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(mv.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(mv.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(_v[e]),mv.copy(_v[e]),"local"===r&&mv.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(mv.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(vv.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(vv.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(yv),this.dispatchEvent(Mv)}}pointerUp(t){0===t.button&&(this.dragging&&null!==this.axis&&(Sv.mode=this.mode,this.dispatchEvent(Sv)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(yv),this.dispatchEvent(Mv),this.pointStart.copy(this.pointEnd))}getRaycaster(){return fv}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function wv(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Ev(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Tv(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function Av(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Cv(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Rv(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Pv=new pi,Lv=new Ae(0,1,0),Iv=new Ae(0,0,0),Dv=new ni,Uv=new Te,Nv=new Te,Ov=new Ae,Fv=new ni,kv=new Ae(1,0,0),Bv=new Ae(0,1,0),zv=new Ae(0,0,1),Gv=new Ae,Hv=new Ae,Vv=new Ae;class Wv extends Ci{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new Ki({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new xo({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const a=t.clone();a.color.setHex(65280);const s=t.clone();s.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new Bo(0,.04,.1,12);p.translate(0,.05,0);const f=new Pn(.08,.08,.08);f.translate(0,.04,0);const m=new cn;m.setAttribute("position",new en([0,0,0,1,0,0],3));const g=new Bo(.0075,.0075,.5,3);function v(t,e){const i=new Vo(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}g.translate(0,.25,0);const _={X:[[new Cn(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new Cn(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new Cn(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Cn(p,a),[0,.5,0]],[new Cn(p,a),[0,-.5,0],[Math.PI,0,0]],[new Cn(g,a)]],Z:[[new Cn(p,s),[0,0,.5],[Math.PI/2,0,0]],[new Cn(p,s),[0,0,-.5],[-Math.PI/2,0,0]],[new Cn(g,s),null,[Math.PI/2,0,0]]],XYZ:[[new Cn(new Go(.1,0),c.clone()),[0,0,0]]],XY:[[new Cn(new Pn(.15,.15,.01),l.clone()),[.15,.15,0]]],YZ:[[new Cn(new Pn(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Cn(new Pn(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},y={X:[[new Cn(new Bo(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Cn(new Bo(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Cn(new Bo(.2,0,.6,4),i),[0,.3,0]],[new Cn(new Bo(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Cn(new Bo(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Cn(new Bo(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Cn(new Go(.2,0),i)]],XY:[[new Cn(new Pn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Cn(new Pn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Cn(new Pn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},x={START:[[new Cn(new Go(.01,2),n),null,null,null,"helper"]],END:[[new Cn(new Go(.01,2),n),null,null,null,"helper"]],DELTA:[[new To(function(){const t=new cn;return t.setAttribute("position",new en([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new To(m,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new To(m,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new To(m,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new Cn(v(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new Cn(v(.5,.5),r)]],Y:[[new Cn(v(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Cn(v(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new Cn(v(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new To(m,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},b={XYZE:[[new Cn(new Ho(.25,10,8),i)]],X:[[new Cn(new Vo(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Cn(new Vo(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Cn(new Vo(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Cn(new Vo(.75,.1,2,24),i)]]},w={X:[[new Cn(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new Cn(g,r),[0,0,0],[0,0,-Math.PI/2]],[new Cn(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Cn(f,a),[0,.5,0]],[new Cn(g,a)],[new Cn(f,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Cn(f,s),[0,0,.5],[Math.PI/2,0,0]],[new Cn(g,s),[0,0,0],[Math.PI/2,0,0]],[new Cn(f,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Cn(new Pn(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Cn(new Pn(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Cn(new Pn(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Cn(new Pn(.1,.1,.1),c.clone())]]},E={X:[[new Cn(new Bo(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Cn(new Bo(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Cn(new Bo(.2,0,.6,4),i),[0,.3,0]],[new Cn(new Bo(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Cn(new Bo(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Cn(new Bo(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Cn(new Pn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Cn(new Pn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Cn(new Pn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Cn(new Pn(.2,.2,.2),i),[0,0,0]]]},T={X:[[new To(m,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new To(m,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new To(m,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(t){const e=new Ci;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),a=t[i][n][1],s=t[i][n][2],o=t[i][n][3],h=t[i][n][4];r.name=i,r.tag=h,a&&r.position.set(a[0],a[1],a[2]),s&&r.rotation.set(s[0],s[1],s[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const l=r.geometry.clone();l.applyMatrix4(r.matrix),r.geometry=l,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(_)),this.add(this.gizmo.rotate=A(S)),this.add(this.gizmo.scale=A(w)),this.add(this.picker.translate=A(y)),this.add(this.picker.rotate=A(b)),this.add(this.picker.scale=A(E)),this.add(this.helper.translate=A(x)),this.add(this.helper.rotate=A(M)),this.add(this.helper.scale=A(T)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Nv;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Lv.copy(kv).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Lv.copy(Bv).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Lv.copy(zv).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Lv.copy(zv).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Lv.copy(kv).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Lv.copy(Bv).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(Uv.copy(e),Lv.copy(this.eye).applyQuaternion(vv.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(Dv.lookAt(this.eye,Iv,Bv)),"X"===n.name&&(vv.setFromAxisAngle(kv,Math.atan2(-Lv.y,Lv.z)),vv.multiplyQuaternions(Uv,vv),n.quaternion.copy(vv)),"Y"===n.name&&(vv.setFromAxisAngle(Bv,Math.atan2(Lv.x,Lv.z)),vv.multiplyQuaternions(Uv,vv),n.quaternion.copy(vv)),"Z"===n.name&&(vv.setFromAxisAngle(zv,Math.atan2(Lv.y,Lv.x)),vv.multiplyQuaternions(Uv,vv),n.quaternion.copy(vv)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some((function(t){return n.name===t})))&&(n.material.color.setHex(16776960),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(vv.setFromEuler(Pv.set(0,0,0)),n.quaternion.copy(e).multiply(vv),Math.abs(Lv.copy(kv).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(vv.setFromEuler(Pv.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(vv),Math.abs(Lv.copy(Bv).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(vv.setFromEuler(Pv.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(vv),Math.abs(Lv.copy(zv).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(vv.setFromEuler(Pv.set(0,Math.PI/2,0)),Lv.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(Dv.lookAt(Iv,Lv,Bv)),n.quaternion.multiply(vv),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),mv.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),mv.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(mv),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class Xv extends Cn{constructor(){super(new Jn(1e5,1e5,2,2),new Ki({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Gv.copy(kv).applyQuaternion("local"===e?this.worldQuaternion:Nv),Hv.copy(Bv).applyQuaternion("local"===e?this.worldQuaternion:Nv),Vv.copy(zv).applyQuaternion("local"===e?this.worldQuaternion:Nv),Lv.copy(Hv),this.mode){case"translate":case"scale":switch(this.axis){case"X":Lv.copy(this.eye).cross(Gv),Ov.copy(Gv).cross(Lv);break;case"Y":Lv.copy(this.eye).cross(Hv),Ov.copy(Hv).cross(Lv);break;case"Z":Lv.copy(this.eye).cross(Vv),Ov.copy(Vv).cross(Lv);break;case"XY":Ov.copy(Vv);break;case"YZ":Ov.copy(Gv);break;case"XZ":Lv.copy(Vv),Ov.copy(Hv);break;case"XYZ":case"E":Ov.set(0,0,0)}break;default:Ov.set(0,0,0)}0===Ov.length()?this.quaternion.copy(this.cameraQuaternion):(Fv.lookAt(mv.set(0,0,0),Ov,Lv),this.quaternion.setFromRotationMatrix(Fv)),super.updateMatrixWorld(t)}}class jv extends To{constructor(t,e=1,i=16776960,n=new Ae){const r=new cn;r.setAttribute("position",new en([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new xo({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const a=new cn;a.setAttribute("position",new en([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),this.helper=new Cn(a,new Ki({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}class Yv extends hv{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.viewerExplode=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Ae).length(),this.viewer.update()},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new Ae).length(),r=t.extents.getCenter(new Ae),a=-r.dot(e);this.plane=new Xn(e,a),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new jv(this.plane,n,i,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new Ci,this.planeCenter.position.copy(t.extents.getCenter(new Ae)),this.viewer.helpers.add(this.planeCenter),this.transform=new bv(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform),this.viewer.on("explode",this.viewerExplode),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.viewerExplode),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.removeFromParent(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class qv extends Yv{constructor(t){super(t,new Ae(1,0,0),16711680)}}class Kv extends Yv{constructor(t){super(t,new Ae(0,1,0),65280)}}class Zv extends Yv{constructor(t){super(t,new Ae(0,0,1),255)}}class Jv{constructor(t){this.syncExtents=()=>{const t=this.viewer.models.reduce(((t,e)=>{const i=(new Pe).setFromObject(e.scene);return t.isEmpty()?t.copy(i):t.union(i)}),new Pe);this.viewer.extents.copy(t),this.viewer.target.copy(t.getCenter(new Ae))},this.viewer=t,this.viewer.addEventListener("geometryend",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents)}dispose(){this.viewer.removeEventListener("geometryend",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents)}}class Qv{constructor(t){this.viewer=t,this.ambientLight=new Nh(16777215,0),this.viewer.camera.add(this.ambientLight),this.directionalLight=new Uh(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.camera.add(this.directionalLight)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight=void 0,this.directionalLight.removeFromParent(),this.directionalLight=void 0}}class $v extends Rs{constructor(){super();const t=new Pn;t.deleteAttribute("uv");const e=new Wo({side:x}),i=new Wo,n=new Ih(16777215,5,28,2);n.position.set(.418,16.199,.3),this.add(n);const r=new Cn(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new Cn(t,i);a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),this.add(a);const s=new Cn(t,i);s.position.set(-5.607,-.754,-.758),s.rotation.set(0,.994,0),s.scale.set(1.97,1.534,3.955),this.add(s);const o=new Cn(t,i);o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),this.add(o);const h=new Cn(t,i);h.position.set(-2.017,.018,6.124),h.rotation.set(0,.333,0),h.scale.set(2.002,4.566,2.064),this.add(h);const l=new Cn(t,i);l.position.set(2.291,-.756,-2.621),l.rotation.set(0,-.286,0),l.scale.set(1.546,1.552,1.496),this.add(l);const c=new Cn(t,i);c.position.set(-2.193,-.369,-5.547),c.rotation.set(0,.516,0),c.scale.set(3.875,3.487,2.986),this.add(c);const d=new Cn(t,t_(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const u=new Cn(t,t_(50));u.position.set(-16.109,18.021,-8.207),u.scale.set(.1,2.425,2.751),this.add(u);const p=new Cn(t,t_(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const f=new Cn(t,t_(43));f.position.set(-.462,8.89,14.52),f.scale.set(4.38,5.441,.088),this.add(f);const m=new Cn(t,t_(20));m.position.set(3.235,11.486,-12.541),m.scale.set(2.5,2,.1),this.add(m);const g=new Cn(t,t_(100));g.position.set(0,20,0),g.scale.set(1,.1,1),this.add(g)}dispose(){const t=new Set;this.traverse((e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))}));for(const e of t)e.dispose()}}function t_(t){const e=new Ki;return e.color.setScalar(t),e}class e_{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215)},this.viewer=t,this.backgroundColor=new Yi(16777215);const e=new $v,i=new vr(this.viewer.renderer);this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.scene.environment=i.fromScene(e).texture,this.viewer.addEventListener("optionschange",this.syncOptions),e.dispose()}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.environment=void 0,this.viewer.scene.background=void 0}}class i_{constructor(t){this.geometryEnd=t=>{const e=this.viewer.extents.getSize(new Ae).length();this.viewer.camera.near=e/100,this.viewer.camera.far=100*e,this.viewer.camera.updateMatrixWorld(),this.viewer.camera.updateProjectionMatrix(),this.viewer.executeCommand("setDefaultViewPosition","sw"),this.viewer.executeCommand("zoomToExtents")},this.viewer=t,this.viewer.addEventListener("geometryend",this.geometryEnd)}dispose(){this.viewer.removeEventListener("geometryend",this.geometryEnd)}}class n_{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&(this.viewer.camera.aspect=e/i,this.viewer.camera.updateProjectionMatrix(),this.viewer.renderer.setSize(e,i,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:e,height:i}))},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class r_{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t)},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class a_ extends Ci{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new hr(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new Ki({toneMapped:!1,color:"#aa0000"}),i=new Ki({toneMapped:!1,color:"#00aa00"}),n=new Ki({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(e.color,"X"),a=this.getSpriteMaterial(i.color,"Y"),s=this.getSpriteMaterial(n.color,"Z"),o=new Bo(.01,.01,1,3);o.translate(0,.5,0);const h=new Bo(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Cn(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Cn(o,e),[0,0,0],[0,0,-Math.PI/2]],[new Ys(r),[1.55,0,0]]],Y:[[new Cn(h,i),[0,.5,0],null],[new Cn(o,i),null,null],[new Ys(a),[0,1.55,0]]],Z:[[new Cn(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Cn(o,n),null,[Math.PI/2,0,0]],[new Ys(s),[0,0,1.55]]]};Object.keys(l).forEach((t=>{l[t].forEach((e=>{const i=e[0],n=e[1],r=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),r&&i.rotation.set(r[0],r[1],r[2]),i.updateMatrixWorld(),this.add(i)}))}))}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const r=new ko(i);return r.colorSpace=bt,new Ds({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.clippingPlanes,i=t.getViewport(new Me);t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clippingPlanes=[],t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(i),t.clippingPlanes=e}}class s_{constructor(t){this.viewerRender=()=>{this.viewer.extents.isEmpty()||this.wcsHelper.render(this.viewer.renderer)},this.wcsHelper=new a_(t.camera),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}t.CANVAS_EVENTS=o,t.CanvasEvents=s,t.Dragger=class{constructor(t){this.name=""}initialize(){}dispose(){}updatePreview(){}},t.Options=a,t.Viewer=class extends tc{constructor(t){super(),this._options=new a(this),this.client=t,this.canvasEvents=o,this.canvaseventlistener=t=>this.emit(t),this.extents=new Pe,this.target=new Ae,this.draggerFactory={Pan:lv,Zoom:cv,Orbit:hv,Walk:pv,CuttingPlaneXAxis:qv,CuttingPlaneYAxis:Kv,CuttingPlaneZAxis:Zv},this._activeDragger=null,this.models=[],this.components=[],this.selected=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new Kg}get options(){return this._options}get draggers(){return Object.keys(this.draggerFactory)}get markup(){return this._markup}initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),this.scene=new Rs,this.helpers=new Rs;const i=t.parentElement.getBoundingClientRect(),n=i.width||1,r=i.height||1;return this.camera=new Fn(45,n/r,.01,1e3),this.camera.up.set(0,0,1),this.renderer=new Cs({canvas:t,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(n,r),this.renderer.toneMapping=z,this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this),this.components.push(new Jv(this)),this.components.push(new Qv(this)),this.components.push(new e_(this)),this.components.push(new i_(this)),this.components.push(new n_(this)),this.components.push(new r_(this)),this.components.push(new Jh(this)),this.components.push(new s_(this)),this.syncOptions(),this.syncOverlay(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this.components.forEach((t=>t.dispose())),this.components=[],this.setActiveDragger(),this.removeAllListeners(),this.clear(),this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.renderer=void 0,this.camera=void 0,this.scene=void 0,this.helpers=void 0,this}isInitialized(){return!!this.renderer}render(t){if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const e=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=e;const i=(t-this.renderTime)/1e3;this.renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:i})}update(t=!1){this.renderNeeded=!0,t&&this.render(performance.now()),this.emitEvent({type:"update",data:t})}syncOptions(t=this.options){}loadReferences(t){return Promise.resolve(this)}async open(t){if(!this.renderer)return this;let e;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:t,model:t}),t){const i=await t.getModels()||[];e=i.find((t=>t.default))||i[0]}if(!e)throw new Error("No default model found");const i=e.database.split(".").pop();if("gltf"!==i)throw new Error(`Unknown geometry type: ${i}`);const n=`${e.httpClient.serverUrl}${e.path}/${e.database}`,r={requestHeader:e.httpClient.headers};return await this.loadReferences(e),await this.loadGltfFile(n,void 0,r),this}cancel(){return this.emitEvent({type:"cancel"}),this}openGltfFile(t,e=new Map,i={}){return this.renderer?(this.cancel(),this.clear(),this.emitEvent({type:"open"}),this.loadGltfFile(t,e,i)):Promise.resolve(this)}async loadGltfFile(t,e=new Map,i={}){const n=new $l(t,e,i);try{this.emitEvent({type:"geometrystart"});const t=new rl(n);t.setPath(n.path),t.setRequestHeader(i.requestHeader),t.setCrossOrigin(i.crossOrigin||t.crossOrigin),t.setWithCredentials(i.withCredentials||t.withCredentials);const e=await t.loadAsync(n.fileURL,(t=>{const{lengthComputable:e,loaded:i,total:n}=t,r=e?i/n:1;this.emitEvent({type:"geometryprogress",data:r})}));if(!this.scene)return this;if(!e.scene)throw new Error("No glTF scene found");this.models.push(e),this.scene.add(e.scene),this.syncOptions(),this.syncOverlay(),this.update(),this.emitEvent({type:"databasechunk"}),this.emitEvent({type:"geometryend",data:e.scene})}catch(t){throw this.emitEvent({type:"geometryerror",data:t}),t}finally{n.dispose()}return this}clear(){if(!this.renderer)return this;function t(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach((t=>{t.dispose()})))}return this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.helpers.traverse(t),this.helpers.clear(),this.models.forEach((e=>e.scene.traverse(t))),this.models.forEach((t=>t.scene.removeFromParent())),this.models=[],this.scene.clear(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){if(!this._activeDragger||this._activeDragger.name!==t){if(this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()){const e=this.draggerFactory[t];e&&(this._activeDragger=new e(this),this._activeDragger.name=t)}const e=this.canvas;e&&(e.className=e.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${t.toLowerCase()}`).join(" ")),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}is3D(){return!0}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1,r=new Ae(i,n,-1);return r.unproject(this.camera),{x:r.x,y:r.y,z:r.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Ae(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return n("ThreeJS").executeCommand(t,this,...e)}getComponent(t){return this.components.find((e=>e instanceof t))}drawViewpoint(t){var e,i,n;if(!this.renderer)return;const r=({x:t,y:e,z:i})=>new Ae(t,e,i),a=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{t&&(this.camera.up.copy(r(t.up_vector)),this.camera.fov=t.field_of_view,this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix())})(t.perspective_camera),(t=>{null==t||t.forEach((t=>{const e=new Xn;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)}))})(t.clipping_planes),(t=>{this.setSelected(null==t?void 0:t.map((t=>t.handle)))})(t.selection),this._markup.setViewpoint(t),this.target=r(null!==(n=null===(i=t.custom_fields)||void 0===i?void 0:i.camera_target)&&void 0!==n?n:this.target),this.setActiveDragger(a),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.perspective_camera=(()=>({view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Ae)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}))(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach((i=>{const n={location:t(i.coplanarPoint(new Ae)),direction:t(i.normal)};e.push(n)})),e})(),e.selection=(()=>this.getSelected().map((t=>({handle:t}))))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),this.emitEvent({type:"createviewpoint",data:e}),e}},t.commands=n,t.defaultOptions=r}));