const REVISION="4.6.0",MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},CullFaceNone=0,CullFaceBack=1,CullFaceFront=2,CullFaceFrontBack=3,BasicShadowMap=0,PCFShadowMap=1,PCFSoftShadowMap=2,ESMShadowMap=4,PCFShadowMapPoissonDisk=5,BilinearShadowMap=6,FrontSide=0,BackSide=1,DoubleSide=2,TwoPassDoubleSide=3,NoBlending=0,NormalBlending=1,AdditiveBlending=2,SubtractiveBlending=3,MultiplyBlending=4,CustomBlending=5,AddEquation=100,SubtractEquation=101,ReverseSubtractEquation=102,MinEquation=103,MaxEquation=104,ZeroFactor=200,OneFactor=201,SrcColorFactor=202,OneMinusSrcColorFactor=203,SrcAlphaFactor=204,OneMinusSrcAlphaFactor=205,DstAlphaFactor=206,OneMinusDstAlphaFactor=207,DstColorFactor=208,OneMinusDstColorFactor=209,SrcAlphaSaturateFactor=210,NeverDepth=0,AlwaysDepth=1,LessDepth=2,LessEqualDepth=3,EqualDepth=4,GreaterEqualDepth=5,GreaterDepth=6,NotEqualDepth=7,MultiplyOperation=0,MixOperation=1,AddOperation=2,NoToneMapping=0,LinearToneMapping=1,ReinhardToneMapping=2,CineonToneMapping=3,ACESFilmicToneMapping=4,CustomToneMapping=5,LogarithmicMaxToneMapping=6,PhysicalMaxToneMapping=7,FilmicBlenderToneMapping=8,AgXBlenderToneMapping=9,ToneMappingLookNone=0,ToneMappingLookAgXPunchy=1,UVMapping=300,CubeReflectionMapping=301,CubeRefractionMapping=302,EquirectangularReflectionMapping=303,EquirectangularRefractionMapping=304,CubeUVReflectionMapping=306,RepeatWrapping=1e3,ClampToEdgeWrapping=1001,MirroredRepeatWrapping=1002,NearestFilter=1003,NearestMipmapNearestFilter=1004,NearestMipMapNearestFilter=1004,NearestMipmapLinearFilter=1005,NearestMipMapLinearFilter=1005,LinearFilter=1006,LinearMipmapNearestFilter=1007,LinearMipMapNearestFilter=1007,LinearMipmapLinearFilter=1008,LinearMipMapLinearFilter=1008,UnsignedByteType=1009,ByteType=1010,ShortType=1011,UnsignedShortType=1012,IntType=1013,UnsignedIntType=1014,FloatType=1015,HalfFloatType=1016,UnsignedShort4444Type=1017,UnsignedShort5551Type=1018,UnsignedInt248Type=1020,AlphaFormat=1021,RGBFormat=1022,RGBAFormat=1023,LuminanceFormat=1024,LuminanceAlphaFormat=1025,DepthFormat=1026,DepthStencilFormat=1027,RedFormat=1028,RedIntegerFormat=1029,RGFormat=1030,RGIntegerFormat=1031,RGBAIntegerFormat=1033,RGB_S3TC_DXT1_Format=33776,RGBA_S3TC_DXT1_Format=33777,RGBA_S3TC_DXT3_Format=33778,RGBA_S3TC_DXT5_Format=33779,RGB_PVRTC_4BPPV1_Format=35840,RGB_PVRTC_2BPPV1_Format=35841,RGBA_PVRTC_4BPPV1_Format=35842,RGBA_PVRTC_2BPPV1_Format=35843,RGB_ETC1_Format=36196,RGB_ETC2_Format=37492,RGBA_ETC2_EAC_Format=37496,RGBA_ASTC_4x4_Format=37808,RGBA_ASTC_5x4_Format=37809,RGBA_ASTC_5x5_Format=37810,RGBA_ASTC_6x5_Format=37811,RGBA_ASTC_6x6_Format=37812,RGBA_ASTC_8x5_Format=37813,RGBA_ASTC_8x6_Format=37814,RGBA_ASTC_8x8_Format=37815,RGBA_ASTC_10x5_Format=37816,RGBA_ASTC_10x6_Format=37817,RGBA_ASTC_10x8_Format=37818,RGBA_ASTC_10x10_Format=37819,RGBA_ASTC_12x10_Format=37820,RGBA_ASTC_12x12_Format=37821,RGBA_BPTC_Format=36492,LoopOnce=2200,LoopRepeat=2201,LoopPingPong=2202,InterpolateDiscrete=2300,InterpolateLinear=2301,InterpolateSmooth=2302,ZeroCurvatureEnding=2400,ZeroSlopeEnding=2401,WrapAroundEnding=2402,NormalAnimationBlendMode=2500,AdditiveAnimationBlendMode=2501,TrianglesDrawMode=0,TriangleStripDrawMode=1,TriangleFanDrawMode=2,LinearEncoding$1=3e3,sRGBEncoding$1=3001,BasicDepthPacking=3200,RGBADepthPacking=3201,LinearDepthPacking=3202,RGBADistancePacking=3301,ESMDistancePacking=3302,TangentSpaceNormalMap=0,ObjectSpaceNormalMap=1,NoColorSpace="",SRGBColorSpace="srgb",LinearSRGBColorSpace="srgb-linear",ZeroStencilOp=0,KeepStencilOp=7680,ReplaceStencilOp=7681,IncrementStencilOp=7682,DecrementStencilOp=7683,IncrementWrapStencilOp=34055,DecrementWrapStencilOp=34056,InvertStencilOp=5386,NeverStencilFunc=512,LessStencilFunc=513,EqualStencilFunc=514,LessEqualStencilFunc=515,GreaterStencilFunc=516,NotEqualStencilFunc=517,GreaterEqualStencilFunc=518,AlwaysStencilFunc=519,StaticDrawUsage=35044,DynamicDrawUsage=35048,StreamDrawUsage=35040,StaticReadUsage=35045,DynamicReadUsage=35049,StreamReadUsage=35041,StaticCopyUsage=35046,DynamicCopyUsage=35050,StreamCopyUsage=35042,GLSL1="100",GLSL3="300 es",_SRGBAFormat=1035,MOD_SUITE="ALL",V3DL="__V3DL__0000000000",ViewportFitNone=0,ViewportFitVertical=1,ViewportFitHorizontal=2,ViewportFitAuto=3,ViewportFitFill=4,ViewportFitOverscan=5,IBLEnvironmentPMREM=0,IBLEnvironmentProbeCubemap=1,IBLEnvironmentProbe=2,IBLEnvironmentNone=3,TweenLinear=0,TweenSpherical=1,ReflectionProbeTypeInfinite=0,ReflectionProbeTypeSphere=1,ReflectionProbeTypeBox=2,NoOIT=0,OITWeighted=1,ConstraintSpaceWorld=0,ConstraintSpaceCustom=1,ConstraintSpaceLocal=2;class EventDispatcher{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,r=n.length;t>8&255]+_lut[e>>16&255]+_lut[e>>24&255]+"-"+_lut[255&t]+_lut[t>>8&255]+"-"+_lut[t>>16&15|64]+_lut[t>>24&255]+"-"+_lut[63&n|128]+_lut[n>>8&255]+"-"+_lut[n>>16&255]+_lut[n>>24&255]+_lut[255&r]+_lut[r>>8&255]+_lut[r>>16&255]+_lut[r>>24&255]).toLowerCase()}function clamp(e,t=0,n=1){return Math.max(t,Math.min(n,e))}function euclideanModulo(e,t){return(e%t+t)%t}function mapLinear(e,t,n,r,o){return r+(e-t)*(o-r)/(n-t)}function inverseLerp(e,t,n){return e!==t?(n-e)/(t-e):0}function lerp(e,t,n){return(1-n)*e+n*t}function damp(e,t,n,r){return lerp(e,t,1-Math.exp(-n*r))}function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,2*t)-t)}function smoothstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)}function smootherstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function randFloat(e,t){return e+Math.random()*(t-e)}function randFloatSpread(e){return e*(.5-Math.random())}function seededRandom(e){void 0!==e&&(_seed=e);let t=_seed+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function degToRad(e){return e*DEG2RAD}function radToDeg(e){return e*RAD2DEG}function isPowerOfTwo(e){return 0==(e&e-1)&&0!==e}function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function setQuaternionFromProperEuler(e,t,n,r,o){const i=Math.cos,a=Math.sin,s=i(n/2),l=a(n/2),c=i((t+r)/2),u=a((t+r)/2),d=i((t-r)/2),h=a((t-r)/2),p=i((r-t)/2),f=a((r-t)/2);switch(o){case"XYX":e.set(s*u,l*d,l*h,s*c);break;case"YZY":e.set(l*h,s*u,l*d,s*c);break;case"ZXZ":e.set(l*d,l*h,s*u,s*c);break;case"XZX":e.set(s*u,l*f,l*p,s*c);break;case"YXY":e.set(l*p,s*u,l*f,s*c);break;case"ZYZ":e.set(l*f,l*p,s*u,s*c);break;default:console.warn("v3d.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+o)}}function denormalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function normalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}function hashString(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return t>>>0}function expAverage(e,t,n,r){let o=Math.exp(-n/r);return e*o+(1-o)*t}function expAverageClamp(e,t,n,r,o){let i=expAverage(e,t,n,r);return Math.abs(e-t)o&&(r=rt&&(t=e[n]);return t}function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const TYPED_ARRAYS={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function getTypedArray(e,t){return new TYPED_ARRAYS[e](t)}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function isDef(e){return void 0!==e}function clampArray(e,t,n){for(let r=0;r1&&(i=o.minor-r.minor,0===i&&n>2&&(i=o.patch-r.patch,0===i&&n>3&&(i=engineVersionPreToNumber(o.pre)-engineVersionPreToNumber(r.pre)))),Math.sign(i)}function shaderFloatStr(e){return`${e%1?e:`${e}.0`}`}function getGlobalScope(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:global}const modulesInfo={};function findModulePath(e=""){const t=document.getElementsByTagName("script");let n=e;for(let r=t.length-1;r>=0;--r){const o=t[r].src,i=o.search(/\/v3d[\w.]+js/);i>-1&&(n=o.substr(0,i)+"/"+e)}return n}function loadModule(e,t=function(e){},n=function(e){}){modulesInfo[e]=modulesInfo[e]||{status:0,loadCallbacks:[],errorCallbacks:[]};const r=modulesInfo[e];if(4==r.status)return void t(e);if(r.loadCallbacks.push(t),r.errorCallbacks.push(n),r.status>0)return;let o=findModulePath(e);const i=document.createElement("script");i.type="text/javascript",i.src=o,function(e){i.onload=function(){modulesInfo[e].loadCallbacks.forEach((function(t){t(e)})),modulesInfo[e].status=4},i.onerror=function(){modulesInfo[e].errorCallbacks.forEach((function(t){t(e)})),modulesInfo[e].status=0}}(e),document.getElementsByTagName("head")[0].appendChild(i),r.status=3}function arrayForEachPromise(e,t,n=0){const r=function(e,r,o,i){const a=performance.now();return t(e,r,o),a-i>n?(i=a,new Promise((function(e){setTimeout((function(){e(i)}),1)}))):i};let o=Promise.resolve(performance.now());return e.forEach((function(e,t,n){o=o.then(r.bind(null,e,t,n))})),o}function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const FN={[SRGBColorSpace]:{[LinearSRGBColorSpace]:SRGBToLinear},[LinearSRGBColorSpace]:{[SRGBColorSpace]:LinearToSRGB}},ColorManagement={legacyMode:!0,get workingColorSpace(){return LinearSRGBColorSpace},set workingColorSpace(e){console.warn("v3d.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(this.legacyMode||t===n||!t||!n)return e;if(FN[t]&&void 0!==FN[t][n]){const r=FN[t][n];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},_colorKeywords={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},_rgb$1={r:0,g:0,b:0},_hslA={h:0,s:0,l:0},_hslB={h:0,s:0,l:0};function hue2rgb(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}function toComponents(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class Color{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=SRGBColorSpace){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ColorManagement.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=ColorManagement.workingColorSpace){return this.r=e,this.g=t,this.b=n,ColorManagement.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=ColorManagement.workingColorSpace){if(e=euclideanModulo(e,1),t=clamp(t,0,1),n=clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=hue2rgb(o,r,e+1/3),this.g=hue2rgb(o,r,e),this.b=hue2rgb(o,r,e-1/3)}return ColorManagement.toWorkingColorSpace(this,r),this}setStyle(e,t=SRGBColorSpace){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("v3d.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const o=r[1],i=r[2];switch(o){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,ColorManagement.toWorkingColorSpace(this,t),n(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,ColorManagement.toWorkingColorSpace(this,t),n(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const r=parseFloat(e[1])/360,o=parseFloat(e[2])/100,i=parseFloat(e[3])/100;return n(e[4]),this.setHSL(r,o,i,t)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=r[1],n=e.length;if(3===n)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,ColorManagement.toWorkingColorSpace(this,t),this;if(6===n)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,ColorManagement.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=SRGBColorSpace){const n=_colorKeywords[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("v3d.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=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=SRGBColorSpace){return ColorManagement.fromWorkingColorSpace(toComponents(this,_rgb$1),e),clamp(255*_rgb$1.r,0,255)<<16^clamp(255*_rgb$1.g,0,255)<<8^clamp(255*_rgb$1.b,0,255)<<0}getHexString(e=SRGBColorSpace){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ColorManagement.workingColorSpace){ColorManagement.fromWorkingColorSpace(toComponents(this,_rgb$1),t);const n=_rgb$1.r,r=_rgb$1.g,o=_rgb$1.b,i=Math.max(n,r,o),a=Math.min(n,r,o);let s,l;const c=(a+i)/2;if(a===i)s=0,l=0;else{const e=i-a;switch(l=c<=.5?e/(i+a):e/(2-i-a),i){case n:s=(r-o)/e+(r2048||t.height>2048?(console.warn("v3d.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=createElementNS("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),o=r.data;for(let e=0;e0&&(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 RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case MirroredRepeatWrapping: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 RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case MirroredRepeatWrapping: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)}}Texture.DEFAULT_IMAGE=null,Texture.DEFAULT_MAPPING=300,Texture.DEFAULT_ANISOTROPY=1;class Vector4{constructor(e=0,t=0,n=0,r=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,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,r=this.z,o=this.w,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r+i[12]*o,this.y=i[1]*t+i[5]*n+i[9]*r+i[13]*o,this.z=i[2]*t+i[6]*n+i[10]*r+i[14]*o,this.w=i[3]*t+i[7]*n+i[11]*r+i[15]*o,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,r,o;const i=.01,a=.1,s=e.elements,l=s[0],c=s[4],u=s[8],d=s[1],h=s[5],p=s[9],f=s[2],m=s[6],g=s[10];if(Math.abs(c-d)s&&e>_?e_?s=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const o=Math.sqrt(r),i=Math.atan2(o,t*n);e=Math.sin(e*i)/o,a=Math.sin(a*i)/o}const o=a*n;if(s=s*e+d*o,l=l*e+h*o,c=c*e+p*o,u=u*e+f*o,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,o,i){const a=n[r],s=n[r+1],l=n[r+2],c=n[r+3],u=o[i],d=o[i+1],h=o[i+2],p=o[i+3];return e[t]=a*p+c*u+s*h-l*d,e[t+1]=s*p+c*d+l*u-a*h,e[t+2]=l*p+c*h+a*d-s*u,e[t+3]=c*p-a*u-s*d-l*h,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,r=e._y,o=e._z,i=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(r/2),u=a(o/2),d=s(n/2),h=s(r/2),p=s(o/2);switch(i){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:console.warn("v3d.Quaternion: .setFromEuler() encountered an unknown order: "+i)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],o=t[8],i=t[1],a=t[5],s=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-s)*e,this._y=(o-l)*e,this._z=(i-r)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-s)/e,this._x=.25*e,this._y=(r+i)/e,this._z=(o+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(o-l)/e,this._x=(r+i)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(i-r)/e,this._x=(o+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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,r=e._y,o=e._z,i=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+i*a+r*l-o*s,this._y=r*c+i*s+o*a-n*l,this._z=o*c+i*l+n*s-r*a,this._w=i*c-n*a-r*s-o*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,o=this._z,i=this._w;let a=i*e._w+n*e._x+r*e._y+o*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=i,this._x=n,this._y=r,this._z=o,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*i+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*o+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=i*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=o*u+this._z*d,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),r=2*Math.PI*Math.random(),o=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(o),n*Math.cos(o),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vector3{constructor(e=0,t=0,n=0){Vector3.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(_quaternion$4.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_quaternion$4.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*r,this.y=o[1]*t+o[4]*n+o[7]*r,this.z=o[2]*t+o[5]*n+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=e.elements,i=1/(o[3]*t+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*r+o[12])*i,this.y=(o[1]*t+o[5]*n+o[9]*r+o[13])*i,this.z=(o[2]*t+o[6]*n+o[10]*r+o[14])*i,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,o=e.x,i=e.y,a=e.z,s=e.w,l=s*t+i*r-a*n,c=s*n+a*t-o*r,u=s*r+o*n-i*t,d=-o*t-i*n-a*r;return this.x=l*s+d*-o+c*-a-u*-i,this.y=c*s+d*-i+u*-o-l*-a,this.z=u*s+d*-a+l*-i-c*-o,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,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r,this.y=o[1]*t+o[5]*n+o[9]*r,this.z=o[2]*t+o[6]*n+o[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,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,r=e.y,o=e.z,i=t.x,a=t.y,s=t.z;return this.x=r*s-o*a,this.y=o*i-n*s,this.z=n*a-r*i,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 _vector$c.copy(this).projectOnVector(e),this.sub(_vector$c)}reflect(e){return this.sub(_vector$c.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(clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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}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 _vector$c=new Vector3,_quaternion$4=new Quaternion;class Box3{constructor(e=new Vector3(1/0,1/0,1/0),t=new Vector3(-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){let t=1/0,n=1/0,r=1/0,o=-1/0,i=-1/0,a=-1/0;for(let s=0,l=e.length;so&&(o=l),c>i&&(i=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(o,i,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,o=-1/0,i=-1/0,a=-1/0;for(let s=0,l=e.count;so&&(o=l),c>i&&(i=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(o,i,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,_vector$b),_vector$b.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(_center),_extents.subVectors(this.max,_center),_v0$2.subVectors(e.a,_center),_v1$7.subVectors(e.b,_center),_v2$4.subVectors(e.c,_center),_f0.subVectors(_v1$7,_v0$2),_f1.subVectors(_v2$4,_v1$7),_f2.subVectors(_v0$2,_v2$4);let t=[0,-_f0.z,_f0.y,0,-_f1.z,_f1.y,0,-_f2.z,_f2.y,_f0.z,0,-_f0.x,_f1.z,0,-_f1.x,_f2.z,0,-_f2.x,-_f0.y,_f0.x,0,-_f1.y,_f1.x,0,-_f2.y,_f2.x,0];return!!satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),t=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$b.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(_vector$b).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()||(_points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_points)),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)}scale(e){return this.getCenter(_center),_extents.subVectors(this.max,_center),_extents.multiply(e),this.min.copy(_center).sub(_extents),this.max.copy(_center).add(_extents),this}}const _points=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],_vector$b=new Vector3,_box$4=new Box3,_v0$2=new Vector3,_v1$7=new Vector3,_v2$4=new Vector3,_f0=new Vector3,_f1=new Vector3,_f2=new Vector3,_center=new Vector3,_extents=new Vector3,_triangleNormal=new Vector3,_testAxis=new Vector3;function satForAxes(e,t,n,r,o){for(let i=0,a=e.length-3;i<=a;i+=3){_testAxis.fromArray(e,i);const a=o.x*Math.abs(_testAxis.x)+o.y*Math.abs(_testAxis.y)+o.z*Math.abs(_testAxis.z),s=t.dot(_testAxis),l=n.dot(_testAxis),c=r.dot(_testAxis);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const _box$3=new Box3,_v1$6=new Vector3,_v2$3=new Vector3;class Sphere{constructor(e=new Vector3,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):_box$3.setFromPoints(e).getCenter(n);let r=0;for(let t=0,o=e.length;tthis.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;_v1$6.subVectors(e,this.center);const t=_v1$6.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(_v1$6,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):(_v2$3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_v1$6.copy(e.center).add(_v2$3)),this.expandByPoint(_v1$6.copy(e.center).sub(_v2$3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const _vector$a=new Vector3,_segCenter=new Vector3,_segDir=new Vector3,_diff=new Vector3,_edge1=new Vector3,_edge2=new Vector3,_normal$1=new Vector3;class Ray{constructor(e=new Vector3,t=new Vector3(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_vector$a)),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.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_vector$a.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_vector$a.copy(this.direction).multiplyScalar(t).add(this.origin),_vector$a.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){_segCenter.copy(e).add(t).multiplyScalar(.5),_segDir.copy(t).sub(e).normalize(),_diff.copy(this.origin).sub(_segCenter);const o=.5*e.distanceTo(t),i=-this.direction.dot(_segDir),a=_diff.dot(this.direction),s=-_diff.dot(_segDir),l=_diff.lengthSq(),c=Math.abs(1-i*i);let u,d,h,p;if(c>0)if(u=i*s-a,d=i*a-s,p=o*c,u>=0)if(d>=-p)if(d<=p){const e=1/c;u*=e,d*=e,h=u*(u+i*d+2*a)+d*(i*u+d+2*s)+l}else d=o,u=Math.max(0,-(i*d+a)),h=-u*u+d*(d+2*s)+l;else d=-o,u=Math.max(0,-(i*d+a)),h=-u*u+d*(d+2*s)+l;else d<=-p?(u=Math.max(0,-(-i*o+a)),d=u>0?-o:Math.min(Math.max(-o,-s),o),h=-u*u+d*(d+2*s)+l):d<=p?(u=0,d=Math.min(Math.max(-o,-s),o),h=d*(d+2*s)+l):(u=Math.max(0,-(i*o+a)),d=u>0?o:Math.min(Math.max(-o,-s),o),h=-u*u+d*(d+2*s)+l);else d=i>0?-o:o,u=Math.max(0,-(i*d+a)),h=-u*u+d*(d+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(_segDir).multiplyScalar(d).add(_segCenter),h}intersectSphere(e,t){_vector$a.subVectors(e.center,this.origin);const n=_vector$a.dot(this.direction),r=_vector$a.dot(_vector$a)-n*n,o=e.radius*e.radius;if(r>o)return null;const i=Math.sqrt(o-r),a=n-i,s=n+i;return a<0&&s<0?null:a<0?this.at(s,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,r,o,i,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),c>=0?(o=(e.min.y-d.y)*c,i=(e.max.y-d.y)*c):(o=(e.max.y-d.y)*c,i=(e.min.y-d.y)*c),n>i||o>r?null:((o>n||isNaN(n))&&(n=o),(i=0?(a=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,_vector$a)}intersectTriangle(e,t,n,r,o){_edge1.subVectors(t,e),_edge2.subVectors(n,e),_normal$1.crossVectors(_edge1,_edge2);let i,a=this.direction.dot(_normal$1);if(a>0){if(r)return null;i=1}else{if(!(a<0))return null;i=-1,a=-a}_diff.subVectors(this.origin,e);const s=i*this.direction.dot(_edge2.crossVectors(_diff,_edge2));if(s<0)return null;const l=i*this.direction.dot(_edge1.cross(_diff));if(l<0)return null;if(s+l>a)return null;const c=-i*_diff.dot(_normal$1);return c<0?null:this.at(c/a,o)}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 Matrix4{constructor(){Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,r,o,i,a,s,l,c,u,d,h,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=o,g[5]=i,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=h,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 Matrix4).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,r=1/_v1$5.setFromMatrixColumn(e,0).length(),o=1/_v1$5.setFromMatrixColumn(e,1).length(),i=1/_v1$5.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*i,t[9]=n[9]*i,t[10]=n[10]*i,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,r=e.y,o=e.z,i=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),c=Math.cos(o),u=Math.sin(o);if("XYZ"===e.order){const e=i*c,n=i*u,r=a*c,o=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+r*l,t[5]=e-o*l,t[9]=-a*s,t[2]=o-e*l,t[6]=r+n*l,t[10]=i*s}else if("YXZ"===e.order){const e=s*c,n=s*u,r=l*c,o=l*u;t[0]=e+o*a,t[4]=r*a-n,t[8]=i*l,t[1]=i*u,t[5]=i*c,t[9]=-a,t[2]=n*a-r,t[6]=o+e*a,t[10]=i*s}else if("ZXY"===e.order){const e=s*c,n=s*u,r=l*c,o=l*u;t[0]=e-o*a,t[4]=-i*u,t[8]=r+n*a,t[1]=n+r*a,t[5]=i*c,t[9]=o-e*a,t[2]=-i*l,t[6]=a,t[10]=i*s}else if("ZYX"===e.order){const e=i*c,n=i*u,r=a*c,o=a*u;t[0]=s*c,t[4]=r*l-n,t[8]=e*l+o,t[1]=s*u,t[5]=o*l+e,t[9]=n*l-r,t[2]=-l,t[6]=a*s,t[10]=i*s}else if("YZX"===e.order){const e=i*s,n=i*l,r=a*s,o=a*l;t[0]=s*c,t[4]=o-e*u,t[8]=r*u+n,t[1]=u,t[5]=i*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+r,t[10]=e-o*u}else if("XZY"===e.order){const e=i*s,n=i*l,r=a*s,o=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+o,t[5]=i*c,t[9]=n*u-r,t[2]=r*u-n,t[6]=a*c,t[10]=o*u+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(_zero,e,_one)}lookAt(e,t,n){const r=this.elements;return _z.subVectors(e,t),0===_z.lengthSq()&&(_z.z=1),_z.normalize(),_x.crossVectors(n,_z),0===_x.lengthSq()&&(1===Math.abs(n.z)?_z.x+=1e-4:_z.z+=1e-4,_z.normalize(),_x.crossVectors(n,_z)),_x.normalize(),_y.crossVectors(_z,_x),r[0]=_x.x,r[4]=_y.x,r[8]=_z.x,r[1]=_x.y,r[5]=_y.y,r[9]=_z.y,r[2]=_x.z,r[6]=_y.z,r[10]=_z.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,i=n[0],a=n[4],s=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],v=n[7],A=n[11],x=n[15],y=r[0],b=r[4],C=r[8],S=r[12],M=r[1],E=r[5],T=r[9],w=r[13],I=r[2],L=r[6],R=r[10],B=r[14],P=r[3],D=r[7],N=r[11],F=r[15];return o[0]=i*y+a*M+s*I+l*P,o[4]=i*b+a*E+s*L+l*D,o[8]=i*C+a*T+s*R+l*N,o[12]=i*S+a*w+s*B+l*F,o[1]=c*y+u*M+d*I+h*P,o[5]=c*b+u*E+d*L+h*D,o[9]=c*C+u*T+d*R+h*N,o[13]=c*S+u*w+d*B+h*F,o[2]=p*y+f*M+m*I+g*P,o[6]=p*b+f*E+m*L+g*D,o[10]=p*C+f*T+m*R+g*N,o[14]=p*S+f*w+m*B+g*F,o[3]=_*y+v*M+A*I+x*P,o[7]=_*b+v*E+A*L+x*D,o[11]=_*C+v*T+A*R+x*N,o[15]=_*S+v*w+A*B+x*F,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],r=e[8],o=e[12],i=e[1],a=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+o*s*u-r*l*u-o*a*d+n*l*d+r*a*h-n*s*h)+e[7]*(+t*s*h-t*l*d+o*i*d-r*i*h+r*l*c-o*s*c)+e[11]*(+t*l*u-t*a*h-o*i*u+n*i*h+o*a*c-n*l*c)+e[15]*(-r*a*c-t*s*u+t*a*d+r*i*u-n*i*d+n*s*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 r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],i=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],f=e[13],m=e[14],g=e[15],_=u*m*l-f*d*l+f*s*h-a*m*h-u*s*g+a*d*g,v=p*d*l-c*m*l-p*s*h+i*m*h+c*s*g-i*d*g,A=c*f*l-p*u*l+p*a*h-i*f*h-c*a*g+i*u*g,x=p*u*s-c*f*s-p*a*d+i*f*d+c*a*m-i*u*m,y=t*_+n*v+r*A+o*x;if(0===y)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/y;return e[0]=_*b,e[1]=(f*d*o-u*m*o-f*r*h+n*m*h+u*r*g-n*d*g)*b,e[2]=(a*m*o-f*s*o+f*r*l-n*m*l-a*r*g+n*s*g)*b,e[3]=(u*s*o-a*d*o-u*r*l+n*d*l+a*r*h-n*s*h)*b,e[4]=v*b,e[5]=(c*m*o-p*d*o+p*r*h-t*m*h-c*r*g+t*d*g)*b,e[6]=(p*s*o-i*m*o-p*r*l+t*m*l+i*r*g-t*s*g)*b,e[7]=(i*d*o-c*s*o+c*r*l-t*d*l-i*r*h+t*s*h)*b,e[8]=A*b,e[9]=(p*u*o-c*f*o-p*n*h+t*f*h+c*n*g-t*u*g)*b,e[10]=(i*f*o-p*a*o+p*n*l-t*f*l-i*n*g+t*a*g)*b,e[11]=(c*a*o-i*u*o-c*n*l+t*u*l+i*n*h-t*a*h)*b,e[12]=x*b,e[13]=(c*f*r-p*u*r+p*n*d-t*f*d-c*n*m+t*u*m)*b,e[14]=(p*a*r-i*f*r-p*n*s+t*f*s+i*n*m-t*a*m)*b,e[15]=(i*u*r-c*a*r+c*n*s-t*u*s-i*n*d+t*a*d)*b,this}scale(e){const t=this.elements,n=e.x,r=e.y,o=e.z;return t[0]*=n,t[4]*=r,t[8]*=o,t[1]*=n,t[5]*=r,t[9]*=o,t[2]*=n,t[6]*=r,t[10]*=o,t[3]*=n,t[7]*=r,t[11]*=o,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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return 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),r=Math.sin(t),o=1-n,i=e.x,a=e.y,s=e.z,l=o*i,c=o*a;return this.set(l*i+n,l*a-r*s,l*s+r*a,0,l*a+r*s,c*a+n,c*s-r*i,0,l*s-r*a,c*s+r*i,o*s*s+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,r,o,i){return this.set(1,n,o,0,e,1,i,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,o=t._x,i=t._y,a=t._z,s=t._w,l=o+o,c=i+i,u=a+a,d=o*l,h=o*c,p=o*u,f=i*c,m=i*u,g=a*u,_=s*l,v=s*c,A=s*u,x=n.x,y=n.y,b=n.z;return r[0]=(1-(f+g))*x,r[1]=(h+A)*x,r[2]=(p-v)*x,r[3]=0,r[4]=(h-A)*y,r[5]=(1-(d+g))*y,r[6]=(m+_)*y,r[7]=0,r[8]=(p+v)*b,r[9]=(m-_)*b,r[10]=(1-(d+f))*b,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let o=_v1$5.set(r[0],r[1],r[2]).length();const i=_v1$5.set(r[4],r[5],r[6]).length(),a=_v1$5.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],_m1$2.copy(this);const s=1/o,l=1/i,c=1/a;return _m1$2.elements[0]*=s,_m1$2.elements[1]*=s,_m1$2.elements[2]*=s,_m1$2.elements[4]*=l,_m1$2.elements[5]*=l,_m1$2.elements[6]*=l,_m1$2.elements[8]*=c,_m1$2.elements[9]*=c,_m1$2.elements[10]*=c,t.setFromRotationMatrix(_m1$2),n.x=o,n.y=i,n.z=a,this}makePerspective(e,t,n,r,o,i){const a=this.elements,s=2*o/(t-e),l=2*o/(n-r),c=(t+e)/(t-e),u=(n+r)/(n-r),d=-(i+o)/(i-o),h=-2*i*o/(i-o);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=h,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,r,o,i){const a=this.elements,s=1/(t-e),l=1/(n-r),c=1/(i-o),u=(t+e)*s,d=(n+r)*l,h=(i+o)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-h,a[3]=0,a[7]=0,a[11]=0,a[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}composeE(e,t,n){const r=this.elements;this.makeRotationFromEuler(t);const o=n.x,i=n.y,a=n.z;return r[0]*=o,r[1]*=o,r[2]*=o,r[3]=0,r[4]*=i,r[5]*=i,r[6]*=i,r[7]=0,r[8]*=a,r[9]*=a,r[10]*=a,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decomposeE(e,t,n,r=t.order){const o=this.elements;let i=_v1$5.set(o[0],o[1],o[2]).length();const a=_v1$5.set(o[4],o[5],o[6]).length(),s=_v1$5.set(o[8],o[9],o[10]).length();this.determinant()<0&&(i=-i),e.x=o[12],e.y=o[13],e.z=o[14],_m1$2.copy(this);const l=1/i,c=1/a,u=1/s;return _m1$2.elements[0]*=l,_m1$2.elements[1]*=l,_m1$2.elements[2]*=l,_m1$2.elements[4]*=c,_m1$2.elements[5]*=c,_m1$2.elements[6]*=c,_m1$2.elements[8]*=u,_m1$2.elements[9]*=u,_m1$2.elements[10]*=u,t.setFromRotationMatrix(_m1$2,r),n.x=i,n.y=a,n.z=s,this}}const _v1$5=new Vector3,_m1$2=new Matrix4,_zero=new Vector3(0,0,0),_one=new Vector3(1,1,1),_x=new Vector3,_y=new Vector3,_z=new Vector3,_matrix$2=new Matrix4,_quaternion$3=new Quaternion;class Euler{constructor(e=0,t=0,n=0,r=Euler.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,o=r[0],i=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],d=r[6],h=r[10];switch(t){case"XYZ":this._y=Math.asin(clamp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-i,o)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,o),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-i,l)):(this._y=0,this._z=Math.atan2(s,o));break;case"ZYX":this._y=Math.asin(-clamp(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(s,o)):(this._x=0,this._z=Math.atan2(-i,l));break;case"YZX":this._z=Math.asin(clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-clamp(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,o)):(this._x=Math.atan2(-c,h),this._y=0);break;default:console.warn("v3d.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _matrix$2.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_matrix$2,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _quaternion$3.setFromEuler(this),this.setFromQuaternion(_quaternion$3,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}toVector3(e){return console.warn("v3d.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead"),e?e.set(this._x,this._y,this._z):new Vector3(this._x,this._y,this._z)}makeAlternative(){var e="X"===this._order[1]?-1:1,t="Y"===this._order[1]?-1:1,n="Z"===this._order[1]?-1:1;return this._x=angleToRange_mPi_Pi(e*(this._x+Math.PI)),this._y=angleToRange_mPi_Pi(t*(this._y+Math.PI)),this._z=angleToRange_mPi_Pi(n*(this._z+Math.PI)),this}equalsEps(e,t){return Math.abs(this._x-e._x)>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,e,_scale$9),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,_quaternion$2,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[4],t[5],t[6]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n0&&(r.userData=this.userData),!1===this.disableChildRendering&&(r.disableChildRendering=!1),!0===this.hidpiCompositing&&(r.hidpiCompositing=!0),0!==this.objectIndex&&(r.objectIndex=this.objectIndex),this.objectColor&&this.objectColor.isColor&&(r.objectColor=this.objectColor.getHex()),1!==this.objectAlpha&&(r.objectAlpha=this.objectAlpha),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(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,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),o.length>0&&(n.textures=o),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=r,n;function i(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){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.disableChildRendering=e.disableChildRendering,this.hidpiCompositing=e.hidpiCompositing,this.objectIndex=e.objectIndex,this.objectColor.copy(e.objectColor),this.objectAlpha=e.objectAlpha,this.constraints=[];for(let t=0;t0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,n,r,o){_v0$1.subVectors(r,t),_v1$3.subVectors(n,t),_v2$2.subVectors(e,t);const i=_v0$1.dot(_v0$1),a=_v0$1.dot(_v1$3),s=_v0$1.dot(_v2$2),l=_v1$3.dot(_v1$3),c=_v1$3.dot(_v2$2),u=i*l-a*a;if(0===u)return o.set(-2,-1,-1);const d=1/u,h=(l*s-a*c)*d,p=(i*c-a*s)*d;return o.set(1-h-p,p,h)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,_v3$1),_v3$1.x>=0&&_v3$1.y>=0&&_v3$1.x+_v3$1.y<=1}static getUV(e,t,n,r,o,i,a,s){return this.getBarycoord(e,t,n,r,_v3$1),s.set(0,0),s.addScaledVector(o,_v3$1.x),s.addScaledVector(i,_v3$1.y),s.addScaledVector(a,_v3$1.z),s}static isFrontFacing(e,t,n,r){return _v0$1.subVectors(n,t),_v1$3.subVectors(e,t),_v0$1.cross(_v1$3).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _v0$1.subVectors(this.c,this.b),_v1$3.subVectors(this.a,this.b),.5*_v0$1.cross(_v1$3).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,o){return Triangle.getUV(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,o=this.c;let i,a;_vab.subVectors(r,n),_vac.subVectors(o,n),_vap.subVectors(e,n);const s=_vab.dot(_vap),l=_vac.dot(_vap);if(s<=0&&l<=0)return t.copy(n);_vbp.subVectors(e,r);const c=_vab.dot(_vbp),u=_vac.dot(_vbp);if(c>=0&&u<=c)return t.copy(r);const d=s*u-c*l;if(d<=0&&s>=0&&c<=0)return i=s/(s-c),t.copy(n).addScaledVector(_vab,i);_vcp.subVectors(e,o);const h=_vab.dot(_vcp),p=_vac.dot(_vcp);if(p>=0&&h<=p)return t.copy(o);const f=h*l-s*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(_vac,a);const m=c*p-h*u;if(m<=0&&u-c>=0&&h-p>=0)return _vbc.subVectors(o,r),a=(u-c)/(u-c+(h-p)),t.copy(r).addScaledVector(_vbc,a);const g=1/(m+f+d);return i=f*g,a=d*g,t.copy(n).addScaledVector(_vab,i).addScaledVector(_vac,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let materialId=0;class Material extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:materialId++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.blending=NormalBlending,this.side=FrontSide,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=SrcAlphaFactor,this.blendDst=OneMinusSrcAlphaFactor,this.blendEquation=AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0,this.depthPrepass=!1,this.receiveShadow=!1,this.castShadow=!1,this.profile="",this.defines={},this.definesFragOnly=[],this.DefaultEnvMapAutoAssign=!0,this.envMapAutoAssign=this.DefaultEnvMapAutoAssign,this.gtaoVisible=!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("v3d.Material: '"+t+"' parameter is undefined.");continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("v3d."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}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),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&&!this.isMeshNodeMaterial&&(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),this.blending!==NormalBlending&&(n.blending=this.blending),this.side!==FrontSide&&(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.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=r(e.textures),o=r(e.images);t.length>0&&(n.textures=t),o.length>0&&(n.images=o)}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 r=0;r!==e;++r)n[r]=t[r].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.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this.depthPrepass=e.depthPrepass,this.defines=Object.assign({},e.defines),this.definesFragOnly=e.definesFragOnly.slice(),this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.profile=e.profile,this.envMapAutoAssign=e.envMapAutoAssign,this.gtaoVisible=e.gtaoVisible,this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}get needsUpdate(){return 0!=this.version}}class MeshBasicMaterial extends Material{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(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=MultiplyOperation,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 _vector$9=new Vector3,_vector2$1=new Vector2;class BufferAttribute{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("v3d.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=35044,this.updateRange={offset:0,count:-1},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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,o=this.itemSize;r0&&(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 r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let o=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],i=[];for(let t=0,r=n.length;t0&&(r[t]=i,o=!0)}o&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const i=this.groups;i.length>0&&(e.data.groups=JSON.parse(JSON.stringify(i)));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 r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const o=e.morphAttributes;for(const e in o){const n=[],r=o[e];for(let e=0,o=r.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;en.far?null:{distance:c,point:_intersectionPointWorld.clone(),object:e}}function checkBufferGeometryIntersection$1(e,t,n,r,o,i,a,s,l,c,u,d){_vA$1.fromBufferAttribute(o,c),_vB$1.fromBufferAttribute(o,u),_vC$1.fromBufferAttribute(o,d);const h=e.morphTargetInfluences;if(i&&h){_morphA.set(0,0,0),_morphB.set(0,0,0),_morphC.set(0,0,0);for(let e=0,t=i.length;e0?1:-1,c.push(T.x,T.y,T.z),u.push(s/m),u.push(1-i/g),M+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;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 Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4,this.controls=null,this.viewportFit={type:0,initialAspect:1},this.ignoreShadowLayers=!1}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),e.controls&&(this.controls=e.controls.clone()),this.viewportFit.type=e.viewportFit.type,this.viewportFit.initialAspect=e.viewportFit.initialAspect,this.ignoreShadowLayers=e.ignoreShadowLayers,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(e){return(new this.constructor).copy(this,e)}}class PerspectiveCamera extends Camera{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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*RAD2DEG*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*DEG2RAD*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*RAD2DEG*Math.atan(Math.tan(.5*DEG2RAD*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,r,o,i){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=r,this.view.width=o,this.view.height=i,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*DEG2RAD*this.fov)/this.zoom,n=2*t,r=this.aspect*n,o=-.5*r;const i=this.view;if(null!==this.view&&this.view.enabled){const e=i.fullWidth,a=i.fullHeight;o+=i.offsetX*r/e,t-=i.offsetY*n/a,r*=i.width/e,n*=i.height/a}const a=this.filmOffset;0!==a&&(o+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,t,t-n,e,this.far),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 fov=-90,aspect=1;class CubeCamera extends Object3D{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new PerspectiveCamera(-90,1,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);const o=new PerspectiveCamera(-90,1,e,t);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(-1,0,0),this.add(o);const i=new PerspectiveCamera(-90,1,e,t);i.layers=this.layers,i.up.set(0,0,-1),i.lookAt(0,1,0),this.add(i);const a=new PerspectiveCamera(-90,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);const s=new PerspectiveCamera(-90,1,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(0,0,1),this.add(s);const l=new PerspectiveCamera(-90,1,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,o,i,a,s,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=NoToneMapping,e.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,o),e.setRenderTarget(n,2),e.render(t,i),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(e,t,n,r,o,i,a,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:CubeReflectionMapping,n,r,o,i,a,s,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.source.data}set images(e){this.source.data=e}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new CubeTexture(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:LinearFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection(in vec3 dir, in mat4 matrix) {\n\n return normalize((matrix * vec4(dir, 0.0)).xyz);\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection(position, modelMatrix);\n\n #include \n #include \n\n }\n ",fragmentShader:"\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include \n\n void main() {\n\n vec3 direction = normalize(vWorldDirection);\n\n vec2 sampleUV = equirectUv(direction);\n\n gl_FragColor = texture2D(tEquirect, sampleUV);\n\n }\n "},r=new BoxGeometry(5,5,5),o=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:BackSide,blending:NoBlending});o.uniforms.tEquirect.value=t;const i=new Mesh(r,o),a=t.minFilter;t.minFilter===LinearMipmapLinearFilter&&(t.minFilter=LinearFilter);return new CubeCamera(1,10,this).update(e,i),t.minFilter=a,i.geometry.dispose(),i.material.dispose(),this}clear(e,t,n,r){const o=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(o)}}const _vector1=new Vector3,_vector2=new Vector3,_normalMatrix=new Matrix3;class Plane{constructor(e=new Vector3(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=_vector1.subVectors(n,t).cross(_vector2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(_vector1),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return o<0||o>1?null:t.copy(n).multiplyScalar(o).add(e.start)}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||_normalMatrix.getNormalMatrix(e),r=this.coplanarPoint(_vector1).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),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 _sphere$3=new Sphere,_vector$7=new Vector3;class Frustum{constructor(e=new Plane,t=new Plane,n=new Plane,r=new Plane,o=new Plane,i=new Plane){this.planes=[e,t,n,r,o,i]}set(e,t,n,r,o,i){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(o),a[5].copy(i),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],g=n[13],_=n[14],v=n[15];return t[0].setComponents(a-r,u-s,f-d,v-m).normalize(),t[1].setComponents(a+r,u+s,f+d,v+m).normalize(),t[2].setComponents(a+o,u+l,f+h,v+g).normalize(),t[3].setComponents(a-o,u-l,f-h,v-g).normalize(),t[4].setComponents(a-i,u-c,f-p,v-_).normalize(),t[5].setComponents(a+i,u+c,f+p,v+_).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_sphere$3.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$3)}intersectsSprite(e){return _sphere$3.center.set(0,0,0),_sphere$3.radius=.7071067811865476,_sphere$3.applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$3)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,_vector$7.y=r.normal.y>0?e.max.y:e.min.y,_vector$7.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(_vector$7)<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 WebGLAnimation(){let e=null,t=!1,n=null,r=null;function o(t,i){n(t,i),r=e.requestAnimationFrame(o)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(o),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const n=t.isWebGL2;let r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function(t,o){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version0?n:t).get(m)}const g=e.xr,_=g.getSession&&g.getSession();_&&"additive"===_.environmentBlendMode&&(m=null),null===m?f(s,u):m&&m.isColor&&(f(m,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===CubeUVReflectionMapping)?(void 0===c&&(c=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(ShaderLib.backgroundCube.uniforms),vertexShader:ShaderLib.backgroundCube.vertexShader,fragmentShader:ShaderLib.backgroundCube.fragmentShader,side:BackSide,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){const r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),o.update(c)),c.material.uniforms.envMap.value=m,c.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,c.material.toneMapped=i.backgroundToneMapped,d===m&&h===m.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=m,h=m.version,p=e.toneMapping),c.layers.enableAll(),r.unshift(c,c.geometry,c.material,0,0,null)):m&&m.isTexture&&(void 0===l&&(l=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(ShaderLib.background.uniforms),vertexShader:ShaderLib.background.vertexShader,fragmentShader:ShaderLib.background.fragmentShader,side:FrontSide,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),o.update(l)),l.material.uniforms.t2D.value=m,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.toneMapped=i.backgroundToneMapped,!0===m.matrixAutoUpdate&&m.updateMatrix(),l.material.uniforms.uvTransform.value.copy(m.matrix),d===m&&h===m.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=m,h=m.version,p=e.toneMapping),l.layers.enableAll(),r.unshift(l,l.geometry,l.material,0,0,null))}}}function WebGLBindingStates(e,t,n,r){const o=e.getParameter(34921),i=r.isWebGL2?null:t.get("OES_vertex_array_object"),a=r.isWebGL2||null!==i,s={},l=p(null);let c=l,u=!1;function d(t){return r.isWebGL2?e.bindVertexArray(t):i.bindVertexArrayOES(t)}function h(t){return r.isWebGL2?e.deleteVertexArray(t):i.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],r=[];for(let e=0;e=0){const n=o[t];let r=i[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;a++}}return c.attributesNum!==a||c.index!==r}(o,A,h,x),y&&function(e,t,n,r){const o={},i=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=i[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),o[t]=r,a++}}c.attributes=o,c.attributesNum=a,c.index=r}(o,A,h,x)}else{const e=!0===l.wireframe;c.geometry===A.id&&c.program===h.id&&c.wireframe===e||(c.geometry=A.id,c.program=h.id,c.wireframe=e,y=!0)}null!==x&&n.update(x,34963),(y||u)&&(u=!1,function(o,i,a,s){if(!1===r.isWebGL2&&(o.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=s.attributes,c=a.getAttributes(),u=i.defaultAttributeValues;for(const t in c){const r=c[t];if(r.location>=0){let i=l[t];if(void 0===i&&("instanceMatrix"===t&&o.instanceMatrix&&(i=o.instanceMatrix),"instanceColor"===t&&o.instanceColor&&(i=o.instanceColor)),void 0!==i){const t=i.normalized,a=i.itemSize,l=n.get(i);if(void 0===l)continue;const c=l.buffer,u=l.type,d=l.bytesPerElement;if(i.isInterleavedBufferAttribute){const n=i.data,l=n.stride,h=i.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const i="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=o(a);s!==a&&(console.warn("v3d.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=i||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),h=e.getParameter(3379),p=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),v=d>0,A=i||t.has("OES_texture_float");return{isWebGL2:i,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:o,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:h,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:A,floatVertexTextures:v&&A,maxSamples:i?e.getParameter(36183):0}}function WebGLClipping(e){const t=this;let n=null,r=0,o=!1,i=!1;const a=new Plane,s=new Matrix3,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,o){const i=null!==e?e.length:0;let c=null;if(0!==i){if(c=l.value,!0!==o||null===c){const t=r+4*i,o=n.matrixWorldInverse;s.getNormalMatrix(o),(null===c||c.length0){const a=new WebGLCubeRenderTarget(i.height/2);return a.fromEquirectangularTexture(e,o),t.set(o,a),o.addEventListener("dispose",r),n(a.texture,o.mapping)}return null}}}return o},dispose:function(){t=new WeakMap}}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,n=1,r=-1,o=.1,i=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=r,this.near=o,this.far=i,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,r,o,i){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=r,this.view.width=o,this.view.height=i,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,r=(this.top+this.bottom)/2;let o=n-e,i=n+e,a=r+t,s=r-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;o+=e*this.view.offsetX,i=o+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(o,i,a,s,this.near,this.far),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}}class RawShaderMaterial extends ShaderMaterial{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Scene extends Object3D{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,this.backgroundToneMapped=!0,this.postprocessing=[],this.worldMaterial=null,this.worldEnvMapProbe=null,"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_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,this.backgroundToneMapped=e.backgroundToneMapped,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.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.backgroundIntensity=this.backgroundIntensity),!1===this.backgroundToneMapped&&(t.backgroundToneMapped=!1),t}get autoUpdate(){return console.warn("v3d.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("v3d.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}dispose(){this.dispatchEvent({type:"dispose"})}}let MAX_TILE_SIZE=256;const LOD_CONFIG=[{relSize:1,sigma:0,origin:[0,0]},{relSize:.5,sigma:.025,origin:[0,2/3]},{relSize:1/4,sigma:.07,origin:[.5,2/3]},{relSize:1/8,sigma:.18,origin:[.75,2/3]},{relSize:1/16,sigma:.24,origin:[.875,2/3]},{relSize:1/16,sigma:.3,origin:[.875,17/24]},{relSize:1/16,sigma:.36,origin:[.875,.75]},{relSize:1/16,sigma:.42,origin:[.875,19/24]},{relSize:1/16,sigma:.48,origin:[.875,20/24]},{relSize:1/16,sigma:.54,origin:[.875,.875]},{relSize:1/16,sigma:.6,origin:[.875,22/24]}];function _getLodTileSize(e){return LOD_CONFIG[e].relSize*MAX_TILE_SIZE}function _getLodOrigin(e){return LOD_CONFIG[e].origin.map((function(e){return e*MAX_TILE_SIZE*3}))}const MAX_SAMPLES=20,_flatCamera=new OrthographicCamera,_lodPlanes=_createPlanes(),_clearColor$2=new Color;let _oldTarget=null;const PHI=(1+Math.sqrt(5))/2,INV_PHI=1/PHI,_axisDirections=[new Vector3(1,1,1),new Vector3(-1,1,1),new Vector3(1,1,-1),new Vector3(-1,1,-1),new Vector3(0,PHI,INV_PHI),new Vector3(0,PHI,-INV_PHI),new Vector3(INV_PHI,0,PHI),new Vector3(-INV_PHI,0,PHI),new Vector3(PHI,INV_PHI,0),new Vector3(-PHI,INV_PHI,0)];class PMREMGenerator{constructor(e,t){this._renderer=e,this._pingPongRenderTarget=null,this._equirectShader=null,this._cubemapShader=null,this.flipCubemapX=!0,Object.defineProperties(this,{maxTileSize:{get:function(){return MAX_TILE_SIZE},set:function(e){MAX_TILE_SIZE=e}}}),void 0!==t&&(this.maxTileSize=t),this._blurMaterial=_getBlurShader(20,this.maxTileSize),this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){_oldTarget=this._renderer.getRenderTarget();const o=this._allocateTargets();return this._sceneToCubeUV(e,n,r,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e){return e.magFilter=LinearFilter,e.minFilter=LinearFilter,e.generateMipmaps=!1,this.fromCubemap(e)}fromCubemap(e){_oldTarget=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t,this.flipCubemapX),this._applyPMREM(t),this._cleanup(t),t}fromCubeRenderTarget(e,t){const n=this._allocateTargets(e.texture,t);return this._cubeRTToCubeUV(e,n,this.flipCubemapX),this._applyPMREM(n),this._cleanup(n),n}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=_getCubemapShader(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=_getEquirectShader(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<_lodPlanes.length;e++)_lodPlanes[e].dispose();this._renderer=null}_cleanup(e){this._renderer.setRenderTarget(_oldTarget),e.scissorTest=!1,e.setSize(e.width,e.height)}_allocateTargets(e,t){const n={magFilter:LinearFilter,minFilter:LinearFilter,generateMipmaps:!1,type:e?e.type:HalfFloatType,format:e?e.format:RGBAFormat,encoding:e?e.encoding:LinearEncoding$1,depthBuffer:!1,stencilBuffer:!1};void 0!==t&&Object.assign(n,t);const r=_createRenderTarget(n);return r.depthBuffer=!e,null===this._pingPongRenderTarget&&(this._pingPongRenderTarget=_createRenderTarget(n)),r}_compileMaterial(e){const t=new Scene;t.add(new Mesh(_lodPlanes[0],e)),this._renderer.compile(t,_flatCamera)}_sceneToCubeUV(e,t,n,r){const o=new PerspectiveCamera(90,1,t,n),i=[1,1,1,1,-1,1],a=[1,1,-1,-1,-1,1],s=this._renderer,l=s.outputEncoding,c=s.toneMapping,u=s.toneMappingExposure;s.getClearColor(_clearColor$2);const d=s.getClearAlpha();s.toneMapping=LinearToneMapping,s.toneMappingExposure=1,s.outputEncoding=LinearEncoding$1,e.scale.z*=-1;let h=e.background;if(h&&h.isColor){h.convertSRGBToLinear();const t=Math.max(h.r,h.g,h.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127);h=h.multiplyScalar(Math.pow(2,-n));const r=(n+128)/255;s.setClearColor(h,r),e.background=null}for(let t=0;t<6;t++){const n=t%3;0===n?(o.up.set(0,i[t],0),o.lookAt(a[t],0,0)):1===n?(o.up.set(0,0,i[t]),o.lookAt(0,a[t],0)):(o.up.set(0,i[t],0),o.lookAt(0,0,a[t]));const l=_getLodTileSize(0);_setViewport(r,n*l,t>2?l:0,l,l),s.setRenderTarget(r),s.render(e,o)}s.toneMapping=c,s.toneMappingExposure=u,s.outputEncoding=l,s.setClearColor(_clearColor$2,d),e.scale.z*=-1}_textureToCubeUV(e,t,n){const r=this._renderer,o=new Scene;e.isCubeTexture?null===this._cubemapShader&&(this._cubemapShader=_getCubemapShader()):null===this._equirectShader&&(this._equirectShader=_getEquirectShader());const i=e.isCubeTexture?this._cubemapShader:this._equirectShader;o.add(new Mesh(_lodPlanes[0],i));const a=i.uniforms;a.envMap.value=e,e.isCubeTexture?a.flipCubemapX.value=n||!1:a.texelSize.value.set(1/e.image.width,1/e.image.height);const s=_getLodTileSize(0);_setViewport(t,0,0,3*s,2*s),r.setRenderTarget(t),r.render(o,_flatCamera)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&(f=20,p=19/3,h=o/p);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e2?0:-1,r=[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];a.set(r,18*e),s.set(i,12*e);const o=[e,e,e,e,e,e];l.set(o,6*e)}const c=new BufferGeometry;return c.setAttribute("position",new BufferAttribute(a,3)),c.setAttribute("uv",new BufferAttribute(s,2)),c.setAttribute("faceIndex",new BufferAttribute(l,1)),c}))}function _createRenderTarget(e){const t=_getLodTileSize(0),n=new WebGLRenderTarget(3*t,3*t,e);return n.texture.mapping=CubeUVReflectionMapping,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function _setViewport(e,t,n,r,o){e.viewport.set(t,n,r,o),e.scissor.set(t,n,r,o)}function _getBlurShader(e,t){const n=new Float32Array(e),r=new Vector3(0,1,0),o=new RawShaderMaterial({defines:{n:e,cubeUV_maxTileSize:shaderFloatStr(t)},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},lodIdx:{value:0},poleAxis:{value:r}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n precision highp float;\n precision highp int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform int samples;\n uniform float weights[n];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform float lodIdx;\n uniform vec3 poleAxis;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include \n\n vec3 getSample(float theta, vec3 axis) {\n\n float cosTheta = cos(theta);\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross(axis, vOutputDirection) * sin(theta)\n + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\n return bilinearCubeUV(envMap, sampleDirection, lodIdx);\n\n }\n\n void main() {\n\n vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\n if (all(equal(axis, vec3(0.0)))) {\n\n axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\n }\n\n axis = normalize(axis);\n\n gl_FragColor = vec4(0.0);\n gl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\n for (int i = 1; i < n; i++) {\n\n if (i >= samples) {\n\n break;\n\n }\n\n float theta = dTheta * float(i);\n gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n gl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\n }\n\n }\n ",blending:NoBlending,depthTest:!1,depthWrite:!1});return o.type="SphericalGaussianBlur",o}function _getEquirectShader(){const e=new Vector2(1,1),t=new RawShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform vec2 texelSize;\n\n #define RECIPROCAL_PI 0.31830988618\n #define RECIPROCAL_PI2 0.15915494\n\n void main() {\n\n gl_FragColor = vec4(0.0);\n\n vec3 outputDirection = normalize(vOutputDirection);\n vec2 uv;\n uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\n vec2 f = fract(uv / texelSize - 0.5);\n uv -= f * texelSize;\n vec3 tl = texture2D(envMap, uv).rgb;\n uv.x += texelSize.x;\n vec3 tr = texture2D(envMap, uv).rgb;\n uv.y += texelSize.y;\n vec3 br = texture2D(envMap, uv).rgb;\n uv.x -= texelSize.x;\n vec3 bl = texture2D(envMap, uv).rgb;\n\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n gl_FragColor.rgb = mix(tm, bm, f.y);\n\n }\n ",blending:NoBlending,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function _getCubemapShader(){const e=new RawShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipCubemapX:{value:!0}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n precision mediump float;\n precision mediump int;\n\n uniform bool flipCubemapX;\n\n varying vec3 vOutputDirection;\n\n uniform samplerCube envMap;\n\n void main() {\n\n gl_FragColor = textureCube(envMap, vec3(vOutputDirection.x * (flipCubemapX ? -1.0 : 1.0), vOutputDirection.yz));\n\n }\n ",blending:NoBlending,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function _getCommonVertexShader(){return"\n\n precision mediump float;\n precision mediump int;\n\n attribute vec3 position;\n attribute vec2 uv;\n attribute float faceIndex;\n\n varying vec3 vOutputDirection;\n\n // RH coordinate system; PMREM face-indexing convention\n vec3 getDirection(vec2 uv, float face) {\n\n uv = 2.0 * uv - 1.0;\n\n vec3 direction = vec3(uv, 1.0);\n\n if (face == 0.0) {\n\n direction = direction.zyx;\n direction.z *= -1.0;\n\n } else if (face == 1.0) {\n\n direction = direction.xzy;\n direction.z *= -1.0;\n\n } else if (face == 3.0) {\n\n direction = direction.zyx;\n direction.x *= -1.0;\n\n } else if (face == 4.0) {\n\n direction = direction.xzy;\n direction.y *= -1.0;\n\n } else if (face == 5.0) {\n\n direction.xz *= -1.0;\n\n }\n\n return direction;\n\n }\n\n void main() {\n\n vOutputDirection = getDirection(uv, faceIndex);\n gl_Position = vec4(position, 1.0);\n\n }\n "}function WebGLCubeUVMaps(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const o=t.get(n);void 0!==o&&(t.delete(n),o.dispose())}return{get:function(o){if(o&&o.isTexture){const i=o.mapping,a=i===EquirectangularReflectionMapping||i===EquirectangularRefractionMapping,s=i===CubeReflectionMapping||i===CubeRefractionMapping;if(a||s){if(o.isRenderTargetTexture&&!0===o.needsPMREMUpdate){o.needsPMREMUpdate=!1;let r=t.get(o);return null===n&&(n=new PMREMGenerator(e)),r=a?n.fromEquirectangular(o,r):n.fromCubemap(o,r),t.set(o,r),r.texture}if(t.has(o))return t.get(o).texture;{const i=o.image;if(a&&i&&i.height>0||s&&i&&function(e){let t=0;const n=6;for(let r=0;rt.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);const m=new Float32Array(p*f*4*o),g=new DataArrayTexture(m,p,f,o);g.type=FloatType,g.needsUpdate=!0;const _=4*h;for(let t=0;t0)return e;const o=t*n;let i=arrayCacheF32[o];if(void 0===i&&(i=new Float32Array(o),arrayCacheF32[o]=i),0!==t){r.toArray(i,0);for(let r=1,o=0;r!==t;++r)o+=n,e[r].toArray(i,o)}return i}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n":" "} ${o}: ${n[e]}`)}return r.join("\n")}function getEncodingComponents(e){switch(e){case LinearEncoding$1:return["Linear","(value)"];case sRGBEncoding$1:return["sRGB","(value)"];default:return console.warn("v3d.WebGLProgram: Unsupported encoding:",e),["Linear","(value)"]}}function getShaderErrors(e,t,n){const r=e.getShaderParameter(t,35713),o=e.getShaderInfoLog(t).trim();if(r&&""===o)return"";const i=/ERROR: 0:(\d+)/.exec(o);if(i){const r=parseInt(i[1]);return n.toUpperCase()+"\n\n"+o+"\n\n"+handleSource(e.getShaderSource(t),r)}return o}function getTexelEncodingFunction(e,t){const n=getEncodingComponents(t);return"vec4 "+e+"(vec4 value) { return LinearTo"+n[0]+n[1]+"; }"}function getToneMappingFunction(e,t){let n;switch(t){case LinearToneMapping:n="Linear";break;case ReinhardToneMapping:n="Reinhard";break;case CineonToneMapping:n="OptimizedCineon";break;case ACESFilmicToneMapping:n="ACESFilmic";break;case CustomToneMapping:n="Custom";break;case LogarithmicMaxToneMapping:n="LogarithmicMax";break;case PhysicalMaxToneMapping:n="PhysicalMax";break;case FilmicBlenderToneMapping:n="FilmicBlender";break;case AgXBlenderToneMapping:n="AgX";break;default:console.warn("v3d.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}function genToneMappingLookDefine(e){let t="TONE_MAPPING_LOOK_NONE";return e===ToneMappingLookAgXPunchy&&(t="TONE_MAPPING_LOOK_AGX_PUNCHY"),t}function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID||e.useSlopeScaledBias?"#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(filterEmptyLine).join("\n")}function generateDefines(e,t=[]){const n=[];for(const r in e){const o=e[r];!1===o||t.indexOf(r)>-1||n.push("#define "+r+" "+o)}return n.join("\n")}function fetchAttributeLocations(e,t){const n={},r=e.getProgramParameter(t,35721);for(let o=0;o`,r+t[n])}return e}const includePattern=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(includePattern,includeReplacer)}function includeReplacer(e,t){const n=ShaderChunk[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return resolveIncludes(("undefined"!=typeof __V3D_DEVTOOLS__?`// included: "${t}"\n`:"")+n)}function unrollLoops(e){const t=new RegExp("#pragma unroll_loop_start[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\w+)\\+\\+\\) \\{"),n=new RegExp("\\{|\\}","g");let r;for(;r=t.exec(e);){let t,o;t=o=n.lastIndex=r.index+r[0].length;let i,a=1;do{(i=n.exec(e))&&("{"==i[0]?a++:"}"==i[0]&&a--,o=i.index)}while(i&&a>0);if(0==a){const i=e.substring(r.index,n.lastIndex),a=e.substring(t,o),s=new RegExp(`\\[${r[1]}\\]`,"g"),l=new RegExp(`\\(${r[1]}\\)`,"g");let c="";const u=parseInt(r[2]),d=parseInt(r[5])+("="===r[4]?1:0);for(let e=u;e0&&(A+="\n"),x=[f,m].filter(filterEmptyLine).join("\n"),x.length>0&&(x+="\n")):(A=[generatePrecision(n),"#define SHADER_NAME "+n.shaderName,e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",g,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",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 "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",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.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",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_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",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?"#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.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",n.planeReflProbe?"#define USE_PLANE_REFLECTION":"","\n uniform mat4 modelMatrix;\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n uniform mat4 viewMatrix;\n uniform mat3 normalMatrix;\n uniform vec3 cameraPosition;\n uniform bool isOrthographic;\n\n #ifdef USE_INSTANCING\n attribute mat4 instanceMatrix;\n #endif\n\n #ifdef USE_INSTANCING_COLOR\n attribute vec3 instanceColor;\n #endif\n\n attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n\n #ifdef USE_TANGENT\n attribute vec4 tangent;\n #endif\n\n #if defined(USE_COLOR_ALPHA)\n attribute vec4 color;\n #elif defined(USE_COLOR)\n attribute vec3 color;\n #endif\n\n #if (defined(USE_MORPHTARGETS) && !defined(MORPHTARGETS_TEXTURE))\n #if MORPHTARGETS_COUNT > 0\n attribute vec3 morphTarget0;\n #endif\n #if MORPHTARGETS_COUNT > 1\n attribute vec3 morphTarget1;\n #endif\n #if MORPHTARGETS_COUNT > 2\n attribute vec3 morphTarget2;\n #endif\n #if MORPHTARGETS_COUNT > 3\n attribute vec3 morphTarget3;\n #endif\n #if MORPHTARGETS_COUNT > 4\n attribute vec3 morphTarget4;\n #endif\n #if MORPHTARGETS_COUNT > 5\n attribute vec3 morphTarget5;\n #endif\n\n #ifdef USE_MORPHNORMALS\n #if MORPHTARGETS_COUNT > 0\n attribute vec3 morphNormal0;\n #endif\n #if MORPHTARGETS_COUNT > 1\n attribute vec3 morphNormal1;\n #endif\n #if MORPHTARGETS_COUNT > 2\n attribute vec3 morphNormal2;\n #endif\n #if MORPHTARGETS_COUNT > 3\n attribute vec3 morphNormal3;\n #endif\n #if MORPHTARGETS_COUNT > 4\n attribute vec3 morphNormal4;\n #endif\n #if MORPHTARGETS_COUNT > 5\n attribute vec3 morphNormal5;\n #endif\n #else\n #if MORPHTARGETS_COUNT > 6\n attribute vec3 morphTarget6;\n #endif\n #if MORPHTARGETS_COUNT > 7\n attribute vec3 morphTarget7;\n #endif\n #if MORPHTARGETS_COUNT > 8\n attribute vec3 morphTarget8;\n #endif\n #if MORPHTARGETS_COUNT > 9\n attribute vec3 morphTarget9;\n #endif\n #if MORPHTARGETS_COUNT > 10\n attribute vec3 morphTarget10;\n #endif\n #if MORPHTARGETS_COUNT > 11\n attribute vec3 morphTarget11;\n #endif\n #endif\n #endif\n\n #ifdef USE_SKINNING\n attribute vec4 skinIndex;\n attribute vec4 skinWeight;\n #endif\n "].filter(filterEmptyLine).join("\n"),x=[f,generatePrecision(n),"#define SHADER_NAME "+n.shaderName,m,getMaterialProfile(n.materialProfile),e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",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 "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",0!==n.envMapCubeUVTileSize?`#define cubeUV_maxTileSize ${shaderFloatStr(n.envMapCubeUVTileSize)}`:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",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.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",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_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",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.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",n.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+p:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==NoToneMapping?"#define TONE_MAPPING":"",n.toneMapping!==NoToneMapping?"#define TONE_MAPPING_LOOK "+genToneMappingLookDefine(n.toneMappingLook):"",n.toneMapping!==NoToneMapping?ShaderChunk.tonemapping_pars_fragment:"",n.toneMapping!==NoToneMapping?getToneMappingFunction("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque&&!n.alphaToCoverage?"#define OPAQUE":"",ShaderChunk.encodings_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"",`#define ESM_DISTANCE_SCALE ${shaderFloatStr(n.esmDistanceScale)}`,n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",n.useGTAO?"#define USE_GTAO":"",e.compatSettings.gtaoDisableBkgFix?"#define GTAO_DISABLE_BKG_FIX":"",n.dirLightShadowsCSMLUT&&n.isWebGL2?`#define LUT_DIR_LIGHT_SHADOWS_CSM int[](${n.dirLightShadowsCSMLUT})`:"","\n"].filter(filterEmptyLine).join("\n")),n.isMeshNodeMaterial&&(a=replaceNodeChunks(a,n.nodeChunks),s=replaceNodeChunks(s,n.nodeChunks)),a=resolveIncludes(a),a=replaceLightNums(a,n),a=replaceClippingPlaneNums(a,n),n.customPrepTokens&&(a=replaceCustomTokens(a,n.customPrepTokens)),s=resolveIncludes(s),s=replaceLightNums(s,n),s=replaceClippingPlaneNums(s,n),n.customPrepTokens&&(s=replaceCustomTokens(s,n.customPrepTokens)),a=unrollLoops(a),s=unrollLoops(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",A=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+A,x=["#define varying in",n.glslVersion===GLSL3?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===GLSL3?"":"#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);let b=y+A+a,C=y+x+s;e.debug.disableCompiledShaderCache&&(b+="\nconst float ANTI_CACHE = "+Math.random()+";",C+="\nconst float ANTI_CACHE = "+Math.random()+";");const S=WebGLShader(o,35633,b),M=WebGLShader(o,35632,C);"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:{shaderName:n.shaderName,materialName:n.materialName,vertex:b,fragment:C}})),o.attachShader(_,S),o.attachShader(_,M),void 0!==n.index0AttributeName?o.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(_,0,"position"),o.linkProgram(_);let E,T,w=!0;function I(){if(w=!1,e.debug.checkShaderErrors){const e=o.getProgramInfoLog(_).trim(),t=o.getShaderInfoLog(S).trim(),n=o.getShaderInfoLog(M).trim();let r=!0,i=!0;if(!1===o.getProgramParameter(_,35714)){r=!1;const t=getShaderErrors(o,S,"vertex"),n=getShaderErrors(o,M,"fragment");console.error("v3d.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(_,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(i=!1);i&&(v.diagnostics={runnable:r,programLog:e,vertexShader:{log:t,prefix:A},fragmentShader:{log:n,prefix:x}})}o.deleteShader(S),o.deleteShader(M)}return this.getUniforms=function(){return void 0===E&&(w&&I(),E=new WebGLUniforms(o,_)),E},this.getAttributes=function(){return void 0===T&&(w&&I(),T=fetchAttributeLocations(o,_)),T},this.destroy=function(){r.releaseStatesOfProgram(this),o.deleteProgram(_),this.program=void 0},this.name=n.shaderName,this.id=programIdCount++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=M,this.profile={calcRenderTime:!1,renderTime:0,timerQueries:[],materials:[]},this.getTexUniformCount=function(){return this.getUniforms().seq.reduce((function(e,t){if(t.info)switch(t.info.type){case 35678:case 35679:case 35680:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:e+=t.info.size}return e}),0)},this.beginTimerQuery=function(e,t){if(!this.profile.calcRenderTime)return;const n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(!n)return;let r;t?(r=e.createQuery(),e.beginQuery(n.TIME_ELAPSED_EXT,r)):(r=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,r)),this.profile.timerQueries.push(r)},this.endTimerQuery=function(e,t){if(!this.profile.calcRenderTime)return;const n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(!n)return;t?e.endQuery(n.TIME_ELAPSED_EXT):n.endQueryEXT(n.TIME_ELAPSED_EXT);const r=this.profile.timerQueries;for(let o=r.length-1;o>=0;o--){const i=r[o],a=t?e.getQueryParameter(i,34919):n.getQueryObjectEXT(i,n.QUERY_RESULT_AVAILABLE_EXT),s=e.getParameter(n.GPU_DISJOINT_EXT);if(a&&!s){const a=t?e.getQueryParameter(i,34918):n.getQueryObjectEXT(i,n.QUERY_RESULT_EXT);this.profile.renderTime+=a/1e6,r.splice(o,1)}}},this}let _id=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),o=this._getShaderStage(n),i=this._getShaderCacheForMaterial(e);return!1===i.has(r)&&(i.add(r),r.usedTimes++),!1===i.has(o)&&(i.add(o),o.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 WebGLShaderStage(e),t.set(e,n)),n}}class WebGLShaderStage{constructor(e){this.id=_id++,this.code=e,this.usedTimes=0}}function WebGLPrograms(e,t,n,r,o,i,a){const s=new Layers,l=new WebGLShaderCache,c=[],u=o.isWebGL2,d=o.logarithmicDepthBuffer,h=o.vertexTextures;let p=o.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",MeshMaskMaterial:"mask",MeshNodeMaterial:"node"};return this.programs=c,{getParameters:function(i,s,c,m,g,_){const v=m.fog,A=g.geometry,x=i.isMeshStandardMaterial||i.isMeshNodeMaterial?m.environment:null,y=(i.isMeshStandardMaterial||i.isMeshNodeMaterial?n:t).get(i.envMap||x),b=y&&y.mapping===CubeUVReflectionMapping?y.image.height:null,C=f[i.type];null!==i.precision&&(p=o.getMaxPrecision(i.precision),p!==i.precision&&console.warn("v3d.WebGLProgram.getParameters:",i.precision,"not supported, using",p,"instead."));const S=A.morphAttributes.position||A.morphAttributes.normal||A.morphAttributes.color,M=void 0!==S?S.length:0;let E,T,w,I,L=0;if(void 0!==A.morphAttributes.position&&(L=1),void 0!==A.morphAttributes.normal&&(L=2),void 0!==A.morphAttributes.color&&(L=3),C){const e=ShaderLib[C];E=e.vertexShader,T=e.fragmentShader}else E=i.vertexShader,T=i.fragmentShader,l.update(i),w=l.getVertexShaderID(i),I=l.getFragmentShaderID(i);const R=e.getRenderTarget(),B=i.alphaTest>0,P=i.clearcoat>0,D=i.iridescence>0;return{isWebGL2:u,shaderID:C,shaderName:i.type,vertexShader:E,fragmentShader:T,defines:i.defines,customVertexShaderID:w,customFragmentShaderID:I,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:p,instancing:!0===g.isInstancedMesh,instancingColor:!0===g.isInstancedMesh&&null!==g.instanceColor,supportsVertexTextures:h,outputEncoding:null===R?e.outputEncoding:!0===R.isXRRenderTarget?R.texture.encoding:LinearEncoding$1,map:!!i.map,matcap:!!i.matcap,envMap:!!y,envMapMode:y&&y.mapping,envMapCubeUVHeight:b,lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,objectSpaceNormalMap:i.normalMapType===ObjectSpaceNormalMap,tangentSpaceNormalMap:i.normalMapType===TangentSpaceNormalMap,decodeVideoTexture:!!i.map&&!0===i.map.isVideoTexture&&i.map.encoding===sRGBEncoding$1,clearcoat:P,clearcoatMap:P&&!!i.clearcoatMap,clearcoatRoughnessMap:P&&!!i.clearcoatRoughnessMap,clearcoatNormalMap:P&&!!i.clearcoatNormalMap,iridescence:D,iridescenceMap:D&&!!i.iridescenceMap,iridescenceThicknessMap:D&&!!i.iridescenceThicknessMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,specularIntensityMap:!!i.specularIntensityMap,specularColorMap:!!i.specularColorMap,opaque:!1===i.transparent&&i.blending===NormalBlending,alphaMap:!!i.alphaMap,alphaTest:B,gradientMap:!!i.gradientMap,sheen:i.sheen>0,sheenColorMap:!!i.sheenColorMap,sheenRoughnessMap:!!i.sheenRoughnessMap,transmission:i.transmission>0,transmissionMap:!!i.transmissionMap,thicknessMap:!!i.thicknessMap,combine:i.combine,vertexTangents:!!i.normalMap&&!!A.attributes.tangent,vertexColors:i.vertexColors,vertexAlphas:!0===i.vertexColors&&!!A.attributes.color&&4===A.attributes.color.itemSize,vertexUvs:!!(i.map||i.bumpMap||i.normalMap||i.specularMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.clearcoatMap||i.clearcoatRoughnessMap||i.clearcoatNormalMap||i.iridescenceMap||i.iridescenceThicknessMap||i.displacementMap||i.transmissionMap||i.thicknessMap||i.specularIntensityMap||i.specularColorMap||i.sheenColorMap||i.sheenRoughnessMap),uvsVertexOnly:!(i.map||i.bumpMap||i.normalMap||i.specularMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.clearcoatNormalMap||i.iridescenceMap||i.iridescenceThicknessMap||i.transmission>0||i.transmissionMap||i.thicknessMap||i.specularIntensityMap||i.specularColorMap||i.sheen>0||i.sheenColorMap||i.sheenRoughnessMap||!i.displacementMap),fog:!!v,useFog:!0===i.fog,fogExp2:v&&v.isFogExp2,flatShading:!!i.flatShading,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==A.morphAttributes.position,morphNormals:void 0!==A.morphAttributes.normal,morphColors:void 0!==A.morphAttributes.color,morphTargetsCount:M,morphTextureStride:L,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:i.toneMapped?e.toneMapping:NoToneMapping,toneMappingLook:i.toneMapped?e.toneMappingLook:ToneMappingLookNone,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===DoubleSide,flipSided:i.side===BackSide,useDepthPacking:!!i.depthPacking,depthPacking:i.depthPacking||0,envMapCubeUVTileSize:b&&void 0!==y.image?y.image.width/3:0,distancePacking:void 0!==i.distancePacking&&i.distancePacking,useSlopeScaledBias:void 0!==i.useSlopeScaledBias&&i.useSlopeScaledBias,esmDistanceScale:e.shadowMap.esmDistanceScale,numRectAreaLightShadows:s.rectAreaShadowMap.length,numDirLightShadowsCSM:s.directionalShadowCSM.length,numDirLightShadowCSMCascades:s.directionalShadowCSMCascade.length,numDirLightShadowsCSMWithFade:s.numDirectionalShadowsCSMWithFade,dirLightShadowsCSMLUT:s.directionalShadowCSMLUT,planeReflProbe:!!_,materialName:i.name,materialProfile:i.profile,unitsScaleFactor:e.unitsScaleFactor,alphaToCoverage:!!i.alphaToCoverage,customPrepTokens:i.customPrepTokens,definesFragOnly:i.definesFragOnly,isMeshNodeMaterial:i.isMeshNodeMaterial,nodeChunks:i.nodeChunks,nodeChunksHash:i.nodeChunksHash,useGTAO:i.isMeshNodeMaterial&&i.canUseGTAO()&&e.canUseGTAO(),index0AttributeName:i.index0AttributeName,extensionDerivatives:i.extensions&&i.extensions.derivatives,extensionFragDepth:i.extensions&&i.extensions.fragDepth,extensionDrawBuffers:i.extensions&&i.extensions.drawBuffers,extensionShaderTextureLOD:i.extensions&&i.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:i.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]);if(void 0!==t.customPrepTokens)for(const e in t.customPrepTokens)n.push(e),n.push(t.customPrepTokens[e]);return void 0!==t.definesFragOnly&&n.push(t.definesFragOnly.join()),!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),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.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.toneMappingLook),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking),e.push(t.unitsScaleFactor),e.push(t.esmDistanceScale),e.push(t.numRectAreaLightShadows),e.push(t.numDirLightShadowsCSM),e.push(t.numDirLightShadowCSMCascades),e.push(t.numDirLightShadowsCSMWithFade),e.push(t.dirLightShadowsCSMLUT)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.lightMap&&s.enable(7);t.aoMap&&s.enable(8);t.emissiveMap&&s.enable(9);t.bumpMap&&s.enable(10);t.normalMap&&s.enable(11);t.objectSpaceNormalMap&&s.enable(12);t.tangentSpaceNormalMap&&s.enable(13);t.clearcoat&&s.enable(14);t.clearcoatMap&&s.enable(15);t.clearcoatRoughnessMap&&s.enable(16);t.clearcoatNormalMap&&s.enable(17);t.iridescence&&s.enable(18);t.iridescenceMap&&s.enable(19);t.iridescenceThicknessMap&&s.enable(20);t.displacementMap&&s.enable(21);t.specularMap&&s.enable(22);t.roughnessMap&&s.enable(23);t.metalnessMap&&s.enable(24);t.gradientMap&&s.enable(25);t.alphaMap&&s.enable(26);t.alphaTest&&s.enable(27);t.vertexColors&&s.enable(28);t.vertexAlphas&&s.enable(29);t.vertexUvs&&s.enable(30);t.vertexTangents&&s.enable(31);t.uvsVertexOnly&&s.enable(32);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.physicallyCorrectLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.specularIntensityMap&&s.enable(15);t.specularColorMap&&s.enable(16);t.transmission&&s.enable(17);t.transmissionMap&&s.enable(18);t.thicknessMap&&s.enable(19);t.sheen&&s.enable(20);t.sheenColorMap&&s.enable(21);t.sheenRoughnessMap&&s.enable(22);t.decodeVideoTexture&&s.enable(23);t.opaque&&s.enable(24);e.push(s.mask),s.disableAll(),t.distancePacking&&s.enable(0);t.useSlopeScaledBias&&s.enable(1);t.useGTAO&&s.enable(2);t.planeReflProbe&&s.enable(3);t.alphaToCoverage&&s.enable(4);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),void 0!==t.nodeChunksHash&&n.push(t.nodeChunksHash),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=ShaderLib[t];n=UniformsUtils.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=c.length;e0?r.push(u):!0===a.transparent?o.push(u):n.push(u)},unshift:function(e,t,a,s,l,c){const u=i(e,t,a,s,l,c);a.transmission>0?r.unshift(u):!0===a.transparent?o.unshift(u):n.unshift(u)},finish:function(){for(let n=t,r=e.length;n1&&n.sort(e||painterSortStable),r.length>1&&r.sort(t||reversePainterSortStable),o.length>1&&o.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let o;return void 0===r?(o=new WebGLRenderList,e.set(t,[o])):n>=r.length?(o=new WebGLRenderList,r.push(o)):o=r[n],o},dispose:function(){e=new WeakMap}}}function UniformsCache(){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 Vector3,color:new Color};break;case"SpotLight":n={position:new Vector3,direction:new Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":n={color:new Color,position:new Vector3,halfWidth:new Vector3,halfHeight:new Vector3}}return e[t.id]=n,n}}}function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={cascadeIdxEnd:1,cameraNear:1,shadowFar:0,fade:.25};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadow:0,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"PointLight":case"RectAreaLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1}}return e[t.id]=n,n}}}let nextVersion=0;function sortOrderOfLights(e,t){const n=e.shadow,r=t.shadow;let o=0;return n&&n.isDirectionalLightShadowCSM&&r&&r.isDirectionalLightShadowCSM&&(o+=(0!=r.fade?1:0)-(0!=n.fade?1:0)),(t.castShadow?4:0)-(e.castShadow?4:0)+(t.map?2:0)-(e.map?2:0)+o}function WebGLLights(e,t){const n=new UniformsCache,r=ShadowUniformsCache(),o={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numRectAreaShadows:-1,numDirectionalShadowsCSM:-1,numDirectionalShadowsCSMCascade:-1,numDirectionalShadowsCSMWithFade:-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,rectAreaShadow:[],rectAreaShadowMap:[],rectAreaShadowMatrix:[],directionalShadowCSM:[],directionalShadowCSMMap:[],directionalShadowCSMMatrix:[],directionalShadowCSMCascade:[],directionalShadowCSMLUT:[],numDirectionalShadowsCSMWithFade:0};for(let e=0;e<9;e++)o.probe.push(new Vector3);const i=new Vector3,a=new Matrix4,s=new Matrix4;return{setup:function(i,a){let s=0,l=0,c=0;for(let e=0;e<9;e++)o.probe[e].set(0,0,0);let u=0,d=0,h=0,p=0,f=0,m=0,g=0,_=0,v=0,A=0,x=0,y=0,b=0;i.sort(sortOrderOfLights);const C=!0!==a?Math.PI:1;for(let e=0,t=i.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(o.rectAreaLTC1=UniformsLib.LTC_FLOAT_1,o.rectAreaLTC2=UniformsLib.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(o.rectAreaLTC1=UniformsLib.LTC_HALF_1,o.rectAreaLTC2=UniformsLib.LTC_HALF_2):console.error("v3d.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),o.ambient[0]=s,o.ambient[1]=l,o.ambient[2]=c;const S=o.hash;S.directionalLength===u&&S.pointLength===d&&S.spotLength===h&&S.rectAreaLength===p&&S.hemiLength===f&&S.numPointShadows===m&&S.numSpotShadows===g&&S.numSpotMaps===_&&S.numRectAreaShadows===A&&S.numDirectionalShadowsCSM===x&&S.numDirectionalShadowsCSMCascade===b&&S.numDirectionalShadowsCSMWithFade===y||(o.directional.length=u,o.spot.length=h,o.rectArea.length=p,o.point.length=d,o.hemi.length=f,o.pointShadow.length=m,o.pointShadowMap.length=m,o.spotShadow.length=g,o.spotShadowMap.length=g,o.pointShadowMatrix.length=m,o.spotLightMatrix.length=g+_-v,o.spotLightMap.length=_,o.numSpotLightShadowsWithMaps=v,S.directionalLength=u,S.pointLength=d,S.spotLength=h,S.rectAreaLength=p,S.hemiLength=f,S.numPointShadows=m,S.numSpotShadows=g,S.numSpotMaps=_,o.rectAreaShadow.length=A,o.rectAreaShadowMap.length=A,o.rectAreaShadowMatrix.length=A,o.directionalShadowCSM.length=x,o.directionalShadowCSMMap.length=b,o.directionalShadowCSMMatrix.length=b,o.directionalShadowCSMCascade.length=b,o.directionalShadowCSMLUT.length=b,o.numDirectionalShadowsCSMWithFade=y,S.numRectAreaShadows=A,S.numDirectionalShadowsCSM=x,S.numDirectionalShadowsCSMCascade=b,S.numDirectionalShadowsCSMWithFade=y,o.version=nextVersion++)},setupView:function(e,t){let n=0,l=0,c=0,u=0,d=0,h=0;const p=t.matrixWorldInverse;for(let f=0,m=e.length;fe.influenceDistance-t.influenceDistance))},pushPlaneReflProbe:function(e){a.push(e)}}}function WebGLRenderStates(e,t){let n=new WeakMap;return{get:function(r,o=0){const i=n.get(r);let a;return void 0===i?(a=new WebGLRenderState(e,t),n.set(r,[a])):o>=i.length?(a=new WebGLRenderState(e,t),i.push(a)):a=i[o],a},dispose:function(){n=new WeakMap}}}class MeshDepthMaterial extends Material{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,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.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,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 MeshDistanceMaterial extends Material{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new Vector3,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=RGBADistancePacking,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.distancePacking=e.distancePacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this}}const _projScreenMatrix$2=new Matrix4,_lightPositionWorld$2=new Vector3,_lookTarget$2=new Vector3;class LightShadow{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)],this.expBias=1,this.slopeScaledBias=0,this._additionalMap2D=null,this._additionalMapCube=null,this.isLightShadow=!0}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;_lightPositionWorld$2.setFromMatrixPosition(e.matrixWorld),t.position.copy(_lightPositionWorld$2),_lookTarget$2.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(_lookTarget$2),t.updateMatrixWorld(),_projScreenMatrix$2.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix$2),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(_projScreenMatrix$2)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose(),null!==this._additionalMap2D&&this._additionalMap2D.dispose(),null!==this._additionalMapCube&&this._additionalMapCube.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this.expBias=e.expBias,this.slopeScaledBias=e.slopeScaledBias,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}}const OMNI_MAP_ANGLE=Math.PI/4,_projScreenMatrix$1=new Matrix4,_lightPositionWorld$1=new Vector3,_lookTarget$1=new Vector3;class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.useOmniMaps=!1,this.useMinFov90=!1,this._frameExtentsOmni=new Vector2(4,2),this._viewportCountOmni=6,this._viewportsOmni=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,-1,0)],this._cubeUps=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)]}updateMatrices(e,t=0){if(this.useOmniMaps){const n=this.camera,r=this.matrix;_lightPositionWorld$1.setFromMatrixPosition(e.matrixWorld),n.position.copy(_lightPositionWorld$1),_lookTarget$1.copy(n.position),_lookTarget$1.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(_lookTarget$1),n.updateMatrixWorld(),r.makeTranslation(-_lightPositionWorld$1.x,-_lightPositionWorld$1.y,-_lightPositionWorld$1.z),_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix$1)}else{const t=this.camera,n=2*RAD2DEG*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;n===t.fov&&r===t.aspect&&o===t.far||(t.fov=n,t.aspect=r,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}}getViewportCount(){return this.useOmniMaps?this._viewportCountOmni:super.getViewportCount()}getViewport(e){return this.useOmniMaps?this._viewportsOmni[e]:super.getViewport(e)}getFrameExtents(){return this.useOmniMaps?this._frameExtentsOmni:super.getFrameExtents()}calcUseOmniMaps(e){return this.useOmniMaps=e>OMNI_MAP_ANGLE,this.useOmniMaps}copy(e){return super.copy(e),this.focus=e.focus,this.useOmniMaps=e.useOmniMaps,this.useMinFov90=e.useMinFov90,this}}const ESM_BLUR_TO_SAMPLES_COEFF=.8,ESM_OCT_BLUR_TO_SAMPLES_COEFF=.2,SPOT_WIDE_TO_NARROW_COEFF=.8,DIR_ESM_BLUR_COEFF=50;function WebGLShadowMap(e,t,n){let r=new Frustum;const o=new Vector2,i=new Vector2,a=new Vector4,s=new MeshDepthMaterial({depthPacking:RGBADepthPacking}),l=new MeshDistanceMaterial,c={},u=n.maxTextureSize,d=n.isWebGL2,h={0:BackSide,1:FrontSide,2:DoubleSide},p=new Matrix4;new Matrix4;const f=new Vector2(u,u),m=new Vector3,g=new Vector3;new Vector3;const _=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,1,0),new Vector3(0,-1,0),new Vector3(0,0,1),new Vector3(0,0,-1)],v=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,1,0)];new Vector4,new Vector4,new Vector4,new Vector4,new Vector4,new Vector4,new Sphere,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3;const A=new Mesh(new PlaneGeometry(1,1,1,1));A.name="esmFarPlane",A.castShadow=!0,A.material.shadowSide=FrontSide;const x=0,y=1,b=0,C=new OrthographicCamera(-1,1,1,-1,0,10),S=new Mesh(new PlaneGeometry(2,2)),M=new ShaderMaterial({type:"ShadowCubeOctahedral",defines:Object.assign({},ShaderLib.cubeOctahedral.defines),uniforms:UniformsUtils.clone(ShaderLib.cubeOctahedral.uniforms),vertexShader:ShaderLib.cubeOctahedral.vertexShader,fragmentShader:ShaderLib.cubeOctahedral.fragmentShader}),E={},T={},w=this;function I(t,n,r,o,i,a,u,d,p){let f=null;const m=d||u===ESMShadowMap?t.customDistanceMaterial:t.customDepthMaterial;if(f=void 0!==m?m:d||u===ESMShadowMap?l:s,e.localClippingEnabled&&!0===r.clipShadows&&Array.isArray(r.clippingPlanes)&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0||r.map&&r.alphaTest>0){const e=f.uuid,t=r.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let o=n[t];void 0===o&&(o=f.clone(),n[t]=o),f=o}switch(f.visible=r.visible,f.wireframe=r.wireframe,f.side=null!==r.shadowSide?r.shadowSide:h[r.side],f.alphaMap=r.alphaMap,f.alphaTest=r.alphaTest,f.map=r.map,f.clipShadows=r.clipShadows,f.clippingPlanes=r.clippingPlanes,f.clipIntersection=r.clipIntersection,f.displacementMap=r.displacementMap,f.displacementScale=r.displacementScale,f.displacementBias=r.displacementBias,f.wireframeLinewidth=r.wireframeLinewidth,f.linewidth=r.linewidth,!d&&u!==ESMShadowMap||!0!==f.isMeshDistanceMaterial||(f.referencePosition.copy(p),f.nearDistance=i,f.farDistance=a,f.distancePacking=u===ESMShadowMap?ESMDistancePacking:RGBADistancePacking),u===ESMShadowMap&&(f.defines.DISTANCE_SCALE=shaderFloatStr(w.esmDistanceScale)),o.shadow.isDirectionalLightShadowCascade&&o.shadow.pancakeDepth&&(f.defines.PANCAKE_DEPTH="",f.defines.CAM_WIDTH=shaderFloatStr(o.shadow.camera.right),f.defines.CAM_HEIGHT=shaderFloatStr(o.shadow.camera.top)),u){case BasicShadowMap:case BilinearShadowMap:case PCFShadowMap:case PCFSoftShadowMap:case PCFShadowMapPoissonDisk:f.useSlopeScaledBias=!0,f.slopeScaledBias=o.shadow.slopeScaledBias;break;case ESMShadowMap:f.useSlopeScaledBias=!0,f.slopeScaledBias=.5}return f}function L(n,o,i,a,s,l){if(!1===n.visible)return;if((o.ignoreShadowLayers||n.layers.test(o.layers))&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,n.matrixWorld);const r=t.update(n),o=n.material;if(Array.isArray(o)){const t=r.groups;for(let c=0,u=t.length;cu||o.y>u)&&(o.x>u&&(i.x=Math.floor(u/h.x),o.x=i.x*h.x,c.mapSize.x=i.x),o.y>u&&(i.y=Math.floor(u/h.y),o.y=i.y*h.y,c.mapSize.y=i.y)),s.isSpotLight&&c.map&&c.map.width/c.map.height!=2){const e=c.map;c.map=c._additionalMap2D,c._additionalMap2D=e}const p=s.isPointLight||s.isRectAreaLight||s.isSpotLight&&c.useOmniMaps;if(p?s.isSpotLight&&(d.fov=90,d.updateProjectionMatrix()):s.isSpotLight&&c.useMinFov90&&(d.fov=90,d.updateProjectionMatrix()),null===c.map){const e={minFilter:NearestFilter,magFilter:NearestFilter,format:RGBAFormat};c.map=new WebGLRenderTarget(o.x,o.y,e),c.map.texture.name=s.name+".shadowMap",d.updateProjectionMatrix()}e.state.buffers.color.setClear(1,1,1,1),e.setRenderTarget(c.map),e.clear();const f=c.getViewportCount();for(let o=0;o=1):-1!==R.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(R)[1]),I=L>=2);let B=null,P={};const D=e.getParameter(3088),N=e.getParameter(2978),F=(new Vector4).fromArray(D),O=(new Vector4).fromArray(N);function V(t,n,r){const o=new Uint8Array(4),i=e.createTexture();e.bindTexture(t,i),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;tr||e.height>r)&&(o=r/Math.max(e.width,e.height)),o<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?floorPowerOfTwo:Math.floor,i=r(o*e.width),a=r(o*e.height);void 0===m&&(m=v(i,a));const s=n?v(i,a):m;s.width=i,s.height=a;return s.getContext("2d").drawImage(e,0,0,i,a),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+i+"x"+a+")."),s}return"data"in e&&console.warn("v3d.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function x(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter}function b(t){e.generateMipmap(t)}function C(n,r,o,i,a=!1){if(!1===s)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=r;return 6403===r&&(5126===o&&(l=33326),5131===o&&(l=33325),5121===o&&(l=33321)),33319===r&&(5126===o&&(l=33328),5131===o&&(l=33327),5121===o&&(l=33323)),6408===r&&(5126===o&&(l=34836),5131===o&&(l=34842),5121===o&&(l=i===sRGBEncoding$1&&!1===a?35907:32856),32819===o&&(l=32854),32820===o&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function S(e,t,n){return!0===y(e,n)||e.isFramebufferTexture&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter?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 M(e){return e===NearestFilter||e===NearestMipmapNearestFilter||e===NearestMipmapLinearFilter?9728:9729}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,o=g.get(n);if(o){const r=o[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&w(e),0===Object.keys(o).length&&g.delete(n)}r.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=t.texture,o=r.get(t),i=r.get(n);void 0!==i.__webglTexture&&(e.deleteTexture(i.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(o.__webglFramebuffer[t]),o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(o.__webglFramebuffer),o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&e.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer)for(let t=0;t0&&o.__version!==e.version){const n=e.image;if(null===n)console.warn("v3d.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void N(o,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(3553,o.__webglTexture,33984+t)}const R={[RepeatWrapping]:10497,[ClampToEdgeWrapping]:33071,[MirroredRepeatWrapping]:33648},B={[NearestFilter]:9728,[NearestMipmapNearestFilter]:9984,[NearestMipmapLinearFilter]:9986,[LinearFilter]:9729,[LinearMipmapNearestFilter]:9985,[LinearMipmapLinearFilter]:9987};function P(n,i,a){if(a?(e.texParameteri(n,10242,R[i.wrapS]),e.texParameteri(n,10243,R[i.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,R[i.wrapR]),e.texParameteri(n,10240,B[i.magFilter]),e.texParameteri(n,10241,B[i.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),i.wrapS===ClampToEdgeWrapping&&i.wrapT===ClampToEdgeWrapping||console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to v3d.ClampToEdgeWrapping."),e.texParameteri(n,10240,M(i.magFilter)),e.texParameteri(n,10241,M(i.minFilter)),i.minFilter!==NearestFilter&&i.minFilter!==LinearFilter&&console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to v3d.NearestFilter or v3d.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(i.magFilter===NearestFilter)return;if(i.minFilter!==NearestMipmapLinearFilter&&i.minFilter!==LinearMipmapLinearFilter)return;if(i.type===FloatType&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&i.type===HalfFloatType&&!1===t.has("OES_texture_half_float_linear"))return;(i.anisotropy>1||r.get(i).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,o.getMaxAnisotropy())),r.get(i).__currentAnisotropy=i.anisotropy)}}function D(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const o=n.source;let i=g.get(o);void 0===i&&(i={},g.set(o,i));const s=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.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===i[s]&&(i[s]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,a.addTextureSpec(n),r=!0),i[s].usedTimes++;const o=i[t.__cacheKey];void 0!==o&&(i[t.__cacheKey].usedTimes--,0===o.usedTimes&&w(n)),t.__cacheKey=s,t.__webglTexture=i[s].texture}return r}function N(t,o,a){let l=3553;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=35866),o.isData3DTexture&&(l=32879);const c=D(t,o),d=o.source;n.bindTexture(l,t.__webglTexture,33984+a);const h=r.get(d);if(d.version!==h.__version||!0===c){n.activeTexture(33984+a),e.pixelStorei(37440,o.flipY),e.pixelStorei(37441,o.premultiplyAlpha),e.pixelStorei(3317,o.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==ClampToEdgeWrapping||e.wrapT!==ClampToEdgeWrapping||e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter)}(o)&&!1===x(o.image);let r=A(o.image,t,!1,u);r=k(o,r);const p=x(r)||s,f=i.convert(o.format,o.encoding);let m,g=i.convert(o.type),_=C(o.internalFormat,f,g,o.encoding,o.isVideoTexture);P(l,o,p);const v=o.mipmaps,M=s&&!0!==o.isVideoTexture,E=void 0===h.__version||!0===c,T=S(o,r,p);if(o.isDepthTexture)_=6402,s?_=o.type===FloatType?36012:o.type===UnsignedIntType?33190:o.type===UnsignedInt248Type?35056:33189:o.type===FloatType&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),o.format===DepthFormat&&6402===_&&o.type!==UnsignedShortType&&o.type!==UnsignedIntType&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),o.type=UnsignedIntType,g=i.convert(o.type)),o.format===DepthStencilFormat&&6402===_&&(_=34041,o.type!==UnsignedInt248Type&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),o.type=UnsignedInt248Type,g=i.convert(o.type))),E&&(M?n.texStorage2D(3553,1,_,r.width,r.height):n.texImage2D(3553,0,_,r.width,r.height,0,f,g,null));else if(o.isDataTexture)if(v.length>0&&p){M&&E&&n.texStorage2D(3553,T,_,v[0].width,v[0].height);for(let e=0,t=v.length;e>=1,t>>=1}}else if(v.length>0&&p){M&&E&&n.texStorage2D(3553,T,_,v[0].width,v[0].height);for(let e=0,t=v.length;e=34069&&l<=34074)&&e.framebufferTexture2D(36160,s,l,r.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function O(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let o=33189;if(s&&(o=33190),r||G(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===FloatType?o=36012:t.type===UnsignedIntType&&(o=33190));const r=U(n);G(n)?h.renderbufferStorageMultisampleEXT(36161,r,o,n.width,n.height):e.renderbufferStorageMultisample(36161,r,o,n.width,n.height)}else e.renderbufferStorage(36161,o,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const o=U(n);r&&!1===G(n)?e.renderbufferStorageMultisample(36161,o,35056,n.width,n.height):G(n)?h.renderbufferStorageMultisampleEXT(36161,o,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let o=0;o0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function k(e,n){const r=e.encoding,o=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===_SRGBAFormat||r!==LinearEncoding$1&&(r===sRGBEncoding$1?!1===s?!0===t.has("EXT_sRGB")&&o===RGBAFormat?(e.format=_SRGBAFormat,e.minFilter=LinearFilter,e.generateMipmaps=!1):n=ImageUtils.sRGBToLinear(n):o===RGBAFormat&&i===UnsignedByteType||console.warn("v3d.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("v3d.WebGLTextures: Unsupported texture encoding:",r)),n}this.allocateTextureUnit=function(){const e=I;return e>=l&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),I+=1,e},this.resetTextureUnits=function(){I=0},this.setTexture2D=L,this.setTexture2DArray=function(e,t){const o=r.get(e);e.version>0&&o.__version!==e.version?N(o,e,t):n.bindTexture(35866,o.__webglTexture,33984+t)},this.setTexture3D=function(e,t){const o=r.get(e);e.version>0&&o.__version!==e.version?N(o,e,t):n.bindTexture(32879,o.__webglTexture,33984+t)},this.setTextureCube=function(t,o){const a=r.get(t);t.version>0&&a.__version!==t.version?function(t,o,a){if(6!==o.image.length)return;const l=D(t,o),u=o.source;n.bindTexture(34067,t.__webglTexture,33984+a);const d=r.get(u);if(u.version!==d.__version||!0===l){n.activeTexture(33984+a),e.pixelStorei(37440,o.flipY),e.pixelStorei(37441,o.premultiplyAlpha),e.pixelStorei(3317,o.unpackAlignment),e.pixelStorei(37443,0);const t=o.isCompressedTexture||o.image[0].isCompressedTexture,r=o.image[0]&&o.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=t||r?r?o.image[e].image:o.image[e]:A(o.image[e],!1,!0,c),h[e]=k(o,h[e]);const p=h[0],f=x(p)||s,m=i.convert(o.format,o.encoding),g=i.convert(o.type),_=C(o.internalFormat,m,g,o.encoding),v=s&&!0!==o.isVideoTexture,M=void 0===d.__version||!0===l;let E,T=S(o,p,f);if(P(34067,o,f),t){v&&M&&n.texStorage2D(34067,T,_,p.width,p.height);for(let e=0;e<6;e++){E=h[e].mipmaps;for(let t=0;t0&&T++,n.texStorage2D(34067,T,_,h[0].width,h[0].height));for(let e=0;e<6;e++)if(r){v?n.texSubImage2D(34069+e,0,0,0,h[e].width,h[e].height,m,g,h[e].data):n.texImage2D(34069+e,0,_,h[e].width,h[e].height,0,m,g,h[e].data);for(let t=0;t0&&!1===G(t)){const r=h?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n0&&!1===G(t)){const o=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],i=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=r.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;ts+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),null!==o&&(s.matrix.fromArray(o.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),o.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(o.linearVelocity)):s.hasLinearVelocity=!1,o.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(o.angularVelocity)):s.hasAngularVelocity=!1));null!==a&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==o&&(r=o),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent)))}return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==o),null!==l&&(l.visible=null!==i),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Group;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class DepthTexture extends Texture{constructor(e,t,n,r,o,i,a,s,l,c){if((c=void 0!==c?c:DepthFormat)!==DepthFormat&&c!==DepthStencilFormat)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===DepthFormat&&(n=UnsignedIntType),void 0===n&&c===DepthStencilFormat&&(n=UnsignedInt248Type),super(null,r,o,i,a,s,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:NearestFilter,this.minFilter=void 0!==s?s:NearestFilter,this.flipY=!1,this.generateMipmaps=!1}}class Raycaster{constructor(e,t,n=0,r=1/0){this.ray=new Ray(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Layers,this.params={Mesh:{omitGeometry:!1},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{},checkVisibility:!0},this.layers.enable(3),this.layers.enable(4),this.layers.enable(5),this.layers.enable(6),this.layers.enable(7)}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("v3d.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return intersectObject(e,this,n,t,this.params.checkVisibility),n.sort(ascSort),n}intersectObjects(e,t=!0,n=[]){for(let r=0,o=e.length;r=0&&(_[r]=null,g[r].disconnect(n))}for(let t=0;t=_.length){_.push(n),r=e;break}if(null===_[e]){_[e]=n,r=e;break}}if(-1===r)break}const o=g[r];o&&o.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=g[e];return void 0===t&&(t=new WebXRController,g[e]=t),t.getTargetRaySpace(e)},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new WebXRController,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new WebXRController,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===n.isPresenting&&console.warn("v3d.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("v3d.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||i},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(f=e.getRenderTarget(),r.addEventListener("select",P),r.addEventListener("selectstart",P),r.addEventListener("selectend",P),r.addEventListener("squeeze",P),r.addEventListener("squeezestart",P),r.addEventListener("squeezeend",P),r.addEventListener("end",D),r.addEventListener("inputsourceschange",N),!0!==p.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:o};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),m=new WebGLRenderTarget(d.framebufferWidth,d.framebufferHeight,{format:RGBAFormat,type:UnsignedByteType,encoding:e.outputEncoding,stencilBuffer:p.stencil})}else{let n=null,i=null,a=null;p.depth&&(a=p.stencil?35056:33190,n=p.stencil?DepthStencilFormat:DepthFormat,i=p.stencil?UnsignedInt248Type:UnsignedIntType);const s={colorFormat:32856,depthFormat:a,scaleFactor:o};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(s),r.updateRenderState({layers:[u]}),m=new WebGLRenderTarget(u.textureWidth,u.textureHeight,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(u.textureWidth,u.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:p.stencil,encoding:e.outputEncoding,samples:p.antialias?4:0});e.properties.get(m).__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(1),s=null,i=await r.requestReferenceSpace(a),G.setContext(r),G.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const F=new Vector3,O=new Vector3;function V(e,t){if(null===t)e.matrixWorld.copy(e.matrix),I.identity(),s=null;else{e.matrixWorld.copy(e.matrix),I.copy(t.matrixWorld).invert().decompose(L,B,R);var n=new XRRigidTransform({x:L.x,y:L.y,z:L.z},{x:B.x,y:B.y,z:B.z,w:B.w});s=i.getOffsetReferenceSpace(n)}e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;C.near=y.near=x.near=e.near,C.far=y.far=x.far=e.far,S===C.near&&M===C.far||(r.updateRenderState({depthNear:C.near,depthFar:C.far}),S=C.near,M=C.far);const t=e.parent,n=C.cameras;V(C,t);for(let e=0;et&&(A.set(e,e.lastChangedTime),n.dispatchEvent({type:"planechanged",data:e}))}else v.add(e),A.set(e,r.lastChangedTime),n.dispatchEvent({type:"planeadded",data:e})}h=null})),this.setAnimationLoop=function(e){U=e},this.dispose=function(){},this.arHitTest=function(e,t,n,o){if(!r||!XRSession.prototype.requestHitTestSource)return;T=n||function(){},w=o||function(){},this.raycaster=this.raycaster||new Raycaster,this.raycaster.setFromCamera({x:e,y:t},b[0]);const i=this.raycaster.ray;new XRRay(i.origin,i.direction),r.requestReferenceSpace("viewer").then((function(e){const t={space:e};r.requestHitTestSource(t).then((function(e){E=e}))}))}}}function WebGLMaterials(e,t){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),r.alphaMap&&(n.alphaMap.value=r.alphaMap),r.bumpMap&&(n.bumpMap.value=r.bumpMap,n.bumpScale.value=r.bumpScale,r.side===BackSide&&(n.bumpScale.value*=-1)),r.displacementMap&&(n.displacementMap.value=r.displacementMap,n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap),r.normalMap&&(n.normalMap.value=r.normalMap,n.normalScale.value.copy(r.normalScale),r.side===BackSide&&n.normalScale.value.negate()),r.specularMap&&(n.specularMap.value=r.specularMap),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const o=t.get(r).envMap;if(o&&(n.envMap.value=o,n.flipEnvMap.value=o.isCubeTexture&&!1===o.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 t=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*t}let i,a;r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity),r.map?i=r.map:r.specularMap?i=r.specularMap:r.displacementMap?i=r.displacementMap:r.normalMap?i=r.normalMap:r.bumpMap?i=r.bumpMap:r.roughnessMap?i=r.roughnessMap:r.metalnessMap?i=r.metalnessMap:r.alphaMap?i=r.alphaMap:r.emissiveMap?i=r.emissiveMap:r.clearcoatMap?i=r.clearcoatMap:r.clearcoatNormalMap?i=r.clearcoatNormalMap:r.clearcoatRoughnessMap?i=r.clearcoatRoughnessMap:r.iridescenceMap?i=r.iridescenceMap:r.iridescenceThicknessMap?i=r.iridescenceThicknessMap:r.specularIntensityMap?i=r.specularIntensityMap:r.specularColorMap?i=r.specularColorMap:r.transmissionMap?i=r.transmissionMap:r.thicknessMap?i=r.thicknessMap:r.sheenColorMap?i=r.sheenColorMap:r.sheenRoughnessMap&&(i=r.sheenRoughnessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),n.uvTransform.value.copy(i.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,getUnlitUniformColorSpace(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,o,i,a){r.ssrParams&&function(e,t){e.invProjectionMatrix.value=t.ssrParams.invProjectionMatrix,e.ssrSourceBuffer.value=t.ssrParams.sourceBuffer.texture,e.ssrDepthBuffer.value=t.ssrParams.depthBuffer.texture,e.ssrBackfaceDepthBuffer.value=t.ssrParams.backfaceDepthBuffer.texture,e.ssrResolution.value.set(t.ssrParams.sourceBuffer.width,t.ssrParams.sourceBuffer.height),e.ssrStride.value=t.ssrParams.stride,e.ssrThickness.value=t.ssrParams.thickness,e.ssrMaxDistance.value=t.ssrParams.maxDistance,e.ssrJitter.value=t.ssrParams.jitter}(e,r),r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(e,r):r.isMeshToonMaterial?(n(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(n(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(n(e,r),function(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap);n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap);const r=t.get(n).envMap;r&&(e.envMapIntensity.value=n.envMapIntensity,e.envMapParallaxType.value=n.envMapParallaxType,e.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv))}(e,r),r.isMeshPhysicalMaterial&&function(e,t,n){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),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===BackSide&&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),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,r,a)):r.isMeshMatcapMaterial?(n(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?(n(e,r),function(e,t){e.slopeScaledBias.value=t.slopeScaledBias}(e,r)):r.isMeshDistanceMaterial?(n(e,r),function(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance,e.slopeScaledBias.value=t.slopeScaledBias}(e,r)):r.isMeshNormalMaterial?n(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(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,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let o;t.map?o=t.map:t.alphaMap&&(o=t.alphaMap);void 0!==o&&(!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uvTransform.value.copy(o.matrix))}(e,r,o,i):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);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isMeshMaskMaterial?(n(e,r),function(e,t){t.cameraNearFar&&(e.cameraNearFar.value=t.cameraNearFar);e.depthTexture.value=t.depthTexture,t.textureMatrix&&(e.textureMatrix.value=t.textureMatrix)}(e,r)):r.isMeshNodeMaterial?function(e,n){n.alphaTest>0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;r&&(e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&r.isRenderTargetTexture?-1:1,e.envMapIntensity.value=n.envMapIntensity,e.envMapParallaxType.value=n.envMapParallaxType,e.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv));n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias);e.materialIndex.value=n.materialIndex}(e,r):r.isMeshLineMaterial?function(e,t){e.lineWidth.value=t.lineWidth,e.sizeAttenuation.value=t.sizeAttenuation,e.color.value=t.color,e.opacity.value=t.opacity,e.useMap.value=t.useMap,t.map&&(e.map.value=t.map);e.useAlphaMap.value=t.useAlphaMap,t.alphaMap&&(e.alphaMap.value=t.alphaMap);e.visibility.value=t.visibility,e.alphaTest.value=t.alphaTest,e.repeat.value=t.repeat}(e,r):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)},refreshGTAOUniforms:function(e,t){e.gtaoMap.value=t},refreshPlaneReflProbeUniforms:function(e,t){e.planeReflTexture.value=t.renderTarget.texture,e.planeReflTextureMatrix.value.copy(t.textureMatrix),e.planeReflDir.value.copy(t.normal),e.planeReflBoundingBoxMin.value.copy(t.boundingBox.min),e.planeReflBoundingBoxMax.value.copy(t.boundingBox.max),e.planeReflInvModelMatrix.value.copy(t.matrixWorldInverse),e.planeReflFalloff.value=t.falloff}}}function WebGLUniformsGroups(e,t,n,r){let o={},i={},a=[];const s=n.isWebGL2?e.getParameter(35375):0;function l(e,t,n){const r=e.value;if(void 0===n[t]){if("number"==typeof r)n[t]=r;else{const e=Array.isArray(r)?r:[r],o=[];for(let t=0;t0){o=n%r;0!==o&&r-o-a.boundary<0&&(n+=r-o,i.__offset=n)}n+=a.storage}o=n%r,o>0&&(n+=r-o);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e1)&&!window.MSStream},checkAndroid:function(){return!!navigator.userAgent.match(/Android/i)},checkSafari:function(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)},checkFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_float")||t&&!n.getExtension("OES_texture_float_linear"))},checkHalfFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_half_float")||t&&!n.getExtension("OES_texture_half_float_linear"))},checkHalfFloatReadPixels:function(e){const t=e.getContext(),n=e.capabilities;return!/Firefox/.test(navigator.userAgent)&&!!(t.getExtension("EXT_color_buffer_half_float")||n.isWebGL2&&t.getExtension("EXT_color_buffer_float"))},checkFloatReadPixels:function(e){const t=e.getContext();return!!(e.capabilities.isWebGL2||t.getExtension("OES_texture_float")||t.getExtension("WEBGL_color_buffer_float"))},checkDepthTex:function(e){const t=e.getContext();return!(!e.capabilities.isWebGL2&&!t.getExtension("WEBGL_depth_texture"))},getGPUVendor:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");if(/Firefox/.test(navigator.userAgent))return t.getParameter(7936);{const e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_VENDOR_WEBGL):""}},getGPUModel:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");if(/Firefox/.test(navigator.userAgent))return t.getParameter(7937);{const e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_RENDERER_WEBGL):""}},checkWebXR:function(e,t,n){"xr"in navigator&&navigator.xr.isSessionSupported?navigator.xr.isSessionSupported(e).then((function(e){e?t():n()})).catch(n):n()},checkNativeWebXR:function(){return!1},checkCardboard:function(){return!1},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)},checkWebAudio:function(){return void 0!==(window.AudioContext||window.webkitAudioContext)},isSafariWithMultisamplingBug:function(){const e=navigator.userAgent;return!(!this.checkSafari()&&!e.match("MicroMessenger"))&&(e.match("Version/15.4")||e.match(/CPU (OS|iPhone OS) (15_4|15_4_1|15_4_2|15_4_3) like Mac OS X/))},isSafariWithUint16Bug:function(){const e=navigator.userAgent;return!(!this.checkSafari()&&!e.match("MicroMessenger"))&&e.match(/CPU (OS|iPhone OS) (11_[0-9][0-9_]*|12_[0-9][0-9_]*) like Mac OS X/)},isTouchDevice:function(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}};class Pass extends EventDispatcher{constructor(){super(),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("v3d.Pass: .render() must be implemented in derived pass.")}setCamera(e){}dispose(){}}const _camera$1=new OrthographicCamera(-1,1,1,-1,0,1),_geometry$1=new BufferGeometry;_geometry$1.setAttribute("position",new Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),_geometry$1.setAttribute("uv",new Float32BufferAttribute([0,2,0,0,2,0],2));class FullScreenQuad{constructor(e){this._mesh=new Mesh(_geometry$1,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,_camera$1)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}static dispose(){_geometry$1.dispose()}}const LAYER_TRANSPARENT=1,LAYER_TRANSPARENT_NOT_SUPPORTED=2,_clearColor$1=new Color,_tmpLayers=new Layers;class WebGLOITMethod{constructor(e,t){this.resolution=e,this.textureType=t,this.type="WebGLOITMethod",this.mute=!1}render(){this.mute}dispose(){}setSize(e,t){this.resolution.set(e,t)}_ensureProperBuffersClearing(e){e.state.buffers.depth.setTest(!0),e.state.buffers.depth.setMask(!0),e.state.buffers.color.setMask(!0)}}WebGLOITMethod.prototype.isWebGLOITMethod=!0;class WebGLOITWeighted extends WebGLOITMethod{constructor(e,t,n){super(e,t),this.type="WebGLOITWeighted",this.shader=ShaderLib.oitWeighted,this.uniforms=UniformsUtils.clone(this.shader.uniforms),this.scene=null,this.camera=null,this.aaSamples=n||0,this.renderTargetMRT=new WebGLMultipleRenderTargets(this.resolution.x,this.resolution.y,2),this.renderTargetMRT.texture[0].name="wboit_rgba",this.renderTargetMRT.texture[0].format=RGBAFormat,this.renderTargetMRT.texture[0].type=t,this.renderTargetMRT.texture[1].name="wboit_r",this.renderTargetMRT.texture[1].format=RedFormat,this.renderTargetMRT.texture[1].type=t,this.aaSamples>0&&(this.renderTargetMRTMSAA=new WebGLMultipleRenderTargets(this.resolution.x,this.resolution.y,2,{samples:n}),this.renderTargetMRTMSAA.texture[0].name="wboit_rgba",this.renderTargetMRTMSAA.texture[0].format=RGBAFormat,this.renderTargetMRTMSAA.texture[0].type=t,this.renderTargetMRTMSAA.texture[1].name="wboit_r",this.renderTargetMRTMSAA.texture[1].format=RedFormat,this.renderTargetMRTMSAA.texture[1].type=t),this.fsQuadSolver=new FullScreenQuad(new ShaderMaterial({defines:Object.assign({},this.shader.defines),uniforms:UniformsUtils.clone(this.shader.uniforms),vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader,depthTest:!1,depthWrite:!1,blending:CustomBlending,blendEquation:AddEquation,blendSrc:SrcAlphaFactor,blendDst:OneMinusSrcAlphaFactor,blendEquationAlpha:AddEquation,blendSrcAlpha:OneFactor,blendDstAlpha:OneMinusSrcAlphaFactor})),this._layerMasks={},this._matSettings={},this._savedCameraLayers=new Layers}dispose(){super.dispose(),this.renderTargetMRT.dispose(),this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.dispose()}setSize(e,t){super.setSize(e,t),this.renderTargetMRT.setSize(e,t),this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.setSize(e,t)}render(e,t,n,r,o){if(this.mute)return;this._ensureProperBuffersClearing(e);const i=e.getRenderTarget();if(i.isWebGLCubeRenderTarget)return void t(n,r,o);const a=r.overrideMaterial;if(a&&!this.isSupportedMaterial(a))return void t(n,r,o);if(this.resolution.x!==i.width&&this.resolution.y!==i.height)return console.warn("v3d.WebGLOITRenderer: render target size mismatch in v3d.WebGLOITWeighted."),void t(n,r,o);this.scene=r,this.camera=o,this._savedCameraLayers.mask=this.camera.layers.mask;const s=e.getClearColor(_clearColor$1),l=e.getClearAlpha(),c=e.autoClear,u=e.useOIT,d=e.sortObjects;e.setClearColor(0),e.setClearAlpha(0),e.autoClear=!1,e.sortObjects=!1,e.useOIT=!1;const h=this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.samples==i.samples;if(a){const s=[{object:r,material:a}];this._accumulationPass(e,t,h,n,s);const l=a.colorWrite;a.colorWrite=!1,a.needsUpdate=!0,e.setRenderTarget(i),t(n,r,o),a.colorWrite=l,a.needsUpdate=!0}else this._saveLayers(n),this._setupLayers(n),o.layers.disableAll(),o.layers.enable(2),t(n,r,o),o.layers.disableAll(),o.layers.enable(1),this._accumulationPass(e,t,h,n),e.setRenderTarget(i),this._renderOnlyDepth(e,t,n,r,o),this._restoreLayers(n);e.setRenderTarget(i),this._solverPass(e,h),e.setClearColor(s),e.setClearAlpha(l),e.sortObjects=d,e.autoClear=c,e.useOIT=u}isSupportedMaterial(e){return!(!e||!e.isMeshStandardMaterial&&!e.isMeshNodeMaterial)}_accumulationPass(e,t,n,r,o){o||(o=r);const i=e.getContext(),a=e.getRenderTarget(),s=e.getClearAlpha();if(this._saveMatSettings(o),this._setupMatSettings(o),e.setClearAlpha(1),a)if(n){e.setRenderTarget(this.renderTargetMRTMSAA),e.clear();const n=e.properties.get(this.renderTargetMRTMSAA).__webglDepthRenderbuffer,o=e.properties.get(a).__webglDepthRenderbuffer;if(o&&(i.framebufferRenderbuffer(36160,36096,36161,o),36053!==i.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.");t(r,this.scene,this.camera);if(e.getTextureUtils().updateMultisampleRenderTarget(this.renderTargetMRTMSAA),o&&(i.framebufferRenderbuffer(36160,36096,36161,n||null),36053!==i.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.samples>0){e.setRenderTarget(this.renderTargetMRT),e.clear();const n=e.properties.get(this.renderTargetMRT).__webglFramebuffer,o=e.properties.get(a).__webglMultisampledFramebuffer;if(o&&(i.bindFramebuffer(36008,o),i.bindFramebuffer(36009,n),i.blitFramebuffer(0,0,this.resolution.x,this.resolution.y,0,0,this.resolution.x,this.resolution.y,256,9728),i.bindFramebuffer(36160,n),36053!==i.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted. Can not blit depth buffer from v3d.WebGLMultisampleRenderTarget.");t(r,this.scene,this.camera)}else{e.setRenderTarget(this.renderTargetMRT),e.clear();const n=e.properties.get(this.renderTargetMRT),o=n.__webglDepthRenderbuffer||n.__webglDepthbuffer,s=e.properties.get(a),l=s.__webglDepthRenderbuffer||s.__webglDepthbuffer;if(l){if(i.framebufferRenderbuffer(36160,36096,36161,l),36053!==i.checkFramebufferStatus(36160))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.depthTexture){const t=e.properties.get(a.depthTexture).__webglTexture;i.framebufferTexture2D(36160,36096,3553,t,0)}if(t(r,this.scene,this.camera),l){if(i.framebufferRenderbuffer(36160,36096,36161,o||null),36053!==i.checkFramebufferStatus(36160))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.depthTexture&&(i.framebufferRenderbuffer(36160,36096,36161,o||null),36053!==i.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else console.error("v3d.WebGLOITRenderer: undefined render target in v3d.WebGLOITWeighted.");this._restoreMatSettings(o),e.setClearAlpha(s),e.setRenderTarget(a)}_solverPass(e,t){const n=t?this.renderTargetMRTMSAA:this.renderTargetMRT;this.fsQuadSolver.material.uniforms.tRGBABuffer.value=n.texture[0],this.fsQuadSolver.material.uniforms.tFloatBuffer.value=n.texture[1],this.fsQuadSolver.render(e)}_testInitialLayersWithInitialCameraLayers(e){const t=this._layerMasks[e.id];return _tmpLayers.mask=void 0!==t?t:e.layers.mask,this._savedCameraLayers.test(_tmpLayers)}_saveLayers(e){this._layerMasks[this.camera.id]=this.camera.layers.mask;for(let t=0,n=e.length;t{if(null===e.influenceGroup)return e.intersectsMesh(o);return o.groupNames.includes(e.influenceGroup)^e.influenceGroupInv}))||t.worldEnvMapProbe;if(e){r.envMap=e.renderTarget?.texture||null;const t=e.parallaxDistance;r.envMapParallaxMatrix.copy(e.matrixWorldInverse).premultiply(W.makeScale(1/t,1/t,1/t)),r.envMapParallaxMatrixInv.copy(e.matrixWorld).multiply(W.makeScale(t,t,t)),r.envMapParallaxType=e.parallaxType}}const l=(r.isMeshStandardMaterial||r.isMeshNodeMaterial?ee:J).get(r.envMap||a),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!r.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,f=!!n.morphAttributes.color,g=r.toneMapped?m.toneMapping:NoToneMapping,_=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==_?_.length:0,C=r.side===BackSide,S=q.get(r),w=h.state.lights;if(!0===D&&(!0===N||e!==y)){const t=e===y&&r.id===x;le.setState(r,e,t)}const I=Fe(o,r,h),L=r.isMeshNodeMaterial&&r.canUseGTAO()&&m.canUseGTAO();let R=!1,B=!1;if(r.version===S.__version)S.needsLights&&S.lightsStateVersion!==w.state.version||S.outputEncoding!==s||o.isInstancedMesh&&!1===S.instancing?R=!0:o.isInstancedMesh||!0!==S.instancing?o.isSkinnedMesh&&!1===S.skinning?R=!0:o.isSkinnedMesh||!0!==S.skinning?S.envMap!==l?(R=!0,B=!0):!0===r.fog&&S.fog!==i?R=!0:void 0===S.numClippingPlanes||S.numClippingPlanes===le.numPlanes&&S.numIntersection===le.numIntersection?(S.vertexAlphas!==c||S.vertexTangents!==u||S.morphTargets!==d||S.morphNormals!==p||S.morphColors!==f||S.toneMapping!==g||!0===j.isWebGL2&&S.morphTargetsCount!==v||S.planeReflProbe!==I||r.isMeshNormalMaterial&&S.flipSided!==C||S.useGTAO!==L)&&(R=!0):R=!0:R=!0:R=!0;else if(R=!0,S.__version=r.version,r.nodeRGBArr)for(let e=0;e{e.isLight?(n.pushLight(e),e.castShadow&&n.pushShadow(e)):e.isCubeReflectionProbe?n.pushEnvMapProbe(e):e.isPlaneReflectionProbe&&n.pushPlaneReflProbe(e)})),n.setupLights(m.physicallyCorrectLights),n.sortEnvMapProbes();let r=null;return e.worldEnvMapProbe&&null!==e.worldEnvMapProbe.renderTarget&&(r=e.worldEnvMapProbe.renderTarget.texture),e.traverse((e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((t=>{(t.isMeshStandardMaterial||t.isMeshPhysicalMaterial||t.isMeshNodeMaterial)&&(e.material.envMap=r,e.material.needsUpdate=!0)}))}})),n},this.compile=function(e,t){this.gtaoMapEnabled=!0;const n=se.get(e,f.length);this._compilePrepareRenderState(e,t,n);const r={};e.traverse((function(t){const o=t.material;if(o)if(Array.isArray(o))for(let i=0;i0&&function(e,t,n){const r=j.isWebGL2;null===F&&(F=new WebGLRenderTarget(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?HalfFloatType:UnsignedByteType,minFilter:LinearMipmapLinearFilter,samples:r&&!0===i?4:0}));m.getDrawingBufferSize(V),r?F.setSize(V.x,V.y):F.setSize(floorPowerOfTwo(V.x),floorPowerOfTwo(V.y));const o=m.getRenderTarget();m.setRenderTarget(F),m.clear();const a=m.toneMapping;m.toneMapping=NoToneMapping,Re(e,t,n),m.toneMapping=a,Z.updateMultisampleRenderTarget(F),Z.updateRenderTargetMipmap(F),m.setRenderTarget(o)}(o,t,n),r&&K.viewport(b.copy(r)),o.length>0&&Re(o,t,n),a.length>0&&Re(a,t,n),s.length>0&&(H&&m.oitRenderer.method!==NoOIT?m.oitRenderer.render(m,Re,s,t,n):Re(s,t,n)),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function Re(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let o=0,i=e.length;ot.intersectsMesh(e)))||null}we.setAnimationLoop((function(e){Me&&Me(e)})),"undefined"!=typeof self&&we.setContext(self),this.setAnimationLoop=function(e){Me=e,xe.setAnimationLoop(e),null===e?we.stop():we.start()},xe.addEventListener("sessionstart",Ee),xe.addEventListener("sessionend",Te),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("v3d.WebGLRenderer.render: camera is not an instance of v3d.Camera.");if(!0===g)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===xe.enabled&&!0===xe.isPresenting&&(!0===xe.cameraAutoUpdate&&xe.updateCamera(t),t=xe.getCamera()),!0===e.isScene&&e.onBeforeRender(m,e,t,A),h=se.get(e,f.length),h.init(),f.push(h),O.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),P.setFromProjectionMatrix(O),N=this.localClippingEnabled,D=le.init(this.clippingPlanes,N,t),d=ae.get(e,p.length),d.init(),p.push(d),Ie(e,t,0,m.sortObjects),d.finish(),!0===m.sortObjects&&d.sort(w,I),!0===D&&le.beginShadows();const n=h.state.shadowsArray;if(ce.render(n,e,t),!0===D&&le.endShadows(),!0===this.info.autoReset&&this.info.reset(),ue.render(d,e),h.setupLights(m.physicallyCorrectLights),h.sortEnvMapProbes(),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t0?f[f.length-1]:null,p.pop(),d=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(e,t,n){q.get(e.texture).__webglTexture=t,q.get(e.depthTexture).__webglTexture=n;const r=q.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(console.warn("v3d.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=q.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){A=e,_=t,v=n;let r=!0,o=null,i=!1,a=!1;if(e){const n=q.get(e);void 0!==n.__useDefaultFramebuffer?(K.bindFramebuffer(36160,null),r=!1):void 0===n.__webglFramebuffer?Z.setupRenderTarget(e):n.__hasExternalTextures&&Z.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture);const s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);const l=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(o=l[t],i=!0):o=j.isWebGL2&&e.samples>0&&!1===Z.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:l,b.copy(e.viewport),C.copy(e.scissor),S=e.scissorTest}else b.copy(L).multiplyScalar(T).floor(),C.copy(R).multiplyScalar(T).floor(),S=B;if(K.bindFramebuffer(36160,o)&&j.drawBuffers&&r&&K.drawBuffers(e,o),K.viewport(b),K.scissor(C),K.setScissorTest(S),i){const r=q.get(e.texture);_e.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(a){const r=q.get(e.texture),o=t||0;_e.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,o)}x=-1},this.readRenderTargetPixels=function(e,t,n,r,o,i,a){if(!e||!e.isWebGLRenderTarget)return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not v3d.WebGLRenderTarget.");let s=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){K.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==RGBAFormat&&fe.convert(s)!==_e.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===HalfFloatType&&(Y.has("EXT_color_buffer_half_float")||j.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===UnsignedByteType||fe.convert(l)===_e.getParameter(35738)||l===FloatType&&(j.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||c))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-o&&_e.readPixels(t,n,r,o,fe.convert(s),fe.convert(l),i)}finally{const e=null!==A?q.get(A).__webglFramebuffer:null;K.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const r=Math.pow(2,-n),o=Math.floor(t.image.width*r),i=Math.floor(t.image.height*r);Z.setTexture2D(t,0),_e.copyTexSubImage2D(3553,n,0,0,e.x,e.y,o,i),K.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const o=t.image.width,i=t.image.height,a=fe.convert(n.format),s=fe.convert(n.type);Z.setTexture2D(n,0),_e.pixelStorei(37440,n.flipY),_e.pixelStorei(37441,n.premultiplyAlpha),_e.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?_e.texSubImage2D(3553,r,e.x,e.y,o,i,a,s,t.image.data):t.isCompressedTexture?_e.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):_e.texSubImage2D(3553,r,e.x,e.y,a,s,t.image),0===r&&n.generateMipmaps&&_e.generateMipmap(3553),K.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,o=0){if(m.isWebGL1Renderer)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const i=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=fe.convert(r.format),c=fe.convert(r.type);let u;if(r.isData3DTexture)Z.setTexture3D(r,0),u=32879;else{if(!r.isDataArrayTexture)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: only supports v3d.DataTexture3D and v3d.DataTexture2DArray.");Z.setTexture2DArray(r,0),u=35866}_e.pixelStorei(37440,r.flipY),_e.pixelStorei(37441,r.premultiplyAlpha),_e.pixelStorei(3317,r.unpackAlignment);const d=_e.getParameter(3314),h=_e.getParameter(32878),p=_e.getParameter(3316),f=_e.getParameter(3315),g=_e.getParameter(32877),_=n.isCompressedTexture?n.mipmaps[0]:n.image;_e.pixelStorei(3314,_.width),_e.pixelStorei(32878,_.height),_e.pixelStorei(3316,e.min.x),_e.pixelStorei(3315,e.min.y),_e.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?_e.texSubImage3D(u,o,t.x,t.y,t.z,i,a,s,l,c,_.data):n.isCompressedArrayTexture?(console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_e.compressedTexSubImage3D(u,o,t.x,t.y,t.z,i,a,s,l,_.data)):_e.texSubImage3D(u,o,t.x,t.y,t.z,i,a,s,l,c,_),_e.pixelStorei(3314,d),_e.pixelStorei(32878,h),_e.pixelStorei(3316,p),_e.pixelStorei(3315,f),_e.pixelStorei(32877,g),0===o&&r.generateMipmaps&&_e.generateMipmap(u),K.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Z.setTextureCube(e,0):e.isData3DTexture?Z.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Z.setTexture2DArray(e,0):Z.setTexture2D(e,0),K.unbindTexture()},this.resetState=function(){_=0,v=0,A=null,K.reset(),me.reset()},"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.updateGeometry=function(e){return re.update(e)},this.setOIT=function(e,t){this.oitRenderer.setSize(M,E),this.oitRenderer.texType=null!==fe.convert(HalfFloatType)?HalfFloatType:UnsignedByteType;let n=t||(!0===i?4:0);this.oitRenderer.isMethodCompatible(e,j)?this.oitRenderer.setMethod(e,n):console.log("v3d.WebGLRenderer: the OIT method is not compatible.")},this.getOIT=function(){return this.oitRenderer.method},Object.defineProperty(this,"useOIT",{get:function(){return H},set:function(e){this.setTransparentSort(e?function(){}:null),H=e}})}class WebGL1Renderer extends WebGLRenderer{}WebGL1Renderer.prototype.isWebGL1Renderer=!0;class FogExp2{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Color(e),this.density=t}clone(){return new FogExp2(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Fog{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Color(e),this.near=t,this.far=n}clone(){return new Fog(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class InterleavedBuffer{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=generateUUID()}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 r=0,o=this.stride;re.far||t.push({distance:s,point:_intersectPoint.clone(),uv:Triangle.getUV(_intersectPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2),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 transformVertex(e,t,n,r,o,i){_alignedPosition.subVectors(e,n).addScalar(.5).multiply(r),void 0!==o?(_rotatedPosition.x=i*_alignedPosition.x-o*_alignedPosition.y,_rotatedPosition.y=o*_alignedPosition.x+i*_alignedPosition.y):_rotatedPosition.copy(_alignedPosition),e.copy(t),e.x+=_rotatedPosition.x,e.y+=_rotatedPosition.y,e.applyMatrix4(_viewWorldMatrix)}const _v1$2=new Vector3,_v2$1=new Vector3;class LOD extends Object3D{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,r;for(n=1,r=t.length;n0){_v1$2.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(_v1$2);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){_v1$2.setFromMatrixPosition(e.matrixWorld),_v2$1.setFromMatrixPosition(this.matrixWorld);const n=_v1$2.distanceTo(_v2$1)/e.zoom;let r,o;for(t[0].object.visible=!0,r=1,o=t.length;r=e))break;t[r-1].object.visible=!1,t[r].object.visible=!0}for(this._currentLevel=r-1;rs)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,i.start),r=Math.min(f.count,i.start+i.count)-1;ns)continue;d.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(d);re.far||t.push({distance:r,point:u.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;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;eo.far)return;i.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}class VideoTexture extends Texture{constructor(e,t,n,r,o,i,a,s,l){super(e,t,n,r,o,i,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==i?i:LinearFilter,this.magFilter=void 0!==o?o:LinearFilter,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class FramebufferTexture extends Texture{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.generateMipmaps=!1,this.needsUpdate=!0}}class CompressedTexture extends Texture{constructor(e,t,n,r,o,i,a,s,l,c,u,d){super(null,i,a,s,l,c,r,o,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(e,t,n,r,o,i){super(e,t,n,o,i),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ClampToEdgeWrapping}}class CanvasTexture extends Texture{constructor(e,t,n,r,o,i,a,s,l){super(e,t,n,r,o,i,a,s,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Curve{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("v3d.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),o=0;t.push(0);for(let i=1;i<=e;i++)n=this.getPoint(i/e),o+=n.distanceTo(r),t.push(o),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const o=n.length;let i;i=t||e*n[o-1];let a,s=0,l=o-1;for(;s<=l;)if(r=Math.floor(s+(l-s)/2),a=n[r]-i,a<0)s=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(r=l,n[r]===i)return r/(o-1);const c=n[r];return(r+(i-c)/(n[r+1]-c))/(o-1)}getTangent(e,t){const n=1e-4;let r=e-n,o=e+n;r<0&&(r=0),o>1&&(o=1);const i=this.getPoint(r),a=this.getPoint(o),s=t||(i.isVector2?new Vector2:new Vector3);return s.copy(a).sub(i).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Vector3,r=[],o=[],i=[],a=new Vector3,s=new Matrix4;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new Vector3)}o[0]=new Vector3,i[0]=new Vector3;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],a),i[0].crossVectors(r[0],o[0]);for(let t=1;t<=e;t++){if(o[t]=o[t-1].clone(),i[t]=i[t-1].clone(),a.crossVectors(r[t-1],r[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(clamp(r[t-1].dot(r[t]),-1,1));o[t].applyMatrix4(s.makeRotationAxis(a,e))}i[t].crossVectors(r[t],o[t])}if(!0===t){let t=Math.acos(clamp(o[0].dot(o[e]),-1,1));t/=e,r[0].dot(a.crossVectors(o[0],o[e]))>0&&(t=-t);for(let n=1;n<=e;n++)o[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),i[n].crossVectors(r[n],o[n])}return{tangents:r,normals:o,binormals:i}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class EllipseCurve extends Curve{constructor(e=0,t=0,n=1,r=1,o=0,i=2*Math.PI,a=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=i,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new Vector2,r=2*Math.PI;let o=this.aEndAngle-this.aStartAngle;const i=Math.abs(o)r;)o-=r;o0?0:(Math.floor(Math.abs(l)/o)+1)*o:0===c&&l===o-1&&(l=o-2,c=1),this.closed||l>0?a=r[(l-1)%o]:(tmp$1.subVectors(r[0],r[1]).add(r[0]),a=tmp$1);const u=r[l%o],d=r[(l+1)%o];if(this.closed||l+2r.length-2?r.length-1:i+1],u=r[i>r.length-3?r.length-1:i+2];return n.set(CatmullRom(a,s.x,l.x,c.x,u.x),CatmullRom(a,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=r[o]-n,i=this.curves[o],a=i.getLength(),s=0===a?0:1-e/a;return i.getPointAt(s,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class LatheGeometry extends BufferGeometry{constructor(e=[new Vector2(0,-.5),new Vector2(.5,0),new Vector2(0,.5)],t=12,n=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=clamp(r,0,2*Math.PI);const o=[],i=[],a=[],s=[],l=[],c=1/t,u=new Vector3,d=new Vector2,h=new Vector3,p=new Vector3,f=new Vector3;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-m,h.z=0*g,f.copy(h),h.normalize(),s.push(h.x,h.y,h.z);break;case e.length-1:s.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-m,h.z=0*g,p.copy(h),h.x+=f.x,h.y+=f.y,h.z+=f.z,h.normalize(),s.push(h.x,h.y,h.z),f.copy(p)}for(let o=0;o<=t;o++){const h=n+o*c*r,p=Math.sin(h),f=Math.cos(h);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*f,i.push(u.x,u.y,u.z),d.x=o/t,d.y=n/(e.length-1),a.push(d.x,d.y);const r=s[3*n+0]*p,c=s[3*n+1],h=s[3*n+0]*f;l.push(r,c,h)}}for(let n=0;n0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new Float32BufferAttribute(u,3)),this.setAttribute("normal",new Float32BufferAttribute(d,3)),this.setAttribute("uv",new Float32BufferAttribute(h,2))}static fromJSON(e){return new CylinderGeometry(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ConeGeometry extends CylinderGeometry{constructor(e=1,t=1,n=32,r=1,o=!1,i=0,a=2*Math.PI){super(0,e,t,n,r,o,i,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:i,thetaLength:a}}static fromJSON(e){return new ConeGeometry(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class PolyhedronGeometry extends BufferGeometry{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const o=[],i=[];function a(e,t,n,r){const o=r+1,i=[];for(let r=0;r<=o;r++){i[r]=[];const a=e.clone().lerp(n,r/o),s=t.clone().lerp(n,r/o),l=o-r;for(let e=0;e<=l;e++)i[r][e]=0===e&&r===o?a:a.clone().lerp(s,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(i[e+0]+=1),n<.2&&(i[e+2]+=1),r<.2&&(i[e+4]+=1))}}()}(),this.setAttribute("position",new Float32BufferAttribute(o,3)),this.setAttribute("normal",new Float32BufferAttribute(o.slice(),3)),this.setAttribute("uv",new Float32BufferAttribute(i,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new PolyhedronGeometry(e.vertices,e.indices,e.radius,e.details)}}class DodecahedronGeometry extends PolyhedronGeometry{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new DodecahedronGeometry(e.radius,e.detail)}}const _v0=new Vector3,_v1$1=new Vector3,_normal=new Vector3,_triangle=new Triangle;class EdgesGeometry extends BufferGeometry{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,r=Math.pow(10,n),o=Math.cos(DEG2RAD*t),i=e.getIndex(),a=e.getAttribute("position"),s=i?i.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},h=[];for(let e=0;e80*n){s=c=e[0],l=u=e[1];for(let t=n;tc&&(c=d),h>u&&(u=h);p=Math.max(c-s,u-l),p=0!==p?32767/p:0}return earcutLinked(i,a,n,s,l,p,0),a}};function linkedList(e,t,n,r,o){let i,a;if(o===signedArea(e,t,n,r)>0)for(i=t;i=t;i-=r)a=insertNode(i,e[i],e[i+1],a);return a&&equals(a,a.next)&&(removeNode(a),a=a.next),a}function filterPoints(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!equals(r,r.next)&&0!==area(r.prev,r,r.next))r=r.next;else{if(removeNode(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function earcutLinked(e,t,n,r,o,i,a){if(!e)return;!a&&i&&indexCurve(e,r,o,i);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,i?isEarHashed(e,r,o,i):isEar(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),removeNode(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?earcutLinked(e=cureLocalIntersections(filterPoints(e),t,n),t,n,r,o,i,2):2===a&&splitEarcut(e,t,n,r,o,i):earcutLinked(filterPoints(e),t,n,r,o,i,1);break}}function isEar(e){const t=e.prev,n=e,r=e.next;if(area(t,n,r)>=0)return!1;const o=t.x,i=n.x,a=r.x,s=t.y,l=n.y,c=r.y,u=oi?o>a?o:a:i>a?i:a,p=s>l?s>c?s:c:l>c?l:c;let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=h&&f.y>=d&&f.y<=p&&pointInTriangle(o,s,i,l,a,c,f.x,f.y)&&area(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function isEarHashed(e,t,n,r){const o=e.prev,i=e,a=e.next;if(area(o,i,a)>=0)return!1;const s=o.x,l=i.x,c=a.x,u=o.y,d=i.y,h=a.y,p=sl?s>c?s:c:l>c?l:c,g=u>d?u>h?u:h:d>h?d:h,_=zOrder(p,f,t,n,r),v=zOrder(m,g,t,n,r);let A=e.prevZ,x=e.nextZ;for(;A&&A.z>=_&&x&&x.z<=v;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==o&&A!==a&&pointInTriangle(s,u,l,d,c,h,A.x,A.y)&&area(A.prev,A,A.next)>=0)return!1;if(A=A.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&x!==a&&pointInTriangle(s,u,l,d,c,h,x.x,x.y)&&area(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;A&&A.z>=_;){if(A.x>=p&&A.x<=m&&A.y>=f&&A.y<=g&&A!==o&&A!==a&&pointInTriangle(s,u,l,d,c,h,A.x,A.y)&&area(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&x!==a&&pointInTriangle(s,u,l,d,c,h,x.x,x.y)&&area(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function cureLocalIntersections(e,t,n){let r=e;do{const o=r.prev,i=r.next.next;!equals(o,i)&&intersects(o,r,r.next,i)&&locallyInside(o,i)&&locallyInside(i,o)&&(t.push(o.i/n|0),t.push(r.i/n|0),t.push(i.i/n|0),removeNode(r),removeNode(r.next),r=e=i),r=r.next}while(r!==e);return filterPoints(r)}function splitEarcut(e,t,n,r,o,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&isValidDiagonal(a,e)){let s=splitPolygon(a,e);return a=filterPoints(a,a.next),s=filterPoints(s,s.next),earcutLinked(a,t,n,r,o,i,0),void earcutLinked(s,t,n,r,o,i,0)}e=e.next}a=a.next}while(a!==e)}function eliminateHoles(e,t,n,r){const o=[];let i,a,s,l,c;for(i=0,a=t.length;i=r.next.y&&r.next.y!==r.y){const e=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=i&&e>o&&(o=e,n=r.x=r.x&&r.x>=l&&i!==r.x&&pointInTriangle(an.x||r.x===n.x&§orContainsSector(n,r)))&&(n=r,d=u)),r=r.next}while(r!==s);return n}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,r){let o=e;do{0===o.z&&(o.z=zOrder(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,sortLinked(o)}function sortLinked(e){let t,n,r,o,i,a,s,l,c=1;do{for(n=e,e=null,i=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(o=n,n=n.nextZ,s--):(o=r,r=r.nextZ,l--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=r}i.nextZ=null,c*=2}while(a>1);return e}function zOrder(e,t,n,r,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,n=e;do{(t.x=(e-a)*(i-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(i-s)>=(o-a)*(r-s)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,r){const o=sign(area(e,t,n)),i=sign(area(e,t,r)),a=sign(area(n,r,e)),s=sign(area(n,r,t));return o!==i&&a!==s||(!(0!==o||!onSegment(e,n,t))||(!(0!==i||!onSegment(e,r,t))||(!(0!==a||!onSegment(n,e,r))||!(0!==s||!onSegment(n,t,r)))))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,r=!1;const o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}function splitPolygon(e,t){const n=new Node(e.i,e.x,e.y),r=new Node(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function insertNode(e,t,n,r){const o=new Node(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Node(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(e,t,n,r){let o=0;for(let i=t,a=n-r;i2&&e[t-1].equals(e[0])&&e.pop()}function addContour(e,t){for(let n=0;nNumber.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(l*l+c*c),p=t.x-s/d,f=t.y+a/d,m=((n.x-c/h-p)*c-(n.y+l/h-f)*l)/(a*c-s*l);r=p+a*m-e.x,o=f+s*m-e.y;const g=r*r+o*o;if(g<=2)return new Vector2(r,o);i=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(r=-s,o=a,i=Math.sqrt(u)):(r=a,o=s,i=Math.sqrt(u/2))}return new Vector2(r/i,o/i)}const R=[];for(let e=0,t=E.length,n=t-1,r=e+1;e=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=E.length;e=0;){const r=n;let o=n-1;o<0&&(o=e.length-1);for(let e=0,n=s+2*p;e0)&&h.push(t,o,l),(e!==n-1||s1?.5*s-u:-.5*u+.5*d;break;case"bottom":c=s-u+d;break;case"bottomBaseline":c=i>1?s-u-d:0}(Math.abs(l)>0||Math.abs(c)>0)&&e.translate(l,c,0)}class BlenderTextGeometry extends TextGeometry{constructor(e,t){super(e,t),alignTextGeometry(this,t.alignX||"left",t.alignY||"bottom",e,t.font),this.type="BlenderTextGeometry"}cloneWithText(e){var t=this.parameters.parameters;return new BlenderTextGeometry(e,{font:t.font,size:t.size,height:t.height,curveSegments:t.curveSegments,bevelEnabled:t.bevelEnabled,bevelThickness:t.bevelThickness,bevelSize:t.bevelSize,alignX:t.alignX,alignY:t.alignY})}}class TeapotGeometry extends BufferGeometry{constructor(e=50,t=10,n=!0,r=!0,o=!0,i=!0,a=!0){const s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,3,16,17,18,7,19,20,21,11,22,23,24,15,25,26,27,18,28,29,30,21,31,32,33,24,34,35,36,27,37,38,39,30,40,41,0,33,42,43,4,36,44,45,8,39,46,47,12,12,13,14,15,48,49,50,51,52,53,54,55,56,57,58,59,15,25,26,27,51,60,61,62,55,63,64,65,59,66,67,68,27,37,38,39,62,69,70,71,65,72,73,74,68,75,76,77,39,46,47,12,71,78,79,48,74,80,81,52,77,82,83,56,56,57,58,59,84,85,86,87,88,89,90,91,92,93,94,95,59,66,67,68,87,96,97,98,91,99,100,101,95,102,103,104,68,75,76,77,98,105,106,107,101,108,109,110,104,111,112,113,77,82,83,56,107,114,115,84,110,116,117,88,113,118,119,92,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,123,136,137,120,127,138,139,124,131,140,141,128,135,142,143,132,132,133,134,135,144,145,146,147,148,149,150,151,68,152,153,154,135,142,143,132,147,155,156,144,151,157,158,148,154,159,160,68,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,164,177,178,161,168,179,180,165,172,181,182,169,176,183,184,173,173,174,175,176,185,186,187,188,189,190,191,192,193,194,195,196,176,183,184,173,188,197,198,185,192,199,200,189,196,201,202,193,203,203,203,203,204,205,206,207,208,208,208,208,209,210,211,212,203,203,203,203,207,213,214,215,208,208,208,208,212,216,217,218,203,203,203,203,215,219,220,221,208,208,208,208,218,222,223,224,203,203,203,203,221,225,226,204,208,208,208,208,224,227,228,209,209,210,211,212,229,230,231,232,233,234,235,236,237,238,239,240,212,216,217,218,232,241,242,243,236,244,245,246,240,247,248,249,218,222,223,224,243,250,251,252,246,253,254,255,249,256,257,258,224,227,228,209,252,259,260,229,255,261,262,233,258,263,264,237,265,265,265,265,266,267,268,269,270,271,272,273,92,119,118,113,265,265,265,265,269,274,275,276,273,277,278,279,113,112,111,104,265,265,265,265,276,280,281,282,279,283,284,285,104,103,102,95,265,265,265,265,282,286,287,266,285,288,289,270,95,94,93,92],l=[1.4,0,2.4,1.4,-.784,2.4,.784,-1.4,2.4,0,-1.4,2.4,1.3375,0,2.53125,1.3375,-.749,2.53125,.749,-1.3375,2.53125,0,-1.3375,2.53125,1.4375,0,2.53125,1.4375,-.805,2.53125,.805,-1.4375,2.53125,0,-1.4375,2.53125,1.5,0,2.4,1.5,-.84,2.4,.84,-1.5,2.4,0,-1.5,2.4,-.784,-1.4,2.4,-1.4,-.784,2.4,-1.4,0,2.4,-.749,-1.3375,2.53125,-1.3375,-.749,2.53125,-1.3375,0,2.53125,-.805,-1.4375,2.53125,-1.4375,-.805,2.53125,-1.4375,0,2.53125,-.84,-1.5,2.4,-1.5,-.84,2.4,-1.5,0,2.4,-1.4,.784,2.4,-.784,1.4,2.4,0,1.4,2.4,-1.3375,.749,2.53125,-.749,1.3375,2.53125,0,1.3375,2.53125,-1.4375,.805,2.53125,-.805,1.4375,2.53125,0,1.4375,2.53125,-1.5,.84,2.4,-.84,1.5,2.4,0,1.5,2.4,.784,1.4,2.4,1.4,.784,2.4,.749,1.3375,2.53125,1.3375,.749,2.53125,.805,1.4375,2.53125,1.4375,.805,2.53125,.84,1.5,2.4,1.5,.84,2.4,1.75,0,1.875,1.75,-.98,1.875,.98,-1.75,1.875,0,-1.75,1.875,2,0,1.35,2,-1.12,1.35,1.12,-2,1.35,0,-2,1.35,2,0,.9,2,-1.12,.9,1.12,-2,.9,0,-2,.9,-.98,-1.75,1.875,-1.75,-.98,1.875,-1.75,0,1.875,-1.12,-2,1.35,-2,-1.12,1.35,-2,0,1.35,-1.12,-2,.9,-2,-1.12,.9,-2,0,.9,-1.75,.98,1.875,-.98,1.75,1.875,0,1.75,1.875,-2,1.12,1.35,-1.12,2,1.35,0,2,1.35,-2,1.12,.9,-1.12,2,.9,0,2,.9,.98,1.75,1.875,1.75,.98,1.875,1.12,2,1.35,2,1.12,1.35,1.12,2,.9,2,1.12,.9,2,0,.45,2,-1.12,.45,1.12,-2,.45,0,-2,.45,1.5,0,.225,1.5,-.84,.225,.84,-1.5,.225,0,-1.5,.225,1.5,0,.15,1.5,-.84,.15,.84,-1.5,.15,0,-1.5,.15,-1.12,-2,.45,-2,-1.12,.45,-2,0,.45,-.84,-1.5,.225,-1.5,-.84,.225,-1.5,0,.225,-.84,-1.5,.15,-1.5,-.84,.15,-1.5,0,.15,-2,1.12,.45,-1.12,2,.45,0,2,.45,-1.5,.84,.225,-.84,1.5,.225,0,1.5,.225,-1.5,.84,.15,-.84,1.5,.15,0,1.5,.15,1.12,2,.45,2,1.12,.45,.84,1.5,.225,1.5,.84,.225,.84,1.5,.15,1.5,.84,.15,-1.6,0,2.025,-1.6,-.3,2.025,-1.5,-.3,2.25,-1.5,0,2.25,-2.3,0,2.025,-2.3,-.3,2.025,-2.5,-.3,2.25,-2.5,0,2.25,-2.7,0,2.025,-2.7,-.3,2.025,-3,-.3,2.25,-3,0,2.25,-2.7,0,1.8,-2.7,-.3,1.8,-3,-.3,1.8,-3,0,1.8,-1.5,.3,2.25,-1.6,.3,2.025,-2.5,.3,2.25,-2.3,.3,2.025,-3,.3,2.25,-2.7,.3,2.025,-3,.3,1.8,-2.7,.3,1.8,-2.7,0,1.575,-2.7,-.3,1.575,-3,-.3,1.35,-3,0,1.35,-2.5,0,1.125,-2.5,-.3,1.125,-2.65,-.3,.9375,-2.65,0,.9375,-2,-.3,.9,-1.9,-.3,.6,-1.9,0,.6,-3,.3,1.35,-2.7,.3,1.575,-2.65,.3,.9375,-2.5,.3,1.125,-1.9,.3,.6,-2,.3,.9,1.7,0,1.425,1.7,-.66,1.425,1.7,-.66,.6,1.7,0,.6,2.6,0,1.425,2.6,-.66,1.425,3.1,-.66,.825,3.1,0,.825,2.3,0,2.1,2.3,-.25,2.1,2.4,-.25,2.025,2.4,0,2.025,2.7,0,2.4,2.7,-.25,2.4,3.3,-.25,2.4,3.3,0,2.4,1.7,.66,.6,1.7,.66,1.425,3.1,.66,.825,2.6,.66,1.425,2.4,.25,2.025,2.3,.25,2.1,3.3,.25,2.4,2.7,.25,2.4,2.8,0,2.475,2.8,-.25,2.475,3.525,-.25,2.49375,3.525,0,2.49375,2.9,0,2.475,2.9,-.15,2.475,3.45,-.15,2.5125,3.45,0,2.5125,2.8,0,2.4,2.8,-.15,2.4,3.2,-.15,2.4,3.2,0,2.4,3.525,.25,2.49375,2.8,.25,2.475,3.45,.15,2.5125,2.9,.15,2.475,3.2,.15,2.4,2.8,.15,2.4,0,0,3.15,.8,0,3.15,.8,-.45,3.15,.45,-.8,3.15,0,-.8,3.15,0,0,2.85,.2,0,2.7,.2,-.112,2.7,.112,-.2,2.7,0,-.2,2.7,-.45,-.8,3.15,-.8,-.45,3.15,-.8,0,3.15,-.112,-.2,2.7,-.2,-.112,2.7,-.2,0,2.7,-.8,.45,3.15,-.45,.8,3.15,0,.8,3.15,-.2,.112,2.7,-.112,.2,2.7,0,.2,2.7,.45,.8,3.15,.8,.45,3.15,.112,.2,2.7,.2,.112,2.7,.4,0,2.55,.4,-.224,2.55,.224,-.4,2.55,0,-.4,2.55,1.3,0,2.55,1.3,-.728,2.55,.728,-1.3,2.55,0,-1.3,2.55,1.3,0,2.4,1.3,-.728,2.4,.728,-1.3,2.4,0,-1.3,2.4,-.224,-.4,2.55,-.4,-.224,2.55,-.4,0,2.55,-.728,-1.3,2.55,-1.3,-.728,2.55,-1.3,0,2.55,-.728,-1.3,2.4,-1.3,-.728,2.4,-1.3,0,2.4,-.4,.224,2.55,-.224,.4,2.55,0,.4,2.55,-1.3,.728,2.55,-.728,1.3,2.55,0,1.3,2.55,-1.3,.728,2.4,-.728,1.3,2.4,0,1.3,2.4,.224,.4,2.55,.4,.224,2.55,.728,1.3,2.55,1.3,.728,2.55,.728,1.3,2.4,1.3,.728,2.4,0,0,0,1.425,0,0,1.425,.798,0,.798,1.425,0,0,1.425,0,1.5,0,.075,1.5,.84,.075,.84,1.5,.075,0,1.5,.075,-.798,1.425,0,-1.425,.798,0,-1.425,0,0,-.84,1.5,.075,-1.5,.84,.075,-1.5,0,.075,-1.425,-.798,0,-.798,-1.425,0,0,-1.425,0,-1.5,-.84,.075,-.84,-1.5,.075,0,-1.5,.075,.798,-1.425,0,1.425,-.798,0,.84,-1.5,.075,1.5,-.84,.075];super(),t=Math.max(2,Math.floor(t));const c=3.15*(a?1:1.3)/2,u=e/c;let d=n?(8*t-4)*t:0;d+=r?(16*t-4)*t:0,d+=o?40*t*t:0;const h=new Uint32Array(3*d);let p=n?4:0;p+=r?8:0,p+=o?20:0,p*=(t+1)*(t+1);const f=new Float32Array(3*p),m=new Float32Array(3*p),g=new Float32Array(2*p),_=new Matrix4;_.set(-1,3,-3,1,3,-6,3,0,-3,3,0,0,1,0,0,0);const v=[],A=[],x=[],y=[],b=[],C=[],S=[],M=[],E=[],T=new Vector3;let w,I,L,R,B=0,P=0;const D=new Vector3,N=new Matrix4,F=new Matrix4,O=new Vector4,V=new Vector4,U=new Vector4,G=new Vector4,k=new Vector3,z=new Vector3,Q=_.clone();Q.transpose();const W=(e,t,n)=>!(f[3*e]===f[3*t]&&f[3*e+1]===f[3*t+1]&&f[3*e+2]===f[3*t+2]||f[3*e]===f[3*n]&&f[3*e+1]===f[3*n+1]&&f[3*e+2]===f[3*n+2]||f[3*t]===f[3*n]&&f[3*t+1]===f[3*n+1]&&f[3*t+2]===f[3*n+2]);for(let e=0;e<3;e++)C[e]=new Matrix4;const H=n?32:28,X=t+1;let Y=0,j=0,K=0,$=0,q=0;for(let e=o?0:20;e=28){for(let t=0;t<3;t++){for(let n=0;n<4;n++)for(let r=0;r<4;r++)v[4*r+n]=l[3*s[16*e+4*n+r]+t],i&&e>=20&&e<28&&2!==t&&(v[4*r+n]*=1.077),a||2!==t||(v[4*r+n]*=1.3);N.set(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15]),F.multiplyMatrices(N,_),C[t].multiplyMatrices(Q,F)}for(let e=0;e<=t;e++){const n=e/t;for(let e=0;e<=t;e++){const r=e/t;for(R=4,I=L=1;R--;)A[R]=I,x[R]=L,I*=n,L*=r,3===R?(y[R]=b[R]=0,B=P=1):(y[R]=B*(3-R),b[R]=P*(3-R),B*=n,P*=r);O.fromArray(A),V.fromArray(x),U.fromArray(y),G.fromArray(b);for(let e=0;e<3;e++)w=O.clone(),w.applyMatrix4(C[e]),S[e]=w.dot(V),w=U.clone(),w.applyMatrix4(C[e]),M[e]=w.dot(V),w=O.clone(),w.applyMatrix4(C[e]),E[e]=w.dot(G);k.fromArray(M),z.fromArray(E),T.crossVectors(z,k),T.normalize(),0===S[0]&&0===S[1]?D.set(0,S[2]>c?1:-1,0):D.set(T.x,T.z,-T.y),f[j++]=u*S[0],f[j++]=u*(S[2]-c),f[j++]=-u*S[1],m[K++]=D.x,m[K++]=D.y,m[K++]=D.z,g[$++]=1-r,g[$++]=1-n}}for(let e=0;e0!=e>0&&this.version++,this._sheen=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 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.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class MeshPhongMaterial extends Material{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Color(16777215),this.specular=new Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class MeshToonMaterial extends Material{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Color(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class MeshNormalMaterial extends Material{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class MeshLambertMaterial extends Material{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class MeshMatcapMaterial extends Material{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Color(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class LineDashedMaterial extends LineBasicMaterial$1{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class MeshMaskMaterial extends Material{constructor(e){super(),this.type="MeshMaskMaterial",this.side=DoubleSide,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.lights=!1,this.cameraNearFar=null,this.depthTexture=null,this.textureMatrix=null,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,e.cameraNearFar&&(this.cameraNearFar=e.cameraNearFar.clone()),e.textureMatrix&&(this.textureMatrix=e.textureMatrix.clone()),e.depthTexture&&(this.depthTexture=e.depthTexture),this}}MeshMaskMaterial.prototype.isMeshMaskMaterial=!0;class Interpolant{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r: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,r=t[n],o=t[n-1];e:{t:{let i;n:{r:if(!(e=o)break e;{const a=t[1];e=o)break t}i=n,n=0}}for(;n>>1;ee?n-1:n,s=i>e?i-1:i,l=this.edge(n,i).copy();l.v=a,l.w=s,t.addEdge(l)}}this.V--,this.adjList=t.adjList,this.nodeInfo.splice(e,1),this.edges=t.edges}},DiGraph.prototype.insert=function(e,t,n,r=(e=>e),o=(e=>e)){const i=this.V,a=e.V;for(let t=0;t "+r[e]+";"}}t+="}",console.log(t)};const Edge=function(e,t,n){this.v=e,this.w=t,this.weight=n};Edge.prototype.either=function(){return this.v},Edge.prototype.other=function(e){return e==this.v?this.w:this.v},Edge.prototype.from=function(){return this.v},Edge.prototype.to=function(){return this.w},Edge.prototype.copy=function(e=(e=>e)){const t=new Edge(0,0,0);for(const n in this)this.hasOwnProperty(n)&&("object"==typeof this[n]?t[n]=e(this[n]):t[n]=this[n]);return t};const WeightedGraph=function(e){this.V=e,this.adjList=[],this.nodeInfo=[];for(let t=0;t-1){r.removedNodes.push(o+e.len());const i=e.findInEdges(n),s=t.findOutEdges(o);for(let e=0;e0&&connectNodes(e,e.len()-2,0,e.len()-1,0)}for(let t=0;t0&&(connectNodes(e,e.len()-1,0,e.len()-2,0),connectNodes(e,e.len()-1,1,e.len()-2,1))}for(let t=0;t-1}function m(e){return e.type.indexOf("varying")>-1}function g(e,n){return n=isDef(n)?n:"color",t.nodeVCAliases[e]||n}function _(e,t,n,r){const o=new DataTexture(e,t,1,n,r,Texture.DEFAULT_MAPPING,ClampToEdgeWrapping,ClampToEdgeWrapping,LinearFilter,LinearFilter);return o.needsUpdate=!0,o}function v(e){return!0===e.isVideoTexture&&e.encoding===sRGBEncoding$1?"1":"0"}function A(e,t,n,r,o){let i;return t==n?i=e:"float"==t&&"vec3"==n?i="vec3("+[e,e,e].join(",")+")":"float"==t&&"vec4"==n?i="vec4("+[e,e,e,e].join(",")+")":"vec3"==t&&"float"==n||"vec4"==t&&"float"==n?i="("+[e+"[0]",e+"[1]",e+"[2]"].join("+")+")/3.0":"vec3"==t&&"vec4"==n?i="vec4("+e+", 1.0)":"vec4"==t&&"vec3"==n?i="vec3("+[e+"[0]",e+"[1]",e+"[2]"].join(",")+")":"float"==t&&"int"==n?i="int("+e+")":"int"==t&&"float"==n||"bool"==t&&"float"==n?i="float("+e+")":console.error("MeshNodeMaterial: Missing type conversion: "+t+" -> "+n),(o<1||1!=o&&"normal"==r)&&(i="mix("+r+","+i+","+P(o)+")","normal"==r&&(i="normalize("+i+")")),i}function x(e,t,n,r,o){let i;const a=[],s=R(n),l=R(r);for(let n=0;n0||isConnInput(e,l,15))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[18]>0||isConnInput(e,l,18))&&(t.defines.USE_SHEEN=""),c.inputFactors.length=0;break;case"TRIGO_AR":c.params.push(E(u.function)),c.params.push(E(u.units));break;case"TWO_SIDED_AR":c.params.push(E("faceDirection"));break;case"USER_DATA_COLOR_AR":h=g(u.colorLayer,""),h?(p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(E(B("vec4",u.defaultColor)));break;case"ATTRIBUTE_BL":case"VERTEX_COLOR_BL":h=g(u.colorLayer,""),h?(p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(E("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BSDF_PRINCIPLED_BL":c.params.push(E("geometryNormal")),25==u.inputs.length?((u.inputs[14]>0||isConnInput(e,l,14))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[12]>0||isConnInput(e,l,12))&&(t.defines.USE_SHEEN_BLENDER_OLD="")):((u.inputs[17]>0||isConnInput(e,l,17))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[22]>0||isConnInput(e,l,22))&&(t.defines.USE_SHEEN_BLENDER=""));break;case"BSDF_REFRACTION_BL":c.params.push(E("geometryNormal")),c.params.push(E("BSDF_REFRACTION_"+u.distribution));break;case"BUMP_BL":c.params.push(b(u.invert));break;case"CAMERA_BL":c.params.push(E("vViewPosition")),i(e,"OUTPUT_MATERIAL_BL")>0||i(e,"OUTPUT_WORLD_BL")>0?c.params.push(M(!0)):c.params.push(M(!1));break;case"CLAMP_BL":c.params.push(E("RANGE"==u.clampType));break;case"COMBINE_COLOR_BL":c.params.push(E("NODE_COMB_COL_"+u.mode));break;case"CURVE_FLOAT_BL":t.useFloatTex?(m=new Float32Array(1024),A=1):(m=new Uint8Array(1024),A=255);for(let e=0;e<256;e++){let t=A*(u.curveData[e]/2+.5);m[4*e]=clamp(t,0,A)}y=_(m,256,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++;break;case"CURVE_RGB_BL":case"CURVE_VEC_BL":t.useFloatTex?(m=new Float32Array(1024),A=1):(m=new Uint8Array(1024),A=255);for(let e=0;e<256;e++){let t,n,r,o;P=u.curveData.length/256,P>3?(t=A*u.curveData[P*e],n=A*u.curveData[P*e+1],r=A*u.curveData[P*e+2],o=A*u.curveData[P*e+3]):(t=A*(u.curveData[P*e]/2+.5),n=A*(u.curveData[P*e+1]/2+.5),r=A*(u.curveData[P*e+2]/2+.5),o=A),m[4*e]=clamp(t,0,A),m[4*e+1]=clamp(n,0,A),m[4*e+2]=clamp(r,0,A),m[4*e+3]=clamp(o,0,A)}y=_(m,256,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++;break;case"EEVEE_SPECULAR_BL":c.params.push(E("geometryNormal")),(u.inputs[6]>0||isConnInput(e,l,6))&&(t.defines.USE_CLEARCOAT="");break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":case"INCIDENT":case"POSITION":c.params.push(E("vViewPosition"));break;case"GRADIENT_MX":c.params.push(E(B("float",u.color2Pos))),c.params.push(E(B("int",u.gradientType))),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(E("vViewPosition")),c.params.push(E("MAPPING_"+u.mapping)),c.params.push(E("AXIS_"+u.axis)),c.params.push(E(B("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])])));break;case"GRADIENT_RAMP_MX":t.useFloatTex?(m=new Float32Array(2048),A=1):(m=new Uint8Array(2048),A=255);for(let e=0;e<512;e++){let t,n,r,o;t=A*u.gradientData[3*e],n=A*u.gradientData[3*e+1],r=A*u.gradientData[3*e+2],o=1,m[4*e]=clamp(t,0,A),m[4*e+1]=clamp(n,0,A),m[4*e+2]=clamp(r,0,A),m[4*e+3]=clamp(o,0,A)}y=_(m,512,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++,c.params.push(E(B("int",u.gradientType))),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(E("geometryNormal")),c.params.push(E("vViewPosition")),["SPHERICAL_ENVIRONMENT","CYLINDRICAL_ENVIRONMENT","SHRINK_WRAP_ENVIRONMENT","SCREEN"].indexOf(u.mapping)>-1?c.params.push(E("MAPPING_EXPLICIT_MAP_CHANNEL")):c.params.push(E("MAPPING_"+u.mapping)),c.params.push(E("AXIS_"+u.axis)),c.params.push(E(B("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])])));break;case"MAPPING_BL":c.params.push(E("NODE_MAPPING_"+u.vectorType));break;case"MAP_RANGE_BL":isDef(u.dataType)&&c.params.push(E("NODE_MAP_RANGE_TYPE_"+u.dataType)),c.params.push(E("NODE_MAP_RANGE_INTERP_"+u.interpolationType)),c.params.push(M(u.clamp));break;case"NEW_GEOMETRY_BL":c.params.push(E("faceDirection")),c.params.push(E("vViewPosition")),c.params.push(E("normal")),isConnOutput(e,l,2)&&(t.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":h="tangent",p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(E("vNormal"));break;case"SEPARATE_COLOR_BL":c.params.push(E("NODE_SEP_COL_"+u.mode));break;case"TANGENT_BL":"RADIAL"===u.directionType?(c.params.push(E("TANGENT_AXIS_"+u.axis)),c.params.push(E("vViewPosition")),c.params.push(E("normal")),t.needsBoundingBox=!0):"UV_MAP"===u.directionType&&(h="tangent",p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"TEX_BRICK_BL":c.params.push(E(B("float",u.offset))),c.params.push(E(B("int",u.offsetFrequency))),c.params.push(E(B("float",u.squash))),c.params.push(E(B("int",u.squashFrequency)));break;case"TEX_COORD_BL":c.params.push(E(`nodeTexCoordObjectMatrices[${o}]`)),c.params.push(E("vViewPosition")),c.params.push(E("normal")),h="uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),isConnOutput(e,l,0)&&(t.needsBoundingBox=!0),t.nodeTexCoordObject.push(null),t.nodeTexCoordObjectMap[u.name]=o,o++;break;case"TEX_ENVIRONMENT_BL":case"TEX_IMAGE_BL":if(R=C(d,u.texture),c.params.push(R),c.params.push(E(v(t.nodeTextures[R.name]))),"TEX_ENVIRONMENT_BL"==d){const e=u.projection;c.params.push(E("TEX_PROJ_"+e))}else if("TEX_IMAGE_BL"==d){let t;switch(u.alphaMode||"STRAIGHT"){case"STRAIGHT":t=isConnOutput(e,l,1)?"TEX_ALPHA_CLEAR":"TEX_ALPHA_PREMUL";break;case"PREMUL":t=isConnOutput(e,l,1)?"TEX_ALPHA_UNPREMUL":"TEX_ALPHA_CLEAR";break;case"CHANNEL_PACKED":t="TEX_ALPHA_CLEAR";break;case"NONE":t="TEX_ALPHA_ONE";break;default:console.error("MeshNodeMaterial: incorrect TEX_IMAGE_BL alpha mode"),t="TEX_ALPHA_ONE"}c.params.push(E(t)),c.params.push(E("normal"));const n=u.projection;c.params.push(E("TEX_PROJ_"+n)),c.params.push(b(u.projectionBlend)),c.params.push(M(u.clampToEdgeNoExtend))}break;case"TEX_GRADIENT_BL":c.params.push(E("TEX_GRAD_"+u.gradientType));break;case"TEX_NOISE_BL":isDef(u.noiseType)&&c.params.push(E("TEX_NOISE_"+u.noiseType)),c.params.push(E(B("float",u.falloffFactor))),c.params.push(E(B("float",u.dispersionFactor)));break;case"TEX_SKY_BL":if(N=(new Vector3).fromArray(u.sunDirection).angleTo(new Vector3(0,0,1)),"PREETHAM"==u.skyType)F=PreethamSkyModelUtils.getDistParams(u.turbidity,0).concat([0,0,0,0]),O=PreethamSkyModelUtils.getDistParams(u.turbidity,1).concat([0,0,0,0]),V=PreethamSkyModelUtils.getDistParams(u.turbidity,2).concat([0,0,0,0]),U=PreethamSkyModelUtils.getZenithParams(u.turbidity,N,0),G=PreethamSkyModelUtils.getZenithParams(u.turbidity,N,1),k=PreethamSkyModelUtils.getZenithParams(u.turbidity,N,2);else if("HOSEK_WILKIE"==u.skyType){const e=Math.max(Math.PI/2-N,0);F=HosekWilkieSkyModelUtils.getDistParams(u.turbidity,u.groundAlbedo,e,0),O=HosekWilkieSkyModelUtils.getDistParams(u.turbidity,u.groundAlbedo,e,1),V=HosekWilkieSkyModelUtils.getDistParams(u.turbidity,u.groundAlbedo,e,2),U=HosekWilkieSkyModelUtils.getRadiance(u.turbidity,u.groundAlbedo,e,0),G=HosekWilkieSkyModelUtils.getRadiance(u.turbidity,u.groundAlbedo,e,1),k=HosekWilkieSkyModelUtils.getRadiance(u.turbidity,u.groundAlbedo,e,2)}else F=O=V=new Array(9).fill(0),U=G=k=0;c.params.push(E("TEX_SKY_"+u.skyType)),c.params.push(b([F[0],O[0],V[0]])),c.params.push(b([F[1],O[1],V[1]])),c.params.push(b([F[2],O[2],V[2]])),c.params.push(b([F[3],O[3],V[3]])),c.params.push(b([F[4],O[4],V[4]])),c.params.push(b([F[5],O[5],V[5]])),c.params.push(b([F[6],O[6],V[6]])),c.params.push(b([F[7],O[7],V[7]])),c.params.push(b([F[8],O[8],V[8]])),c.params.push(b([U,G,k])),c.params.push(b(u.sunDirection));break;case"TEX_VORONOI_BL":c.params.push(E("DISTANCE_"+u.distance)),c.params.push(E("FEATURE_"+u.feature));break;case"TEX_WAVE_BL":c.params.push(E("TEX_WAVE_TYPE_"+u.waveType)),c.params.push(E("TEX_WAVE_PROFILE_"+u.waveProfile)),c.params.push(E(`TEX_WAVE_BANDS_DIR_${u.bandsDirection}`)),c.params.push(E(`TEX_WAVE_RINGS_DIR_${u.ringsDirection}`));break;case"MATH_BL":c.outputs[0].clamp=u.useClamp;break;case"MIX_BL":switch(c.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":t.defines.HSV_NODES=""}"RGBA"==u.dataType&&(c.outputs[0].clamp=u.clampResult);break;case"MIX_RGB_BL":switch(c.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":t.defines.HSV_NODES=""}c.outputs[0].clamp=u.useClamp;break;case"MIX_SHADER_BL":let I=-1;for(let t=1;t<3;t++){const n=findConnectedNode(e,l,t);n&&"BSDF_TRANSPARENT_BL"==n.originData.type&&(I=t-1)}c.params.push(E(String(I)));break;case"NORMAL_BL":c.params.push(b(u.outputs[0]));break;case"RGB_BL":case"RGB_MX":R=(new Vector4).fromArray(u.outputs[0]),t.nodeRGB.push(R),t.nodeRGBMap[u.name]=r,c.params.push(E("nodeRGB["+r+"]")),r++;break;case"UVMAP_BL":s=u.uvLayer,h=t.nodeUVAliases[s]||"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"VALUE_BL":case"VALUE_MX":case"ANIM_CURVE_TA_MY":case"ANIM_CURVE_TU_MY":case"VALUE":R=u.outputs[0],t.nodeValue[a]=R,t.nodeValueMap[u.name]=a,c.params.push(E("nodeValue["+a+"]")),a++;break;case"VALTORGB_BL":D=u.curve;const z=new("STEP"==D.interpolation?DiscreteInterpolant:LinearInterpolant)(new Float32Array(D.input),new Float32Array(D.output),4);t.useFloatTex?(m=new Float32Array(1024),A=1):(m=new Uint8Array(1024),A=255);for(let e=0;e<256;e++){const t=z.evaluate(e/255);m[4*e]=A*t[0],m[4*e+1]=A*t[1],m[4*e+2]=A*t[2],m[4*e+3]=A*t[3]}y=_(m,256,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),"STEP"==D.interpolation&&(y.minFilter=NearestFilter,y.magFilter=NearestFilter),L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++;break;case"VECTOR_ROTATE_BL":c.params.push(E(B("float",u.invert?-1:1)));break;case"VECT_TRANSFORM_BL":const Q=u.vectorType,W=u.convertFrom,H=u.convertTo;"NORMAL"==Q&&(c.outputs[0].normalize=!0);let X="";W==H?X="VEC_TRANS_NONE":(X="VEC_TRANS_"+W[0]+"_"+H[0],"VECTOR"!=Q&&"NORMAL"!=Q||(X+="_DIR")),c.params.push(E(X)),i(e,"OUTPUT_MATERIAL_BL")>0||i(e,"OUTPUT_WORLD_BL")>0?c.params.push(M(!0)):c.params.push(M(!1));break;case"BITMAP_MX":case"BITMAP_ENV_MX":case"REFLECT_REFRACT_MX":if(f=C(d,u.texture),c.params.push(f),"BITMAP_MX"==d){h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(E("MAPPING_"+u.mapping)),c.params.push(E("AXIS_"+u.axis));const e=B("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])]);c.params.push(E(e))}else c.params.push(E(u.reflectMode)),c.params.push(b(u.IOR));c.params.push(E(v(t.nodeTextures[f.name]))),"BITMAP_MX"!=d&&"BITMAP_ENV_MX"!=d||(c.params.push(M(u.alphaAsMono)),c.params.push(M(u.alphaAsRGB)),c.outputs.push({name:d.toLowerCase()+"_out1_n"+l,type:"float",clamp:!1,normalize:!1}));break;case"BLEND_MX":c.params.push(M(u.useCurve)),c.params.push(b(u.curveLower)),c.params.push(b(u.curveUpper));break;case"BUMP_MX":f=C("BITMAP_MX",u.texture),c.params.push(f),c.params.push(E("-vViewPosition")),c.params.push(E("normal")),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"COLOR_CORRECTION_MX":const Y=B("ivec4",[u.rewireR,u.rewireG,u.rewireB,u.rewireA]);c.params.push(E(Y)),u.gainPivotGammaLift&&(c.params.push(b(u.gainPivotGammaLift)),c.params.push(M(u.enableR)),c.params.push(M(u.enableG)),c.params.push(M(u.enableB)),c.params.push(S(u.exposureMode)),c.params.push(b(u.printerLights)));break;case"COMPOSITE_LAYER_MX":c.params.push(E(B("int",u.blendMode)));const j=isConnInput(e,l,1)?u.opacity:0;c.params.push(b(j));break;case"COLOR_MAP_MX":c.params.push(M(u.reverseGamma));break;case"FALLOFF_MX":if(c.params.push(E("-vViewPosition")),4!=u.falloffType)c.params.push(b(u.IOR)),c.params.push(S(u.falloffType));else{const e=void 0!==u.extrapolateOn&&u.extrapolateOn,t=void 0===u.nearDistance?0:u.nearDistance,n=void 0===u.farDistance?100:u.farDistance;c.params.push(M(e)),c.params.push(b(t)),c.params.push(b(n))}break;case"MASK_MX":c.params.push(M(u.maskInverted));break;case"MATERIAL_MX":c.params.push(b(u.inputFactors[9])),c.params.push(b(u.inputFactors[10])),u.inputFactors[9]=1,u.inputFactors[10]=1,c.params.push(M(u.selfIllumColorOn));break;case"MATTE_SHADOW_MX":c.params.push(E("normal")),c.params.push(M(u.receiveShadows)),c.params.push(b(u.shadowBrightness)),c.params.push(b(u.color));break;case"NOISE_MX":2==u.coordType?(h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)):c.params.push(E("vViewPosition")),c.params.push(S(u.noiseType)),c.params.push(S(u.coordType));break;case"NORMAL_BUMP_MX":h="tangent",p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(E("normal"));const K="ivec2("+w(u.flip[0])+","+w(u.flip[1])+")";c.params.push(E(K));break;case"OUTPUT_MAP_MX":if(c.params.push(M(u.invert)),c.params.push(M(u.clamp)),c.params.push(M(u.alphaFromRGB)),u.colorMap){t.useFloatTex?(x=u.colorMap,m=new Float32Array(1024),A=1):(x=clampArray(u.colorMap.slice(),0,1),m=new Uint8Array(1024),A=255),P=x.length/256;for(let e=0;e<256;e++)m[4*e]=A*x[P*e],3==P?(m[4*e+1]=A*x[P*e+1],m[4*e+2]=A*x[P*e+2]):(m[4*e+1]=m[4*e],m[4*e+2]=m[4*e]),m[4*e+3]=A;y=_(m,256,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++}break;case"PHYSICAL_MX":c.params.push(E("geometryNormal")),c.params.push(b(u.emitLuminance));const $=void 0===u.brdfMode||u.brdfMode,q=void 0===u.brdfLow?0:u.brdfLow,Z=void 0===u.brdfHigh?0:u.brdfHigh,J=void 0===u.brdfCurve?0:u.brdfCurve;c.params.push(M(!$)),c.params.push(E(B("float",q))),c.params.push(E(B("float",Z))),c.params.push(E(B("float",J))),c.params.push(M(isDef(u.roughnessInv)&&u.roughnessInv)),c.params.push(M(isDef(u.transRoughnessLock)&&u.transRoughnessLock)),c.params.push(M(isDef(u.transRoughnessInv)&&u.transRoughnessInv)),c.params.push(M(isDef(u.thinWalled)&&u.thinWalled)),(u.inputs[18]>0||isConnInput(e,l,18))&&(t.defines.USE_CLEARCOAT="");break;case"PHY_SUN_SKY_ENV_MX":const ee=15*u.haze+2,te=new Spherical;N=Math.PI/2-u.sunPolarAngle;const ne=Math.PI-u.sunAzimuthAngle;te.phi=N,te.theta=ne;const re=(new Vector3).setFromSpherical(te).toArray();F=PreethamSkyModelUtils.getDistParams(ee,0),O=PreethamSkyModelUtils.getDistParams(ee,1),V=PreethamSkyModelUtils.getDistParams(ee,2),U=PreethamSkyModelUtils.getZenithParams(ee,N,0),G=PreethamSkyModelUtils.getZenithParams(ee,N,1),k=PreethamSkyModelUtils.getZenithParams(ee,N,2),U/=.06,U*=1e3,c.params.push(b([F[0],O[0],V[0]])),c.params.push(b([F[1],O[1],V[1]])),c.params.push(b([F[2],O[2],V[2]])),c.params.push(b([F[3],O[3],V[3]])),c.params.push(b([F[4],O[4],V[4]])),c.params.push(b([U,G,k]));const oe=PreethamSkyModelUtils.getSunIlluminance(re,ee),ie=[0,0,0];c.params.push(b(re)),c.params.push(b(oe)),c.params.push(b(ie)),c.params.push(b(u.globalIntensity/MAX_LIGHT_INT_MULT)),c.params.push(b(u.groundColor));break;case"REFLECT_REFRACT_COLOR_MX":R=u.outputs[0],c.params.push(b(R));break;case"VERTEX_COLOR_MX":h="color",p=T(h,3),c.attributes.push({name:h,type:"attribute vec3"}),c.params.push(p);break;case"BUMP_2D_MY":c.params.push(E("vNormal")),u.bumpInterp>0&&(h="tangent",p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"COLOR_COMPOSITE_MY":case"COLOR_LOGIC_MY":case"COLOR_MATH_MY":case"CONDITION_MY":case"FLOAT_COMPOSITE_MY":case"FLOAT_LOGIC_MY":case"FLOAT_MATH_MY":case"MULTIPLY_DIVIDE_MY":c.params.push(E(u.operation));break;case"COLOR_CORRECT_MY":c.params.push(M(u.colClamp)),c.params.push(b(u.colClampMin)),c.params.push(b(u.colClampMax)),c.params.push(M(u.alphaClamp)),c.params.push(b(u.alphaClampMin)),c.params.push(b(u.alphaClampMax)),c.params.push(M(u.unpremultiplyInput)),c.params.push(M(u.premultiplyResult));break;case"COLOR_MASK_MY":c.params.push(M(u.maskAlphaIsLuminance));break;case"COMPOSE_MATRIX_MY":c.params.push(M(u.useEulerRotation)),c.params.push(E(u.inputRotateOrder));break;case"FILE_MY":case"ENV_SPHERE_MY":if(R=C("FILE_MY",u.texture),c.params.push(R),c.params.push(E(v(t.nodeTextures[R.name]))),"ENV_SPHERE_MY"==d)c.params.push(E("normal"));else{const t=!1===u.fileHasAlpha;c.params.push(M(t&&isConnOutput(e,l,0)))}break;case"RAMP_MY":t.useFloatTex?(m=new Float32Array(2048),A=1):(m=new Uint8Array(2048),A=255);for(let e=0;e<512;e++){let t,n,r,o;t=A*u.rampData[3*e],n=A*u.rampData[3*e+1],r=A*u.rampData[3*e+2],o=1,m[4*e]=clamp(t,0,A),m[4*e+1]=clamp(n,0,A),m[4*e+2]=clamp(r,0,A),m[4*e+3]=clamp(o,0,A)}y=_(m,512,RGBAFormat,t.useFloatTex?FloatType:UnsignedByteType),y.wrapS=u.wrapS,y.wrapT=u.wrapT,L=MeshNodeMaterial.nodeTexUniName(d,n),t.nodeTextures[L]=y,c.params.push(C(d,n)),n++,c.params.push(E(B("int",u.rampType)));break;case"SAMPLER_INFO_MY":c.params.push(E("faceDirection")),h="tangent",p=T(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),h="uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"UNIT_CONVERSION_MY":c.params.push(b(u.conversionFactor));break;case"VECTOR_PRODUCT_MY":c.params.push(E(u.operation)),c.params.push(M(u.normalizeOutput));break;case"OSL_NODE":isDef(u.texture)&&(f=C(d,u.texture),c.params.push(f));const ae=u.globalVariables||[];ae.indexOf("P")>-1&&c.params.push(E("oslGetP(vViewPosition)")),ae.indexOf("I")>-1&&c.params.push(E("oslGetI(vViewPosition)")),ae.indexOf("N")>-1&&c.params.push(E("oslGetN(normal)")),(ae.indexOf("u")>-1||ae.indexOf("v")>-1)&&(h="uv",c.attributes.push({name:h,type:"attribute vec2"}),ae.indexOf("u")>-1&&c.params.push(T(h+"_u",1,h+".x")),ae.indexOf("v")>-1&&c.params.push(T(h+"_v",1,"1.0 - "+h+".y")));break;case"RGB_ALPHA":R=(new Vector4).fromArray(u.outputs[0].concat([u.outputs[1]])),t.nodeRGB.push(R),t.nodeRGBMap[u.name]=r,c.params.push(E("nodeRGB["+r+"]")),r++;break;case"U_FLOAT":h="uv",p=T(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)}}var s;for(let t=0;t");for(let t=0;tJSON.parse(JSON.stringify(e)),u=c;e.insert(s,l.inputs,l.outputs,c,u);const d=l.removedNodes.sort((function(e,t){return t-e}));for(let t=0;t0||isConnInput(e,t,14))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,0,t,23)}if("BSDF_PRINCIPLED_BL"==o&&!isConnInput(e,t,21)&&(n.inputs[17]>0||isConnInput(e,t,17))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,0,t,21)}if("EEVEE_SPECULAR_BL"==o&&!isConnInput(e,t,8)&&(n.inputs[6]>0||isConnInput(e,t,6))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,0,t,8)}if("OSL_NODE"==o){const r=n.initializers;for(let i=0;i0||isConnInput(e,t,15))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,0,t,25)}if("MIX_BL"==o&&n.outputs.length>1){const r=[-1,-1,-1,-1,-1,-1,-1],o=[-1,-1,-1];switch(n.dataType){case"RGBA":n.inputs=[n.inputs[0],n.inputs[6],n.inputs[7]],r[0]=0,r[6]=1,r[7]=2,n.outputs=[n.outputs[2]],o[2]=0;break;case"VECTOR":n.inputs=[n.inputs[0],n.inputs[1],n.inputs[4],n.inputs[5]],r[0]=0,r[1]=1,r[4]=2,r[5]=3,n.outputs=[n.outputs[1]],o[1]=0;break;case"FLOAT":n.inputs=[n.inputs[0],n.inputs[2],n.inputs[3]],r[0]=0,r[2]=1,r[3]=2,n.outputs=[n.outputs[0]],o[0]=0}const i=e.findInEdges(t);for(let e=0;e=0;e--){const n=t.connections[e];r[n.to]>-1?n.to=r[n.to]:t.connections.splice(e,1)}}const a=e.findOutEdges(t);for(let e=0;e=0;e--){const n=t.connections[e];o[n.from]>-1?n.from=o[n.from]:t.connections.splice(e,1)}}}if("BUMP_2D_MY"==r&&n.bumpInterp>0){n.inputs[1]=[0,0,0];const r=e.findInEdges(t);for(let t=0;t=0){const n=findConnectedNode(e,t,0);if(!n||"BACKGROUND_BL"!=n.originData.type)return null;if(0==e.findInEdges(e.nodeIndex(n)).length)return(new Color).fromArray(n.originData.inputs[0]).multiplyScalar(n.originData.inputs[1]);if(isConnInput(e,e.nodeIndex(n),1))return null;const r=findConnectedNode(e,e.nodeIndex(n),0);if(!r||("MIX_BL"!=r.originData.type||"RGBA"!=r.originData.dataType)&&"MIX_RGB_BL"!=r.originData.type||"MIX"!=r.originData.blendType)return null;const o=findConnectedNode(e,e.nodeIndex(r),0);return o&&"LIGHT_PATH_BL"==o.originData.type?isConnInput(e,e.nodeIndex(r),2)?null:isConnOutput(e,e.nodeIndex(o),0)?(new Color).fromArray(r.originData.inputs[2]):null:null}if(t=firstNodeType(e,"OUTPUT_MX"),t>=0&&0==e.findInEdges(t).length)return(new Color).fromArray(e.node(t).originData.inputs[0]);if(t=firstNodeType(e,"SKYDOME_LIGHT_AR"),t>=0){if(0==e.findInEdges(t).length){const n=e.node(t);return(new Color).fromArray(n.originData.inputs[0]).multiplyScalar(n.originData.inputs[1])}const n=findConnectedNode(e,t,0);if(!n||"RAY_SWITCH_AR"!=n.originData.type)return null;if(0==e.findInEdges(e.nodeIndex(n)).length)return(new Color).fromArray(n.originData.inputs[0])}return null}useAddTransparency(){const e=this.nodeGraph,t=firstNodeType(e,"OUTPUT_MATERIAL_BL");if(t>=0){const n=findConnectedNode(e,t,0);if(n&&"ADD_SHADER_BL"==n.originData.type){const t=findConnectedNode(e,e.nodeIndex(n),0),r=findConnectedNode(e,e.nodeIndex(n),1);if(t&&r&&("BSDF_TRANSPARENT_BL"==t.originData.type||"BSDF_TRANSPARENT_BL"==r.originData.type))return!0}}return!1}copy(e){super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=UniformsUtils.clone(e.uniforms),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this.color.copy(e.color),this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.envMapParallaxType=e.envMapParallaxType,this.envMapParallaxMatrix.copy(e.envMapParallaxMatrix),this.envMapParallaxMatrixInv.copy(e.envMapParallaxMatrixInv),this.materialIndex=e.materialIndex,this.profile=e.profile,this.nodeTextures=e.nodeTextures,this.nodeRGB=e.nodeRGB.slice(),this.nodeRGBMap=Object.assign({},e.nodeRGBMap),this.nodeRGBArr=e.nodeRGBArr.slice(),this.nodeTexCoordObject=e.nodeTexCoordObject.slice(),this.nodeTexCoordObjectMap=Object.assign({},e.nodeTexCoordObjectMap),this.nodeTexCoordObjectArr=e.nodeTexCoordObjectArr.slice(),this.nodeValue=e.nodeValue.slice(),this.nodeValueMap=Object.assign({},e.nodeValueMap),this.needsBoundingBox=e.needsBoundingBox,this.useFloatTex=e.useFloatTex,this.nodeGraph=new DiGraph(e.nodeGraph.len());for(let t=0;t{if(0===e.times.length)return;const t=[Math.max(n/o,e.times[0]),Math.min(r/o,e.times[e.times.length-1])];if(t[0]>t[1])return;const i=e.times.findIndex((e=>e>=t[0])),s=e.times.findLastIndex((e=>e<=t[1])),l=e.getValueSize();let c=[],u=isTypedArray(e.times)?e.times.subarray(i,s+1):e.times.slice(i,s+1),d=[],h=[],p=isTypedArray(e.values)?e.values.subarray(i*l,(s+1)*l):e.values.slice(i*l,(s+1)*l),f=[];const m=i>s;let g,_;(m||t[0]e.times[s])&&(d=[t[1]],f=e.createInterpolant().evaluate(d[0])),isTypedArray(e.times)?(g=new e.times.constructor(c.length+u.length+d.length),g.set(c),g.set(u,c.length),g.set(d,c.length+u.length)):g=c.concat(u,d),isTypedArray(e.values)?(_=new e.values.constructor(h.length+p.length+f.length),_.set(h),_.set(p,h.length),_.set(f,h.length+p.length)):_=h.concat(p,f),e.times=g,e.values=_,a.push(e)}));const s=a.reduce(((e,t)=>Math.min(e,t.times[0])),1/0);return a.forEach((e=>e.shift(-s))),i.tracks=a,i.resetDuration(),i}function makeClipAdditive(e,t=0,n=e,r=30){r<=0&&(r=30);const o=n.tracks.length,i=t/r;for(let t=0;t=r.times[d]){const e=d*l+s,t=e+l-s;h=arraySlice(r.values,e,t)}else{const e=r.createInterpolant(),t=s,n=l-s;e.evaluate(i),h=arraySlice(e.resultBuffer,t,n)}if("quaternion"===o){(new Quaternion).fromArray(h).normalize().conjugate().toArray(h)}const p=a.times.length;for(let e=0;et;)--i;if(++i,0!==o||i!==r){o>=i&&(i=Math.max(i,1),o=i-1);const e=this.getValueSize();this.times=arraySlice(n,o,i),this.values=arraySlice(this.values,o*e,i*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("v3d.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,o=n.length;0===o&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);let i=null;for(let t=0;t!==o;t++){const r=n[t];if("number"==typeof r&&isNaN(r)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==i&&i>r){console.error("v3d.KeyframeTrack: Out of order keys.",this,t,r,i),e=!1;break}i=r}if(void 0!==r&&isTypedArray(r))for(let t=0,n=r.length;t!==n;++t){const n=r[t];if(isNaN(n)){console.error("v3d.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=arraySlice(this.times),t=arraySlice(this.values),n=this.getValueSize(),r=2302===this.getInterpolation(),o=e.length-1;let i=1;for(let a=1;a0){e[i]=e[o];for(let e=o*n,r=i*n,a=0;a!==n;++a)t[r+a]=t[e+a];++i}return i!==e.length?(this.times=arraySlice(e,0,i),this.values=arraySlice(t,0,i*n)):(this.times=e,this.values=t),this}clone(){const e=arraySlice(this.times,0),t=arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=2301;class BooleanKeyframeTrack extends KeyframeTrack{}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=2300,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,i=this.sampleValues,a=this.valueSize,s=(n-t)/(r-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Quaternion.slerpFlat(o,0,i,l-a,i,l,s);return o}}class QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",QuaternionKeyframeTrack.prototype.DefaultInterpolation=2301,QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=2300,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class VectorKeyframeTrack extends KeyframeTrack{}VectorKeyframeTrack.prototype.ValueTypeName="vector";class AnimationClip{constructor(e,t=-1,n,r=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,o=n.length;e!==o;++e)t.push(parseKeyframeTrack(n[e]).scale(r));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(KeyframeTrack.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const o=t.length,i=[];for(let e=0;e1){const e=i[1];let t=r[e];t||(r[e]=t=[]),t.push(n)}}const i=[];for(const e in r)i.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return i}static parseAnimation(e,t){if(!e)return console.error("v3d.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,o){if(0!==n.length){const i=[],a=[];flattenJSON(n,i,a,r),0!==i.length&&o.push(new e(t,i,a))}},r=[],o=e.name||"default",i=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(o),this.manager.itemEnd(e)}),0),o;if(void 0!==loading[e])return void loading[e].push({onLoad:t,onProgress:n,onError:r});loading[e]=[],loading[e].push({onLoad:t,onProgress:n,onError:r});const i=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,s=this.responseType;fetch(i).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("v3d.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=loading[e],r=t.body.getReader(),o=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),i=o?parseInt(o):0,a=0!==i;let s=0;const l=new ReadableStream({start(e){!function t(){r.read().then((({done:r,value:o})=>{if(r)e.close();else{s+=o.byteLength;const r=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:i});for(let e=0,t=n.length;e{switch(s){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,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{Cache.add(e,t);const n=loading[e];delete loading[e];for(let e=0,r=n.length;e{const n=loading[e];if(void 0===n)throw this.manager.itemError(e),t;delete loading[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class AnimationLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){const o=this,i=new FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(function(n){try{t(o.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),n,r)}parse(e){const t=[];for(let n=0;nt.length;)t.push(new CSMFrustum);t.length=e.length;for(let r=0;rthis.numCascades;)e.pop().dispose();for(let t=e.length;tl.distanceTo(a[2])?s[2]:a[2];let u=l.distanceTo(c);if(this.fade>0){const t=Math.min(e.far,this.maxDistance),n=e.near,r=i.vertices.far[0].z/(t-n);u+=this.fade*Math.pow(r,2)*(t-n)}o.left=-u/2,o.right=u/2,o.top=u/2,o.bottom=-u/2,o.near=0,o.far=u+this.lightMargin,o.updateProjectionMatrix(),r.bias=this.bias,r.normalBias=this.normalBias,r.esmBlurRadius=r.radius/((o.right-o.left)/2)}}getBreaks(e){const t=e.near,n=Math.min(e.far,this.maxDistance),r=this.numCascades,o=this.exponent,i=this._breaks;i.length=0,this.customSplitsCallback?this.customSplitsCallback(r,t,n,i,o):function(e,t,n,r,o){_uniformArray.length=0,_logArray.length=0,function(e,t,n,r){for(let o=1;o0:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const o=e.uniforms[t];switch(r.uniforms[t]={},o.type){case"t":r.uniforms[t].value=n(o.value);break;case"c":r.uniforms[t].value=(new Color).setHex(o.value);break;case"v2":r.uniforms[t].value=(new Vector2).fromArray(o.value);break;case"v3":r.uniforms[t].value=(new Vector3).fromArray(o.value);break;case"v4":r.uniforms[t].value=(new Vector4).fromArray(o.value);break;case"m3":r.uniforms[t].value=(new Matrix3).fromArray(o.value);break;case"m4":r.uniforms[t].value=(new Matrix4).fromArray(o.value);break;default:r.uniforms[t].value=o.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(r.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)r.extensions[t]=e.extensions[t];if(void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=n(e.map)),void 0!==e.matcap&&(r.matcap=n(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),r.normalScale=(new Vector2).fromArray(t)}return void 0!==e.displacementMap&&(r.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(r.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(r.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(r.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new Vector2).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(r.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(r.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(r.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(r.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:ShadowMaterial,SpriteMaterial:SpriteMaterial,RawShaderMaterial:RawShaderMaterial,ShaderMaterial:ShaderMaterial,PointsMaterial:PointsMaterial$1,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshToonMaterial:MeshToonMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshBasicMaterial:MeshBasicMaterial,MeshMatcapMaterial:MeshMatcapMaterial,LineDashedMaterial:LineDashedMaterial,LineBasicMaterial:LineBasicMaterial$1,Material:Material}[e]}}class LoaderUtils{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,r=e.length;n0){const n=new LoadingManager(t);o=new ImageLoader(n),o.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){r=new ImageLoader(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,o=t+t;e!==o;++e)if(n[e]!==n[e+t]){a.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,o=r;e!==o;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==o;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){Quaternion.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,o){const i=this._workIndex*o;Quaternion.multiplyQuaternionsFlat(e,i,e,t,e,n),Quaternion.slerpFlat(e,t,e,t,e,i,r)}_lerp(e,t,n,r,o){const i=1-r;for(let a=0;a!==o;++a){const o=t+a;e[o]=e[o]*i+e[n+a]*r}}_lerpAdditive(e,t,n,r,o){for(let i=0;i!==o;++i){const o=t+i;e[o]=e[o]+e[n+i]*r}}}const _RESERVED_CHARS_RE="\\[\\]\\.",_reservedRe=new RegExp("[\\[\\]\\.]","g"),_wordChar="[^\\[\\]\\.]",_wordCharOrDot="[^"+"\\[\\]\\.".replace("\\.","")+"]";/((?:WC+[\/:])*)/.source.replace("WC",_wordChar);const _nodeRe=/(WCOD+)?/.source.replace("WCOD",_wordCharOrDot),_objectRe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",_wordChar),_propertyRe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",_wordChar),_trackRe=new RegExp("^"+_nodeRe+_objectRe+_propertyRe+"$"),_supportedObjectNames=["material","materials","bones","map"];class Composite{constructor(e,t,n){const r=n||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class PropertyBinding{constructor(e,t,n){this.path=t,this.parsedPath=n||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,n):new PropertyBinding(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_reservedRe,"")}static parseTrackName(e){const t=_trackRe.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[1],objectName:t[2],objectIndex:t[3],propertyName:t[4],propertyIndex:t[5]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==_supportedObjectNames.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),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 r=0;r=o){const i=o++,c=e[i];t[c.uuid]=l,e[l]=c,t[s]=i,e[i]=a;for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[i],o=t[l];t[l]=r,t[i]=o}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let o=this.nCachedObjects_,i=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e];t[l]=t[o],t.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const o=this._bindings;if(void 0!==r)return o[r];const i=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);r=o.length,n[e]=r,i.push(e),a.push(t),o.push(u);for(let n=c,r=s.length;n!==r;++n){const r=s[n];u[n]=new PropertyBinding(r,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const r=this._paths,o=this._parsedPaths,i=this._bindings,a=i.length-1,s=i[a];t[e[a]]=n,i[n]=s,i.pop(),o[n]=o[a],o.pop(),r[n]=r[a],r.pop()}}}class AnimationAction{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const o=t.tracks,i=o.length,a=new Array(i),s={endingStart:2400,endingEnd:2400};for(let e=0;e!==i;++e){const t=o[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._pingIsEven=!0,this._startTime=null,this.time=0,this.timeStart=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this._pingIsEven=!0,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,r=e._clip.duration,o=r/n,i=n/r;e.warp(1,o,t),this.warp(i,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,o=r.time,i=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=o,s[1]=o+n,l[0]=e/i,l[1]=t/i,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled)return void this._updateWeight(e);const o=this._startTime;if(null!==o){const r=(e-o)*n;if(r<0||0===n)return;this._startTime=null,t=n*r}t*=this._updateTimeScale(e);const i=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===AdditiveAnimationBlendMode)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(i),t[n].accumulateAdditive(a);else for(let n=0,o=e.length;n!==o;++n)e[n].evaluate(i),t[n].accumulate(r,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_loopIsPing(e){if(2202!==this.loop)return!0;if(-1==e)return!0;return 0==(1&e)===this._pingIsEven}_updateTime(e){if(0===e)return this.time;if(2200!==this.loop&&this.repetitions<=0)return this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1}),this.time;var t=this.timeStart,n=Math.max(t,this._clip.duration),r=n-t;if(2200===this.loop)return this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.timen)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var o=2202===this.loop,i=this._loopIsPing(this._loopCount)?1:-1;this.time+=i*e;var a=this.timen,s=!1;if(-1===this._loopCount&&(s=a,this._loopCount=s?-1:0,this._pingIsEven=!s,e>=0?this._setEndings(!0,0===this.repetitions,o):this._setEndings(0===this.repetitions,!0,o)),a){var l=Math.floor((this.time-t)/r);this._loopCount+=Math.abs(l);var c=this.repetitions-this._loopCount;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1});else{if(1==c){var u=e<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);var d=(this.time-t)%r;d<0&&(d+=r),this.time=o?n-d:d+t,s||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}return this.time}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=e?this.zeroSlopeAtStart?2401:2400:2402,r.endingEnd=t?this.zeroSlopeAtEnd?2401:2400:2402)}_scheduleFading(e,t,n){const r=this._mixer,o=r.time;let i=this._weightInterpolant;null===i&&(i=r._lendControlInterpolant(),this._weightInterpolant=i);const a=i.parameterPositions,s=i.sampleValues;return a[0]=o,s[0]=t,a[1]=o+e,s[1]=n,this}}const _controlInterpolantsResultBuffer=new Float32Array(1);class AnimationMixer extends EventDispatcher{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,o=r.length,i=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==o;++e){const o=r[e],l=o.name;let u=c[l];if(void 0!==u)++u.referenceCount,i[e]=u;else{if(u=i[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const r=t&&t._propertyBindings[e].binding.parsedPath;u=new PropertyMixer(PropertyBinding.create(n,l,r),o.ValueTypeName,o.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,l),i[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,o=Math.sign(e),i=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(r,e,o,i)}const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(i);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}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}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))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$4.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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 _startP=new Vector3,_startEnd=new Vector3;class Line3{constructor(e=new Vector3,t=new Vector3){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){_startP.subVectors(e,this.start),_startEnd.subVectors(this.end,this.start);const n=_startEnd.dot(_startEnd);let r=_startEnd.dot(_startP)/n;return t&&(r=clamp(r,0,1)),r}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const _vector$3=new Vector3;class SpotLightHelper extends Object3D{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new BufferGeometry,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e1)for(let n=0;n{e.visible=n}))}r.visible=e}update(){const e=this.csm,t=e._sceneViewCamera;if(!t||e._needsUpdate)return;const n=e._cascades,r=n.length,o=e.mainFrustum,i=e._frustums,a=this.frustumLines.geometry.getAttribute("position"),s=this.cascadeLines,l=this.cascadePlanes,c=this.shadowLines;for(this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.updateMatrixWorld(!0);s.length>r;){this.remove(s.pop()),this.remove(l.pop());const e=c.pop();e.children[0].dispose(),this.remove(e)}for(;s.length.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{_axis.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(_axis,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class AxesHelper extends LineSegments{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new BufferGeometry;n.setAttribute("position",new Float32BufferAttribute(t,3)),n.setAttribute("color",new Float32BufferAttribute([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new LineBasicMaterial$1({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new Color,o=this.geometry.attributes.color.array;return r.set(e),r.toArray(o,0),r.toArray(o,3),r.set(t),r.toArray(o,6),r.toArray(o,9),r.set(n),r.toArray(o,12),r.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ShapePath{constructor(){this.type="ShapePath",this.color=new Color,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,o,i){return this.currentPath.bezierCurveTo(e,t,n,r,o,i),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let o=n-1,i=0;iNumber.EPSILON){if(l<0&&(n=t[i],s=-s,a=t[o],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return r}const n=ShapeUtils.isClockWise,r=this.subPaths;if(0===r.length)return[];let o,i,a;const s=[];if(1===r.length)return i=r[0],a=new Shape,a.curves=i.curves,s.push(a),s;let l=!n(r[0].getPoints());l=e?!l:l;const c=[],u=[];let d,h,p=[],f=0;u[f]=void 0,p[f]=[];for(let t=0,a=r.length;t1){let e=!1,n=0;for(let e=0,t=u.length;e0&&!1===e&&(p=c)}for(let e=0,t=u.length;e>-t-14,r[256|e]=1024>>-t-14|32768,o[e]=-t-1,o[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,o[e]=13,o[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,o[e]=24,o[256|e]=24):(r[e]=31744,r[256|e]=64512,o[e]=13,o[256|e]=13)}const i=new Uint32Array(2048),a=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,i[e]=t|n}for(let e=1024;e<2048;++e)i[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:o,mantissaTable:i,exponentTable:a,offsetTable:s}}function toHalfFloat(e){Math.abs(e)>65504&&console.warn("v3d.DataUtils.toHalfFloat(): Value out of range."),e=clamp(e,-65504,65504),_tables.floatView[0]=e;const t=_tables.uint32View[0],n=t>>23&511;return _tables.baseTable[n]+((8388607&t)>>_tables.shiftTable[n])}function fromHalfFloat(e){const t=e>>10;return _tables.uint32View[0]=_tables.mantissaTable[_tables.offsetTable[t]+(1023&e)]+_tables.exponentTable[t],_tables.floatView[0]}var DataUtils=Object.freeze({__proto__:null,fromHalfFloat:fromHalfFloat,toHalfFloat:toHalfFloat});class AfterimagePass extends Pass{constructor(e,t,n){super(),this.damp=t,this.shader=ShaderLib.afterimage,this.uniforms=UniformsUtils.clone(this.shader.uniforms),this.uniforms.damp.value=this.damp,this.textureComp=new WebGLRenderTarget(e.x,e.y,n),this.textureOld=new WebGLRenderTarget(e.x,e.y,n),this.shaderMaterial=new ShaderMaterial({uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.compFsQuad=new FullScreenQuad(this.shaderMaterial);const r=new MeshBasicMaterial;this.copyFsQuad=new FullScreenQuad(r)}dispose(){this.textureComp.dispose(),this.textureOld.dispose()}render(e,t,n){this.uniforms.tOld.value=this.textureOld.texture,this.uniforms.tNew.value=n.texture,this.uniforms.damp.value=this.damp,e.setRenderTarget(this.textureComp),this.compFsQuad.render(e),this.copyFsQuad.material.map=this.textureComp.texture,this.renderToScreen?(e.setRenderTarget(null),this.copyFsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.copyFsQuad.render(e));const r=this.textureOld;this.textureOld=this.textureComp,this.textureComp=r}setSize(e,t){this.textureComp.setSize(e,t),this.textureOld.setSize(e,t)}}class BloomPass extends Pass{constructor(e,t,n,r,o){super(),this.strength=void 0!==t?t:1,this.radius=clamp(n),this.threshold=r,this.resolution=void 0!==e?new Vector2(e.x,e.y):new Vector2(256,256),o=o||{minFilter:LinearFilter,magFilter:LinearFilter,format:RGBAFormat},this.clearColor=new Color(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new WebGLRenderTarget(i,a,o),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e65535?Uint32Array:Uint16Array;this.geometry.setIndex(new BufferAttribute(new m(p),1))}}}()});class MeshLineMaterial extends RawShaderMaterial{constructor(e){super(),this.type="MeshLineMaterial",this.lineWidth=1,this.sizeAttenuation=1,this.color=new Color(16777215),this.opacity=1,this.useMap=0,this.map=null,this.useAlphaMap=0,this.alphaMap=null,this.visibility=1,this.alphaTest=0,this.repeat=new Vector2(1,1),this.uniforms={lineWidth:{value:1},sizeAttenuation:{value:1},color:{value:new Color(16777215)},opacity:{value:1},useMap:{value:0},map:{value:null},alphaMap:{value:null},useAlphaMap:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new Vector2(1,1)}},this.vertexShader=ShaderChunk.raw_meshline_vert,this.fragmentShader=ShaderChunk.raw_meshline_frag,this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.sizeAttenuation=e.sizeAttenuation,this.color.copy(e.color),this.opacity=e.opacity,this.useMap=e.useMap,this.map=e.map,this.useAlphaMap=e.useAlphaMap,this.alphaMap=e.alphaMap,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}MeshLineMaterial.prototype.isMeshLineMaterial=!0;class OutlinePass extends Pass{constructor(e,t,n,r){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new Vector4(1,1,1,1),this.hiddenEdgeColor=new Vector4(.1,.04,.02,1),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this.renderToScreen=!1,this.resolution=void 0!==e?new Vector2(e.x,e.y):new Vector2(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),i=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new WebGLRenderTarget(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.renderTargetDepthBuffer=new WebGLRenderTarget(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new WebGLRenderTarget(o,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new WebGLRenderTarget(o,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new WebGLRenderTarget(Math.round(o/2),Math.round(i/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new WebGLRenderTarget(o,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new WebGLRenderTarget(Math.round(o/2),Math.round(i/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeparableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new Vector2(o,i),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new Vector2(Math.round(o/2),Math.round(i/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial();const a=ShaderLib.copy;this.copyUniforms=UniformsUtils.clone(a.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ShaderMaterial({defines:Object.assign({},a.defines),uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,blending:NoBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Color,this.oldClearAlpha=1,this.basic=new MeshBasicMaterial({toneMapped:!1}),this.fsQuad=new FullScreenQuad(null),this.camera=new OrthographicCamera(-1,1,1,-1,0,1),this.tempPulseColor1=new Vector4,this.tempPulseColor2=new Vector4,this.textureMatrix=new Matrix4,this.visibilityState=new WeakMap,this._depthMaterial=new MeshDepthMaterial({blending:NoBlending,depthPacking:RGBADepthPacking,side:DoubleSide}),this._maskMaterial=new MeshMaskMaterial({side:DoubleSide})}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t);let n=Math.round(e/this.downSampleRatio),r=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,r),this.renderTargetBlurBuffer1.setSize(n,r),this.renderTargetEdgeBuffer1.setSize(n,r),this.separableBlurMaterial1.uniforms.texSize.value=new Vector2(n,r),n=Math.round(n/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(n,r),this.renderTargetEdgeBuffer2.setSize(n,r),this.separableBlurMaterial2.uniforms.texSize.value=new Vector2(n,r)}saveVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof Mesh&&e.visibilityState.set(t,t.visible)}))}restoreVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof Mesh&&(t.visible=e.visibilityState.get(t))}))}changeVisibilityOfSelectedObjects(e){const t=this;function n(n){n instanceof Mesh&&t.visibilityState.get(n)&&(n.visible=e)}for(let e=0;e0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new Vector2(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=OutlinePass.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=OutlinePass.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=OutlinePass.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=OutlinePass.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,o&&e.context.enable(e.context.STENCIL_TEST),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=i,this.renderScene.traverse((function(e){e.isAnnotationControl&&(e.doUpdate=e._doUpdateSave)}))}getEdgeDetectionMaterial(){return new ShaderMaterial({type:"OutlineEdgeDetection",defines:{HIDDEN_EDGE_ALPHA:1},uniforms:{maskTexture:{value:null},texSize:{value:new Vector2(.5,.5)},visibleEdgeColor:{value:new Vector4(1,1,1,1)},hiddenEdgeColor:{value:new Vector4(1,1,1,1)}},vertexShader:ShaderChunk.pp_plane_vert,fragmentShader:ShaderChunk.pp_outline_edge_frag})}getSeparableBlurMaterial(e){return new ShaderMaterial({type:"OutlineSeparableBlur",defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Vector2(.5,.5)},direction:{value:new Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:ShaderChunk.pp_plane_vert,fragmentShader:ShaderChunk.pp_outline_blur_frag})}getOverlayMaterial(){return new ShaderMaterial({type:"OutlineOverlay",uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:ShaderChunk.pp_plane_vert,fragmentShader:ShaderChunk.pp_outline_overlay_frag,blending:CustomBlending,blendEquation:AddEquation,blendEquationAlpha:AddEquation,blendSrc:SrcAlphaFactor,blendDst:OneMinusSrcAlphaFactor,blendSrcAlpha:OneFactor,blendDstAlpha:OneFactor,depthTest:!1,depthWrite:!1,transparent:!0})}setCamera(e){this.renderCamera=e}}OutlinePass.BlurDirectionX=new Vector2(1,0),OutlinePass.BlurDirectionY=new Vector2(0,1);class RenderPass extends Pass{constructor(e,t,n,r,o){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==o?o:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Color}render(e,t,n){const r=e.autoClear;let o,i;e.autoClear=!1,void 0!==this.overrideMaterial&&(i=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),o=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,o),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=i),e.autoClear=r}setCamera(e){this.camera=e}}const FRAMES_TIME_THRESHOLD=4;class SSAARenderPass extends Pass{constructor(e,t,n,r){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==r?r:0,this._oldClearColor=new Color;const o=ShaderLib.copy;this.copyUniformsAccum=UniformsUtils.clone(o.uniforms),this.copyMaterialAccum=new ShaderMaterial({type:"SSAACopyAccum",defines:Object.assign({},o.defines),uniforms:this.copyUniformsAccum,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:AdditiveBlending,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new FullScreenQuad(this.copyMaterialAccum),this.copyUniformsFinal=UniformsUtils.clone(o.uniforms),this.copyMaterialFinal=new ShaderMaterial({type:"SSAACopyFinal",defines:Object.assign({},o.defines),uniforms:this.copyUniformsFinal,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:NoBlending,depthTest:!1,depthWrite:!1}),this.fsQuadFinal=new FullScreenQuad(this.copyMaterialFinal),this.iterative=!1,this.iterativeFrame=0}_getJitterOffsets(){return _JitterVectors[Math.max(0,Math.min(this.sampleLevel,5))]}_isLastIterativeFrame(){const e=this._getJitterOffsets();return this.iterativeFrame==e.length-1}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null,this.accumRenderTarget.dispose(),this.accumRenderTarget=null)}setSize(e,t){this.sampleRenderTarget&&(this.sampleRenderTarget.setSize(e,t),this.accumRenderTarget.setSize(e,t))}render(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=n.clone(),this.sampleRenderTarget.texture.name="SSAARenderPass.sample",this.accumRenderTarget=n.clone(),this.accumRenderTarget.texture.name="SSAARenderPass.accum");const r=this._getJitterOffsets(),o=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);const i=e.getClearAlpha(),a=1/r.length;this.copyUniformsAccum.tDiffuse.value=this.sampleRenderTarget.texture;const s=n.width,l=n.height,c=this.camera.view?this.camera.view.offsetX:0,u=this.camera.view?this.camera.view.offsetY:0;let d,h;this.iterative?(d=this.iterativeFrame,h=performance.now()):d=0;const p=r.length;for(let n=d;n4)break}this.iterative&&(this._isLastIterativeFrame()?(this.copyUniformsFinal.tDiffuse.value=this.accumRenderTarget.texture,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuadFinal.render(e),this.iterativeFrame=0):this.iterativeFrame++),this.camera.setViewOffset&&this.camera.setViewOffset(s,l,c,u,s,l),e.autoClear=o,e.setClearColor(this._oldClearColor,i)}isLastIterativeFrame(){console.error("isLastIterativeFrame() deprectated, use pass event listener instead")}setCamera(e){this.camera=e}}const _JitterVectors=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],REFLECT_OBJ_LAYER=3,REFLECT_OBJ_AFTER_LAYER=4,REFRACT_OBJ_LAYER=5,REFRACT_OBJ_AFTER_LAYER=6;class SSRPass extends Pass{constructor(e,t,n){super(),this.enabled=!0,this.needsSwap=!1,n=n||{},this.objects=n.objects||[],this.steps=isDef(n.steps)||10,this.stride=isDef(n.stride)||30,this.binarySearchSteps=isDef(n.binarySearchSteps)||4,this.renderTargetScale=isDef(n.renderTargetScale)||.5,this.thickness=isDef(n.thickness)||.01,this.maxDistance=isDef(n.maxDistance)||100,this.jitter=isDef(n.jitter)||1,this.useRefract=isDef(n.useRefract)||!1,this.renderAfter=isDef(n.renderAfter)||[],this.simpleRefraction=isDef(n.simpleRefraction)||!1,this.scene=e,this.camera=t,this._prevClearColor=new Color,this._depthBuffer=new WebGLRenderTarget(256,256,{minFilter:NearestFilter,magFilter:NearestFilter,format:RGBAFormat,type:HalfFloatType}),this._depthBuffer.texture.name="SSRPass.Depth",this._depthBuffer.texture.generateMipmaps=!1,this._depthMaterial=new MeshDepthMaterial,this._depthMaterial.depthPacking=3202,this._backfaceDepthBuffer=this._depthBuffer.clone(),this._backfaceDepthBuffer.texture.name="SSRPass.Depth",this._backfaceDepthMaterial=new MeshDepthMaterial,this._backfaceDepthMaterial.depthPacking=3202,this._backfaceDepthMaterial.side=BackSide,this.basic=new MeshBasicMaterial,this.fsQuad=new FullScreenQuad(null)}_setLayer(e,t){e.layers.set(t),e.isMesh&&e.isMaterialGeneratedMesh&&e.parent.layers.enable(t)}dispose(){this._depthBuffer.dispose(),this._backfaceDepthBuffer.dispose();for(let e=0;e${WM_TEXT}`,t.appendChild(r),setTimeout((function(){t.contains(r)&&890310108==hashString(r.textContent)||e.dispose()}),1e3)},isXML:function(e){return null!==e.match(/.*\.xml$/)},isJS:function(e){return null!==e.match(/.*\.js$/)},addToAppList:function(e){const t=getGlobalScope();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))},removeFromAppList:function(e){const t=getGlobalScope();if(t.v3d&&t.v3d.apps){const n=t.v3d.apps.indexOf(e);n>-1&&t.v3d.apps.splice(n,1)}},printPerformanceInfo:function(e,t){t=t||1;const n=e.renderer.info,r=n.autoReset;n.autoReset=!1,n.reset();const o=e.frame;for(let e=0;e1e4);const l=-1!=e._loadSceneURL.indexOf(".xz",e._loadSceneURL.length-3);i("Asset Compression: "+(l?"yes":"no"),0==l);const c=a/t;i("FPS: "+c,c<30);const u=n.render.calls/a;i("Render Calls: "+u,u>1e3);const d=n.render.triangles/a;i("Triangles Rendered: "+d,d>1e6),i("Geometry Buffers: "+n.memory.geometries,n.memory.geometries>200),i("HDR Rendering: "+(e.useHDR?"yes":"no")),i("Order-Independent Transparency: "+(e.renderer.useOIT?"yes":"no"));const h=e.renderer.getDrawingBufferSize(new Vector2);i("Viewport Resolution: "+h.x+"x"+h.y),i(`Pixel Ratio: ${e.renderer.getPixelRatio()} (current) / ${window.devicePixelRatio} (device)`);let p="N/A";switch(e._envIBLMode){case 0:p="PMREM",p+=` ${e._pmremMaxTileSize} px`;break;case 2:p="Light Probe",p+=` ${e._pmremMaxTileSize} px`}i(`Image-Based Lighting: ${p}`);let f=0,m=0,g=0,_=0,v=0,A=0;e.scene.traverse((function(e){e.isLight&&(f++,e.castShadow&&e.shadow&&(_++,v=e.shadow.mapSize.width,A=e.shadow.mapSize.height)),e.isCubeReflectionProbe&&m++,e.isPlaneReflectionProbe&&g++})),i("Lights: "+f,f>10),i(`Reflection Probes: ${m} (cube) / ${g} (plane) `,m>3||g>1);const x=[];if(e.postprocessing){e.postprocessing.gtaoGenerator&&x.push("GTAO");e.postprocessing.composer.passes.forEach((function(e){for(let t in PP_PASSES)if(e instanceof PP_PASSES[t])return void x.push(t);x.push("Undefined")}))}i(`Post-Processing: ${x.length?x.join(","):"N/A"}`);let y="N/A";if(_&&e.renderer.shadowMap&&e.renderer.shadowMap.enabled){switch(e.renderer.shadowMap.type){case BasicShadowMap:y="Basic";break;case BilinearShadowMap:y="Bilinear";break;case PCFShadowMap:y="PCF";break;case PCFSoftShadowMap:y="PCF (Bilinear)";break;case PCFShadowMapPoissonDisk:y="PCF (Poisson Disk)";break;case ESMShadowMap:y="ESM";break;default:y="Unknown"}y+=` ${_}x${v}x${A}`}i("Shadow Map: "+y,_>4||v>2048||A>2048);const b=n.programs.slice(0);i("Materials and Shaders: "+b.length,b>100),b.sort((function(e,t){return t.profile.renderTime-e.profile.renderTime}));let C=0;for(let e=0;e16),C+=r,t.profile.renderTime=0}i("Total Render Time: "+String(Math.round(10*C)/10)+"ms",C>16),i("Textures & Render Buffers: "+n.memory.textures,n.memory.textures>100);const S=Array.from(n.memory.textureSpecs.values());S.sort((function(e,t){return e.typet.type?-1:e.width!=t.width?t.width-e.width:t.height-e.height}));for(let e=0;e=4096||t.height>=4096)}n.autoReset=r}),1e3*t)}},Compat={prepareRenderer:function(e){const t=Detector.getGPUVendor(e),n=Detector.getGPUModel(e),r=Detector.checkAndroid();r&&"ARM"===t&&"Mali-T760"===n&&(e.compatSettings.saturateSpecEnvBlenderApprox=!0),e.compatSettings.gtaoDisableBkgFix=r}};function CubeCopy(e){this.sourceTexture=e,this.camera=new OrthographicCamera(-1,1,1,-1,0,1),this.shader=new ShaderMaterial({type:"CubeCopy",uniforms:{faceIdx:{value:0},cubemap:{value:null}},vertexShader:"\n uniform int faceIdx;\n\n varying vec3 vCubeDirection;\n\n vec3 uvToCubeDirection(vec2 uv, int face) {\n vec3 dir;\n uv = 2.0 * uv - 1.0;\n\n if (face == 0) {\n dir = vec3(1.0, -uv.y, -uv.x);\n } else if (face == 1) {\n dir = vec3(-1.0, -uv.y, uv.x);\n } else if (face == 2) {\n dir = vec3(uv.x, 1.0, uv.y);\n } else if (face == 3) {\n dir = vec3(uv.x, -1.0, -uv.y);\n } else if (face == 4) {\n dir = vec3(uv.x, -uv.y, 1.0);\n } else if (face == 5) {\n dir = vec3(-uv.x, -uv.y, -1.0);\n }\n return dir;\n }\n\n void main() {\n vCubeDirection = uvToCubeDirection(uv, faceIdx);\n gl_Position = vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform samplerCube cubemap;\n\n varying vec3 vCubeDirection;\n\n void main() {\n gl_FragColor = textureCube(cubemap, vCubeDirection);\n\n #include \n\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n }\n "}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new Mesh(new PlaneGeometry(2,2),this.shader),this.scene=new Scene,this.scene.add(this.camera),this.scene.add(this.planeMesh)}CubeCopy.prototype={constructor:CubeCopy,render:function(e,t,n=1){var r=e.toneMapping,o=e.toneMappingExposure,i=e.getRenderTarget();e.toneMapping=LinearToneMapping,e.toneMappingExposure=n;for(var a=0;a<6;a++)e.setRenderTarget(t,a),this.shader.uniforms.faceIdx.value=a,e.render(this.scene,this.camera);e.toneMapping=r,e.toneMappingExposure=o,e.setRenderTarget(i)},dispose:function(){this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};var STD_TEX_PROPERTY_NAMES=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],MaterialUtils={disposeTextures:function(e){if(STD_TEX_PROPERTY_NAMES.forEach((function(t){e[t]&&e[t].isTexture&&e[t].dispose()})),"MeshNodeMaterial"==e.type)for(var t in e.nodeTextures)e.nodeTextures[t]&&e.nodeTextures[t].dispose()}};function _useHalfFloatCubemaps(e){return!!Detector.checkHalfFloatTex(e,!0)&&(!/Firefox/.test(navigator.userAgent)||!/Android/.test(navigator.userAgent))}function renderSceneToCubemap(e,t,n,{camPos:r=new Vector3,clipStart:o=.1,clipEnd:i=100}={}){_useHalfFloatCubemaps(t)||(console.warn("v3d.RenderUtils: disabling half float cubemaps"),n.texture.type=UnsignedByteType);const a=new CubeCamera(o,i,n);a.position.copy(r);let s=e.worldMaterial;if(null!==s&&s.isMeshNodeMaterial){const r=new Mesh(new BoxGeometry(1,1,1),s);r.material.side=BackSide,r.material.defines.WORLD_NODES=1,new CubeCamera(.1,10,n).update(t,r),r.geometry.disposeBoundsTree&&r.geometry.disposeBoundsTree(),r.geometry.dispose();const o=e.background;e.background=null;const i=t.autoClearColor;t.autoClearColor=!1,a.update(t,e),t.autoClearColor=i,e.background=o}else a.update(t,e);return a.renderTarget}function renderWorldNodeMatToCubemap(e,t,n,r){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");const o=new Scene;return o.worldMaterial=t,renderSceneToCubemap(o,e,new WebGLCubeRenderTarget(n,r))}function assignAllLayersMask(e){const t=e.layers.mask;return e.layers.set(0),e.isArrayCamera&&(e.layers.enable(1),e.layers.enable(2)),e.layers.enable(3),e.layers.enable(4),e.layers.enable(5),e.layers.enable(6),e.layers.enable(7),t}var RenderUtils=Object.freeze({__proto__:null,assignAllLayersMask:assignAllLayersMask,renderSceneToCubemap:renderSceneToCubemap,renderWorldNodeMatToCubemap:renderWorldNodeMatToCubemap});const _box=new Box3,_sphere=new Sphere,_matrix4=new Matrix4,_vector3=new Vector3,_vector3_2=new Vector3;class CubeReflectionProbe extends Object3D{constructor(e=256){super(),this.type="CubeReflectionProbe",this.influenceType=1,this.influenceDistance=1,this.parallaxType=1,this.parallaxDistance=1,this.probeClipStart=.1,this.probeClipEnd=100,this.probeIntensity=1,this.visibilityGroup=null,this.visibilityGroupInv=!1,this.influenceGroup=null,this.influenceGroupInv=!1,this._renderTargetCube=new WebGLCubeRenderTarget(e,{encoding:sRGBEncoding$1,format:RGBAFormat,generateMipmaps:!0,minFilter:LinearMipmapLinearFilter,type:HalfFloatType}),this._exposureRenderTargetCube=this._renderTargetCube.clone(),this.renderTarget=null,this.matrixWorldInverse=new Matrix4}setSize(e){this._renderTargetCube.setSize(e,e),this._exposureRenderTargetCube.setSize(e,e)}setEncoding(e){this._renderTargetCube.texture.encoding=e,this._exposureRenderTargetCube.texture.encoding=e}intersectsMesh(e){let t=!1;const n=e.geometry,r=n.boundsTree,o=_matrix4;try{o.copy(e.matrixWorld).invert()}catch(e){return!1}switch(o.multiply(this.matrixWorld),this.influenceType){case 0:t=!0;break;case 1:_sphere.center.setScalar(0),_sphere.radius=this.influenceDistance,_sphere.applyMatrix4(o),r?t=r.intersectsSphere(e,_sphere):(null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsSphere(_sphere));break;case 2:const i=_vector3.setScalar(0),a=_vector3_2.setScalar(2*this.influenceDistance);_box.setFromCenterAndSize(i,a),r?t=r.intersectsBox(e,_box,o):(_box.applyMatrix4(o),null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsBox(_box))}return t}update(e,t){const n={};e.traverse((e=>{!e.isCubeReflectionProbe&&this._isVisible(e)||(n[e.id]=e.layers.mask,e.layers.disableAll())}));const r=e.worldMaterial,o=null!==r&&r.isMeshNodeMaterial&&r.needsLightPathDir();let i;o&&(i=r.defines.LIGHT_PATH_IS_CAM_RAY,r.defines.LIGHT_PATH_IS_CAM_RAY=0),renderSceneToCubemap(e,t,this._renderTargetCube,{camPos:this.position,clipStart:this.probeClipStart,clipEnd:this.probeClipEnd}),this._exposureRenderTargetCube.texture.type=this._renderTargetCube.texture.type;const a=new CubeCopy(this._renderTargetCube.texture);a.render(t,this._exposureRenderTargetCube,this.probeIntensity),a.dispose(),this.renderTarget=this.onUpdate(this._exposureRenderTargetCube),o&&(r.defines.LIGHT_PATH_IS_CAM_RAY=i),e.traverse((e=>{!e.isCubeReflectionProbe&&this._isVisible(e)||(e.layers.mask=n[e.id])}))}onUpdate(e){return e}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)}copy(e){return super.copy(e),this.influenceType=e.influenceType,this.influenceDistance=e.influenceDistance,this.parallaxType=e.parallaxType,this.parallaxDistance=e.parallaxDistance,this.probeClipStart=e.probeClipStart,this.probeClipEnd=e.probeClipEnd,this.probeIntensity=e.probeIntensity,this.visibilityGroup=e.visibilityGroup,this.visibilityGroupInv=e.visibilityGroupInv,this.influenceGroup=e.influenceGroup,this.influenceGroupInv=e.influenceGroupInv,this.setSize(e._renderTargetCube.width),this.matrixWorldInverse.copy(e.matrixWorldInverse),this}dispose(){null!==this._renderTargetCube&&this._renderTargetCube.dispose(),null!==this._exposureRenderTargetCube&&this._exposureRenderTargetCube.dispose(),null!==this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=null),this.dispatchEvent({type:"dispose"})}_isVisible(e){if(null===this.visibilityGroup)return!0;if(!e.isMesh)return!0;return-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv}}CubeReflectionProbe.prototype.isCubeReflectionProbe=!0;class EffectComposer{constructor(e,t){if(this.renderer=e,void 0===t){const n=e.getSize(new Vector2);this._pixelRatio=e.getPixelRatio(),this._width=n.width,this._height=n.height,(t=new WebGLRenderTarget(Math.floor(this._width*this._pixelRatio),Math.floor(this._height*this._pixelRatio))).texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new ShaderPass(ShaderLib.copy),this.clock=new Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(Math.floor(this._width*this._pixelRatio),Math.floor(this._height*this._pixelRatio))}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(Math.floor(this._width*this._pixelRatio),Math.floor(this._height*this._pixelRatio))}removePass(e){const t=this.passes.indexOf(e);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t-1&&(n=e+1);this.insertPass(e,n)}enableAllPasses(){for(let e=0;eMath.PI&&(l=s+Math.sign(s-l)*(2*Math.PI-c)),this.sphericalFrom.theta=s,this.sphericalTo.theta=l}return this}}(),start(e){this.active=!0,this.duration=e,this.clock.start()},update:function(){var e=new Vector3,t=new Vector3;return function(n=function(e,t,n){}){var r=this.clock.getElapsedTime()/this.duration;if(r=smootherstep(r,0,1),t.lerpVectors(this.targetFrom,this.targetTo,r),this.movementType===TweenLinear)e.lerpVectors(this.posFrom,this.posTo,r);else if(1===this.movementType){var o=lerp(this.sphericalFrom.radius,this.sphericalTo.radius,r),i=lerp(this.sphericalFrom.phi,this.sphericalTo.phi,r),a=lerp(this.sphericalFrom.theta,this.sphericalTo.theta,r);e.setFromSphericalCoords(o,i,a),e.add(t)}n(r,e,t),r>=1&&(this.active=!1,this.finishCb())}}()}),Object.assign(TweenCameraZoomToController.prototype,{setup:function({posFrom:e=new Vector3,targetFrom:t=new Vector3,posTo:n=new Vector3,targetTo:r=new Vector3,zoomFrom:o=0,zoomTo:i=0,finishCb:a=function(){}}){return this.posFrom.copy(e),this.targetFrom.copy(t),this.posTo.copy(n),this.targetTo.copy(r),this.zoomFrom=o,this.zoomTo=i,this.finishCb=a,this},start(e){this.active=!0,this.duration=e,this.clock.start()},update:function(){new Vector3;const e=new Vector3;return function(t=function(e,t,n){}){let n=this.clock.getElapsedTime()/this.duration;n=smootherstep(n,0,1),e.lerpVectors(this.targetFrom,this.targetTo,n);let r=lerp(this.zoomFrom,this.zoomTo,n);t(n,e,r),n>=1&&(this.active=!1,this.finishCb())}}()});const DEFAULTS={enableCollisions:!0,gazeLevel:1.8,enablePan:!0,panInertia:.05,panSpeedKey:.15,enableRotate:!0,rotateInertia:.05,rotateInertiaTouch:.05,rotateSpeed:.9,rotateSpeedTouch:.75,storyHeight:3,enableZoom:!0,zoomInertia:.05,zoomSpeed:30,zoomSpeedKey:.2,enableDamping:!0,enableKeys:!0};var ACCUM_PER_SEC_COEFF$2=60,ACCUM_CLAMP_ROTATE$2=.001,ACCUM_CLAMP_PAN$2=.001,ACCUM_CLAMP_ZOOM$1=.001;class FirstPersonControls extends EventDispatcher{constructor(e,t){super();var n=this;this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=DEFAULTS.enableDamping,this.enableRotate=DEFAULTS.enableRotate,this.rotateSpeed=DEFAULTS.rotateSpeed,this.rotateSpeedTouch=DEFAULTS.rotateSpeedTouch,this.rotateInertia=DEFAULTS.rotateInertia,this.rotateInertiaTouch=DEFAULTS.rotateInertiaTouch,this.enableZoom=DEFAULTS.enableZoom,this.zoomSpeed=DEFAULTS.zoomSpeed,this.zoomSpeedKey=DEFAULTS.zoomSpeedKey,this.zoomInertia=DEFAULTS.zoomInertia,this.enablePan=DEFAULTS.enablePan,this.panSpeedKey=DEFAULTS.panSpeedKey,this.panInertia=DEFAULTS.panInertia,this.enableKeys=DEFAULTS.enableKeys,this.gazeLevel=DEFAULTS.gazeLevel,this.storyHeight=DEFAULTS.storyHeight,this.collisionMeshes=[],this._enableCollisions=DEFAULTS.enableCollisions;let r=!1;Object.defineProperty(this,"enablePointerLock",{get:()=>r,set(e){r!==e&&(r=e,$())}}),Object.defineProperty(this,"inTween",{get:()=>L.active||R.active});var o,i=new Clock,a=1e-6,s=new Vector3,l=new Vector3,c=new Vector3,u=new Vector3,d=new Quaternion,h=new Vector3,p={};p[Keys.W]=p[Keys.S]=p[Keys.A]=p[Keys.D]=p[Keys.UP_ARROW]=p[Keys.DOWN_ARROW]=p[Keys.LEFT_ARROW]=p[Keys.RIGHT_ARROW]=0;var f=!1,m=new Spherical,g=new Spherical,_=new Vector2,v=1,A=1,x=new Vector2,y=new Vector2,b=0,C=0,S=1,M=1,E=new Vector2,T=new Vector2,w=new Raycaster(new Vector3,new Vector3(0,-1,0));w.params.checkVisibility=!1;var I=!1,L=new TweenCameraController;const R=new TweenCameraZoomToController;var B={type:"change"},P={type:"start"},D={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var N,F=(N=new Vector2,function(e,t){return N.set((e-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-t))/n.screen.width),N});const O=function(){const e=new Vector2;return function(t,r){return e.set(t,-r).multiplyScalar(2/n.screen.width)}}();function V(e){!1!==n.enabled&&(e.preventDefault(),!1!==n.enableRotate&&(y.copy(F(e.pageX,e.pageY).negate()),x.copy(y),f=!0,document.addEventListener("mousemove",U),document.addEventListener("mouseup",G),document.addEventListener("mouseleave",G),n.dispatchEvent(P)))}function U(e){if(!1!==n.enabled&&(e.preventDefault(),f)){if(!1===n.enableRotate)return;y.copy(F(e.pageX,e.pageY).negate()),_.add(y).sub(x),x.copy(y),v=n.rotateSpeed,A=n.rotateInertia}}function G(e){!1!==n.enabled&&(e.preventDefault(),f=!1,document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),n.dispatchEvent(D))}function k(e){if(!1!==n.enabled&&!1!==n.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:C-=.025*e.deltaY,S=n.zoomSpeed,M=n.zoomInertia;break;case 1:C-=.01*e.deltaY,S=n.zoomSpeed,M=n.zoomInertia;break;default:C-=25e-5*e.deltaY,S=n.zoomSpeed,M=n.zoomInertia}n.dispatchEvent(P),n.dispatchEvent(D)}}function z(e){if(!1!==n.enabled){var t=e.targetTouches[0];f=!0,y.copy(F(t.pageX,t.pageY).negate()),x.copy(y),n.dispatchEvent(P)}}function Q(e){if(!1!==n.enabled){e.preventDefault();var t=e.targetTouches[0];!1!==n.enableRotate&&(y.copy(F(t.pageX,t.pageY).negate()),_.add(y).sub(x),x.copy(y),v=n.rotateSpeedTouch,A=n.rotateInertiaTouch)}}function W(e){if(!1!==n.enabled){if(0===e.targetTouches.length)f=!1;else{if(!1===n.enableRotate)return;f=!0,y.copy(F(e.targetTouches[0].pageX,e.targetTouches[0].pageY).negate()),x.copy(y)}n.dispatchEvent(D)}}function H(e){!1!==n.enabled&&e.preventDefault()}function X(e){n.domElement.requestPointerLock()}function Y(e){document.pointerLockElement===n.domElement?(n.dispatchEvent(P),document.addEventListener("mousemove",K)):(n.dispatchEvent(D),document.removeEventListener("mousemove",K))}function j(e){console.error("Pointer lock failed")}function K(e){e.preventDefault(),n.enabled&&n.enableRotate&&(_.add(O(e.movementX,e.movementY).negate()),v=n.rotateSpeed,A=n.rotateInertia)}function $(){q(),n.domElement.addEventListener("contextmenu",H),n.enablePointerLock?(n.domElement.addEventListener("click",X),document.addEventListener("pointerlockchange",Y),document.addEventListener("pointerlockerror",j)):n.domElement.addEventListener("mousedown",V),n.domElement.addEventListener("wheel",k,{passive:!1}),n.domElement.addEventListener("touchstart",z,{passive:!0}),n.domElement.addEventListener("touchend",W),n.domElement.addEventListener("touchmove",Q,{passive:!1}),(o=new KeyListener(window,n.domElement.parentElement)).onKeyDown=function(e){e.keyCode in p&&(p[e.keyCode]=1)}}function q(){n.domElement.removeEventListener("contextmenu",H),n.domElement.removeEventListener("click",X),document.removeEventListener("pointerlockchange",Y),document.removeEventListener("pointerlockerror",j),document.removeEventListener("mousemove",K),n.domElement.removeEventListener("mousedown",V),n.domElement.removeEventListener("wheel",k),n.domElement.removeEventListener("touchstart",z),n.domElement.removeEventListener("touchend",W),n.domElement.removeEventListener("touchmove",Q),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),o&&o.dispose()}var Z,J,ee;this.update=(new Vector3,function(){if(L.active?L.update((function(e,t,r){if(n.object.position.copy(t),n.object.lookAt(r),e>=1){for(var o in g.set(0,0,0),_.set(0,0),b=0,C=0,E.set(0,0),T.set(0,0),p)p[o]=0;i.getDelta()}})):R.active?R.update((function(e,t,r){if(n.object.lookAt(t),n.object.zoom=r,n.object.updateProjectionMatrix(),e>=1){g.set(0,0,0),_.set(0,0),b=0,C=0,E.set(0,0),T.set(0,0);for(let e in p)p[e]=0;i.getDelta()}})):(n.object.getLocalDirection(h),m.setFromVector3(h),m.theta+=g.theta*v,m.phi+=g.phi*v,m.makeSafe(),h.setFromSpherical(m),s.copy(h).add(n.object.position),n.object.lookAtLocal(s),n.object.isPerspectiveCamera?n.object.position.addScaledVector(h,b):n.object.isOrthographicCamera&&(n.object.zoom*=1+.15*b,n.object.updateProjectionMatrix()),l.copy(h).cross(n.object.up).setLength(-E.x),l.add(c.copy(n.object.up).setLength(E.y)),n.object.position.add(l),function(){var e=i.getDelta();for(var t in g.set(g.radius,_.y,_.x),_.x=n.enableDamping?expAverageClamp(_.x,0,e,A,ACCUM_CLAMP_ROTATE$2):0,_.y=n.enableDamping?expAverageClamp(_.y,0,e,A,ACCUM_CLAMP_ROTATE$2):0,g.set(g.radius,g.phi-_.y,g.theta-_.x),E.copy(T),T.x=n.enableDamping?expAverageClamp(T.x,0,e,1,ACCUM_CLAMP_PAN$2):0,T.y=n.enableDamping?expAverageClamp(T.y,0,e,1,ACCUM_CLAMP_PAN$2):0,E.sub(T),E.multiplyScalar(1),b=C,C=n.enableDamping?expAverageClamp(C,0,e,M,ACCUM_CLAMP_ZOOM$1):0,b-=C,b*=S,p){var r=t==Keys.A||t==Keys.LEFT_ARROW||t==Keys.D||t==Keys.RIGHT_ARROW,a=t==Keys.W||t==Keys.UP_ARROW||t==Keys.S||t==Keys.DOWN_ARROW,s=r?n.panInertia:n.zoomInertia,l=r?n.panSpeedKey:n.zoomSpeedKey,c=r?ACCUM_CLAMP_PAN$2:ACCUM_CLAMP_ZOOM$1;if(o.isKeyDown[t])var u=p[t]=1;else{var d=p[t];p[t]=expAverageClamp(p[t],0,e,s,c),u=d-p[t]}n.enabled&&n.enableKeys&&(r&&!n.enablePan||a&&!n.enableZoom||(u*=e*ACCUM_PER_SEC_COEFF$2*l,t==Keys.A||t==Keys.LEFT_ARROW?E.x+=u:t==Keys.D||t==Keys.RIGHT_ARROW?E.x-=u:t==Keys.W||t==Keys.UP_ARROW?b+=u:t!=Keys.S&&t!=Keys.DOWN_ARROW||(b-=u)))}}()),this._enableCollisions&&n.collisionMeshes.length){w.ray.origin.copy(n.object.position),w.far=n.storyHeight;var e=w.intersectObjects(n.collisionMeshes,!1);if(e.length>0){var t=e[0];n.object.position.y=t.point.y+n.gazeLevel,I=!0}else I&&n.object.position.copy(u)}var r=!1;u.distanceToSquared(n.object.position)>a&&(u.copy(n.object.position),r=!0),d.dot(n.object.quaternion)<1-a&&(d.copy(n.object.quaternion),r=!0),r&&n.dispatchEvent(B)}),this.forceMouseUp=function(){G({preventDefault:function(){}})},this.dispose=q,this.releaseFromCollision=function(){I=!1},this.tween=(Z=new Vector3,J=new Vector3,ee=new Vector3,function(e,t,r,o,i){n.object.parent&&(e=Z.copy(e),n.object.parent.worldToLocal(e));var a=n.object.getWorldPosition(J),s=ee.subVectors(t,a).length(),l=n.object.getWorldDirection(ee).multiplyScalar(s).add(a),c=1e-5;e.manhattanDistanceTo(n.object.position)G.active||k.active});var c=new Clock,u=1e-6,d=new Vector3,h=new Vector3,p=new Vector3,f=new Vector2,m=new Vector3,g=new Quaternion,_=r,v=new Vector3,A={};A[Keys.W]=A[Keys.S]=A[Keys.A]=A[Keys.D]=A[Keys.UP_ARROW]=A[Keys.DOWN_ARROW]=A[Keys.LEFT_ARROW]=A[Keys.RIGHT_ARROW]=0;var x=new KeyListener(window);x.onKeyDown=function(e){e.keyCode in A&&(A[e.keyCode]=1)};var y=new Spherical,b=new Spherical,C=new Vector2,S=1,M=1,E=new Vector2,T=new Vector2,w=0,I=0,L=1,R=1,B=0,P=0,D=new Vector2,N=new Vector2,F=1,O=1,V=new Vector2,U=new Vector2,G=new TweenCameraController;const k=new TweenCameraZoomToController;var z={type:"change"},Q={type:"start"},W={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var H,X,Y,j,K=(H=new Vector2,function(e,t){return H.set((e-n.screen.left)/n.screen.width,(t-n.screen.top)/n.screen.height),H}),$=function(){var e=new Vector2;return function(t,r){return e.set((t-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-r))/n.screen.width),e}}();function q(e){if(!1!==n.enabled){switch(e.preventDefault(),e.button){case n.mouseButtons.ROTATE:if(!1===n.enableRotate)return;T.copy($(e.pageX,e.pageY).negate()),E.copy(T),_=o;break;case n.mouseButtons.ZOOM:case n.mouseButtons.PAN:if(!1===n.enablePan)return;V.copy(K(e.pageX,e.pageY)),U.copy(V),_=e.button==n.mouseButtons.PAN?a:i}document.addEventListener("mousemove",Z),document.addEventListener("mouseup",J),document.addEventListener("mouseleave",J),n.dispatchEvent(Q)}}function Z(e){if(!1!==n.enabled)if(e.preventDefault(),_===o){if(!1===n.enableRotate)return;T.copy($(e.pageX,e.pageY).negate()),C.add(T).sub(E),E.copy(T),S=n.rotateSpeed,M=n.rotateInertia}else if(_===a||_===i){if(!1===n.enablePan)return;U.copy(K(e.pageX,e.pageY)),N.add(U).sub(V),V.copy(U),F=n.panSpeed,O=n.panInertia}}function J(e){!1!==n.enabled&&(e.preventDefault(),_=r,document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",J),document.removeEventListener("mouseleave",J),n.dispatchEvent(W))}function ee(e){if(!1!==n.enabled&&!1!==n.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:I-=.025*e.deltaY,L=n.zoomSpeed,R=n.zoomInertia;break;case 1:I-=.01*e.deltaY,L=n.zoomSpeed,R=n.zoomInertia;break;default:I-=25e-5*e.deltaY,L=n.zoomSpeed,R=n.zoomInertia}n.dispatchEvent(Q),n.dispatchEvent(W)}}function te(e){if(!1!==n.enabled){var t=e.touches[0],r=e.touches[1];if(1===e.touches.length){if(!1===n.enableRotate)return;_=s,T.copy($(t.pageX,t.pageY).negate()),E.copy(T)}else{if(!1===n.enableZoom&&!1===n.enablePan)return;if(_=l,n.enableZoom){var o=K(t.pageX-r.pageX,t.pageY-r.pageY);B=P=o.length()}if(n.enablePan){var i=K((t.pageX+r.pageX)/2,(t.pageY+r.pageY)/2);V.copy(i),U.copy(V)}}n.dispatchEvent(Q)}}function ne(e){if(!1!==n.enabled){e.preventDefault();var t=e.touches[0],r=e.touches[1];if(1===e.touches.length){if(!1===n.enableRotate)return;T.copy($(t.pageX,t.pageY).negate()),C.add(T).sub(E),E.copy(T),S=n.rotateSpeedTouch,M=n.rotateInertiaTouch}else{if(!1===n.enableZoom&&!1===n.enablePan)return;var o=K(t.pageX-r.pageX,t.pageY-r.pageY),i=(P=o.length())-B;B=P;var a=K((t.pageX+r.pageX)/2,(t.pageY+r.pageY)/2);U.copy(a);var s=f.subVectors(U,V),l=s.length();V.copy(U),n.enableZoom&&Math.abs(i)>Math.abs(l)&&(I+=i,L=n.zoomSpeedTouch,R=n.zoomInertiaTouch),n.enablePan&&Math.abs(i)<=Math.abs(l)&&(N.add(s),F=n.panSpeedTouch,O=n.panInertiaTouch)}}}function re(e){if(!1!==n.enabled){switch(e.touches.length){case 0:_=r;break;case 1:if(!1===n.enableRotate)return;_=s,T.copy($(e.touches[0].pageX,e.touches[0].pageY).negate()),E.copy(T)}n.dispatchEvent(W)}}function oe(e){!1!==n.enabled&&e.preventDefault()}this.update=(new Vector3,function(){G.active?G.update((function(e,t,r){if(n.object.position.copy(t),n.object.lookAt(r),e>=1){for(var o in b.set(0,0,0),C.set(0,0),w=0,I=0,D.set(0,0),N.set(0,0),A)A[o]=0;c.getDelta()}})):k.active?k.update((function(e,t,r){if(n.object.lookAt(t),n.object.zoom=r,n.object.updateProjectionMatrix(),e>=1){b.set(0,0,0),C.set(0,0),w=0,I=0,D.set(0,0),N.set(0,0);for(let e in A)A[e]=0;c.getDelta()}})):(n.object.getLocalDirection(v),y.setFromVector3(v),y.theta+=b.theta*S,y.phi+=b.phi*S,y.theta=Math.max(n.minAzimuthAngle,Math.min(n.maxAzimuthAngle,y.theta)),y.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,y.phi)),y.makeSafe(),v.setFromSpherical(y),d.copy(v).add(n.object.position),n.object.lookAtLocal(d),n.object.isPerspectiveCamera?n.object.position.addScaledVector(v,w):n.object.isOrthographicCamera&&(n.object.zoom*=1+.15*w,n.object.updateProjectionMatrix()),h.copy(v).cross(n.object.up).setLength(-D.x),h.add(p.copy(n.object.up).setLength(D.y)),n.object.position.add(h),function(){var e=c.getDelta();for(var t in b.set(b.radius,C.y,C.x),C.x=n.enableDamping?expAverageClamp(C.x,0,e,M,ACCUM_CLAMP_ROTATE$1):0,C.y=n.enableDamping?expAverageClamp(C.y,0,e,M,ACCUM_CLAMP_ROTATE$1):0,b.set(b.radius,b.phi-C.y,b.theta-C.x),D.copy(N),N.x=n.enableDamping?expAverageClamp(N.x,0,e,O,ACCUM_CLAMP_PAN$1):0,N.y=n.enableDamping?expAverageClamp(N.y,0,e,O,ACCUM_CLAMP_PAN$1):0,D.sub(N),D.multiplyScalar(F),w=I,I=n.enableDamping?expAverageClamp(I,0,e,R,ACCUM_CLAMP_ZOOM):0,w-=I,w*=L,A){var r=t==Keys.A||t==Keys.LEFT_ARROW||t==Keys.D||t==Keys.RIGHT_ARROW,o=t==Keys.W||t==Keys.UP_ARROW||t==Keys.S||t==Keys.DOWN_ARROW,i=r?n.panInertia:n.zoomInertia,a=r?n.panSpeedKey:n.zoomSpeedKey,s=r?ACCUM_CLAMP_PAN$1:ACCUM_CLAMP_ZOOM;if(x.isKeyDown[t])var l=A[t]=1;else{var u=A[t];A[t]=expAverageClamp(A[t],0,e,i,s),l=u-A[t]}n.enabled&&n.enableKeys&&(r&&!n.enablePan||o&&!n.enableZoom||(l*=e*ACCUM_PER_SEC_COEFF$1*a,t==Keys.A||t==Keys.LEFT_ARROW?D.x+=l:t==Keys.D||t==Keys.RIGHT_ARROW?D.x-=l:t==Keys.W||t==Keys.UP_ARROW?w+=l:t!=Keys.S&&t!=Keys.DOWN_ARROW||(w-=l)))}}());var e=!1;m.distanceToSquared(n.object.position)>u&&(m.copy(n.object.position),e=!0),g.dot(n.object.quaternion)<1-u&&(g.copy(n.object.quaternion),e=!0),e&&n.dispatchEvent(z)}),this.forceMouseUp=function(){J({preventDefault:function(){}})},this.dispose=function(){this.domElement.removeEventListener("contextmenu",oe),this.domElement.removeEventListener("mousedown",q),this.domElement.removeEventListener("wheel",ee),this.domElement.removeEventListener("touchstart",te),this.domElement.removeEventListener("touchend",re),this.domElement.removeEventListener("touchmove",ne),document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",J),document.removeEventListener("mouseleave",J),x.dispose()},this.tween=(X=new Vector3,Y=new Vector3,j=new Vector3,function(e,t,r,o,i){n.object.parent&&(e=X.copy(e),n.object.parent.worldToLocal(e));var a=n.object.getWorldPosition(Y),s=j.subVectors(t,a).length(),l=n.object.getWorldDirection(j).multiplyScalar(s).add(a),c=1e-5;e.manhattanDistanceTo(n.object.position){var e=import.meta.url;return function(t){t=void 0!==(t=t||{})?t:{};var n,r,o=Object.assign;t.ready=new Promise((function(e,t){n=e,r=t}));var i,a,s,l,c,u,d=o({},t),h="object"==typeof window,p="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";f?(m=p?require("path").dirname(m)+"/":__dirname+"/",u=()=>{c||(l=require("fs"),c=require("path"))},i=function(e,t){var n=H(e);return n?t?n:n.toString():(u(),e=c.normalize(e),l.readFileSync(e,t?null:"utf8"))},s=e=>{var t=i(e,!0);return t.buffer||(t=new Uint8Array(t)),t},a=(e,t,n)=>{var r=H(e);r&&t(r),u(),e=c.normalize(e),l.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof q))throw e})),process.on("unhandledRejection",(function(e){throw e})),t.inspect=function(){return"[Emscripten Module object]"}):(h||p)&&(p?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),e&&(m=e),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}catch(t){var n=H(e);if(n)return function(e){for(var t=[],n=0;n255&&(r&=255),t.push(String.fromCharCode(r))}return t.join("")}(n);throw t}},p&&(s=e=>{try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}catch(t){var n=H(e);if(n)return n;throw t}}),a=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{if(200==r.status||0==r.status&&r.response)t(r.response);else{var o=H(e);o?t(o.buffer):n()}},r.onerror=n,r.send(null)}),t.print||console.log.bind(console);var g,_,v=t.printErr||console.warn.bind(console);o(t,d),d=null,t.arguments&&t.arguments,t.thisProgram&&t.thisProgram,t.quit&&t.quit,t.wasmBinary&&(g=t.wasmBinary),t.noExitRuntime,"object"!=typeof WebAssembly&&P("no native wasm support detected");var A=!1;function x(e){return t["_"+e]}function y(e,t,n,r,o){var i={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);(function(e,t,n){(function(e,t,n,r){if(!(r>0))return 0;for(var o=n,i=n+r-1,a=0;a=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a);if(s<=127){if(n>=i)break;t[n++]=s}else if(s<=2047){if(n+1>=i)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=i)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=i)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0})(e,S,t,n)})(e,t=$(n),n)}return t},array:function(e){var t=$(e.length);return function(e,t){C.set(e,t)}(e,t),t}};function a(e){return"string"===t?(n=e)?function(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.subarray&&E)return E.decode(e.subarray(t,o));for(var i="";t>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i}(S,n,r):"":"boolean"===t?Boolean(e):e;var n,r}var s=x(e),l=[],c=0;if(r)for(var u=0;u0;){var n=e.shift();if("function"!=typeof n){var r=n.func;"number"==typeof r?void 0===n.arg?z(r)():z(r)(n.arg):r(void 0===n.arg?null:n.arg)}else n(t)}}O(D="data:application/octet-stream;base64,AGFzbQEAAAABIwdgAX8AYAABf2ABfwF/YAN/f38Bf2ADf39/AGACf38AYAAAAg0CAWEBYQACAWEBYgADAxoZBAMCAAIFBgQCAAQDAQEBAQIAAQEBAAAAAAQFAXABAQEFBwEBgAKAgAIGCQF/AUHQpIADCwdBEAFjAgABZAAIAWUAEQFmABABZwAPAWgADgFpABoBagAZAWsAGAFsABcBbQAWAW4AFQFvAQABcAAUAXEAEwFyABIKl6QBGf0DAQJ/IAJBgARPBEAgACABIAIQARoPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAEEDcUUEQCAAIQIMAQsgAkUEQCAAIQIMAQsgACECA0AgAiABLQAAOgAAIAFBAWohASACQQFqIgJBA3FFDQEgAiADSQ0ACwsCQCADQXxxIgBBwABJDQAgAiAAQUBqIgRLDQADQCACIAEoAgA2AgAgAiABKAIENgIEIAIgASgCCDYCCCACIAEoAgw2AgwgAiABKAIQNgIQIAIgASgCFDYCFCACIAEoAhg2AhggAiABKAIcNgIcIAIgASgCIDYCICACIAEoAiQ2AiQgAiABKAIoNgIoIAIgASgCLDYCLCACIAEoAjA2AjAgAiABKAI0NgI0IAIgASgCODYCOCACIAEoAjw2AjwgAUFAayEBIAJBQGsiAiAETQ0ACwsgACACTQ0BA0AgAiABKAIANgIAIAFBBGohASACQQRqIgIgAEkNAAsMAQsgA0EESQRAIAAhAgwBCyAAIANBBGsiBEsEQCAAIQIMAQsgACECA0AgAiABLQAAOgAAIAIgAS0AAToAASACIAEtAAI6AAIgAiABLQADOgADIAFBBGohASACQQRqIgIgBE0NAAsLIAIgA0kEQANAIAIgAS0AADoAACABQQFqIQEgAkEBaiICIANHDQALCwujAQEBfyACQX9zIQICQCABRQ0AIAFBAXEEfyAALQAAIAJB/wFxc0ECdEGwCGooAgAgAkEIdnMhAiAAQQFqIQAgAUEBawUgAQshAyABQQFGDQADQCAALQABIAAtAAAgAkH/AXFzQQJ0QbAIaigCACACQQh2cyIBQf8BcXNBAnRBsAhqKAIAIAFBCHZzIQIgAEECaiEAIANBAmsiAw0ACwsgAkF/cwtRAQJ/QaAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBoAggADYCACABDwtB1KDAAEEwNgIAQX8L8QwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQeigwAAoAgBJDQEgACABaiEAIANB7KDAACgCAEcEQCABQf8BTQRAIAMoAggiAiABQQN2IgRBA3RBgKHAAGpGGiACIAMoAgwiAUYEQEHYoMAAQdigwAAoAgBBfiAEd3E2AgAMAwsgAiABNgIMIAEgAjYCCAwCCyADKAIYIQYCQCADIAMoAgwiAUcEQCADKAIIIgIgATYCDCABIAI2AggMAQsCQCADQRRqIgIoAgAiBA0AIANBEGoiAigCACIEDQBBACEBDAELA0AgAiEHIAQiAUEUaiICKAIAIgQNACABQRBqIQIgASgCECIEDQALIAdBADYCAAsgBkUNAQJAIAMgAygCHCICQQJ0QYijwABqIgQoAgBGBEAgBCABNgIAIAENAUHcoMAAQdygwAAoAgBBfiACd3E2AgAMAwsgBkEQQRQgBigCECADRhtqIAE2AgAgAUUNAgsgASAGNgIYIAMoAhAiAgRAIAEgAjYCECACIAE2AhgLIAMoAhQiAkUNASABIAI2AhQgAiABNgIYDAELIAUoAgQiAUEDcUEDRw0AQeCgwAAgADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVB8KDAACgCAEYEQEHwoMAAIAM2AgBB5KDAAEHkoMAAKAIAIABqIgA2AgAgAyAAQQFyNgIEIANB7KDAACgCAEcNA0HgoMAAQQA2AgBB7KDAAEEANgIADwsgBUHsoMAAKAIARgRAQeygwAAgAzYCAEHgoMAAQeCgwAAoAgAgAGoiADYCACADIABBAXI2AgQgACADaiAANgIADwsgAUF4cSAAaiEAAkAgAUH/AU0EQCAFKAIIIgIgAUEDdiIEQQN0QYChwABqRhogAiAFKAIMIgFGBEBB2KDAAEHYoMAAKAIAQX4gBHdxNgIADAILIAIgATYCDCABIAI2AggMAQsgBSgCGCEGAkAgBSAFKAIMIgFHBEAgBSgCCCICQeigwAAoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEGIo8AAaiIEKAIARgRAIAQgATYCACABDQFB3KDAAEHcoMAAKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQeygwAAoAgBHDQFB4KDAACAANgIADwsgBSABQX5xNgIEIAMgAEEBcjYCBCAAIANqIAA2AgALIABB/wFNBEAgAEEDdiIBQQN0QYChwABqIQACf0HYoMAAKAIAIgJBASABdCIBcUUEQEHYoMAAIAEgAnI2AgAgAAwBCyAAKAIICyECIAAgAzYCCCACIAM2AgwgAyAANgIMIAMgAjYCCA8LQR8hAiADQgA3AhAgAEH///8HTQRAIABBCHYiASABQYD+P2pBEHZBCHEiAXQiAiACQYDgH2pBEHZBBHEiAnQiBCAEQYCAD2pBEHZBAnEiBHRBD3YgASACciAEcmsiAUEBdCAAIAFBFWp2QQFxckEcaiECCyADIAI2AhwgAkECdEGIo8AAaiEBAkACQAJAQdygwAAoAgAiBEEBIAJ0IgdxRQRAQdygwAAgBCAHcjYCACABIAM2AgAgAyABNgIYDAELIABBAEEZIAJBAXZrIAJBH0YbdCECIAEoAgAhAQNAIAEiBCgCBEF4cSAARg0CIAJBHXYhASACQQF0IQIgBCABQQRxaiIHQRBqKAIAIgENAAsgByADNgIQIAMgBDYCGAsgAyADNgIMIAMgAzYCCAwBCyAEKAIIIgAgAzYCDCAEIAM2AgggA0EANgIYIAMgBDYCDCADIAA2AggLQfigwABB+KDAACgCAEEBayIAQX8gABs2AgALC5IvAQt/IwBBEGsiCyQAAkACQAJAAkACQAJAAkACQAJAAkACQCAAQfQBTQRAQdigwAAoAgAiBkEQIABBC2pBeHEgAEELSRsiB0EDdiICdiIBQQNxBEAgAUF/c0EBcSACaiIDQQN0IgFBiKHAAGooAgAiBEEIaiEAAkAgBCgCCCICIAFBgKHAAGoiAUYEQEHYoMAAIAZBfiADd3E2AgAMAQsgAiABNgIMIAEgAjYCCAsgBCADQQN0IgFBA3I2AgQgASAEaiIBIAEoAgRBAXI2AgQMDAsgB0HgoMAAKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBiKHAAGooAgAiBCgCCCIBIABBgKHAAGoiAEYEQEHYoMAAIAZBfiADd3EiBjYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAHQQNyNgIEIAQgB2oiAiADQQN0IgEgB2siA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGAocAAaiEFQeygwAAoAgAhBAJ/IAZBASABdCIBcUUEQEHYoMAAIAEgBnI2AgAgBQwBCyAFKAIICyEBIAUgBDYCCCABIAQ2AgwgBCAFNgIMIAQgATYCCAtB7KDAACACNgIAQeCgwAAgAzYCAAwMC0HcoMAAKAIAIglFDQEgCUEAIAlrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QYijwABqKAIAIgEoAgRBeHEgB2shAyABIQIDQAJAIAIoAhAiAEUEQCACKAIUIgBFDQELIAAoAgRBeHEgB2siAiADIAIgA0kiAhshAyAAIAEgAhshASAAIQIMAQsLIAEoAhghCCABIAEoAgwiBEcEQCABKAIIIgBB6KDAACgCAEkaIAAgBDYCDCAEIAA2AggMCwsgAUEUaiICKAIAIgBFBEAgASgCECIARQ0DIAFBEGohAgsDQCACIQUgACIEQRRqIgIoAgAiAA0AIARBEGohAiAEKAIQIgANAAsgBUEANgIADAoLQX8hByAAQb9/Sw0AIABBC2oiAEF4cSEHQdygwAAoAgAiCUUNAEEAIAdrIQMCQAJAAkACf0EAIAdBgAJJDQAaQR8gB0H///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgByAAQRVqdkEBcXJBHGoLIgZBAnRBiKPAAGooAgAiAkUEQEEAIQAMAQtBACEAIAdBAEEZIAZBAXZrIAZBH0YbdCEBA0ACQCACKAIEQXhxIAdrIgUgA08NACACIQQgBSIDDQBBACEDIAIhAAwDCyAAIAIoAhQiBSAFIAIgAUEddkEEcWooAhAiAkYbIAAgBRshACABQQF0IQEgAg0ACwsgACAEckUEQEEAIQRBAiAGdCIAQQAgAGtyIAlxIgBFDQMgAEEAIABrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QYijwABqKAIAIQALIABFDQELA0AgACgCBEF4cSAHayIBIANJIQIgASADIAIbIQMgACAEIAIbIQQgACgCECIBBH8gAQUgACgCFAsiAA0ACwsgBEUNACADQeCgwAAoAgAgB2tPDQAgBCgCGCEGIAQgBCgCDCIBRwRAIAQoAggiAEHooMAAKAIASRogACABNgIMIAEgADYCCAwJCyAEQRRqIgIoAgAiAEUEQCAEKAIQIgBFDQMgBEEQaiECCwNAIAIhBSAAIgFBFGoiAigCACIADQAgAUEQaiECIAEoAhAiAA0ACyAFQQA2AgAMCAsgB0HgoMAAKAIAIgJNBEBB7KDAACgCACEDAkAgAiAHayIBQRBPBEBB4KDAACABNgIAQeygwAAgAyAHaiIANgIAIAAgAUEBcjYCBCACIANqIAE2AgAgAyAHQQNyNgIEDAELQeygwABBADYCAEHgoMAAQQA2AgAgAyACQQNyNgIEIAIgA2oiACAAKAIEQQFyNgIECyADQQhqIQAMCgsgB0HkoMAAKAIAIghJBEBB5KDAACAIIAdrIgE2AgBB8KDAAEHwoMAAKAIAIgIgB2oiADYCACAAIAFBAXI2AgQgAiAHQQNyNgIEIAJBCGohAAwKC0EAIQAgB0EvaiIJAn9BsKTAACgCAARAQbikwAAoAgAMAQtBvKTAAEJ/NwIAQbSkwABCgKCAgICABDcCAEGwpMAAIAtBDGpBcHFB2KrVqgVzNgIAQcSkwABBADYCAEGUpMAAQQA2AgBBgCALIgFqIgZBACABayIFcSICIAdNDQlBkKTAACgCACIEBEBBiKTAACgCACIDIAJqIgEgA00NCiABIARLDQoLQZSkwAAtAABBBHENBAJAAkBB8KDAACgCACIDBEBBmKTAACEAA0AgAyAAKAIAIgFPBEAgASAAKAIEaiADSw0DCyAAKAIIIgANAAsLQQAQBCIBQX9GDQUgAiEGQbSkwAAoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEGCyAGIAdNDQUgBkH+////B0sNBUGQpMAAKAIAIgQEQEGIpMAAKAIAIgMgBmoiACADTQ0GIAAgBEsNBgsgBhAEIgAgAUcNAQwHCyAGIAhrIAVxIgZB/v///wdLDQQgBhAEIgEgACgCACAAKAIEakYNAyABIQALAkAgAEF/Rg0AIAdBMGogBk0NAEG4pMAAKAIAIgEgCSAGa2pBACABa3EiAUH+////B0sEQCAAIQEMBwsgARAEQX9HBEAgASAGaiEGIAAhAQwHC0EAIAZrEAQaDAQLIAAiAUF/Rw0FDAMLQQAhBAwHC0EAIQEMBQsgAUF/Rw0CC0GUpMAAQZSkwAAoAgBBBHI2AgALIAJB/v///wdLDQEgAhAEIQFBABAEIQAgAUF/Rg0BIABBf0YNASAAIAFNDQEgACABayIGIAdBKGpNDQELQYikwABBiKTAACgCACAGaiIANgIAQYykwAAoAgAgAEkEQEGMpMAAIAA2AgALAkACQAJAQfCgwAAoAgAiBQRAQZikwAAhAANAIAEgACgCACIDIAAoAgQiAmpGDQIgACgCCCIADQALDAILQeigwAAoAgAiAEEAIAAgAU0bRQRAQeigwAAgATYCAAtBACEAQZykwAAgBjYCAEGYpMAAIAE2AgBB+KDAAEF/NgIAQfygwABBsKTAACgCADYCAEGkpMAAQQA2AgADQCAAQQN0IgNBiKHAAGogA0GAocAAaiICNgIAIANBjKHAAGogAjYCACAAQQFqIgBBIEcNAAtB5KDAACAGQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBB8KDAACAAIAFqIgA2AgAgACACQQFyNgIEIAEgA2pBKDYCBEH0oMAAQcCkwAAoAgA2AgAMAgsgAC0ADEEIcQ0AIAMgBUsNACABIAVNDQAgACACIAZqNgIEQfCgwAAgBUF4IAVrQQdxQQAgBUEIakEHcRsiAGoiAjYCAEHkoMAAQeSgwAAoAgAgBmoiASAAayIANgIAIAIgAEEBcjYCBCABIAVqQSg2AgRB9KDAAEHApMAAKAIANgIADAELQeigwAAoAgAgAUsEQEHooMAAIAE2AgALIAEgBmohAkGYpMAAIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQZikwAAhAANAIAUgACgCACICTwRAIAIgACgCBGoiBCAFSw0DCyAAKAIIIQAMAAsACyAAIAE2AgAgACAAKAIEIAZqNgIEIAFBeCABa0EHcUEAIAFBCGpBB3EbaiIJIAdBA3I2AgQgAkF4IAJrQQdxQQAgAkEIakEHcRtqIgYgByAJaiIIayECIAUgBkYEQEHwoMAAIAg2AgBB5KDAAEHkoMAAKAIAIAJqIgA2AgAgCCAAQQFyNgIEDAMLIAZB7KDAACgCAEYEQEHsoMAAIAg2AgBB4KDAAEHgoMAAKAIAIAJqIgA2AgAgCCAAQQFyNgIEIAAgCGogADYCAAwDCyAGKAIEIgBBA3FBAUYEQCAAQXhxIQUCQCAAQf8BTQRAIAYoAggiAyAAQQN2IgBBA3RBgKHAAGpGGiADIAYoAgwiAUYEQEHYoMAAQdigwAAoAgBBfiAAd3E2AgAMAgsgAyABNgIMIAEgAzYCCAwBCyAGKAIYIQcCQCAGIAYoAgwiAUcEQCAGKAIIIgAgATYCDCABIAA2AggMAQsCQCAGQRRqIgAoAgAiAw0AIAZBEGoiACgCACIDDQBBACEBDAELA0AgACEEIAMiAUEUaiIAKAIAIgMNACABQRBqIQAgASgCECIDDQALIARBADYCAAsgB0UNAAJAIAYgBigCHCIDQQJ0QYijwABqIgAoAgBGBEAgACABNgIAIAENAUHcoMAAQdygwAAoAgBBfiADd3E2AgAMAgsgB0EQQRQgBygCECAGRhtqIAE2AgAgAUUNAQsgASAHNgIYIAYoAhAiAARAIAEgADYCECAAIAE2AhgLIAYoAhQiAEUNACABIAA2AhQgACABNgIYCyAFIAZqIQYgAiAFaiECCyAGIAYoAgRBfnE2AgQgCCACQQFyNgIEIAIgCGogAjYCACACQf8BTQRAIAJBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAg2AgggACAINgIMIAggAjYCDCAIIAA2AggMAwtBHyEAIAJB////B00EQCACQQh2IgAgAEGA/j9qQRB2QQhxIgN0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgA3IgAHJrIgBBAXQgAiAAQRVqdkEBcXJBHGohAAsgCCAANgIcIAhCADcCECAAQQJ0QYijwABqIQQCQEHcoMAAKAIAIgNBASAAdCIBcUUEQEHcoMAAIAEgA3I2AgAgBCAINgIAIAggBDYCGAwBCyACQQBBGSAAQQF2ayAAQR9GG3QhACAEKAIAIQEDQCABIgMoAgRBeHEgAkYNAyAAQR12IQEgAEEBdCEAIAMgAUEEcWoiBCgCECIBDQALIAQgCDYCECAIIAM2AhgLIAggCDYCDCAIIAg2AggMAgtB5KDAACAGQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBB8KDAACAAIAFqIgA2AgAgACACQQFyNgIEIAEgA2pBKDYCBEH0oMAAQcCkwAAoAgA2AgAgBSAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAVBEGpJGyICQRs2AgQgAkGgpMAAKQIANwIQIAJBmKTAACkCADcCCEGgpMAAIAJBCGo2AgBBnKTAACAGNgIAQZikwAAgATYCAEGkpMAAQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAVGDQMgAiACKAIEQX5xNgIEIAUgAiAFayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAU2AgggACAFNgIMIAUgAjYCDCAFIAA2AggMBAtBHyEAIAVCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAUgADYCHCAAQQJ0QYijwABqIQMCQEHcoMAAKAIAIgJBASAAdCIBcUUEQEHcoMAAIAEgAnI2AgAgAyAFNgIAIAUgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBTYCECAFIAI2AhgLIAUgBTYCDCAFIAU2AggMAwsgAygCCCIAIAg2AgwgAyAINgIIIAhBADYCGCAIIAM2AgwgCCAANgIICyAJQQhqIQAMBQsgAigCCCIAIAU2AgwgAiAFNgIIIAVBADYCGCAFIAI2AgwgBSAANgIIC0HkoMAAKAIAIgAgB00NAEHkoMAAIAAgB2siATYCAEHwoMAAQfCgwAAoAgAiAiAHaiIANgIAIAAgAUEBcjYCBCACIAdBA3I2AgQgAkEIaiEADAMLQdSgwABBMDYCAEEAIQAMAgsCQCAGRQ0AAkAgBCgCHCICQQJ0QYijwABqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQdygwAAgCUF+IAJ3cSIJNgIADAILIAZBEEEUIAYoAhAgBEYbaiABNgIAIAFFDQELIAEgBjYCGCAEKAIQIgAEQCABIAA2AhAgACABNgIYCyAEKAIUIgBFDQAgASAANgIUIAAgATYCGAsCQCADQQ9NBEAgBCADIAdqIgBBA3I2AgQgACAEaiIAIAAoAgRBAXI2AgQMAQsgBCAHQQNyNgIEIAQgB2oiBSADQQFyNgIEIAMgBWogAzYCACADQf8BTQRAIANBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAU2AgggACAFNgIMIAUgAjYCDCAFIAA2AggMAQtBHyEAIANB////B00EQCADQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgAyAAQRVqdkEBcXJBHGohAAsgBSAANgIcIAVCADcCECAAQQJ0QYijwABqIQECQAJAIAlBASAAdCICcUUEQEHcoMAAIAIgCXI2AgAgASAFNgIADAELIANBAEEZIABBAXZrIABBH0YbdCEAIAEoAgAhBwNAIAciASgCBEF4cSADRg0CIABBHXYhAiAAQQF0IQAgASACQQRxaiICKAIQIgcNAAsgAiAFNgIQCyAFIAE2AhggBSAFNgIMIAUgBTYCCAwBCyABKAIIIgAgBTYCDCABIAU2AgggBUEANgIYIAUgATYCDCAFIAA2AggLIARBCGohAAwBCwJAIAhFDQACQCABKAIcIgJBAnRBiKPAAGoiACgCACABRgRAIAAgBDYCACAEDQFB3KDAACAJQX4gAndxNgIADAILIAhBEEEUIAgoAhAgAUYbaiAENgIAIARFDQELIAQgCDYCGCABKAIQIgAEQCAEIAA2AhAgACAENgIYCyABKAIUIgBFDQAgBCAANgIUIAAgBDYCGAsCQCADQQ9NBEAgASADIAdqIgBBA3I2AgQgACABaiIAIAAoAgRBAXI2AgQMAQsgASAHQQNyNgIEIAEgB2oiAiADQQFyNgIEIAIgA2ogAzYCACAKBEAgCkEDdiIAQQN0QYChwABqIQVB7KDAACgCACEEAn9BASAAdCIAIAZxRQRAQdigwAAgACAGcjYCACAFDAELIAUoAggLIQAgBSAENgIIIAAgBDYCDCAEIAU2AgwgBCAANgIIC0HsoMAAIAI2AgBB4KDAACADNgIACyABQQhqIQALIAtBEGokACAAC9YCAQF/AkAgAUUNACAAQQA6AAAgACABaiICQQFrQQA6AAAgAUEDSQ0AIABBADoAAiAAQQA6AAEgAkEDa0EAOgAAIAJBAmtBADoAACABQQdJDQAgAEEAOgADIAJBBGtBADoAACABQQlJDQAgAEEAIABrQQNxIgJqIgBBADYCACAAIAEgAmtBfHEiAmoiAUEEa0EANgIAIAJBCUkNACAAQQA2AgggAEEANgIEIAFBCGtBADYCACABQQxrQQA2AgAgAkEZSQ0AIABBADYCGCAAQQA2AhQgAEEANgIQIABBADYCDCABQRBrQQA2AgAgAUEUa0EANgIAIAFBGGtBADYCACABQRxrQQA2AgAgAiAAQQRxQRhyIgJrIgFBIEkNACAAIAJqIQADQCAAQgA3AxggAEIANwMQIABCADcDCCAAQgA3AwAgAEEgaiEAIAFBIGsiAUEfSw0ACwsLAwABC7AEAQd/AkAgACgCACIGQYCAgAhPBEAgACgCBCEEDAELIAAgBkEIdCIGNgIAIAAgACgCECIDQQFqNgIQIAAgAyAAKAIMai0AACAAKAIEQQh0ciIENgIECwJ/IAEvAQAiBSAGQQt2bCIDIARLBEAgASAFQYAQIAVrQQV2ajsBACABIAJBBHRqQQRqIQhBAiEFQQgMAQsgACAEIANrIgQ2AgQgASAFIAVBBXZrOwEAIAYgA2siBkH///8HTQRAIAAgBkEIdCIGNgIAIAAgACgCECIDQQFqNgIQIAAgAyAAKAIMai0AACAEQQh0ciIENgIECyABLwECIgUgBkELdmwiAyAESwRAIAEgBUGAECAFa0EFdmo7AQIgASACQQR0akGEAmohCEEKIQVBCAwBCyAAIAQgA2siBDYCBCABIAUgBUEFdms7AQIgAUGEBGohCCAGIANrIQNBEiEFQYACCyEGIAAgBTYCaEEBIQEDQCAIIAFBAXQiAWohCQJAIANB////B0sEQCADIQIMAQsgACADQQh0IgI2AgAgACAAKAIQIgNBAWo2AhAgACADIAAoAgxqLQAAIARBCHRyIgQ2AgQLAkAgCS8BACIHIAJBC3ZsIgMgBE0EQCAAIAQgA2siBDYCBCAAIAIgA2siAzYCACAJIAcgB0EFdms7AQAgAUEBciEBDAELIAAgAzYCACAJIAdBgBAgB2tBBXZqOwEACyABIAZJDQALIAAgASAGayAFajYCaAvIHwEQfwJAIAAoAigiASAAKAIgIglNDQAgACgCaCICRQ0AIAAoAlQiAyAAKAIkTw0AIAAoAjAgA00NACAAIAIgASAJayIBIAIgASACSRsiBms2AmggCSADQX9zaiEEIAMgCU8EQCAAKAIsIARqIQQLIAAoAhgiAyAEai0AACEBIAAgCUEBajYCICADIAlqIAE6AAACQCAGQQFrIgdFDQAgB0EBcQRAIAAoAhgiAkEAIARBAWoiASABIAAoAixGGyIEai0AACEDIAAgACgCICIBQQFqNgIgIAEgAmogAzoAACAGQQJrIQcLIAZBAkYNAANAIAAoAhgiAkEAIARBAWoiASABIAAoAixGGyIGai0AACEDIAAgACgCICIBQQFqNgIgIAEgAmogAzoAACAAKAIYIgJBACAGQQFqIgEgASAAKAIsRhsiBGotAAAhAyAAIAAoAiAiAUEBajYCICABIAJqIAM6AAAgB0ECayIHDQALCyAAKAIgIgkgACgCJE0NACAAIAk2AiQLAkACQCAJIAAoAihPDQAgAEHcDWohDiAAQeAVaiEPIABB1ABqIRADQCAAKAIQIgMgACgCFEsNASAAIAAoAmQiCkEFdGogACgCdCAJcSIIQQF0aiIMIQYCQCAAKAIAIgVBgICACE8EQCAAKAIEIQQMAQsgACAFQQh0IgU2AgAgACADQQFqIgE2AhAgACAAKAIMIANqLQAAIAAoAgRBCHRyIgQ2AgQgASEDCwJAIAYvAXgiASAFQQt2bCICIARLBEAgACACNgIAIAYgAUGAECABa0EFdmo7AXggCUEBayEFIAlFBEAgACgCLCAFaiEFCyAAKAJwIAlxIAAoAmwiAXQgACgCJCIGBH8gACgCGCAFai0AAAVBAAtBCCABa3ZqIQ1BASEFAkAgCkEGTQRAA0AgBUEBdCIFIAAgDUGADGxqakHkHWohBgJAIAJB////B0sEQCACIQEMAQsgACACQQh0IgE2AgAgACADQQFqIgI2AhAgACAAKAIMIANqLQAAIARBCHRyIgQ2AgQgAiEDCwJAIAYvAQAiCCABQQt2bCICIARNBEAgACAEIAJrIgQ2AgQgACABIAJrIgI2AgAgBiAIIAhBBXZrOwEAIAVBAXIhBQwBCyAAIAI2AgAgBiAIQYAQIAhrQQV2ajsBAAsgBUGAAkkNAAwCCwALIAkgACgCVCIBQX9zaiEFIAEgCU8EQCAAKAIsIAVqIQULIAYEfyAAKAIYIAVqLQAABUEACyEGQQEhBUGAAiEHA0AgACANQYAMbGogBkEBdCIGIAdxIgwgB2ogBWpBAXRqQeQdaiELAkAgAkH///8HSwRAIAIhCAwBCyAAIAJBCHQiCDYCACAAIANBAWoiATYCECAAIAAoAgwgA2otAAAgBEEIdHIiBDYCBCABIQMLIAsCfyAEIAsvAQAiASAIQQt2bCICTyIKRQRAIAAgAjYCACABQYAQIAFrQQV2agwBCyAAIAQgAmsiBDYCBCAAIAggAmsiAjYCAEEAIQcgASABQQV2aws7AQAgByAMcyEHIAVBAXQgCnIiBUGAAkkNAAsLIAAgCUEBajYCICAAKAIYIAlqIAU6AAAgACgCICIJIAAoAiRLBEAgACAJNgIkC0EAIQIgACAAKAJkIgFBBE8EfyABQQlNBEAgACABQQNrNgJkDAMLIAFBBmsFQQALNgJkDAELIAAgBCACayIENgIEIAAgBSACayICNgIAIAYgASABQQV2azsBeCAAIApBAXRqIgshBgJAIAJB////B0sEQCADIQEMAQsgACACQQh0IgI2AgAgACADQQFqIgE2AhAgACAAKAIMIANqLQAAIARBCHRyIgQ2AgQLAkAgBi8B+AMiCiACQQt2bCIDIARNBEAgACAEIANrIgQ2AgQgACACIANrIgI2AgAgBiAKIApBBXZrOwH4AwJAIAJB////B0sEQCABIQYMAQsgACACQQh0IgI2AgAgACABQQFqIgY2AhAgACAAKAIMIAFqLQAAIARBCHRyIgQ2AgQLAkAgCy8BkAQiASACQQt2bCIFIARLBEAgCyABQYAQIAFrQQV2ajsBkAQgBUH///8HTQRAIAAgBUEIdCIFNgIAIAAgBkEBajYCECAAIAAoAgwgBmotAAAgBEEIdHIiBDYCBAsgDC8B2AQiAyAFQQt2bCIBIARNBEAgACAEIAFrNgIEIAAgBSABazYCACAMIAMgA0EFdms7AdgEDAILIAAgATYCACAMIANBgBAgA2tBBXZqOwHYBCAAQQE2AmggAEEJQQsgACgCZEEHSRs2AmQMAwsgACAEIAVrIgQ2AgQgCyABIAFBBXZrOwGQBAJAIAIgBWsiAkH///8HSwRAIAYhAQwBCyAAIAJBCHQiAjYCACAAIAZBAWoiATYCECAAIAAoAgwgBmotAAAgBEEIdHIiBDYCBAsCQCALLwGoBCIGIAJBC3ZsIgMgBEsEQCAAIAM2AgAgCyAGQYAQIAZrQQV2ajsBqAQgACgCWCECDAELIAAgBCADayIENgIEIAsgBiAGQQV2azsBqAQgAiADayICQf///wdNBEAgACACQQh0IgI2AgAgACABQQFqNgIQIAAgACgCDCABai0AACAEQQh0ciIENgIECwJAIAsvAcAEIgMgAkELdmwiASAESwRAIAAgATYCACALIANBgBAgA2tBBXZqOwHABCAAKAJcIQIMAQsgACAEIAFrNgIEIAAgAiABazYCACALIAMgA0EFdms7AcAEIAAoAmAhAiAAIAAoAlw2AmALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAjYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAPIAgQCQwBCyAAIAM2AgAgBiAKQYAQIAprQQV2ajsB+AMgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIA4gCBAJIAAoAmgiAUECa0EDIAFBBkkbIQMgACgCACECQQEhBANAIARBAXQiBCAAIANBB3RqaiEGAkAgAkGAgIAITwRAIAAoAgQhBQwBCyAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgACgCBEEIdHIiBTYCBAsCQCAGLwHYByIIIAJBC3ZsIgEgBU0EQCAAIAUgAWsiBTYCBCAAIAIgAWsiAjYCACAGIAggCEEFdms7AdgHIARBAXIhBAwBCyAAIAE2AgAgBiAIQYAQIAhrQQV2ajsB2AcgASECCyAEQcAASQ0ACyAEQUBqIgNBA00EQCAAIAM2AlQMAQsgACAEQQFxQQJyIgc2AlQgA0EBdiEBIANBDU0EQCAAIAcgAUEBayIKdCIINgJUQQEhByAQIAhBAXRqQQAgBGtBAXRqQYIMaiEGQQAhCwNAIAYgB0EBdCIHaiEMAkAgAkH///8HSwRAIAIhAQwBCyAAIAJBCHQiATYCACAAIAAoAhAiA0EBajYCECAAIAMgACgCDGotAAAgBUEIdHIiBTYCBAsCQCAMLwEAIgMgAUELdmwiAiAFTQRAIAAgBSACayIFNgIEIAAgASACayICNgIAIAwgAyADQQV2azsBACAAQQEgC3QgCGoiCDYCVCAHQQFyIQcMAQsgACACNgIAIAwgA0GAECADa0EFdmo7AQALIAtBAWoiCyAKRw0ACwwBCyABQQVrIQQDQAJAIAJB////B0sEQCACIQMMAQsgACACQQh0IgM2AgAgACAAKAIQIgFBAWo2AhAgASAAKAIMai0AACAFQQh0ciEFCyAAIANBAXYiAjYCACAAIAUgAmsiBkEfdSIBIAdBAXRqQQFqIgc2AlQgACABIAJxIAZqIgU2AgQgBEEBayIEDQALIAAgB0EEdCIHNgJUIANB////D00EQCAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsgAAJ/IAAvAb4NIgEgAkELdmwiBCAFTQRAIAAgBSAEayIFNgIEIAAgB0EBciIHNgJUIAAgASABQQV2azsBvg0gAiAEayEEQQMMAQsgACABQYAQIAFrQQV2ajsBvg1BAgtBAXQiA2pBvA1qIQYgBEH///8HTQRAIAAgBEEIdCIENgIAIAAgACgCECIBQQFqNgIQIAAgASAAKAIMai0AACAFQQh0ciIFNgIECwJAIAYvAQAiASAEQQt2bCICIAVNBEAgACAFIAJrIgU2AgQgBiABIAFBBXZrOwEAIAAgB0ECaiIHNgJUIAQgAmshAiADQQFyIQMMAQsgBiABQYAQIAFrQQV2ajsBAAsgACADQQF0IgNqQbwNaiEGIAJB////B00EQCAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsCQCAGLwEAIgEgAkELdmwiBCAFTQRAIAAgBSAEayIFNgIEIAYgASABQQV2azsBACAAIAdBBGoiBzYCVCACIARrIQQgA0EBciEDDAELIAYgAUGAECABa0EFdmo7AQALIARB////B00EQCAAIARBCHQiBDYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsgACADQQF0akG8DWoiAS8BACICIARBC3ZsIgMgBU0EQCAAIAUgA2s2AgQgACAEIANrNgIAIAEgAiACQQV2azsBACAAIAdBCGo2AlQMAQsgACADNgIAIAEgAkGAECACa0EFdmo7AQALQQAhAiAAKAJUIgYgACgCJE8NAyAAKAIwIAZNDQMgACAAKAJoIgMgACgCKCAAKAIgIgprIgEgAyABIANJGyIIazYCaCAKIAZBf3NqIQIgBiAKTwRAIAAoAiwgAmohAgsgACgCGCIDIAJqLQAAIQEgACAKQQFqNgIgIAMgCmogAToAAAJAIAhBAWsiBUUNACAFQQFxBEAgACgCGCIGQQAgAkEBaiIBIAEgACgCLEYbIgJqLQAAIQMgACAAKAIgIgFBAWo2AiAgASAGaiADOgAAIAhBAmshBQsgCEECRg0AA0AgACgCGCIGQQAgAkEBaiIBIAEgACgCLEYbIgJqLQAAIQMgACAAKAIgIgFBAWo2AiAgASAGaiADOgAAIAAoAhgiBkEAIAJBAWoiASABIAAoAixGGyICai0AACEDIAAgACgCICIBQQFqNgIgIAEgBmogAzoAACAFQQJrIgUNAAsLIAAoAiAiCSAAKAIkTQ0AIAAgCTYCJAsgCSAAKAIoSQ0ACwtBASECIAAoAgAiAUH///8HSw0AIAAgAUEIdDYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgACgCBEEIdHI2AgQLIAILJgEBfyAABEAgACgCsAkiASgCPARAIAEoAhgQBQsgARAFIAAQBQsLMgEBfyAAIAApA4ABIAIgACgCECICayIDrXw3A4ABIAAgASACaiADIAAoAhgQA603AxgLgQEBAn8CQAJAIAJBBE8EQCAAIAFyQQNxDQEDQCAAKAIAIAEoAgBHDQIgAUEEaiEBIABBBGohACACQQRrIgJBA0sNAAsLIAJFDQELA0AgAC0AACIDIAEtAAAiBEYEQCABQQFqIQEgAEEBaiEAIAJBAWsiAg0BDAILCyADIARrDwtBAAsJAEG8oCAoAgALCQBBsKAgKAIAC9QzAhR/An4CQAJAAkACQAJAAkACQAJAAn8Cf0HQoMAAKAIAIgEoAiQEQCABKAIADAELIAFBADoAKCABQgA3AwAgAUIANwMYIAFByABqQeQAEAcgAUEMNgKsAUEACyEAQcCgICgCACENIAFBtKAgKAIAIg42AhAgAUHgAGohDyABQbYBaiEQIAFBsAFqIREgAUGoAWohCANAAkACQAJAAkACQAJAAkACQAJAAkAgCAJ/AkACQAJAIAAOCgECAAoLDAQFBgcOC0GwoCAoAgAhAyABKAKsASECQbSgICgCACEAQbigICgCACEGIAEoAqgBDAILIAggASgCqAEiAGpBCGpBtKAgKAIAIgJBsKAgKAIAakG4oCAoAgAgAmsiAiABKAKsASAAayIAIAAgAksbIgAQAkG0oCBBtKAgKAIAIABqNgIAQQAhAyABQQAgASgCqAEgAGoiACAAIAEoAqwBIgJGGzYCqAEgACACRw0LIAFBATYCACARQYAIQQYQDQRAQQUhAwwMCyAQQQJBABADIAEoALgBRwRAQQchAwwMC0EGIQMgEC0AAA0LIAEgAS0AtwEiADYCICAAQQ9LDQtBAiEDIABBBEsNC0EBIAB0QRNxRQ0LC0G0oCAoAgAiAEG4oCAoAgAiBkYEQEEAIQMMCwtBsKAgKAIAIgMgAGotAAAiAkUEQEG0oCAgAEEBajYCACABIAA2AhBBBiEAIAFBBjYCAAwMCyABQQA2AqgBIAFBAjYCACABIAJBAnRBBGoiAjYCrAEgASACNgJAQQALIgVqQQhqIAAgA2ogBiAAayIAIAIgBWsiAiAAIAJJGyIAEAJBtKAgIABBtKAgKAIAajYCAEEAIQMgAUEAIAEoAqgBIABqIgAgACABKAKsASICRhs2AqgBIAAgAkcNCSABIABBBGsiADYCrAEgESAAQQAQAyABIAEoAqwBIgVqKACwAUcEQEEHIQMMCgsgAUECNgKoASABLACxASIEQT9xBEBBBiEDDAoLQQIhAEJ/IRVCfyEUIARBwABxRQ0FIAEoAgQiAkUEQCABQgA3AwgLIAVBAiAFQQJLGyEGA0AgACAGRgRAQQchAwwLCyAAIAhqLQAIIQMgASAAQQFqIgA2AqgBIAEgASkDCCADQf8Aca0gAq2GhCIUNwMIIANBgAFxRQRAAkAgAw0AIAJFDQBBByEDDAwLIAFBADYCBAwHC0EHIQMgASACQQdqIgI2AgQgAkE/Rw0ACwwJCwJ/IAFBkAFqIQYDQEG4oCAoAgAhAkGwoCAoAgAhBCABKAIEIgVFBEAgAUIANwMIC0G0oCAoAgAiACACIAAgAksbIQICQANAAkAgACACRgRAQQAhAyACIQAMAQsgACAEai0AACEDQbSgICAAQQFqIgA2AgAgASABKQMIIANB/wBxrSAFrYaEIhQ3AwggA0GAAXFFBEAgAw0DIAVFDQNBByEDDAELQQchAyABIAVBB2oiBTYCBCAFQT9HDQELCyABIAEpA4ABIAAgASgCECIAayICrXw3A4ABIAEgACAEaiACIAEoAhgQA603AxggAwwCCyABQQA2AgQCQAJAAkACQAJAIAEoAngOAwACAQMLIAEgFDcDiAFBByABKQNYIBRSDQUaIAFBATYCeAwDCyABIAEpA5gBIBR8NwOYASABIAZBGCABKAKgARADNgKgASABQQE2AnggASABKQOIAUIBfSIUNwOIAQwCCyABQQI2AnggASABKQOQASAUfDcDkAELIAEpA4gBIRQLIBRCAFINAAtBAQsiA0EBRw0IIAFBBzYCAAsCQCABKQOAASIUQbSgICgCACIAIAEoAhAiBGutfEIDg1ANAEGwoCAoAgAhBkG4oCAoAgAgAEYEQCAAIQIMBAtBtKAgIABBAWoiAjYCAEEHIQMgACAGai0AAA0IAkAgFCACIARrrXxCA4NQDQBBsKAgKAIAIQYgAkG4oCAoAgBGDQRBtKAgIABBAmoiBTYCACACIAZqLQAADQkgFCAFIARrrXxCA4NQBEAgBSEADAILQbCgICgCACEGQbigICgCACAFRgRAIAUhAgwFC0G0oCAgAEEDaiICNgIAIAUgBmotAAANCSAUIAIgBGutfEIDg1ANAEG4oCAoAgAgAkYEQEGwoCAoAgAhBgwFC0G0oCAgAEEEajYCAAwJCyACIQALIAFBsKAgKAIAIAAQDEEHIQMgDyABQZABakEYEA0NByABQQg2AgALAn9BtKAgKAIAIQBBuKAgKAIAIQUDQEEAIAAgBUYNARogASkDGCEUIAEoAgQhA0G0oCAgAEEBaiICNgIAQQdBsKAgKAIAIABqLQAAIBQgA62Ip0H/AXFHDQEaIAEgA0EIaiIDNgIEIAIhACADQSBJDQALIAFBADYCBCABQgA3AxhBAQsiA0EBRw0GIAFBCTYCACABQQw2AqwBC0EAIQMgASABKAKoASIAakGwAWpBtKAgKAIAIgJBsKAgKAIAakG4oCAoAgAgAmsiAiABKAKsASAAayIAIAAgAksbIgAQAkG0oCBBtKAgKAIAIABqNgIAIAFBACABKAKoASAAaiIAIAAgASgCrAFGIgAbNgKoASAARQ0FQQchAAJAIAEvALoBQdm0AUcNACABQbQBakEGQQAQAyABKACwAUcNACABNQC0ASABKQOAAUICiFINACABLQC4AQ0AQQFBByABKAIgIAEtALkBRhshAAsgACEDDAULIAEgBiACEAxBACEDDAQLIAEgFDcDMCAEQQBIBEAgASgCBCICRQRAIAFCADcDCAsgACAFIAAgBUsbIQQDQCAAIARGBEBBByEDDAYLIAAgCGotAAghAyABIABBAWoiADYCqAEgASABKQMIIANB/wBxrSACrYaEIhU3AwgCQCADQYABcUUEQCADDQEgAkUNAUEHIQMMBwtBByEDIAEgAkEHaiICNgIEIAJBP0cNAQwGCwsgAUEANgIECyABIBU3AzggBSAAa0ECSQRAQQchAwwECyABIABBAWoiAjYCqAEgACAIai0ACEEhRwRAQQYhAwwECyABIABBAmoiBDYCqAEgAiAIai0ACEEBRwRAQQYhAwwEC0EHIQMgBCAFRg0DIAEgAEEDajYCqAEgASgCsAkhAEEGIQICQCAEIAhqLQAIIgNBJ0sNACAA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")||(N=D,D=t.locateFile?t.locateFile(N,m):m+N);var k=[];function z(e){var t=k[e];return t||(e>=k.length&&(k.length=e+1),k[e]=t=M.get(e)),t}function Q(e){try{return _.grow(e-b.byteLength+65535>>>16),T(_.buffer),1}catch(e){}}var W="function"==typeof atob?atob:function(e){var t,n,r,o,i,a,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=s.indexOf(e.charAt(c++))<<2|(o=s.indexOf(e.charAt(c++)))>>4,n=(15&o)<<4|(i=s.indexOf(e.charAt(c++)))>>2,r=(3&i)<<6|(a=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==i&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(r))}while(c>>=0)>o)return!1;for(var i=1;i<=4;i*=2){var a=r*(1+.2/i);if(a=Math.min(a,e+100663296),Q(Math.min(o,((t=Math.max(e,a))%(n=65536)>0&&(t+=n-t%n),t))))return!0}return!1}};!function(){var e={a:X};function n(e,n){var r,o=e.exports;t.asm=o,T((_=t.asm.c).buffer),M=t.asm.o,r=t.asm.d,I.unshift(r),function(e){if(R--,t.monitorRunDependencies&&t.monitorRunDependencies(R),0==R&&B){var n=B;B=null,n()}}()}function o(e){n(e.instance)}function i(t){return function(){if(!g&&(h||p)){if("function"==typeof fetch&&!V(D))return fetch(D,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+D+"'";return e.arrayBuffer()})).catch((function(){return U(D)}));if(a)return new Promise((function(e,t){a(D,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return U(D)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){v("failed to asynchronously prepare wasm: "+e),P(e)}))}if(R++,t.monitorRunDependencies&&t.monitorRunDependencies(R),t.instantiateWasm)try{return t.instantiateWasm(e,n)}catch(e){return v("Module.instantiateWasm callback failed with error: "+e),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||O(D)||V(D)||"function"!=typeof fetch?i(o):fetch(D,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(o,(function(e){return v("wasm streaming compile failed: "+e),v("falling back to ArrayBuffer instantiation"),i(o)}))}))).catch(r)}(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.d).apply(null,arguments)},t._init_decompressor=function(){return(t._init_decompressor=t.asm.e).apply(null,arguments)},t._decompress=function(){return(t._decompress=t.asm.f).apply(null,arguments)},t._get_in_buffer_ptr=function(){return(t._get_in_buffer_ptr=t.asm.g).apply(null,arguments)},t._get_out_buffer_ptr=function(){return(t._get_out_buffer_ptr=t.asm.h).apply(null,arguments)},t._in_buffer_set_pos=function(){return(t._in_buffer_set_pos=t.asm.i).apply(null,arguments)},t._in_buffer_set_size=function(){return(t._in_buffer_set_size=t.asm.j).apply(null,arguments)},t._out_buffer_set_pos=function(){return(t._out_buffer_set_pos=t.asm.k).apply(null,arguments)},t._out_buffer_set_size=function(){return(t._out_buffer_set_size=t.asm.l).apply(null,arguments)},t._get_curr_output_length=function(){return(t._get_curr_output_length=t.asm.m).apply(null,arguments)},t._is_input_end_reached=function(){return(t._is_input_end_reached=t.asm.n).apply(null,arguments)};var Y,j=t.stackSave=function(){return(j=t.stackSave=t.asm.p).apply(null,arguments)},K=t.stackRestore=function(){return(K=t.stackRestore=t.asm.q).apply(null,arguments)},$=t.stackAlloc=function(){return($=t.stackAlloc=t.asm.r).apply(null,arguments)};function q(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Z(e){function r(){Y||(Y=!0,t.calledRun=!0,A||(G(I),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)e=t.postRun.shift(),L.unshift(e);var e;G(L)}()))}R>0||(!function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)e=t.preRun.shift(),w.unshift(e);var e;G(w)}(),R>0||(t.setStatus?(t.setStatus("Running..."),setTimeout((function(){setTimeout((function(){t.setStatus("")}),1),r()}),1)):r()))}if(t.cwrap=function(e,t,n,r){var o=(n=n||[]).every((function(e){return"number"===e}));return"string"!==t&&o&&!r?x(e):function(){return y(e,t,n,arguments)}},B=function e(){Y||Z(),Y||(B=e)},t.run=Z,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Z(),t.ready}})();const CHUNK_SIZE=524288,ERR_CODES=["","Memory allocation failed","Memory usage limit reached","Unsupported check; not verifying file integrity","Not an .xz file","Unsupported options in the .xz headers","File is corrupt","Unknown decompression bug"],LOAD_PROGRESS_WEIGHT=2,DECOMPRESS_PROGRESS_WEIGHT=1;class XZLoader{constructor(e){this.manager=void 0!==e?e:DefaultLoadingManager,this.crossOrigin="Anonymous",this.xz=null}init(){return this.xz?Promise.resolve():Module().then((e=>{this._emInitDecompressor=e.cwrap("init_decompressor","number"),this._emDecompress=e.cwrap("decompress","number"),this._emGetInBufferPtr=e.cwrap("get_in_buffer_ptr","number"),this._emGetOutBufferPtr=e.cwrap("get_out_buffer_ptr","number"),this._emInBufferSetPos=e.cwrap("in_buffer_set_pos",null,["number"]),this._emInBufferSetSize=e.cwrap("in_buffer_set_size",null,["number"]),this._emOutBufferSetPos=e.cwrap("out_buffer_set_pos",null,["number"]),this._emOutBufferSetSize=e.cwrap("out_buffer_set_size",null,["number"]),this._emGetCurrOutputLength=e.cwrap("get_curr_output_length","number"),this._emIsInputEndReached=e.cwrap("is_input_end_reached","number"),this.xz=e}))}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);const o=this,i=Cache.get(e);if(void 0!==i)return o.manager.itemStart(e),setTimeout((function(){t&&t(i),o.manager.itemEnd(e)}),0),i;const a=this.init(),s=new XMLHttpRequest;return s.open("GET",e,!0),s.addEventListener("load",(function(i){const s=i.target.response;200===this.status||0===this.status?(0===this.status&&console.warn("v3d.XZLoader: HTTP Status 0 received."),a.then((()=>{o.decompressArrayBuffer(s,(function(n){setTimeout((function(){t&&t(n),o.manager.itemEnd(e),Cache.add(e,n)}),1)}),(function(e){if(n){n((2+1*e)/3)}}),(function(t){r&&r(t),o.manager.itemEnd(e),o.manager.itemError(e)}))}))):(r&&r(i),o.manager.itemEnd(e),o.manager.itemError(e))}),!1),n&&s.addEventListener("progress",(function(e){let t;t=e.lengthComputable?e.loaded/e.total:1;n(2*t/3)}),!1),s.addEventListener("error",(function(t){r&&r(t),o.manager.itemEnd(e),o.manager.itemError(e)}),!1),s.responseType="arraybuffer",s.send(null),o.manager.itemStart(e),s}setCrossOrigin(e){return this.crossOrigin=e,this}setPath(e){return this.path=e,this}decompressArrayBuffer(e,t,n,r){const o=this;function i(e){const t=o._emGetInBufferPtr();o.xz.HEAPU8.set(e,t),o._emInBufferSetPos(0),o._emInBufferSetSize(e.length),a()}function a(){o._emOutBufferSetPos(0)}const s=o._emInitDecompressor();if(0!=s)return console.error("XZLoader._emInitDecompressor: error code "+s+" ("+ERR_CODES[s]+")"),void(r&&r(s));const l=new Uint8Array(e),c=l.length,u=[];let d=0,h=Math.min(524288,c),p=0;i(l.subarray(d,h)),function e(){const s=o._emDecompress();if(s)console.error("XZLoader._emDecompress: error code "+s+" ("+ERR_CODES[s]+")"),r&&r(s);else{const r=o._emGetCurrOutputLength();if(u.push(function(e){const t=o._emGetOutBufferPtr();return new Uint8Array(o.xz.HEAPU8.subarray(t,t+e))}(r)),a(),o._emIsInputEndReached()&&(d=h,h=Math.min(h+524288,c),i(l.subarray(d,h))),n&&n(d/c),d==h){const e=u.reduce((function(e,t,n,r){return e+t.length}),0),n=new Uint8Array(e);let r=0;u.forEach((function(e){n.set(e,r),r+=e.length})),t&&t(n.buffer)}else p++,p%2==0?setTimeout(e,1):e()}}()}}class TTFLoader extends Loader{constructor(e){super(e),this.reversed=!1}load(e,t,n,r){const o=this,i=new FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.load(e,(function(e){t(o.parse(e))}),n,r)}parse(e){function t(e){var t,n=[];e.forEach((function(e){"m"===e.type.toLowerCase()?(t=[e],n.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)}));var r=[];return n.forEach((function(e){var t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};r.push(t);for(var n=e.length-1;n>0;n--){var o=e[n];t={type:o.type};void 0!==o.x2&&void 0!==o.y2?(t.x1=o.x2,t.y1=o.y2,t.x2=o.x1,t.y2=o.y1):void 0!==o.x1&&void 0!==o.y1&&(t.x1=o.x1,t.y1=o.y1),t.x=e[n-1].x,t.y=e[n-1].y,r.push(t)}})),r}return"undefined"==typeof opentype?(console.warn("v3d.TTFLoader: The loader requires opentype.js. Make sure it's included before using the loader."),null):function(e,n){for(var r=Math.round,o={},i=1e3/(e.unitsPerEm||2048),a=e.encoding.cmap.glyphIndexMap,s=Object.keys(a),l=0;l(o=s.indexOf("\n"))&&i=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(s.valid|=1,s.programtype=c[1],s.string+=l+"\n";l=n(e),!1!==l;)if(s.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(r))&&(s.gamma=parseFloat(c[1])),(c=l.match(o))&&(s.exposure=parseFloat(c[1])),(c=l.match(i))&&(s.valid|=2,s.format=c[1]),(c=l.match(a))&&(s.valid|=4,s.height=parseInt(c[1],10),s.width=parseInt(c[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=l+"\n";return 2&s.valid?4&s.valid?s:t(3,"missing image size specifier"):t(3,"missing format specifier")}(i);if(-1!==a){const e=a.width,n=a.height,s=function(e,n,r){const o=n;if(o<8||o>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(o!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const i=new Uint8Array(4*n*r);if(!i.length)return t(4,"unable to allocate buffer space");let a=0,s=0;const l=4*o,c=new Uint8Array(4),u=new Uint8Array(l);let d=r;for(;d>0&&se.byteLength)return t(1);if(c[0]=e[s++],c[1]=e[s++],c[2]=e[s++],c[3]=e[s++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=o)return t(3,"bad rgbe scanline format");let n,r=0;for(;r128;if(o&&(n-=128),0===n||r+n>l)return t(3,"bad scanline data");if(o){const t=e[s++];for(let e=0;e{!e.isPlaneReflectionProbe&&this._isVisible(e)||(r[e.id]=e.layers.mask,e.layers.disableAll())}));const o=this.reflectorWorldPosition;o.setFromMatrixPosition(this.matrixWorld);const i=this.cameraWorldPosition;i.setFromMatrixPosition(t.matrixWorld);const a=this.rotationMatrix;a.extractRotation(this.matrixWorld);const s=this.normal;s.set(0,1,0),s.applyMatrix4(a);const l=this.view;if(l.subVectors(o,i),l.dot(s)>0)return void e.traverse((e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=r[e.id])}));l.reflect(s).negate(),l.add(o),a.extractRotation(t.matrixWorld);const c=this.lookAtPosition;c.set(0,0,-1),c.applyMatrix4(a),c.add(i);const u=this.target;u.subVectors(o,c),u.reflect(s).negate(),u.add(o);const d=this.virtualCamera;d.position.copy(l),d.up.set(0,1,0),d.up.applyMatrix4(a),d.up.reflect(s),d.lookAt(u),d.far=t.far,d.updateMatrixWorld();const h=d.projectionMatrix;h.copy(t.projectionMatrix);const p=this.textureMatrix;p.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),p.multiply(h),p.multiply(d.matrixWorldInverse);const f=this.reflectorPlane;f.setFromNormalAndCoplanarPoint(s,o),f.applyMatrix4(d.matrixWorldInverse);const m=this.clipPlane;m.set(f.normal.x,f.normal.y,f.normal.z,f.constant),_vec4Tmp.x=(Math.sign(m.x)+h.elements[8])/h.elements[0],_vec4Tmp.y=(Math.sign(m.y)+h.elements[9])/h.elements[5],_vec4Tmp.z=-1,_vec4Tmp.w=(1+h.elements[10])/h.elements[14],m.multiplyScalar(2/m.dot(_vec4Tmp)),h.elements[2]=m.x,h.elements[6]=m.y,h.elements[10]=m.z+1-this.probeClipStart,h.elements[14]=m.w;const g=n.getRenderTarget(),_=n.xr.enabled,v=n.shadowMap.autoUpdate,A=n.useOIT;n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,n.useOIT=!1,n.setRenderTarget(this.renderTarget),n.state.buffers.depth.setMask(!0),!1===n.autoClear&&n.clear(),n.render(e,d),n.xr.enabled=_,n.shadowMap.autoUpdate=v,n.useOIT=A,n.setRenderTarget(g);const x=t.viewport;void 0!==x&&n.state.viewport(x),e.traverse((e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=r[e.id])})),this._calcLocalBounding()}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)}copy(e){return super.copy(e),this.influenceDistance=e.influenceDistance,this.probeClipStart=e.probeClipStart,this.visibilityGroup=e.visibilityGroup,this.visibilityGroupInv=e.visibilityGroupInv,this}dispose(){null!==this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=null),this.dispatchEvent({type:"dispose"})}_isVisible(e){if(null===this.visibilityGroup)return!0;if(!e.isMesh)return!0;return-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv}}PlaneReflectionProbe.prototype.isPlaneReflectionProbe=!0;class RectAreaLightUniformsLib{static init(e,t){void 0!==e&&void 0!==t||console.error("RectAreaLightUniformsLib: Missing LTC data (required in Verge3D)");const n=new Float32Array(e),r=new Float32Array(t);UniformsLib.LTC_FLOAT_1=new DataTexture(n,64,64,RGBAFormat,FloatType,300,ClampToEdgeWrapping,ClampToEdgeWrapping,LinearFilter,NearestFilter,1),UniformsLib.LTC_FLOAT_2=new DataTexture(r,64,64,RGBAFormat,FloatType,300,ClampToEdgeWrapping,ClampToEdgeWrapping,LinearFilter,NearestFilter,1),UniformsLib.LTC_FLOAT_1.needsUpdate=!0,UniformsLib.LTC_FLOAT_2.needsUpdate=!0;const o=new Uint16Array(e.length);e.forEach((function(e,t){o[t]=toHalfFloat(e)}));const i=new Uint16Array(t.length);t.forEach((function(e,t){i[t]=toHalfFloat(e)})),UniformsLib.LTC_HALF_1=new DataTexture(o,64,64,RGBAFormat,HalfFloatType,300,ClampToEdgeWrapping,ClampToEdgeWrapping,LinearFilter,NearestFilter,1),UniformsLib.LTC_HALF_2=new DataTexture(i,64,64,RGBAFormat,HalfFloatType,300,ClampToEdgeWrapping,ClampToEdgeWrapping,LinearFilter,NearestFilter,1),UniformsLib.LTC_HALF_1.needsUpdate=!0,UniformsLib.LTC_HALF_2.needsUpdate=!0}}class Font{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100,n="left",r="topBaseline",o=-1,i=!1){const a=[],s=createPaths(e,t,this.data,n,r,o,i);for(let e=0,t=s.length;e1?.5*f-m:-n.ascender/2*c;break;case"bottom":h=f-i-n.descender*c;break;case"bottomBaseline":h=f-i}for(let e=0;e=0||null===this.clippingGroup)&&!e.isAuxClippingMesh}assignToObject(e,t=0){const n=this.plane,r=e.material,o=e.geometry;if(r.clippingPlanes=r.clippingPlanes||[],-1==r.clippingPlanes.indexOf(n)&&r.clippingPlanes.push(n),r.clipShadows=this.clipShadows,r.clipIntersection=this.clipIntersection,this.crossSection){this.cleanupAuxMeshes(e);const i=new MeshBasicMaterial;i.depthWrite=!1,i.depthTest=!1,i.colorWrite=!1,i.stencilWrite=!0,i.stencilFunc=519,i.clipShadows=this.clipShadows,i.clipIntersection=this.clipIntersection;const a=!!e.isSkinnedMesh,s=e.morphTargetInfluences,l=isDef(s)&&s.length>0,c=i.clone();let u;c.name="ClipCrossSectionStencilBack",c.side=BackSide,c.clippingPlanes=[n],c.stencilFail=34055,c.stencilZFail=34055,c.stencilZPass=34055,a?(u=new SkinnedMesh(o,c),u.skeleton=e.skeleton):u=new Mesh(o,c),u.renderOrder=t,u.name="ClipCrossSectionStencilBack",u.isAuxClippingMesh=!0,l&&(u.morphTargetInfluences=s.slice(),u.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.add(u);const d=i.clone();let h;d.name="ClipCrossSectionStencilFront",d.side=FrontSide,d.clippingPlanes=[n],d.stencilFail=34056,d.stencilZFail=34056,d.stencilZPass=34056,a?(h=new SkinnedMesh(o,d),h.skeleton=e.skeleton):h=new Mesh(o,d),h.renderOrder=t+.1,h.name="ClipCrossSectionStencilFront",h.isAuxClippingMesh=!0,l&&(h.morphTargetInfluences=s.slice(),h.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.add(h),r.isMeshNodeMaterial&&(this._crossMatProfile=r.profile)}}createCrossSectionPlane(e,t){this.cleanupAuxMeshes();const n=new MeshNodeMaterial({name:"ClipCrossSectionColor",nodeGraph:MeshNodeMaterial.nodeGraphDiffuse(this.crossSectionColor,this.crossSectionOpacity,this._crossMatProfile),profile:this._crossMatProfile,clippingPlanes:e.filter((e=>e!==this.plane)),clipShadows:this.clipShadows,clipIntersection:this.clipIntersection,stencilWrite:!0,stencilRef:0,stencilFunc:517,stencilFail:7681,stencilZFail:7681,stencilZPass:7681,side:this.crossSectionRenderSide});this.crossSectionOpacity<1&&(n.transparent=!0,n.premultipliedAlpha=!0,n.blending=CustomBlending,n.blendEquation=AddEquation,n.blendSrc=OneFactor,n.blendDst=OneMinusSrcAlphaFactor);const r=new PlaneGeometry(this.crossSectionSize,this.crossSectionSize);this.negated?r.rotateX(-Math.PI/2):r.rotateX(Math.PI/2);const o=new Mesh(r,n);o.name="ClipCrossSectionColor",o.isAuxClippingMesh=!0,o.renderOrder=t,o.onAfterRender=function(e){e.clearStencil()},this.add(o)}cleanupAuxMeshes(e=null){if(e)for(let t=e.children.length-1;t>=0;t--){const n=e.children[t];n.isAuxClippingMesh&&n.material.clippingPlanes[0]==this.plane&&(n.geometry.dispose(),n.material.dispose(),e.remove(n))}else for(let e=this.children.length-1;e>=0;e--){const t=this.children[e];t.isAuxClippingMesh&&(t.geometry.dispose(),t.material.dispose(),this.remove(t))}}copy(e){return super.copy(e),this.plane=e.plane,this.clippingGroup=e.clippingGroup,this.clipShadows=e.clipShadows,this.negated=e.negated,this.clipIntersection=e.clipIntersection,this.crossSection=e.crossSection,this.crossSectionColor.copy(e.crossSectionColor),this.crossSectionOpacity=e.crossSectionOpacity,this.crossSectionRenderSide=e.crossSectionRenderSide,this.crossSectionSize=e.crossSectionSize,this._crossMatProfile=e._crossMatProfile,this}}ClippingPlaneObject.prototype.isClippingPlaneObject=!0;const ORBIT_CONTROLS_DEFAULTS={minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,autoRotate:!1,autoRotateSpeed:2,enablePan:!0,panInertia:.05,panSpeed:1.3,panSpeedKey:15,screenSpacePanning:!0,enableRotate:!0,rotateInertia:.05,rotateInertiaTouch:.05,rotateSpeed:1.2,rotateSpeedTouch:.7,enableZoom:!0,zoomInertia:.05,zoomInertiaTouch:.05,zoomSpeed:5,zoomSpeedTouch:1,enableDamping:!0,enableTurnover:!1,enableKeys:!0},ACCUM_PER_SEC_COEFF=60,ACCUM_CLAMP_ROTATE=.1,ACCUM_CLAMP_PAN=.1,ACCUM_CLAMP_DOLLY=.001,Y_Up=new Vector3(0,1,0),QUAT_FLIP=(new Quaternion).setFromAxisAngle(new Vector3(0,0,1),Math.PI),STATE={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},EPS=1e-6,_vec3Tmp$2=new Vector3,_vec3Tmp2$1=new Vector3,_quatTmp$2=new Quaternion,_quatTmp2$1=new Quaternion,_changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"};class OrbitControls extends EventDispatcher{constructor(e,t){super(),void 0===t&&console.warn('v3d.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('v3d.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.targetObj=new Object3D,this.minDistance=ORBIT_CONTROLS_DEFAULTS.minDistance,this.maxDistance=ORBIT_CONTROLS_DEFAULTS.maxDistance,this.minZoom=ORBIT_CONTROLS_DEFAULTS.minZoom,this.maxZoom=ORBIT_CONTROLS_DEFAULTS.maxZoom,this.minPolarAngle=ORBIT_CONTROLS_DEFAULTS.minPolarAngle,this.maxPolarAngle=ORBIT_CONTROLS_DEFAULTS.maxPolarAngle,this.minAzimuthAngle=ORBIT_CONTROLS_DEFAULTS.minAzimuthAngle,this.maxAzimuthAngle=ORBIT_CONTROLS_DEFAULTS.maxAzimuthAngle,this.enableDamping=ORBIT_CONTROLS_DEFAULTS.enableDamping,this.enableZoom=ORBIT_CONTROLS_DEFAULTS.enableZoom,this.zoomSpeed=ORBIT_CONTROLS_DEFAULTS.zoomSpeed,this.zoomSpeedTouch=ORBIT_CONTROLS_DEFAULTS.zoomSpeedTouch,this.zoomInertia=ORBIT_CONTROLS_DEFAULTS.zoomInertia,this.zoomInertiaTouch=ORBIT_CONTROLS_DEFAULTS.zoomInertiaTouch,this.enableRotate=ORBIT_CONTROLS_DEFAULTS.enableRotate,this.rotateSpeed=ORBIT_CONTROLS_DEFAULTS.rotateSpeed,this.rotateSpeedTouch=ORBIT_CONTROLS_DEFAULTS.rotateSpeedTouch,this.rotateInertia=ORBIT_CONTROLS_DEFAULTS.rotateInertia,this.rotateInertiaTouch=ORBIT_CONTROLS_DEFAULTS.rotateInertiaTouch,this.enablePan=ORBIT_CONTROLS_DEFAULTS.enablePan,this.panSpeed=ORBIT_CONTROLS_DEFAULTS.panSpeed,this.screenSpacePanning=ORBIT_CONTROLS_DEFAULTS.screenSpacePanning,this.panSpeedKey=ORBIT_CONTROLS_DEFAULTS.panSpeedKey,this.panInertia=ORBIT_CONTROLS_DEFAULTS.panInertia,this.autoRotate=ORBIT_CONTROLS_DEFAULTS.autoRotate,this.autoRotateSpeed=ORBIT_CONTROLS_DEFAULTS.autoRotateSpeed,this.enableTurnover=ORBIT_CONTROLS_DEFAULTS.enableTurnover,this.enableKeys=ORBIT_CONTROLS_DEFAULTS.enableKeys,this.mouseButtons={ROTATE:MOUSE.LEFT,ZOOM:MOUSE.MIDDLE,PAN:MOUSE.RIGHT},this.target0=this.targetObj.position.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,Object.defineProperty(this,"inTween",{get:()=>w.active||I.active,set(e){w.active=e}}),this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.targetObj.position)},this.saveState=function(){n.targetObj.updateWorldMatrix(!0,!1),n.target0.setFromMatrixPosition(n.targetObj.matrixWorld),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.forceMouseUp=function(){G()},this.reset=function(){n.targetObj.updateWorldMatrix(!0,!1);const e=_vec3Tmp$2.copy(n.target0);n.targetObj.worldToLocal(e),n.targetObj.position.add(e),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(_changeEvent),n.update(),r=STATE.NONE},this.update=function(){const e=new Vector3,t=new Vector3,d=new Vector3,h=new Quaternion;let _=!1,v=!1;return function(){const y=n.object.position;if(n.targetObj.updateWorldMatrix(!0,!1),w.active)w.update((function(t,r,o){if(y.copy(r),e.copy(o),n.object.lookAt(e),t>=1){i.set(0,0,0),s.set(0,0,0),a=1,x.set(0,0);for(let e in c)c[e]=0;f.set(0,0),T.getDelta()}}));else if(I.active)I.update((function(t,r,o){if(e.copy(r),n.object.lookAt(e),n.object.zoom=o,n.object.updateProjectionMatrix(),t>=1){i.set(0,0,0),s.set(0,0,0),a=1,x.set(0,0);for(let e in c)c[e]=0;f.set(0,0),T.getDelta()}}));else{e.setFromMatrixPosition(n.targetObj.matrixWorld),t.copy(y).sub(e);const l=_quatTmp$2.setFromUnitVectors(n.object.up,Y_Up),d=_quatTmp2$1.copy(l).invert();if(t.applyQuaternion(l),o.setFromVector3(t),n.autoRotate&&r===STATE.NONE&&R(2*Math.PI/60/60*n.autoRotateSpeed),o.theta+=i.theta,o.phi+=i.phi,n.enableTurnover){_&&(o.phi-=2*i.phi),v!=_&&r==STATE.NONE&&(v=_),v&&(o.theta-=2*i.theta);const e=o.phi;(e<=0||e>=Math.PI)&&(_=!_,o.theta+=Math.PI,o.phi=e>0?2*Math.PI-e:Math.abs(e))}else isFinite(n.minAzimuthAngle)&&isFinite(n.maxAzimuthAngle)&&(o.theta=clampAngle(o.theta,n.minAzimuthAngle,n.maxAzimuthAngle)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi));o.makeSafe(),n.object.isPerspectiveCamera?(o.radius*=a,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius))):n.object.isOrthographicCamera&&(n.object.zoom/=a,n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom)),n.object.updateProjectionMatrix()),e.add(s),t.setFromSpherical(o),t.applyQuaternion(d),y.copy(e).add(t),n.object.lookAt(e),_&&(n.enableTurnover?n.object.quaternion.multiply(QUAT_FLIP):_=!1),i.set(0,0,0),s.set(0,0,0),function(){const e=T.getDelta();let t,r;p.copy(f),f.x=n.enableDamping?expAverageClamp(f.x,0,e,g,.1):0,f.y=n.enableDamping?expAverageClamp(f.y,0,e,g,.1):0,p.sub(f),function(){const e=n.domElement===document?n.domElement.body:n.domElement,t=e.clientWidth,r=e.clientHeight;if(!t||!r)return;R(2*Math.PI*p.x/t*m),o=2*Math.PI*p.y/r*m,i.phi-=o;var o}(),A.copy(x),x.x=n.enableDamping?expAverageClamp(x.x,0,e,n.panInertia,.1):0,x.y=n.enableDamping?expAverageClamp(x.y,0,e,n.panInertia,.1):0,A.sub(x),A.multiplyScalar(n.panSpeed);for(let o in c)u.isKeyDown[o]?t=c[o]=1:(r=c[o],c[o]=expAverageClamp(c[o],0,e,n.panInertia,.1),t=r-c[o]),n.enabled&&n.enableKeys&&n.enablePan&&(t*=60*e*n.panSpeedKey,o==Keys.A||o==Keys.LEFT_ARROW?A.x+=t:o==Keys.D||o==Keys.RIGHT_ARROW?A.x-=t:o==Keys.W||o==Keys.UP_ARROW?A.y+=t:o!=Keys.S&&o!=Keys.DOWN_ARROW||(A.y-=t));(function(e,t){const r=n.domElement===document?n.domElement.body:n.domElement,o=r.clientWidth,i=r.clientHeight;if(!o||!i)return;if(n.object.isPerspectiveCamera){n.targetObj.updateWorldMatrix(!0,!1);const r=_vec3Tmp$2.setFromMatrixPosition(n.targetObj.matrixWorld),o=n.object.position;let a=_vec3Tmp2$1.copy(o).sub(r).length();a*=Math.tan(n.object.fov/2*DEG2RAD),P(2*e*a/i,n.object.matrix),D(2*t*a/i,n.object.matrix)}else n.object.isOrthographicCamera?(P(e*(n.object.right-n.object.left)/n.object.zoom/o,n.object.matrix),D(t*(n.object.top-n.object.bottom)/n.object.zoom/i,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)})(A.x,A.y),a=S,S=n.enableDamping?expAverageClamp(S,1,e,E,.001):1,a/=S}()}return n.targetObj.position.copy(e),!!(l||d.distanceToSquared(n.object.position)>EPS||8*(1-h.dot(n.object.quaternion))>EPS)&&(n.dispatchEvent(_changeEvent),d.copy(n.object.position),h.copy(n.object.quaternion),l=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",H),n.domElement.removeEventListener("mousedown",V),n.domElement.removeEventListener("wheel",k),n.domElement.removeEventListener("touchstart",z),n.domElement.removeEventListener("touchend",W),n.domElement.removeEventListener("touchmove",Q),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),u.dispose()},this.tween=function(){const e=1e-5;return function(t,r,o,i,a){n.targetObj.updateWorldMatrix(!0,!1);const s=_vec3Tmp$2.setFromMatrixPosition(n.targetObj.matrixWorld);n.object.parent&&(t=_vec3Tmp2$1.copy(t),n.object.parent.worldToLocal(t)),t.manhattanDistanceTo(n.object.position)0?N(L()):C.y<0&&F(L()),y.copy(b),n.update()}(e);break;case STATE.PAN:if(!1===n.enablePan)return;O(e)}}function G(e){!1!==n.enabled&&(document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),n.dispatchEvent(_endEvent),r=STATE.NONE)}function k(e){!1===n.enabled||!1===n.enableZoom||r!==STATE.NONE&&r!==STATE.ROTATE||(e.preventDefault(),e.stopPropagation(),n.dispatchEvent(_startEvent),function(e){M=n.zoomSpeed,E=n.zoomInertia,e.deltaY<0?F(L(Math.abs(e.deltaY)/100)):e.deltaY>0&&N(L(Math.abs(e.deltaY)/100)),n.update()}(e),n.dispatchEvent(_endEvent))}function z(e){if(!1!==n.enabled){switch(e.touches.length){case 1:if(!1===n.enableRotate)return;!function(e){d.set(e.touches[0].pageX,e.touches[0].pageY)}(e),r=STATE.TOUCH_ROTATE;break;case 2:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){if(n.enableZoom){M=n.zoomSpeedTouch,E=n.zoomInertiaTouch;let t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+r*r);y.set(0,o)}if(n.enablePan){let t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);_.set(t,n)}n.update()}(e),r=STATE.TOUCH_DOLLY_PAN;break;default:r=STATE.NONE}r!==STATE.NONE&&n.dispatchEvent(_startEvent)}}function Q(e){if(!1!==n.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===n.enableRotate)return;if(r!==STATE.TOUCH_ROTATE)return;!function(e){B(e.touches[0].pageX,e.touches[0].pageY),m=n.rotateSpeedTouch,g=n.rotateInertiaTouch}(e);break;case 2:if(!1===n.enableZoom&&!1===n.enablePan)return;if(r!==STATE.TOUCH_DOLLY_PAN)return;!function(e){let t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+r*r);b.set(0,o),C.subVectors(b,y),y.copy(b);let i=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(i,a),A.subVectors(v,_),_.copy(v),n.enableZoom&&Math.abs(C.length())>Math.abs(A.length())&&(C.y>0?F(L()):C.y<0&&N(L())),n.enablePan&&Math.abs(C.length())t.x?t.copy(_closestPlanePoint):t.x=Math.max(t.x,_tpos.x);break;case"Y":_tpos.y+=r*n.y,_pos$2.subVectors(t,_tpos),e=_normalVec.dot(_pos$2),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$2,_normalVec).add(_tpos),_closestPlanePoint.y>t.y?t.copy(_closestPlanePoint):t.y=Math.max(t.y,_tpos.y);break;case"Z":_tpos.z+=r*n.z,_pos$2.subVectors(t,_tpos),e=_normalVec.dot(_pos$2),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$2,_normalVec).add(_tpos),_closestPlanePoint.z>t.z?t.copy(_closestPlanePoint):t.z=Math.max(t.z,_tpos.z);break;case"-X":_tpos.x+=r*n.x,_pos$2.subVectors(t,_tpos),e=_normalVec.dot(_pos$2),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$2,_normalVec).add(_tpos),_closestPlanePoint.x=this.distance&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)):"LIMITDIST_OUTSIDE"==this.limitMode?this._distInit<=this.distance&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)):"LIMITDIST_ONSURFACE"==this.limitMode&&this._distInit-this.distance!=0&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)),this._clampSurf&&(e.position.lerpVectors(this._objPosInit,_pos$1,(1-this._sfac)*this.influence),e.parent&&e.parent.worldToLocal(e.position)))}}LimitDistanceConstraint.prototype.isLimitDistanceConstraint=!0;const objPosWorld=new Vector3,objPosTarget=new Vector3,objPosLocal=new Vector3,mat4Tmp=new Matrix4;class LimitLocationConstraint extends TargetConstraint{constructor(e=null){super(e),this.type="LimitLocationConstraint",this.space=2,this.min=(new Vector3).setScalar(-1/0),this.max=(new Vector3).setScalar(1/0)}copy(e){return super.copy(e),this.min.copy(e.min),this.max.copy(e.max),this.space=e.space,this}update(e){if(super.update(e),!this.mute)switch(this.space){case 0:this._updateObjMatrixWorld(e),objPosWorld.setFromMatrixPosition(e.matrixWorld),objPosWorld.clamp(this.min,this.max),objPosLocal.copy(objPosWorld),null!==e.parent&&objPosLocal.applyMatrix4(mat4Tmp.copy(e.parent.matrixWorld).invert()),e.position.copy(objPosLocal);break;case 1:null!==this.target&&(this._updateObjMatrixWorld(e),this._updateObjMatrixWorld(this.target),objPosWorld.setFromMatrixPosition(e.matrixWorld),objPosTarget.copy(objPosWorld),objPosTarget.applyMatrix4(mat4Tmp.copy(this.target.matrixWorld).invert()),objPosTarget.clamp(this.min,this.max),objPosWorld.copy(objPosTarget),objPosWorld.applyMatrix4(this.target.matrixWorld),objPosLocal.copy(objPosWorld),null!==e.parent&&objPosLocal.applyMatrix4(mat4Tmp.copy(e.parent.matrixWorld).invert()),e.position.copy(objPosLocal));break;default:e.position.clamp(this.min,this.max)}}}LimitLocationConstraint.prototype.isLimitLocationConstraint=!0;const _euler=new Euler;class LimitRotationConstraint extends Constraint{constructor(){super(),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}copy(e){return super.copy(e),this.axis=e.axis,this.min=e.min,this.max=e.max,this}update(e){super.update(e),this.mute||("X"==this.axis?(_euler.setFromQuaternion(e.quaternion,"XYZ"),_euler.x=this._clampAngle(_euler.x,this.min,this.max)):"Y"==this.axis?(_euler.setFromQuaternion(e.quaternion,"YZX"),_euler.y=this._clampAngle(_euler.y,this.min,this.max)):"Z"==this.axis&&(_euler.setFromQuaternion(e.quaternion,"ZXY"),_euler.z=this._clampAngle(_euler.z,this.min,this.max)),e.quaternion.setFromEuler(_euler))}_clampAngle(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=clampAngle(e,t,n)),e}}LimitRotationConstraint.prototype.isLimitRotationConstraint=!0;class LimitScaleConstraint extends Constraint{constructor(){super(),this.type="LimitScaleConstraint",this.min=(new Vector3).setScalar(-1/0),this.max=(new Vector3).setScalar(1/0)}copy(e){return super.copy(e),this.min.copy(e.min),this.max.copy(e.max),this}update(e){super.update(e),this.mute||e.scale.clamp(this.min,this.max)}}LimitScaleConstraint.prototype.isLimitScaleConstraint=!0;const QUAT_90_MX$2=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),_objWorldPos=new Vector3,_targetWorldPos=new Vector3,_trackDir=new Vector3,_lockDir=new Vector3,_projDir=new Vector3,_plane=new Plane,_vec=new Vector3,_tmpVec$2=new Vector3,_tmpQuat$2=new Quaternion;class LockedTrackConstraint extends TargetConstraint{constructor(e){super(e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y",this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis,this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){if(super.update(e),this.mute)return;if(_trackDir.set("X"==this.trackAxis?1:"-X"==this.trackAxis?-1:0,"Y"==this.trackAxis?1:"-Y"==this.trackAxis?-1:0,"Z"==this.trackAxis?1:"-Z"==this.trackAxis?-1:0),_lockDir.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1==Math.abs(_trackDir.dot(_lockDir)))return;_objWorldPos.setFromMatrixPosition(e.matrixWorld),_targetWorldPos.setFromMatrixPosition(this.target.matrixWorld),_plane.setFromNormalAndCoplanarPoint(_lockDir,_objWorldPos),_plane.projectPoint(_targetWorldPos,_projDir).sub(_objWorldPos);const t=_vec.crossVectors(_trackDir,_projDir).dot(_lockDir)>0?1:-1;e.setRotationFromAxisAngle(_plane.normal,t*_trackDir.angleTo(_projDir)),e.parent&&(e.parent.matrixWorld.decompose(_tmpVec$2,_tmpQuat$2,_tmpVec$2),e.quaternion.premultiply(_tmpQuat$2.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX$2)}}LockedTrackConstraint.prototype.isLockedTrackConstraint=!0;const UP_WORLD$1=new Vector3(0,1,0),QUAT_90_MX$1=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),plane=new Plane,objWorldPos=new Vector3,targetWorldPos=new Vector3,targetDir=new Vector3,upProjected=new Vector3,lastAxis=new Vector3,rotMat=new Matrix4,tmpVec=new Vector3,tmpQuat=new Quaternion;class TrackToConstraint extends TargetConstraint{constructor(e){super(e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y",this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.upAxis=e.upAxis,this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){if(super.update(e),this.mute)return;const t=this.trackAxis[this.trackAxis.length-1],n=this.upAxis[this.upAxis.length-1],r="-"==this.trackAxis[0],o="-"==this.upAxis[0];if(t==n)return;objWorldPos.setFromMatrixPosition(e.matrixWorld),targetWorldPos.setFromMatrixPosition(this.target.matrixWorld),targetDir.subVectors(targetWorldPos,objWorldPos),targetDir.lengthSq()?targetDir.normalize():targetDir.set(0,-1,0),plane.set(targetDir,0),1!=Math.abs(targetDir.dot(UP_WORLD$1))?plane.projectPoint(UP_WORLD$1,upProjected).normalize():upProjected.set(0,0,-1),r&&targetDir.negate(),o&&upProjected.negate();let i="X"==t?targetDir:"X"==n?upProjected:null,a="Y"==t?targetDir:"Y"==n?upProjected:null,s="Z"==t?targetDir:"Z"==n?upProjected:null;i?a?s||(s=lastAxis.crossVectors(i,a)):a=lastAxis.crossVectors(s,i):i=lastAxis.crossVectors(a,s),rotMat.makeBasis(i,a,s),e.setRotationFromMatrix(rotMat),e.parent&&(e.parent.matrixWorld.decompose(tmpVec,tmpQuat,tmpVec),e.quaternion.premultiply(tmpQuat.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX$1)}}TrackToConstraint.prototype.isTrackToConstraint=!0;class FixOrthoZoomConstraint extends TargetConstraint{constructor(e){super(e),this._orthoZoom=1}copy(e){super.copy(e),this._orthoZoom=e._orthoZoom}update(e){if(super.update(e),this.mute)return;const t=this.target;if(e.parent!==t||!t.isOrthographicCamera)return void console.error("FixOrthoZoom: object should be a direct child of the orthographic camera");const n=this._orthoZoom/t.zoom;e.position.multiplyScalar(n),e.scale.multiplyScalar(n),this._orthoZoom=t.zoom}}FixOrthoZoomConstraint.prototype.isFixOrthoZoomConstraint=!0;const _vec3Tmp$1=new Vector3,_vec3Tmp2=new Vector3,_quatTmp$1=new Quaternion,_bbox=new Box3,_bsphere=new Sphere;class CanvasFitConstraint extends TargetConstraint{constructor(e){super(e),this.type="CanvasFitConstraint",this.edgeH="NONE",this.edgeV="NONE",this.offset=0,this.fitShape="BOX",this.xr=null}copy(e){return super.copy(e),this.edgeH=e.edgeH,this.edgeV=e.edgeV,this.offset=e.offset,this.fitShape=e.fitShape,this.xr=e.xr,this}update(e){if(super.update(e),this.mute)return;if(e.parent!==this.target)return void console.error(`CanvasFitConstraint: object ${e.name} should be a direct child of the camera`);let t,n,r,o;t=this.xr&&this.xr.enabled&&this.xr.isPresenting?this.xr.getCamera():this.target;const i="LEFT"==this.edgeH?-1:"RIGHT"==this.edgeH?1:0,a="BOTTOM"==this.edgeV?-1:"TOP"==this.edgeV?1:0;t.isPerspectiveCamera&&(r=degToRad(t.fov/2),n=Math.atan(t.aspect*Math.tan(r)),"LEFT"==this.edgeH&&(n*=i),"BOTTOM"==this.edgeV&&(r*=a),o=Math.abs(e.position.z)),e.geometry;let s=0,l=0,c=0,u=0;if(e.matrix.compose(e.position,e.quaternion,e.scale),"BOX"==this.fitShape)if(_bbox.makeEmpty(),e.resolveMultiMaterial().forEach((function(e){e.geometry&&(null==e.geometry.boundingBox&&e.geometry.computeBoundingBox(),_bbox.union(e.geometry.boundingBox))})),_bbox.isEmpty())s=-i*this.offset,l=-a*this.offset;else{_bbox.applyMatrix4(e.matrix);const t=_bbox.getCenter(_vec3Tmp$1).sub(e.position),n=_bbox.getSize(_vec3Tmp2).addScalar(2*this.offset);s=-(.5*n.x*i+t.x),l=-(.5*n.y*a+t.y),c=n.x,u=n.y}else if("SPHERE"==this.fitShape)if(_bsphere.makeEmpty(),e.resolveMultiMaterial().forEach((function(e){e.geometry&&(null===e.geometry.boundingSphere&&e.geometry.computeBoundingSphere(),_bsphere.isEmpty()?_bsphere.copy(e.geometry.boundingSphere):_bsphere.union(e.geometry.boundingSphere))})),_bsphere.isEmpty())s=-i*this.offset,l=-a*this.offset;else{_bsphere.applyMatrix4(e.matrix),_bsphere.radius+=this.offset;const o=_vec3Tmp$1.copy(_bsphere.center).sub(e.position);s=-(_bsphere.radius*i+o.x),l=-(_bsphere.radius*a+o.y),t.isPerspectiveCamera&&(s/=Math.cos(n),l/=Math.cos(r)),c=2*_bsphere.radius,u=2*_bsphere.radius}else s=-i*this.offset,l=-a*this.offset;"STRETCH"==this.edgeH?(e.position.x=s,0!==c&&(e.scale.applyQuaternion(_quatTmp$1.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.x*=2*o*Math.tan(n)/c:e.scale.x*=(t.right-t.left)/t.zoom/c,e.scale.applyQuaternion(_quatTmp$1.copy(e.quaternion).invert()))):"NONE"!==this.edgeH&&(t.isPerspectiveCamera?e.position.x=o*Math.tan(n)+s:e.position.x=(i<0?t.left:t.right)/t.zoom+s),"STRETCH"==this.edgeV?(e.position.y=l,0!==u&&(e.scale.applyQuaternion(_quatTmp$1.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.y*=2*o*Math.tan(r)/u:e.scale.y*=(t.top-t.bottom)/t.zoom/u,e.scale.applyQuaternion(_quatTmp$1.copy(e.quaternion).invert()))):"NONE"!==this.edgeV&&(t.isPerspectiveCamera?e.position.y=o*Math.tan(r)+l:e.position.y=(a<0?t.bottom:t.top)/t.zoom+l)}}CanvasFitConstraint.prototype.isCanvasFitConstraint=!0;class CanvasBreakpointsConstraint extends Constraint{constructor(){super(),this.type="CanvasBreakpointsConstraint",this.minWidth=0,this.maxWidth=1/0,this.minHeight=0,this.maxHeight=1/0,this.orientation="ALL",this.appInstance=null}copy(e){return super.copy(e),this.minWidth=e.minWidth,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight,this.maxHeight=e.maxHeight,this.orientation=e.orientation,this.appInstance=e.appInstance,this}update(e){if(super.update(e),this.mute)return;if(!this.appInstance)return;const t=this.appInstance.getWidth(),n=this.appInstance.getHeight();let r;switch(this.orientation){case"ALL":r=!0;break;case"LANDSCAPE":r=t/n>=1;break;case"PORTRAIT":r=t/n<1}if(this.appInstance.getCamera()!==e||t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&r)t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&r?e.traverse((e=>{e.internVisible=!0})):e.traverse((e=>{e.internVisible=!1}));else{let r=this.findAlternativeCamera(e,this.appInstance.scene,t,n);r&&this.appInstance.setCamera(r)}}findAlternativeCamera(e,t,n,r){let o,i,a=!1;return e&&t.traverse((function(t){if(!a&&t.isCamera&&t!=e)for(let e=0;e=1;break;case"PORTRAIT":o=n/r<1}n>=s.minWidth&&n<=s.maxWidth&&r>=s.minHeight&&r<=s.maxHeight&&o&&(i?(console.error("CanvasBreakpointsConstraint: two or more alternative cameras"),a=!0):i=t)}}})),i}}CanvasBreakpointsConstraint.prototype.isCanvasBreakpointsConstraint=!0;const isNdarray=function(e){return!!e&&(!!e.dtype&&new RegExp("function View[0-9]+d(:?"+e.dtype+")+").test(String(e.constructor)))},isNdarrayLike=function(e){return!!e&&(void 0!==e.data&&Array.isArray(e.shape)&&void 0!==e.offset&&void 0!==e.stride)};function isArrayLike(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function inferType(e){if(e){if(isNdarray(e)||isNdarrayLike(e))return"generic"===e.dtype?inferType.GENERIC_NDARRAY:inferType.NDARRAY;if(isArrayLike(e))return inferType.ARRAY_OF_ARRAYS;throw new Error("Unhandled data type. Got type: "+typeof e)}}function capitalize(e){return e[0].toUpperCase()+e.slice(1)}inferType.ARRAY_OF_ARRAYS="Arr",inferType.NDARRAY="Nd",inferType.GENERIC_NDARRAY="GenNd",inferType.PACKED="PackArr";const computeCacheKey=function(e,t,n,r,o,i){var a,s=[],l=!1;for(a=0;a=0;r--){if(o[r]!==(Array.isArray(e[r])?e[r][1]:e[r])-1){o[r]++;break}o[r]=Array.isArray(e[r])?e[r][0]:0}},accessorPreamble=function(e,t,n,r){var o,i=[];switch(inferType(r)){case inferType.NDARRAY:for(i.push(" const "+t+" = "+n+".data;"),i.push(" const "+t+"Offset = "+n+".offset;"),o=0;o1)throw new Error("Analytical derivative not implemented for rational b-splines with order n = "+y+".")}i&&(e="Basis"+e),a&&(e="Der"+a.join("_")+"_"+e);var b=evaluatorCache[e];if(r)var C="function"==typeof r?r:console.log;if(b)return r&&C(codeCache[e]),b.bind(t);var S=[],M="evaluate"+e,E=n.point;i&&(E=function(e,t){for(var n=[],r=0;r "+D+"[i][1] || a === undefined || isNaN(a)) {"),V(" throw new Error('Invalid Spline parameter in dimension '+i+'. Valid domain is ['+"+D+"[i][0]+', '+"+D+"[i][1]+']. but got t'+i+' = '+arguments[i + 1]+'.');"),V(" }"),V("}")),d=0;d "+F(d)+" + 1) {"),V(" m = 0.5 * (h + "+F(d)+") | 0;"),V(" if ("+w([d,"m"])+" > "+P(d)+") h = m;"),V(" else "+F(d)+" = m;"),V("}"),U("\n // Fetch knots for dimension "+d+"\n"),s=1-m[d];s<=m[d];s++)"closed"===x[d]?V(s<0?"let "+I([d,s+m[d]-1])+" = "+z(F(d)+" < "+-s,w([d,0])+" + "+w([d,[N(d),F(d),s]])+" - "+w([d,[N(d)]]),w([d,[F(d),s]]))+";":s>0?"let "+I([d,s+m[d]-1])+" = "+z(F(d)+" + "+s+" > "+N(d),w([d,N(d)])+" + "+w([d,s+" + "+F(d)+" - "+N(d)])+" - "+w([d,0]),w([d,[F(d),s]]))+";":"let "+I([d,s+m[d]-1])+" = "+w([d,[F(d),s]])+";"):V("let "+I([d,s+m[d]-1])+" = "+w([d,[F(d),s]])+";");else{for(U("\n // Directly compute knot interval for dimension "+d+"\n"),"closed"===x[d]?V(F(d)+" = ("+P(d)+" | 0) % "+N(d)+";"):(V(F(d)+" = ("+P(d)+" | 0);"),V("if ("+F(d)+" < "+m[d]+") "+F(d)+" = "+m[d]+";"),V("if ("+F(d)+" > "+N(d)+" - 1) "+F(d)+" = "+N(d)+" - 1;")),U("\n // Compute and clamp knots for dimension "+d+"\n"),s=1-m[d];s<=m[d];s++)V("let "+(h=I([d,s+m[d]-1]))+" = "+F(d)+" + "+s+";");if("clamped"===x[d])for(s=1-m[d];s<=m[d];s++)h=I([d,s+m[d]-1]),s<0&&V("if ("+h+" < "+m[d]+") "+h+" = "+m[d]+";"),s>0&&V("if ("+h+" > "+N(d)+") "+h+" = "+N(d)+";");"closed"===x[d]&&(U("\n // Wrap the B-Spline parameter for closed boundary"),V(P(d)+" %= "+N(d)+";"))}for(d=0,c=[];d=0;d--)for(c[d]=[m[d],m[d]+1],s=0;ss;l--){var W=a&&m[d]-s-a[d]<=0;W?(V("m = 1 / ("+I([d,l-s+m[d]-1])+" - "+I([d,l-1])+");"),_&&(V("a = ("+P(d)+" - "+I([d,l-1])+") * m;"),V("b = 1 - a;"))):(V("a = ("+P(d)+" - "+I([d,l-1])+") / ("+I([d,l-s+m[d]-1])+" - "+I([d,l-1])+");"),V("b = 1 - a;")),_&&ndloop(c,(function(e){var t=e.slice(),n=e.slice();t[d]=l,n[d]=l-1,W&&_&&V("h = "+R(t)+";"),V(R(t)+" = b * "+R(n)+" + a * "+R(t)+";")})),ndloop(c,(function(e){var t,n,r,o=e.slice(),a=e.slice();if(o[d]=l,a[d]=l-1,W){var c=s+1;if(i)t=_?"h * "+R(a)+" / "+R(o)+" * ":"",n=L(o)+(_?" / h":""),r=L(a)+(_?" / "+R(a):""),V(L(o)+" = "+c+" * "+t+"("+n+" - "+r+") * m;");else{var h=o.slice(),f=a.slice();for(u=0;u= 0; "+a+"--) {");for(o=0;o=0;o--)p.push("}");p.push("return this;"),p.push("}");const g=new Function([p.join("\n"),"; return ",f].join(""))();return r&&console.log(p.join("\n")),transformerCache[e]=g,g.bind(t)};var supportCache={};const createSupport=function(e,t,n,r,o){var i=supportCache[e];if(i)return i.bind(t);var a,s,l,c=t.degree,u=t.knots,d=t.splineDimension,h=t.boundary,p=[],f="support"+e,m=n.knot,g=createVariable("t"),_=r?"domain":"d",v=createVariable(r?"size":"s"),A=createVariable(r?"knotIndex":"i"),x=!0;for(l=0;l "+_+"[i][1] || a === undefined || isNaN(a)) {"),y(" throw new Error('Invalid Spline parameter in dimension '+i+'. Valid domain is ['+"+_+"[i][0]+', '+"+_+"[i][1]+']. but got t'+i+' = '+arguments[i + 1]+'.');"),y(" }"),y("}")),l=0;l "+A(l)+" + 1) {"),y(" m = 0.5 * (h + "+A(l)+") | 0;"),y(" if ("+m([l,"m"])+" > "+g(l)+") h = m;"),y(" else "+A(l)+" = m;"),y("}")):"closed"===h[l]?y(A(l)+" = ("+g(l)+" | 0) % "+v(l)+";"):(y(A(l)+" = ("+g(l)+" | 0);"),y("if ("+A(l)+" < "+c[l]+") "+A(l)+" = "+c[l]+";"),y("if ("+A(l)+" > "+v(l)+" - 1) "+A(l)+" = "+v(l)+" - 1;"));for(l=0,s=[];l0&&!isArrayLike(this.knots[0])&&(this.knots=[this.knots]),a=0;a0?1:-1;_tmpQuat$1.setFromAxisAngle(t,o.angleTo(r)*n),e.multiply(_tmpQuat$1)}else i<0&&(_tmpQuat$1.setFromAxisAngle(t,Math.PI),e.multiply(_tmpQuat$1));return e}_calcBankAngle(e,t,n,r){const o=_tmpVecF.copy(t).add(n).normalize();return e*(_tmpVecF1.crossVectors(o,t).normalize().dot(r)>0?1:-1)}_calcCurvature(e,t){return _tmpVecF.crossVectors(e,t).length()/Math.pow(e.length(),3)}_calcSecondDerivative(e,t,n,r){this.secondDerivativeEvaluatorForNonUniformBSplines(_tmpArray3,t);const o=_tmpVecF.fromArray(_tmpArray3);this.derivativeEvaluatorForWeights1(_tmpArray3,t);const i=_tmpArray3[0];this.derivativeEvaluatorForWeights2(_tmpArray3,t);const a=_tmpArray3[0];this.derivativeEvaluatorForWeights0(_tmpArray3,t);const s=_tmpArray3[0];return e.copy(o).sub(_tmpVecF1.copy(r).multiplyScalar(2*i)),e.sub(_tmpVecF1.copy(n).multiplyScalar(a)),e.divideScalar(s),e}_limitAngle(e,t){return e>0?Math.min(e,t):Math.max(e,-t)}_calcChordLengths(e,t){let n=1/Math.max(1,t-1),r=0,o=0;const i=this.curve.domain;let a=i[0][0],s=i[0][1]-i[0][0];const l=_tmpVecF,c=_tmpVecF1;this._calcPosition(l,a);for(let i=0;i=1)return 1;let n=e*t[t.length-1],r=0,o=0,i=t.length-1;for(;rt[o]?r=o+1:i=o-1;return n>t[i]?i+=(n-t[i])/(t[i+1]-t[i]):i-=1-(n-t[i-1])/(t[i]-t[i-1]),i/(t.length-1)}}MotionPathConstraint.prototype.isMotionPathConstraint=!0;const TEXTURE_NODES=["IMAGE_AR","SKYDOME_LIGHT_AR","TEXTURE_BL","TEX_IMAGE_BL","TEX_ENVIRONMENT_BL","BITMAP_MX","BITMAP_ENV_MX","REFLECT_REFRACT_MX","FILE_MY","AI_SKYDOME_LIGHT_MY","OSL_NODE"],JSON_PROGRESS_RATIO=.3,BIN_PROGRESS_RATIO=1;class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension$1(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension$1(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension$1(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension$1(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)})),this.register((function(e){return new V3DLightsExtension(e)})),this.register((function(e){return new V3DLightProbesExtension(e)})),this.register((function(e){return new V3DCurvesExtension(e)})),this.register((function(e){return new V3DClippingPlanesExtension(e)})),this.register((function(e){return new V3DSceneExtension(e)})),this.register((function(e){return new V3DNodeExtension(e)})),this.register((function(e){return new V3DCameraExtension(e)})),this.register((function(e){return new V3DMaterialExtension(e)})),this.register((function(e){return new V3DTextureExtension(e)})),this.onProgress=null}load(e,t,n,r){const o=this;let i;o.onProgress=n||function(){},i=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:LoaderUtils.extractUrlBase(e);const a=-1!=e.indexOf(".xz",e.length-3);let s;a?s=new XZLoader(o.manager):(s=new FileLoader(o.manager),s.setResponseType("arraybuffer"));const l=function(e){o.onProgress&&o.onProgress(.3*e*100)};let c=l;s instanceof FileLoader&&(c=function(e){const t=e.lengthComputable?e.loaded/e.total:1;l(t)}),s.load(e,(function(e){try{o.parse(e,i,t,r,a)}catch(e){void 0!==r&&r(e.constructor===Error?e:new Error("v3d.GLTFLoader: Unable to parse model."))}}),c,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('v3d.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,r,o){let i;const a={},s={};if("string"==typeof e)i=e;else{if(LoaderUtils.decodeText(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{a[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(r&&r(e))}i=a[EXTENSIONS.KHR_BINARY_GLTF].content}else i=LoaderUtils.decodeText(new Uint8Array(e))}const l=JSON.parse(i);if(void 0===l.asset||l.asset.version[0]<2)return void(r&&r(new Error("v3d.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=this;applyExtCompatHacks(l);const u=new GLTFParser(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,loadBinXZ:o,onProgress:function(e){c.onProgress&&c.onProgress(e)}});for(let e=0;e=0&&void 0===s[t]&&console.warn('v3d.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(a),u.setPlugins(s),u.parse((function(e){c.onProgress&&c.onProgress(100),n(e)}),r)}parseAsync(e,t){const n=this;return new Promise((function(r,o){n.parse(e,t,r,o)}))}}function GLTFRegistry(){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 EXTENSIONS={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_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_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing",S8S_V3D_ANIMATION:"S8S_v3d_animation",S8S_V3D_CAMERA:"S8S_v3d_camera",S8S_V3D_MATERIALS:"S8S_v3d_materials",S8S_V3D_MESH:"S8S_v3d_mesh",S8S_V3D_NODE:"S8S_v3d_node",S8S_V3D_SCENE:"S8S_v3d_scene",S8S_V3D_TEXTURE:"S8S_v3d_texture",S8S_V3D_LIGHTS:"S8S_v3d_lights",S8S_V3D_LIGHT_PROBES:"S8S_v3d_light_probes",S8S_V3D_CURVES:"S8S_v3d_curves",S8S_V3D_CLIPPING_PLANES:"S8S_v3d_clipping_planes"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw new Error("v3d.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,i)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=r.images[i.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(o){if(o)return n.loadTextureImage(e,i.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("v3d.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 GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.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],r=this.parser.getDependency("buffer",e.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("v3d.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,o.ready]).then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,i=e.count,a=e.byteStride,s=new ArrayBuffer(i*a),l=new Uint8Array(t[0],n,r);return o.decodeGltfBuffer(new Uint8Array(s),i,a,l,e.mode,e.filter),s}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.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 r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==WEBGL_CONSTANTS$1.TRIANGLES&&e.mode!==WEBGL_CONSTANTS$1.TRIANGLE_STRIP&&e.mode!==WEBGL_CONSTANTS$1.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=n.extensions[this.name].attributes,i=[],a={};for(const e in o)i.push(this.parser.getDependency("accessor",o[e]).then((t=>(a[e]=t,a[e]))));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,o=[];for(const e of n){const t=new Matrix4,n=new Vector3,i=new Quaternion,s=new Vector3(1,1,1),l=new InstancedMesh(e.geometry,e.material,r);for(let e=0;e(e&&(a.target=e),r=Promise.resolve(a),t.cache.add(n,r),r)))}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===o?null:this._loadLight(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class V3DLightProbesExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.S8S_V3D_LIGHT_PROBES,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n0||i.bevelThickness>0,t=new TextGeometry(i.text,{font:l,size:i.size,height:i.height,curveSegments:i.curveSegments,bevelEnabled:e,bevelThickness:i.bevelThickness,bevelSize:i.bevelSize,bevelSegments:i.bevelSegments,alignX:i.alignX,alignY:i.alignY,lineHeight:i.lineHeight,scaledEmSize:i.scaledEmSize});a=new Mesh(t,c)}else a=new Object3D;return a.name=t.createUniqueName(i.name||"curve_"+e),r=Promise.resolve(a),t.cache.add(n,r),r}))}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).curve;return void 0===o?null:this._loadCurve(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class V3DClippingPlanesExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.S8S_V3D_CLIPPING_PLANES,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n-1&&(e.match(/(\d+).(\d+).(\d+)/)||(e+=" v0.0.0"),engineVersionCmp(e,REVISION,2)<0&&console.warn("Loading glTF asset in older version of Verge3D runtime. Please update your application."))}afterRoot(e){const t=this.parser,n=t.json,r=n.scenes[n.scene||0],o=e.scene,i=isDef(r.extensions)?r.extensions[EXTENSIONS.S8S_V3D_SCENE]:void 0,a=[],s=[],l=[];let c;return c=r&&i&&isDef(i.worldMaterial)?t.getDependency("material",i.worldMaterial):Promise.resolve(),c.then((t=>{const n={};t&&(n.material=t),e.world=n})).then((()=>(t.assignedMaterials.forEach((function(e){e.isMeshNodeMaterial&&e.traverseNodes((function(n){"TEX_COORD_BL"===n.originData.type&&isDef(n.originData.object)&&n.originData.object>-1&&(a.push(t.getDependency("node",n.originData.object)),s.push(n),l.push(e))}))})),Promise.all(a)))).then((t=>{for(let e=0;e(t[0]&&(e.controls.orbitTarget=t[0]),t[1]&&(e.controls.collisionMaterial=t[1]),e)))}}class V3DMaterialExtension{constructor(e){this.name=EXTENSIONS.S8S_V3D_MATERIALS,this.parser=e}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshNodeMaterial:null}extendMaterialParams(e,t){const n=this.parser.json,r=n.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name],i=[];if(isDef(o.nodeGraph)){const e=MeshNodeMaterial.nodeGraphFromExtGraph(o.nodeGraph);t.nodeGraph=e,MeshNodeMaterial.nodeGraphTraverse(e,(e=>{const n=e.originData;if(TEXTURE_NODES.indexOf(n.type)>-1&&isDef(n.texture)){const e=MeshNodeMaterial.nodeTexUniName(n.type,n.texture);i.push(this.assignTextureNode(t,e,n.texture))}else"RAMP_MY"==n.type&&(n.wrapS=WEBGL_WRAPPINGS[n.wrapS]||RepeatWrapping,n.wrapT=WEBGL_WRAPPINGS[n.wrapT]||RepeatWrapping)}));const r=n.extensions&&n.extensions[this.name]||{};if(r&&r.nodeGraphs){t.additionalNodeGraphs={};for(let e in r.nodeGraphs){const n=MeshNodeMaterial.nodeGraphFromExtGraph(r.nodeGraphs[e]);t.additionalNodeGraphs[e]=n,MeshNodeMaterial.nodeGraphTraverse(n,(e=>{const n=e.originData;if(TEXTURE_NODES.indexOf(n.type)>-1){const e=MeshNodeMaterial.nodeTexUniName(n.type,n.texture);i.push(this.assignTextureNode(t,e,n.texture))}}))}}}return isDef(o.profile)&&(t.profile=o.profile),isDef(o.renderSide)&&(t.side=RENDER_SIDES[o.renderSide]),isDef(o.useShadows)&&(t.receiveShadow=o.useShadows),isDef(o.useCastShadows)&&(t.castShadow=o.useCastShadows),isDef(o.depthWrite)&&(t.depthWrite=o.depthWrite),isDef(o.depthPrepass)&&(t.depthPrepass=o.depthPrepass),isDef(o.depthTest)&&(t.depthTest=o.depthTest),isDef(o.dithering)&&(t.dithering=o.dithering),isDef(o.materialIndex)&&(t.materialIndex=o.materialIndex),!0===o.alphaToCoverage&&(t.alphaToCoverage=!0),isDef(o.gtaoVisible)&&(t.gtaoVisible=o.gtaoVisible),delete t.metalness,delete t.roughness,Promise.all(i)}assignTextureNode(e,t,n){return this.parser.getDependency("texture",n).then((function(n){e.nodeTextures=e.nodeTextures||{},e.nodeTextures[t]=n}))}assignTransparency(e,t,n){const r=t.extensions[this.name]||{};if(e.premultipliedAlpha=n==ALPHA_MODES.BLEND,n==ALPHA_MODES.BLEND)if(isDef(r.blendMode)){const t=r.blendMode;e.blending=CustomBlending,isDef(t.blendEquation)&&(e.blendEquation=WEBGL_BLEND_EQUATIONS[t.blendEquation]),isDef(t.blendEquationAlpha)&&(e.blendEquationAlpha=WEBGL_BLEND_EQUATIONS[t.blendEquationAlpha]),isDef(t.srcRGB)&&(e.blendSrc=WEBGL_BLEND_FUNCS[t.srcRGB]),isDef(t.dstRGB)&&(e.blendDst=WEBGL_BLEND_FUNCS[t.dstRGB]),isDef(t.srcAlpha)&&(e.blendSrcAlpha=WEBGL_BLEND_FUNCS[t.srcAlpha]),isDef(t.dstAlpha)&&(e.blendDstAlpha=WEBGL_BLEND_FUNCS[t.dstAlpha])}else e.useAddTransparency()?e.blending=AdditiveBlending:assignDefaultBlending(e)}}class V3DTextureExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.S8S_V3D_TEXTURE,this.textureLoaderRGBE=new RGBELoader,this.textureLoaderRGBE.setCrossOrigin(this.parser.options.crossOrigin),this.textureLoaderRGBE.setRequestHeader(this.parser.options.requestHeader)}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t];if(!isDef(i.source))return null;const a=r.images[i.source];let s=n.textureLoader;if("hdr"==(a.uri||"").split(".").pop()||"image/vnd.radiance"==a.mimeType?s=this.textureLoaderRGBE:"xz"!=(a.uri||"").split(".").pop()&&"application/x-xz"!=a.mimeType||(s=new XZLoader),a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return n.loadTextureImage(e,i.source,s)}extendTextureParams(e,t,n){const r=this.name;if(!t.extensions||!t.extensions[r])return null;const o=t.extensions[r],i="linear"==o.colorSpace||"linear rec.709"==o.colorSpace||"non-color"==o.colorSpace?LinearEncoding$1:sRGBEncoding$1;e.encoding=i,(n instanceof RGBELoader||n instanceof XZLoader)&&(e.minFilter=LinearFilter),isDef(o.anisotropy)&&(e.anisotropy=o.anisotropy),isDef(o.uvTransform)&&(e.matrix=(new Matrix3).fromArray(o.uvTransform),e.matrixAutoUpdate=!1)}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[o+e];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,i=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=r-t,u=(n-t)/c,d=u*u,h=d*u,p=e*l,f=p-l,m=-2*h+3*d,g=h-d,_=1-m,v=g-d+u;for(let e=0;e!==a;e++){const t=i[f+e+a],n=i[f+e+s]*c,r=i[p+e+a],l=i[p+e]*c;o[e]=_*t+v*n+m*r+g*l}return o}}const _q=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS$1={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},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:NearestFilter,9729:LinearFilter,9984:NearestMipmapNearestFilter,9985:LinearMipmapNearestFilter,9986:NearestMipmapLinearFilter,9987:LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:ClampToEdgeWrapping,33648:MirroredRepeatWrapping,10497:RepeatWrapping},WEBGL_BLEND_EQUATIONS={32774:AddEquation,32778:SubtractEquation,32779:ReverseSubtractEquation},WEBGL_BLEND_FUNCS={0:ZeroFactor,1:OneFactor,768:SrcColorFactor,769:OneMinusSrcColorFactor,770:SrcAlphaFactor,771:OneMinusSrcAlphaFactor,772:DstAlphaFactor,773:OneMinusDstAlphaFactor,774:DstColorFactor,775:OneMinusDstColorFactor,776:SrcAlphaSaturateFactor},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES$1={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences",intensity:"intensity",power:"power"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},RENDER_SIDES={FRONT:FrontSide,BACK:BackSide,DOUBLE:DoubleSide};function createDefaultMaterial(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:FrontSide,receiveShadow:!0,castShadow:!0})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("v3d.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function addMorphTargets(e,t,n){let r=!1,o=!1,i=!1;for(let e=0,n=t.length;e0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}new Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.onProgress=t.onProgress||function(){},this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,o=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&o<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0),this.assignedMaterials=[]}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,o=this.extensions;this.cache.removeAll(),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 i={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};addUnknownExtensionsToUserData(o,i,r),assignExtrasToUserData(i,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())o(r,t.children[n])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*i+1]),i>=3&&p.setZ(t,u[e*i+2]),i>=4&&p.setW(t,u[e*i+3]),i>=5)throw new Error("v3d.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let i=this.textureLoader;if(o.uri){const e=n.manager.getHandler(o.uri);null!==e&&(i=e)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const r=this,o=this.json,i=o.textures[e],a=o.images[t],s=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=i.name||a.name||"";const s=(o.samplers||{})[i.sampler]||{};return t.magFilter=WEBGL_FILTERS[s.magFilter]||LinearFilter,t.minFilter=WEBGL_FILTERS[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=WEBGL_WRAPPINGS[s.wrapS]||RepeatWrapping,t.wrapT=WEBGL_WRAPPINGS[s.wrapT]||RepeatWrapping,r._invokeAll((function(e){return e.extendTextureParams&&e.extendTextureParams(t,i,n)})),r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const i=r.images[e],a=self.URL||self.webkitURL;let s=i.uri||"",l=!1;if(void 0!==i.bufferView)s=n.getDependency("bufferView",i.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:i.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===i.uri)throw new Error("v3d.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let i=n;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Texture(e);t.needsUpdate=!0,n(t)}),t.load(LoaderUtils.resolveURL(e,o.path),i,void 0,r)}))})).then((function(e){if(e instanceof ArrayBuffer){return n.plugins[EXTENSIONS.S8S_V3D_TEXTURE].textureLoaderRGBE.loadAsync(a.createObjectURL(new Blob([e],{type:"image/vnd.radiance"})))}return Promise.resolve(e)})).then((function(e){return!0===l&&a.revokeObjectURL(s),e.userData.mimeType=i.mimeType||getImageURIMimeType(i.uri),e})).catch((function(e){return console.error("v3d.GLTFLoader: Couldn't load texture",s),new Texture}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then((function(i){if(!i)return null;if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("v3d.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=o.associations.get(i);i=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),o.associations.set(i,t)}}return void 0!==r&&(i.encoding=r),e[t]=i,i}))}assignFinalMaterial(e,t,n){const r=e.geometry;let o=e.material;const i=void 0===r.attributes.tangent,a=void 0!==r.attributes.color&&!o.isMeshNodeMaterial,s=void 0===r.attributes.normal,l=o.isMeshNodeMaterial&&(o.nodeValue.length||o.nodeRGB.length),c=o.isMeshNodeMaterial&&o.hasNode("TEX_COORD_BL"),u=o.isMeshNodeMaterial&&Object.getOwnPropertyNames(t).length>0&&o.hasNode("UVMAP_BL"),d=o.isMeshNodeMaterial&&Object.getOwnPropertyNames(n).length>0&&(o.hasNode("ATTRIBUTE_BL")||o.hasNode("VERTEX_COLOR_BL"));if(e.isPoints){const e="PointsMaterial:"+o.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,o),t.color.copy(o.color),t.map=o.map,t.sizeAttenuation=!1,this.cache.add(e,t)),o=t}else if(e.isLine){const e="LineBasicMaterial:"+o.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,o),t.color.copy(o.color),this.cache.add(e,t)),o=t}if(i||a||s||l||c||u||d){let e="ClonedMaterial:"+o.uuid+":";i&&(e+="derivative-tangents:"),a&&(e+="vertex-colors:"),s&&(e+="flat-shading:");const r=generateUUID();l&&(e=r),c&&(e=r),u&&(e=r),d&&(e=r);let h=this.cache.get(e);h||(h=o.clone(),a&&(h.vertexColors=!0),s&&(h.flatShading=!0),i&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),h.isMeshNodeMaterial&&(Object.assign(h.nodeUVAliases,t),Object.assign(h.nodeVCAliases,n),h.updateNodeGraph()),this.cache.add(e,h),this.associations.set(h,this.associations.get(o))),o=h}o.aoMap&&void 0===r.attributes.uv2&&void 0!==r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),e.material=o,this.assignedMaterials.includes(o)||this.assignedMaterials.push(o)}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let i;const a={},s=[];if((o.extensions||{})[EXTENSIONS.KHR_MATERIALS_UNLIT]){const e=r[EXTENSIONS.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),s.push(e.extendParams(a,o,t))}else{const n=o.pbrMetallicRoughness||{};if(a.color=new Color(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&&s.push(t.assignTexture(a,"map",n.baseColorTexture,sRGBEncoding$1)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(s.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),s.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),i=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),s.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===o.doubleSided&&(a.side=DoubleSide);const l=o.alphaMode||ALPHA_MODES.OPAQUE;if(l===ALPHA_MODES.BLEND?(a.transparent=!0,i!==MeshNodeMaterial&&(a.depthWrite=!1)):(a.transparent=!1,l===ALPHA_MODES.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&i!==MeshBasicMaterial&&(s.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==o.occlusionTexture&&i!==MeshBasicMaterial&&(s.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&i!==MeshBasicMaterial&&(a.emissive=(new Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&i!==MeshBasicMaterial&&s.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,sRGBEncoding$1)),Promise.all(s).then((function(){const n=new i(a);o.name&&(n.name=o.name),n.map&&(n.map.encoding=sRGBEncoding$1),n.emissiveMap&&(n.emissiveMap.encoding=sRGBEncoding$1);const s=t.plugins[EXTENSIONS.S8S_V3D_MATERIALS];return n.isMeshNodeMaterial&&s.assignTransparency(n,o,l),n.isMeshStandardMaterial&&n.normalScale&&s&&isDef(s.profile)&&"max"==s.profile&&(n.normalScale.y=-n.normalScale.y),assignExtrasToUserData(n,o),t.associations.set(n,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(r,n,o),n}))}createUniqueName(e){const t=e;let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(e){return n[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return addPrimitiveAttributes(n,e,t)}))}const i=[];for(let n=0,a=e.length;n0&&updateMorphTargets(h,o),h.name=t.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(h,o),d.extensions&&addUnknownExtensionsToUserData(r,h,d);const f={},m={};if(h.material.isMeshNodeMaterial&&s){if(s.uvLayers)for(let e in s.uvLayers)f[e]=texcoordToAttrName(s.uvLayers[e]);if(s.colorLayers)for(let e in s.colorLayers)m[e]=colorToAttrName(s.colorLayers[e])}t.assignFinalMaterial(h,f,m),c.push(h)}for(let n=0,r=c.length;n-1){p=NumberKeyframeTrack,f="constraints["+h.path.match(/".*"/g)[0]+"]."+h.path.match(/[^\\.]*$/g)[0]}else{let e;p=VectorKeyframeTrack,h.path.indexOf("nodeValue")>-1?(e=h.path.match(/".*"/g)[0],f="material.nodeValue["+e+"]"):h.path.indexOf("nodeRGB")>-1&&(e=h.path.match(/".*"/g)[0],f="material.nodeRGB["+e+"]")}}const m=t.name?t.name:t.uuid,g=void 0!==d.interpolation?INTERPOLATION[d.interpolation]:2301,_=[];if(PATH_PROPERTIES$1[h.path]===PATH_PROPERTIES$1.weights)t.traverse((function(e){e.morphTargetInfluences&&_.push(e.name?e.name:e.uuid)}));else if(h.path.indexOf("material")>-1){const e=n[5];t.traverse((function(t){if(!t.isMesh)return;if(!t.material.isMeshNodeMaterial)return;let n=!1;if(h.extras){n=e[h.extras.material].name===t.material.name;const r=h.path.match(/\["(.*)"\]/);n=n&&null!==r&&null!==t.material.findNodeByName(r[1])}else n=!0;n&&_.push(t.name?t.name:t.uuid)}))}else _.push(m);let v=u.array;if(u.normalized){const e=getNormalizedComponentScale(v.constructor),t=new Float32Array(v.length);for(let n=0,r=v.length;n1?new Group:1===t.length?t[0]:new Object3D,a!==t[0])for(let e=0,n=t.length;e{r._invokeOne((function(n){if(t!==e)return n.extendNodeParams&&n.extendNodeParams(t,o)}))})),r._invokeOne((function(t){return t.extendNodeParams&&t.extendNodeParams(e,o)}))}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],o=this,i=new Scene;r.name&&(i.name=o.createUniqueName(r.name)),assignExtrasToUserData(i,r),r.extensions&&addUnknownExtensionsToUserData(n,i,r);const a=r.nodes||[],s=[];for(let e=0,n=a.length;e{const t=new Map;for(const[e,n]of o.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,n);return e.traverse((e=>{const n=o.associations.get(e);null!=n&&t.set(e,n)})),t})(i),i}))}}function buildNodeHierarchy(e,t,n,r){const o=n.nodes[e];return r.getDependency("node",e).then((function(e){return void 0===o.skin?e:r.getDependency("skin",o.skin).then((function(t){return e.traverse((function(e){e.isSkinnedMesh&&e.bind(t,e.matrixWorld)})),e}))})).then((function(e){t.add(e),(e.isDirectionalLight||e.isSpotLight)&&e.isFreeLight&&t.add(e.target);const i=[];if(o.children){const t=o.children;for(let o=0,a=t.length;o{replaceExtObj("S8S_v3d_animation_data","S8S_v3d_animation",e)})),reportDeprecatedExt("S8S_v3d_animation_data")),n.includes("S8S_v3d_node_data")&&(replaceExtArr("S8S_v3d_node_data","S8S_v3d_node",n),(e.nodes||[]).forEach((e=>{replaceExtObj("S8S_v3d_node_data",[].concat(["S8S_v3d_node"],t),e)})),reportDeprecatedExt("S8S_v3d_node_data")),n.includes("S8S_v3d_material_data")&&(replaceExtArr("S8S_v3d_material_data","S8S_v3d_materials",n),(e.materials||[]).forEach((e=>{e.extensions&&e.extensions.S8S_v3d_material_data&&e.pbrMetallicRoughness?delete e.extensions.S8S_v3d_material_data:replaceExtObj("S8S_v3d_material_data","S8S_v3d_materials",e)})),reportDeprecatedExt("S8S_v3d_material_data")),n.includes("S8S_v3d_mesh_data")&&(replaceExtArr("S8S_v3d_mesh_data","S8S_v3d_mesh",n),(e.meshes||[]).forEach((e=>{replaceExtObj("S8S_v3d_mesh_data","S8S_v3d_mesh",e)})),reportDeprecatedExt("S8S_v3d_mesh_data")),n.includes("S8S_v3d_camera_data")&&(replaceExtArr("S8S_v3d_camera_data","S8S_v3d_camera",n),(e.cameras||[]).forEach((e=>{replaceExtObj("S8S_v3d_camera_data","S8S_v3d_camera",e)})),reportDeprecatedExt("S8S_v3d_camera_data")),n.includes("S8S_v3d_scene_data")&&(replaceExtArr("S8S_v3d_scene_data","S8S_v3d_scene",n),(e.scenes||[]).forEach((e=>{replaceExtObj("S8S_v3d_scene_data","S8S_v3d_scene",e)})),reportDeprecatedExt("S8S_v3d_scene_data")),n.includes("S8S_v3d_texture_data")&&(replaceExtArr("S8S_v3d_texture_data","S8S_v3d_texture",n),(e.textures||[]).forEach((e=>{replaceExtObj("S8S_v3d_texture_data","S8S_v3d_texture",e)})),reportDeprecatedExt("S8S_v3d_texture_data")),n.includes("S8S_v3d_data")&&(replaceExtArr("S8S_v3d_data",t,n),replaceExtObj("S8S_v3d_data",[].concat(t,["S8S_v3d_materials"]),e),reportDeprecatedExt("S8S_v3d_data"));(e.textures||[]).forEach((t=>{if(isDef(t.source)){const n=e.images[t.source],r=n.uri||"",o=n.mimeType;if("hdr"==r.split(".").pop()||"image/vnd.radiance"==o||"xz"==r.split(".").pop()||"application/x-xz"==o){t.extensions=t.extensions||{};const e=t.extensions.S8S_v3d_texture||{};e.source=t.source,delete t.source,t.extensions.S8S_v3d_texture=e,console.warn("Placing HDR map to S8S_v3d_texture extension, please reexport your scene file")}}}))}function replaceExtArr(e,t,n){const r=n.indexOf(e);r>-1&&n.splice(r,1),Array.isArray(t)?t.forEach((e=>{n.push(e)})):n.push(t)}function replaceExtObj(e,t,n){const r=n.extensions||{};Array.isArray(t)?t.forEach((t=>{r[t]=r[e]})):r[t]=r[e],delete r[e]}function reportDeprecatedExt(e){console.warn(`Deprecated '${e}' extension found, please reexport your scene file`)}function extraAttrName(e){return e.indexOf("TEXCOORD_")>-1?texcoordToAttrName(e):e.indexOf("COLOR_")>-1?colorToAttrName(e):""}function texcoordToAttrName(e){return"TEXCOORD_0"==e?"uv":"uv"+String(Number(e.split("TEXCOORD_")[1])+1)}function colorToAttrName(e){return"COLOR_0"==e?"color":"color"+String(Number(e.split("COLOR_")[1])+1)}function assignDefaultBlending(e){e.blending=CustomBlending,e.blendEquation=AddEquation,e.blendSrc=OneFactor,e.blendDst=OneMinusSrcAlphaFactor}const LAYER_INVISIBLE=0,LAYER_NODE_ALPHA_CLIP_HASH=1,LAYER_OTHER=2,_clearColor=new Color;class GTAOMapGenerator extends EventDispatcher{constructor(e,t,n=512,r=512){super(),this.scene=e,this.camera=t,this.width=n,this.height=r,this.distance=.1,this.factor=1,this.precision=1,this.bentNormals=!1,this.bounceApprox=!1,this.noiseTexture=this.createNoiseTexture(),this.fsQuad=new FullScreenQuad(null);const o=new DepthTexture;o.type=UnsignedIntType,this.renderTargetNormalDepth=new WebGLRenderTarget(this.width,this.height,{format:RGBAFormat,depthTexture:o,depthBuffer:!0}),this.renderTargetGTAO=new WebGLRenderTarget(this.width,this.height),this.renderTargetBlurX=new WebGLRenderTarget(this.width,this.height),this.renderTarget=new WebGLRenderTarget(this.width,this.height),this.materialNormal=new MeshNormalMaterial({}),this.materialGTAO=new ShaderMaterial({type:"GTAO",defines:{ORTHO_CAMERA:0,CALC_BENT_NORMALS:0},extensions:{derivatives:!0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},occlDistance:{value:.1},factor:{value:1},occlPrecision:{value:1},bounceApprox:{value:0},mainCameraProjMat:{value:new Matrix4},resolution:{value:new Vector2}},vertexShader:ShaderChunk.pp_plane_vert,fragmentShader:ShaderChunk.pp_gtao_frag}),this.materialBlur=new ShaderMaterial({type:"GTAOBlur",defines:{},uniforms:{tDiffuse:{value:null},tNormal:{value:null},direction:{value:new Vector2},resolution:{value:new Vector2}},customPrepTokens:{BLUR_RADIUS_PX:2},vertexShader:ShaderChunk.pp_plane_vert,fragmentShader:ShaderChunk.pp_gtao_blur_frag}),this._layerMasks={}}setCamera(e){this.camera=e}setSize(e,t){this.width=e,this.height=t,this.renderTargetNormalDepth.setSize(e,t),this.renderTargetGTAO.setSize(e,t),this.renderTargetBlurX.setSize(e,t),this.renderTarget.setSize(e,t),this.materialGTAO.uniforms.mainCameraProjMat.value.copy(this.camera.projectionMatrix),this.materialGTAO.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this.materialBlur.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height)}dispose(){this.dispatchEvent({type:"dispose"}),this.renderTargetNormalDepth.dispose(),this.renderTargetGTAO.dispose(),this.renderTargetBlurX.dispose(),this.renderTarget.dispose(),this.materialNormal.dispose(),this.materialGTAO.dispose(),this.materialBlur.dispose(),this.noiseTexture.dispose()}_saveLayers(){this.scene.traverse((e=>this._layerMasks[e.id]=e.layers.mask))}_setupLayers(){this.scene.traverse((e=>{e.layers.disableAll();const t=e instanceof Mesh&&e.material&&!e.material.gtaoVisible,n=e instanceof Mesh&&e.material&&e.material.isMeshNodeMaterial&&(e.material.alphaTest>0||e.material.alphaToCoverage);t?e.layers.enable(0):n?e.layers.enable(1):e.layers.enable(2)}))}_restoreLayers(){this.scene.traverse((e=>e.layers.mask=this._layerMasks[e.id]))}_setupNodeAlphaClipHashMaterials(){this.scene.traverse((e=>{e instanceof Mesh&&e.material&&e.material.isMeshNodeMaterial&&(e.material.defines.NORMAL_OUTPUT=Number(e.material.alphaTest>0||e.material.alphaToCoverage),e.material.needsUpdate=!0)}))}_restoreNodeAlphaClipHashMaterials(){this.scene.traverse((e=>{e instanceof Mesh&&e.material&&e.material.isMeshNodeMaterial&&(e.material.defines.NORMAL_OUTPUT=0,e.material.needsUpdate=!0)}))}render(e){this._saveLayers(),this._setupLayers(),this.camera.layers.disableAll(),this.camera.layers.enable(1),this._setupNodeAlphaClipHashMaterials(),this._renderOverride(e,null,this.renderTargetNormalDepth,8355839,1,!0),this._restoreNodeAlphaClipHashMaterials(),this.camera.layers.disableAll(),this.camera.layers.enable(2),this._renderOverride(e,this.materialNormal,this.renderTargetNormalDepth,null,null,!0),this._restoreLayers(),this.materialGTAO.defines.ORTHO_CAMERA=this.camera.isOrthographicCamera?1:0,this.materialGTAO.defines.CALC_BENT_NORMALS=this.bentNormals?1:0,this.materialGTAO.needsUpdate=!0,this.materialGTAO.uniforms.tNormal.value=this.renderTargetNormalDepth.texture,this.materialGTAO.uniforms.tDepth.value=this.renderTargetNormalDepth.depthTexture,this.materialGTAO.uniforms.tNoise.value=this.noiseTexture,this.materialGTAO.uniforms.occlDistance.value=this.distance,this.materialGTAO.uniforms.factor.value=this.factor,this.materialGTAO.uniforms.occlPrecision.value=this.precision,this.materialGTAO.uniforms.bounceApprox.value=this.bounceApprox,this.materialGTAO.uniforms.mainCameraProjMat.value.copy(this.camera.projectionMatrix),this.materialGTAO.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this._renderPass(e,this.materialGTAO,this.renderTargetGTAO),this.materialBlur.uniforms.tDiffuse.value=this.renderTargetGTAO.texture,this.materialBlur.map=this.renderTargetGTAO.texture,this.materialBlur.uniforms.tNormal.value=this.renderTargetNormalDepth.texture,this.materialBlur.uniforms.direction.value.set(1,0),this.materialBlur.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this._renderPass(e,this.materialBlur,this.renderTargetBlurX),this.materialBlur.uniforms.tDiffuse.value=this.renderTargetBlurX.texture,this.materialBlur.map=this.renderTargetBlurX.texture,this.materialBlur.uniforms.direction.value.set(0,1),this.materialBlur.uniforms.resolution.value.set(this.renderTargetBlurX.width,this.renderTargetBlurX.height),this._renderPass(e,this.materialBlur,this.renderTarget)}_renderOverride(e,t,n,r,o,i){const a=e.getRenderTarget(),s=e.getClearColor(_clearColor),l=e.getClearAlpha(),c=e.autoClear,u=this.scene.background;e.setRenderTarget(n),null!=r&&(e.setClearColor(r),e.setClearAlpha(o??0),e.clear()),e.autoClear=!1,i&&(this.scene.background=null),t&&(this.scene.overrideMaterial=t),e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.setRenderTarget(a),e.setClearColor(s),e.setClearAlpha(l),e.autoClear=c,this.scene.background=u}_renderPass(e,t,n,r,o){const i=e.getRenderTarget(),a=e.getClearColor(_clearColor),s=e.getClearAlpha(),l=e.autoClear;e.setRenderTarget(n),null!=r&&(e.setClearColor(r),e.setClearAlpha(o??0),e.clear()),e.autoClear=!1,this.fsQuad.material=t,this.fsQuad.render(e),e.setRenderTarget(i),e.setClearColor(a),e.setClearAlpha(s),e.autoClear=l}createNoiseTexture(){const e=new Uint8Array([101,192,145,80,53,136,86,207,229,131,240,6,58,41,171,13,199,63,175,128,113,55,246,66,115,213,157,59,243,114,68,169,255,60,216,5,200,37,250,65,170,48,153,108,125,211,137,29,120,82,38,213,25,198,15,150,33,131,173,16,140,180,9,206,134,20,117,176,99,222,124,190,95,33,198,221,86,68,241,157,227,142,253,96,72,135,169,102,204,253,89,195,50,233,94,38,185,86,235,72,149,163,25,2,146,75,254,14,164,189,0,100,49,187,162,8,181,222,240,52,7,73,41,109,210,123,76,150,226,161,44,11,242,51,107,232,212,116,177,54,141,37,207,77,115,19,59,235,110,42,83,122,160,184,224,148,2,164,248,24,203,109,129,192,208,138,83,182,61,132,28,229,96,121,224,173,248,197,88,127,147,29,193,210,139,96,237,30,63,191,102,54,69,178,32,93,63,170,36,247,17,201,80,155,245,18,60,133,151,32,219,206,165,67,230,20,57,12,171,128,84,221,139,13,236,146,220,252,20,120,222,150,99,166,43,108,196,183,89,45,9,107,74,49,4,100,175,117,246,71,198,113,241,39,174,119,46,82,1,157,105,195,72,9,127,239,217,6,69,145,211,166,230,181,240,136,190,251,87,155,35,219,143,50,22,159,213,92,191,127,212,41,135,237,50,206,88,58,176,118,36,234,27,114,64,93,157,119,21,214,45,129,187,105,92,208,182,66,6,249,27,167,62,185,78,172,29,160,188,25,139,249,161,84,130,254,203,14,37,226,59,143,77,238,0,166,18,254,79,133,103,153,205,113,94,246,12,216,100,116,227,76,209,48,97,186,1,53,144,192,82,169,108,179,28,198,65,228,42,151,122,197,233,53,74,222,24,146,123,56,141,255,3,151,106,20,200,220,73,174,104,216,131,248,7,209,156,86,112,136,177,58,223,11,36,140,241,8,195,178,232,85,200,43,65,180,240,133,61,149,120,231,22,46,71,30,92,230,121,52,242,215,97,26,110,186,89,172,158,102,50,70,34,156,15,189,126,91,34,168,10,245,39,91,163,243,152,202,140,42,188,17,163,8,203,77,156,237,63,118,32,130,251,165,112,208,98,235,161,213,228,81,110,194,178,14,125,185,111,61,173,103,253,71,144,39,125,250,45,207,15,217,177,202,88,1,226,132,75,26,56,12,119,203,46,137,66,209,77,220,3,238,19,80,129,218,179,90,193,168,132,98,146,81,19,235,142,59,183,44,250,174,104,144,69,155,251,97,230,145,33,99,49,159,212,196,31,56,110,225,22,62,2,183,245,55,123,40,106,215,17,150,116,218,194,238,31,186,0,23,55,162,241,194,135,87,118,147,236,4,158,244,75,117,228,35,109,194,67,155,78,168,199,91,64,8,135,47,88,169,212,129,181,111,11,65,170,227,40,68,176,95,201,46,142,209,154,90,165,218,255,188,232,27,121,244,35,163,79,206,124,242,103,72,223,83,204,123,25,247,10,191,111,136,26,85,187,18,236,51,134,7,144,13,99,48,138,227,190,101,223,24,153,60,41,149,30,255,45,152,184,103,78,162,51,252,217,128,171,104,70,197,30,84,114,57,176,205,70,4,148,54,253,181,113,6,231,191,134,172,95,220,56,211,141,233,205,16,66,40,224,5,122,243,179,211,226,127,247,158,85,111,174,126,15,73,202,167,87,215,17,116,3,71,130,19,35,90,124,154,182,98,248,148,57,156,96,43,73,196,34,16,218,237,42,208,94,143,38,247,122,67,52,201,234,164,249,177,199,61,1,108,76,167,31,204,80,231,22,170,0,147,93,120,183,64,28,161,239,57,185,105,28,159,139,184,106,40,81,114,145,242,219,190,239,53,138,112,11,187,133,107,204,239,168,54,141,102,193,81,221,134,9,216,78,229,244,90,23,153,225,10,95,160,43,132,23,214,195,89,47,215,252,62,38,82,228,21,214,251,2,151,109,21,175,197,149,44,5,173,64,210,52,196,69,29,172,83,118,13,154,236,175,119,26,159,137,112,189,44,131,75,171,121,49,232,92,126,62,101,205,130,117,250,138,180,125,207,254,58,225,97,67,37,142,74,98,182,210,7,68,152,202,94,34,243,200,70,39,252,166,16,224,188,32,84,21,100,231,12,106,148,199,178,249,164,5,229,55,245,87,165,234,105,14,225,60,184,140,158,214,27,115,143,74,51,162,147,238,47,76,167,36,137,3,48,126,104,201,189,128,18,47,124,31,244,180,160,115,23,10,101,79,179,193,233,93,246,107,217,4,192,154,221,91,186,234,79,24,219,85,33,152,223]),t=new Uint8Array([7,87,145,233,57,15,124,219,7,163,132,35,222,160,41,99,10,23,228,253,53,207,65,214,94,146,248,134,214,15,97,230,201,181,41,105,189,206,171,100,146,78,188,106,177,87,141,232,198,122,70,178,149,26,124,174,16,55,115,35,70,179,158,111,74,241,122,159,29,90,47,242,23,229,213,16,245,72,26,183,58,136,205,43,86,239,139,226,77,188,203,86,224,144,50,30,135,62,11,218,255,68,156,185,59,121,91,49,199,152,219,109,243,162,14,221,113,192,3,100,42,152,233,168,22,123,251,210,153,191,99,173,139,114,2,133,201,32,169,135,64,118,1,47,89,31,102,76,154,35,63,164,255,127,9,62,106,187,4,91,44,222,17,80,39,209,237,82,107,251,148,11,231,174,208,130,194,171,234,184,248,121,216,199,110,28,212,137,240,77,164,232,25,128,247,150,57,193,20,160,44,211,75,191,96,37,81,254,147,66,8,140,54,21,177,89,74,51,175,93,39,199,55,115,84,202,104,179,230,124,97,222,64,177,27,111,239,158,17,57,105,219,42,209,95,132,231,13,144,244,194,157,226,18,143,180,66,166,48,5,74,32,169,142,7,241,128,52,216,137,185,228,26,124,84,166,189,71,38,158,221,115,1,65,123,102,250,216,34,242,140,113,212,188,249,85,118,197,156,89,5,70,116,167,202,153,240,114,4,246,203,100,46,185,84,31,209,173,6,130,196,22,225,91,155,61,16,49,103,229,36,206,173,249,46,92,12,73,33,223,142,60,172,126,22,234,135,246,151,75,52,97,161,79,182,12,235,132,207,150,184,20,78,143,101,28,196,235,134,178,53,195,24,108,82,215,150,55,168,110,43,189,233,144,207,59,125,44,168,108,34,220,69,166,244,58,225,125,149,63,213,104,253,93,155,184,11,250,73,96,201,8,218,88,14,117,223,105,247,193,71,88,254,122,3,132,191,113,10,181,40,83,0,162,127,41,210,235,122,36,195,18,228,65,131,176,253,38,19,165,0,146,27,203,178,54,96,234,43,159,90,218,245,112,191,229,18,79,66,137,51,160,180,141,118,164,30,101,154,71,137,94,217,56,238,134,17,153,200,80,29,204,67,23,155,52,172,33,145,198,175,7,223,103,87,244,41,79,236,204,51,186,81,199,176,112,77,224,40,110,170,223,144,251,174,131,98,205,73,121,247,97,238,116,29,204,62,2,213,183,145,24,125,241,228,45,31,129,160,92,188,246,62,6,102,50,116,15,240,140,10,218,59,45,151,83,167,255,130,157,107,55,92,219,110,5,61,147,252,8,212,51,12,140,75,126,183,215,83,194,43,226,88,165,109,187,21,215,68,39,192,20,239,198,12,68,174,159,99,121,192,70,231,177,119,209,237,19,154,33,232,163,65,180,29,200,129,4,231,135,182,98,147,76,118,165,136,248,40,211,14,85,169,107,25,151,100,36,164,197,92,58,136,2,123,106,148,252,75,210,162,53,120,9,233,217,46,28,226,83,128,195,245,224,38,141,205,61,249,86,48,227,114,255,186,207,77,236,16,56,39,102,85,30,247,203,60,87,179,103,186,56,152,22,180,131,53,236,81,15,190,134,175,8,72,147,24,99,48,215,192,172,139,240,196,149,108,168,17,127,157,252,1,206,114,74,161,98,3,186,156,120,221,27,108,211,129,40,170,242,158,131,91,115,225,20,178,71,45,222,142,197,36,66,145,93,234,34,198,67,217,109,243,45,67,161,237,54,195,224,85,112,6,32,69,155,9,64,123,212,3,94,242,76,113,214,25,170,49,220,119,148,28,170,90,10,200,143,80,95,153,18,64,202,175,220,250,42,208,96,163,254,133,185,21,52,230,190,126,244,138,13,86,254,58,138,211,125,179,251,34,2,183,248,126,143,54,187,78,136,235,193,50,32,82,117,173,161,98,9,82,63,105,187,19,205,37,230,76,21,104,60,167,119,214,106,37,227,13,101,120,167,25,109,146,227,201,60,238,38,148,206,181,42,163,236,176,128,107,154,184,50,225,208,133,232,49,73,165,90,239,152,204,0,89,182,72,11,156,101,217,14,130,252,111,227,5,72,95,47,196,0,245,94,149,13,84,27,150,193,19,181,68,30,48,243,61,221,127,246,24,138,190,69,88,57,26,141,210,151,220,249,67,117,166,35,194,112,176,202,95,237,139,208,111,129,216,190,142,37,171,197,81,47,119,229,159,200,171,79,120,33,133,169,23,213,80,138,238,69,44,253,63,117,4,56,250,172,78,157,93,116,6,104,162,241,31,182,1,103,46,243,189,59]),n=new Uint8Array(4096);for(let r=0;r<1024;r++)n[4*r]=e[r],n[4*r+1]=t[r],n[4*r+2]=0,n[4*r+3]=0;const r=new DataTexture(n,32,32,RGBAFormat,UnsignedByteType);return r.name="GTAONoiseTexture",r.wrapS=RepeatWrapping,r.wrapT=RepeatWrapping,r.needsUpdate=!0,r}}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e{const r=this._getIdleWorker();-1!==r?(this._initWorker(r),this.workerStatus|=1<e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const KTX2TransferSRGB=2,KTX2_ALPHA_PREMULTIPLIED=1,_taskCache=new WeakMap;let _activeLoaders=0;class KTX2Loader extends Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('v3d.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc")&&e.extensions.has("WEBGL_compressed_texture_s3tc_srgb"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}init(){if(!this.transcoderPending){const e=new FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new FileLoader(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const r=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,r]).then((([e,t])=>{const n=KTX2Loader.BasisWorker.toString(),r=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),_activeLoaders>0&&console.warn("v3d.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_activeLoaders++}return this.transcoderPending}load(e,t,n,r){if(null===this.workerConfig)throw new Error("v3d.KTX2Loader: Missing initialization with `.detectSupport(renderer)`.");const o=new FileLoader(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const i=new CompressedTexture;return o.load(e,(e=>{if(_taskCache.has(e)){return _taskCache.get(e).promise.then(t).catch(r)}this._createTexture([e]).then((function(e){i.copy(e),i.needsUpdate=!0,t&&t(i)})).catch(r)}),n,r),i}_createTextureFrom(e){const{mipmaps:t,width:n,height:r,format:o,type:i,error:a,dfdTransferFn:s,dfdFlags:l}=e;if("error"===i)return Promise.reject(a);const c=new CompressedTexture(t,n,r,o,UnsignedByteType);return c.minFilter=1===t.length?LinearFilter:LinearMipmapLinearFilter,c.magFilter=LinearFilter,c.generateMipmaps=!1,c.needsUpdate=!0,c.encoding=2===s?sRGBEncoding$1:LinearEncoding$1,c.premultiplyAlpha=!!(1&l),c}_createTexture(e,t={}){const n=t,r=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>this._createTextureFrom(e.data)));return _taskCache.set(e[0],{promise:r}),r}dispose(){return URL.revokeObjectURL(this.workerSourceURL),this.workerPool.dispose(),_activeLoaders--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},KTX2Loader.EngineFormat={RGBAFormat:RGBAFormat,RGBA_ASTC_4x4_Format:RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:RGB_ETC1_Format,RGB_ETC2_Format:RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:RGB_S3TC_DXT1_Format},KTX2Loader.BasisWorker=function(){let e,t,n;const r=_EngineFormat,o=_TranscoderFormat,i=_BasisFormat;self.addEventListener("message",(function(a){const u=a.data;switch(u.type){case"init":e=u.config,d=u.transcoderBinary,t=new Promise((e=>{n={wasmBinary:d,onRuntimeInitialized:e},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("v3d.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":t.then((()=>{try{const{width:t,height:a,hasAlpha:d,mipmaps:h,format:p,dfdTransferFn:f,dfdFlags:m}=function(t){const a=new n.KTX2File(new Uint8Array(t));function u(){a.close(),a.delete()}if(!a.isValid())throw u(),new Error("v3d.KTX2Loader: Invalid or unsupported .ktx2 file");const d=a.isUASTC()?i.UASTC_4x4:i.ETC1S,h=a.getWidth(),p=a.getHeight(),f=a.getLevels(),m=a.getHasAlpha(),g=a.getDFDTransferFunc(),_=a.getDFDFlags(),{transcoderFormat:v,engineFormat:A}=function(t,n,a,u){let d,h;const p=t===i.ETC1S?s:l;for(let r=0;r=r&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}function computeTangents(){throw new Error("BufferGeometryUtils: computeTangents renamed to computeMikkTSpaceTangents.")}function computeMikkTSpaceTangents(e,t,n=!0){if(!t||!t.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!e.hasAttribute("position")||!e.hasAttribute("normal")||!e.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function r(e){if(e.normalized||e.isInterleavedBufferAttribute){const t=new Float32Array(e.getCount()*e.itemSize);for(let n=0,r=0;n2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const o=e.index?e.toNonIndexed():e,i=t.generateTangents(r(o.attributes.position),r(o.attributes.normal),r(o.attributes.uv));if(n)for(let e=3;e=2&&a.setY(t,e.getY(t)),r>=3&&a.setZ(t,e.getZ(t)),r>=4&&a.setW(t,e.getW(t));return a}function deinterleaveGeometry(e){const t=e.attributes,n=e.morphTargets,r=new Map;for(const e in t){const n=t[e];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,deinterleaveAttribute(n)),t[e]=r.get(n))}for(const e in n){const t=n[e];t.isInterleavedBufferAttribute&&(r.has(t)||r.set(t,deinterleaveAttribute(t)),n[e]=r.get(t))}}function estimateBytesUsed(e){let t=0;for(const n in e.attributes){const r=e.getAttribute(n);t+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t}function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);const n={},r=e.getIndex(),o=e.getAttribute("position"),i=r?r.count:o.count;let a=0;const s=Object.keys(e.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,n=s.length;te.materialIndex!==t.materialIndex?e.materialIndex-t.materialIndex:e.start-t.start)),null===e.getIndex()){const t=e.getAttribute("position"),n=[];for(let e=0;en&&l.add(t)}l.normalize(),f.setXYZ(t+e,l.x,l.y,l.z)}}return u.setAttribute("normal",f),u}function batchMeshes(e,t){const n={};for(let t=0;t=1&&p.setX(t,o.getX(n)),a>=2&&p.setY(t,o.getY(n)),a>=3&&p.setZ(t,o.getZ(n)),a>=4&&p.setW(t,o.getW(n))}u.setAttribute(t,p)}const h=new Mesh(u,d);t.add(h)}return t}function createMultiMaterialObject(e,t){const n=new Group;for(let r=0,o=t.length;r{const{geometry:n}=e;if(void 0!==n){const{position:i}=n.attributes;if(void 0!==i)for(let n=0,a=i.count;n1&&r.setY(t,e.getY(a)),r.itemSize>2&&r.setZ(t,e.getZ(a)),r.itemSize>3&&r.setW(t,e.getW(a))}}}}function getMaterialByName(e,t){const n=this.getMaterialsByName(e,t);return n.length?n[0]:null}function getMaterialsByName(e,t){const n=[];if(null!==e.scene){e.scene.traverse((function(e){e.material&&e.material.name===t&&-1===n.indexOf(e.material)&&n.push(e.material)}));const r=e.scene.worldMaterial;null!==r&&r.name===t&&-1===n.indexOf(r)&&n.push(r)}return n}function getAnimationActionByName(e,t){for(let n=0;n=i+1e3&&(s.update(1e3*a/(e-i),100),i=e,a=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:t,setMode:r}};Stats.Panel=function(e,t,n){var r=1/0,o=0,i=Math.round,a=i(window.devicePixelRatio||1),s=80*a,l=48*a,c=3*a,u=2*a,d=3*a,h=15*a,p=74*a,f=30*a,m=document.createElement("canvas");m.width=s,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,s,l),g.fillStyle=t,g.fillText(e,c,u),g.fillRect(d,h,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,h,p,f),{dom:m,update:function(l,_){r=Math.min(r,l),o=Math.max(o,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,h),g.fillStyle=t,g.fillText(i(l)+" "+e+" ("+i(r)+"-"+i(o)+")",c,u),g.drawImage(m,d+a,h,p-a,f,d,h,p-a,f),g.fillRect(d+p-a,h,a,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-a,h,a,i((1-l/_)*f))}}};const VRReticleImage="data:image/png;base64,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";class Face3{constructor(e,t,n,r,o,i=0){this.a=e,this.b=t,this.c=n,this.normal=r&&r.isVector3?r:new Vector3,this.vertexNormals=Array.isArray(r)?r:[],this.color=o&&o.isColor?o:new Color,this.vertexColors=Array.isArray(o)?o:[],this.materialIndex=i}clone(){return(new this.constructor).copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;tn.far?null:{distance:l,point:intersectionPointWorld.clone(),object:e}}function checkBufferGeometryIntersection(e,t,n,r,o,i,a,s){vA.fromBufferAttribute(r,i),vB.fromBufferAttribute(r,a),vC.fromBufferAttribute(r,s);var l=checkIntersection(e,e.material,t,n,vA,vB,vC,intersectionPoint);if(l){o&&(uvA.fromBufferAttribute(o,i),uvB.fromBufferAttribute(o,a),uvC.fromBufferAttribute(o,s),l.uv=Triangle.getUV(intersectionPoint,vA,vB,vC,uvA,uvB,uvC,new Vector2));var c=new Vector3;l.face=new Face3(i,a,s,Triangle.getNormal(vA,vB,vC,c)),l.faceIndex=i}return l}function intersectTri(e,t,n,r,o,i){var a=3*o,s=t.index.getX(a),l=t.index.getX(a+1),c=t.index.getX(a+2),u=checkBufferGeometryIntersection(e,n,r,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=o,i&&i.push(u),u):null}function intersectTris(e,t,n,r,o,i,a){for(var s=o,l=o+i;sn&&(n=o,t=r)}return t}class SeparatingAxisBounds{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){for(var n=1/0,r=-1/0,o=0,i=e.length;oe.max||e.min>this.max}}SeparatingAxisBounds.prototype.setFromBox=function(){var e=new Vector3;return function(t,n){for(var r=n.min,o=n.max,i=1/0,a=-1/0,s=0;s<=1;s++)for(var l=0;l<=1;l++)for(var c=0;c<=1;c++){e.x=r.x*s+o.x*(1-s),e.y=r.y*l+o.y*(1-l),e.z=r.z*c+o.z*(1-c);var u=t.dot(e);i=Math.min(u,i),a=Math.max(u,a)}this.min=i,this.max=a}}();var closestPointLineToLine=function(){var e=new Vector3,t=new Vector3,n=new Vector3;return function(r,o,i){var a=r.start,s=e,l=o.start,c=t;n.subVectors(a,l),e.subVectors(r.end,o.start),t.subVectors(o.end,o.start);var u,d,h=n.dot(c),p=c.dot(s),f=c.dot(c),m=n.dot(s),g=s.dot(s)*f-p*p;d=(h+(u=0!==g?(h*p-m*f)/g:0)*p)/f,i.x=u,i.y=d}}(),closestPointsSegmentToSegment=function(){var e=new Vector2,t=new Vector3,n=new Vector3;return function(r,o,i,a){closestPointLineToLine(r,o,e);var s,l,c=e.x,u=e.y;if(c>=0&&c<=1&&u>=0&&u<=1)return r.at(c,i),void o.at(u,a);if(c>=0&&c<=1)return u<0?o.at(0,a):o.at(1,a),void r.closestPointToPoint(a,!0,i);if(u>=0&&u<=1)return c<0?r.at(0,i):r.at(1,i),void o.closestPointToPoint(i,!0,a);s=c<0?r.start:r.end,l=u<0?o.start:o.end;var d=t,h=n;return r.closestPointToPoint(l,!0,t),o.closestPointToPoint(s,!0,n),d.distanceToSquared(l)<=h.distanceToSquared(s)?(i.copy(d),void a.copy(l)):(i.copy(s),void a.copy(h))}}(),sphereIntersectTriangle=function(){var e=new Vector3,t=new Vector3,n=new Plane,r=new Line3;return function(o,i){var a=o.radius,s=o.center,l=i.a,c=i.b,u=i.c;if(r.start=l,r.end=c,r.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;if(r.start=l,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;if(r.start=c,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;var d=i.getPlane(n);if(Math.abs(d.distanceToPoint(s))<=a){var h=d.projectPoint(s,t);if(i.containsPoint(h))return!0}return!1}}();class SeparatingAxisTriangle extends Triangle{constructor(...e){super(...e),this.isSeparatingAxisTriangle=!0,this.satAxes=new Array(4).fill().map((function(){return new Vector3})),this.satBounds=new Array(4).fill().map((function(){return new SeparatingAxisBounds})),this.points=[this.a,this.b,this.c],this.sphere=new Sphere}}SeparatingAxisTriangle.prototype.update=function(){var e=new Array(3);return function(){var t=this.a,n=this.b,r=this.c;e[0]=this.a,e[1]=this.b,e[2]=this.c;var o=this.satAxes,i=this.satBounds,a=o[0],s=i[0];this.getNormal(a),s.setFromPoints(a,e);var l=o[1],c=i[1];l.subVectors(t,n),c.setFromPoints(l,e);var u=o[2],d=i[2];u.subVectors(n,r),d.setFromPoints(u,e);var h=o[3],p=i[3];h.subVectors(r,t),p.setFromPoints(h,e),this.sphere.setFromPoints(this.points)}}(),SeparatingAxisTriangle.prototype.intersectsTriangle=function(){var e=new SeparatingAxisTriangle,t=new Array(3),n=new Array(3),r=new SeparatingAxisBounds,o=new SeparatingAxisBounds,i=new Vector3;return function(a){a.isSeparatingAxisTriangle||(e.copy(a),e.update(),a=e);var s=this.satBounds,l=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(var c=0;c<4;c++){var u=s[c],d=l[c];if(r.setFromPoints(d,n),u.isSeparated(r))return!1}var h=a.satBounds,p=a.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(var f=0;f<4;f++){var m=h[f],g=p[f];if(r.setFromPoints(g,t),m.isSeparated(r))return!1}for(var _=0;_<4;_++)for(var v=l[_],A=0;A<4;A++){var x=p[A];if(i.crossVectors(v,x),r.setFromPoints(i,t),o.setFromPoints(i,n),r.isSeparated(o))return!1}return!0}}(),SeparatingAxisTriangle.prototype.distanceToPoint=function(){var e=new Vector3;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),SeparatingAxisTriangle.prototype.distanceToTriangle=function(){var e=new Vector3,t=new Vector3,n=["a","b","c"],r=new Line3,o=new Line3;return function(i,a=null,s=null){if(this.intersectsTriangle(i))return(a||s)&&(this.getMidpoint(e),i.closestPointToPoint(e,t),this.closestPointToPoint(t,e),a&&a.copy(e),s&&s.copy(t)),0;for(var l=1/0,c=0;c<3;c++){var u=void 0,d=n[c],h=i[d];this.closestPointToPoint(h,e),(u=h.distanceToSquared(e))=0?(r=this.left,o=this.right):(r=this.right,o=this.left);var s=r.intersectRay(n,boxIntersection)?r.raycastFirst(e,t,n):null;if(s){var l=n.origin[a],c=l-s.point[a],u=l-o.boundingData[i],d=l-o.boundingData[i+3],h=c*c;if(h<=u*u&&h<=d*d)return s}var p=o.intersectRay(n,boxIntersection)?o.raycastFirst(e,t,n):null;return s&&p?s.distance<=p.distance?s:p:s||p||null}}MeshBVHNode.prototype.shapecast=function(){var e=new SeparatingAxisTriangle,t=new Box3,n=new Box3;return function(r,o,i=null,a=null){if(this.count&&i){for(var s=r.geometry,l=s.index,c=s.attributes.position,u=this.offset,d=3*u,h=3*(this.count+u);dm)){e.update();var u=t.distanceToTriangle(e,d,h);if(u=i;)o--;if(!(r65535?Uint32Array:Uint16Array)(t);e.setIndex(new BufferAttribute(n,1));for(var r=0;r=t.maxDepth&&(r=!0),a<=t.maxLeafTris||s>=t.maxDepth)return e.offset=i,e.count=a,e;var l=n.getOptimalSplit(e.boundingData,i,a,t.strategy);if(-1===l.axis)return e.offset=i,e.count=a,e;var c=n.partition(i,a,l);if(c===i||c===i+a)e.offset=i,e.count=a;else{e.splitAxis=l.axis;var u=e.left=new MeshBVHNode,d=i,h=c-i;u.boundingData=n.getBounds(d,h,new Float32Array(6)),o(u,d,h,s+1);var p=e.right=new MeshBVHNode,f=c,m=a-h;p.boundingData=n.getBounds(f,m,new Float32Array(6)),o(p,f,m,s+1)}return e},i=[],a=this._getRootIndexRanges(e);if(1===a.length){var s=new MeshBVHNode,l=a[0];null!=e.boundingBox?s.boundingData=boxToArray(e.boundingBox):s.boundingData=n.getBounds(l.offset,l.count,new Float32Array(6)),o(s,l.offset,l.count),i.push(s)}else for(var c=0;ct;)this.remove(this.children.pop())}}}class MeshBVHVisualizer extends Object3D{constructor(e,t=10){super("MeshBVHVisualizer"),this.depth=t,this._mesh=e,this._roots=[],this.update()}update(){for(var e=this._mesh.geometry.boundsTree,t=e?e._roots.length:0;this._roots.length>t;)this._roots.pop();for(var n=0;n=this._roots.length){var r=new MeshBVHRootVisualizer(this._mesh,this.depth,n);this.add(r),this._roots.push(r)}else{var o=this._roots[n];o.depth=this.depth,o.update()}this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}}var ray=new Ray,tmpInverseMatrix=new Matrix4,origMeshRaycastFunc=Mesh.prototype.raycast;function acceleratedRaycast(e,t){if(this.geometry.boundsTree){if(this.isAuxClippingMesh)return;if(void 0===this.material)return;try{tmpInverseMatrix.copy(this.matrixWorld).invert()}catch(e){return}if(ray.copy(e.ray).applyMatrix4(tmpInverseMatrix),!0===e.firstHitOnly){var n=this.geometry.boundsTree.raycastFirst(this,e,ray);n&&t.push(n)}else this.geometry.boundsTree.raycast(this,e,ray,t)}else origMeshRaycastFunc.call(this,e,t)}function computeBoundsTree(e){return this.boundsTree=new MeshBVH(this,e),this.boundsTree}function disposeBoundsTree(){this.boundsTree=null}const TONE_MAP_PARS=["toneMapping","toneMappingLook","toneMappingMidTones","toneMappingPhysicalScale","toneMappingBrightness","toneMappingContrast","toneMappingChromaticAdaptation","toneMappingWhiteColor","toneMappingColorDifferentiation","toneMappingExteriorDaylight","toneMappingWhiteBalance","toneMappingHighlights","toneMappingShadows","toneMappingSaturation","toneMappingAperture","toneMappingShutter","toneMappingISO","toneMappingVignetting"],GLTF_PROGRESS_WEIGHT=.6,COMPILE_PROGRESS_WEIGHT=.4,ONLOAD_100_TIMEOUT=16,TEX_IMAGE_UNITS_WARN_LIMIT=8,HIDPI_LAYER=7,_afterFirstRenderEvent={type:"afterFirstRender"},_afterRenderEvent={type:"afterRender"},_beforeRenderEvent={type:"beforeRender"},_disposeEvent={type:"dispose"},_pauseEvent={type:"pause"},_resumeEvent={type:"resume"},_sceneLoadEvent={type:"sceneLoad"};function recalcVerticalFov(e,t,n){return 2*RAD2DEG*Math.atan(Math.tan(DEG2RAD*e/2)*t/n)}class App extends EventDispatcher{constructor(e,t={},n=null){if(super(),this.container=e instanceof HTMLElement?e:document.getElementById(e),this.scene=null,this.camera=null,this.clock=new Clock,this.mixer=null,this.renderCallbacks=[],this.compileCallbacks=[],this.elapsed=0,this.frame=0,this.preloader=n,this.worldCubemapRes=1024,this._pmremMaxTileSize=256,this._lightProbeCubemapRes=64,this.xrSession=null,this.xrCameraParent=null,this.xrControllers=[],t=t||{},!Detector.checkWebGL()){const e=t.webglErrorMsg||'Ouch! Your device does not support WebGL.
Find out how to fix this here.';return void Detector.showWebGLErrorMessage(this.container,e)}ColorManagement.legacyMode=!1;const r={};r.alpha=!!isDef(t.alpha)&&t.alpha,r.depth=!isDef(t.depth)||t.depth,r.stencil=!isDef(t.stencil)||t.stencil,r.antialias=!isDef(t.antialias)||t.antialias,r.premultipliedAlpha=!isDef(t.premultipliedAlpha)||t.premultipliedAlpha,r.preserveDrawingBuffer=!!isDef(t.preserveDrawingBuffer)&&t.preserveDrawingBuffer,Detector.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy context AA on Safari 15.4"),r.antialias=!1),this.renderer=new WebGLRenderer(r),Compat.prepareRenderer(this.renderer),this.clearBkgOnLoad=!1,this.frameRateDivider=1,this.enableRender=!0,this.disableRenderTrigger=0,this.ssaaOnPause=!1,this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.renderer.outputEncoding=sRGBEncoding$1,this.container.appendChild(this.renderer.domElement),this.container.classList.add("v3d-container"),this.renderer.domElement.classList.add("v3d-canvas"),this.container.setAttribute("translate","no"),this._onContextRestoreCb=()=>{this._onContextRestore()},this.renderer.domElement.addEventListener("webglcontextrestored",this._onContextRestoreCb),this.loader=new GLTFLoader;const o=(new KTX2Loader).setTranscoderPath(findModulePath()).detectSupport(this.renderer);this.loader.setKTX2Loader(o),BufferGeometry.prototype.computeBoundsTree=computeBoundsTree,BufferGeometry.prototype.disposeBoundsTree=disposeBoundsTree,Mesh.prototype.raycast=acceleratedRaycast,this.actions=[],this.materials={push:function(){}},this.updateMaterials=function(){},this._envIBLMode=0,this._envLightProbe=null,this._resizeCb=null,this._loadSceneURL="",this._loadingTime=0,this._backgroundSave=null,this._postprocessingSave=null,this.stats=null,AppUtils.drawWatermark(this),AppUtils.addToAppList(this),this.worldMaterial=null}_updateRendererFromGLTF(e){const t=this,n=Detector.checkHalfFloatTex(this.renderer,!0);if(e.renderer.shadowMap&&(this.renderer.shadowMap.enabled=e.renderer.shadowMap.enabled,this.renderer.shadowMap.type=e.renderer.shadowMap.type,n||this.renderer.shadowMap.type!==ESMShadowMap||(this.renderer.shadowMap.type=PCFSoftShadowMap,e.scene.traverse((function(e){e.isLight&&e.castShadow&&e.shadow&&(e.shadow.bias/=100)})))),e.renderer.physicallyCorrectLights&&(this.renderer.physicallyCorrectLights=!0),this.aaMethod=e.renderer.aaMethod||"AUTO",this.useHDR=Boolean(e.renderer.useHDR&&n),this.renderer.useOIT=e.renderer.useOIT??!1,this.renderer.unitsScaleFactor=e.renderer.unitsScaleFactor??1,e.renderer.toneMapping)for(let t=0;t{e.isMesh&&(t.layers.set(7),t.isMaterialGeneratedMesh&&e.parent.layers.set(7))})),t.useHiDPIRenderPass=!0,t.renderer.setPixelRatio(window.devicePixelRatio))})),t.useHiDPIRenderPass&&e.scene.traverse((function(e){e.isLight&&e.layers.enable(7)}))}_updateMeshesRaycastFromGLTF(e){e.scene&&e.scene.traverse((function(e){const t=e.geometry;e.isMesh&&(!t.computeBoundsTree||0!==Object.keys(t.morphAttributes).length||t.attributes.position.isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute||t.computeBoundsTree({verbose:!1}))}))}_prepareReflProbesFromGLTF(e){e.scene&&e.scene.traverse((e=>{if(e.isCubeReflectionProbe)this._prepareEnvMapProbe(e);else if(e.isPlaneReflectionProbe){let t=this._checkMSAA(this.renderer,4);t>0&&e.makeMultisampleRenderTarget(t)}}))}_prepareEnvMapProbe(e){switch(e.setSize(this._pmremMaxTileSize),this._envIBLMode){case 0:e.onUpdate=e=>this.generateRTargetPMREM(e);break;case 2:case 3:e.onUpdate=()=>null}}_prepareReflProbesEncoding(e,t){e.traverse((e=>{(e.isCubeReflectionProbe||e.isPlaneReflectionProbe)&&e.setEncoding(t)}))}_prepareEnvMapProbeWorld(){if(3==this._envIBLMode)return;const e=new Scene;e.worldMaterial=this.scene.worldMaterial,null===this.scene.worldEnvMapProbe&&(this.scene.worldEnvMapProbe=new CubeReflectionProbe(this._pmremMaxTileSize),this.scene.worldEnvMapProbe.influenceType=0,this.scene.worldEnvMapProbe.parallaxType=0);const t=this.scene.worldEnvMapProbe;switch(this._envIBLMode){case 0:t.onUpdate=e=>this.generateRTargetPMREM(e);break;case 2:t.onUpdate=e=>{const t=e.clone();t.setSize(this._lightProbeCubemapRes,this._lightProbeCubemapRes),Detector.checkHalfFloatReadPixels(this.renderer)?t.texture.type=HalfFloatType:Detector.checkFloatReadPixels(this.renderer)?t.texture.type=FloatType:(console.warn("v3d.App: Target platform does not support reading pixels in float format, expect quality loss."),t.texture.type=UnsignedByteType),t.texture.format=RGBAFormat,t.texture.encoding=LinearEncoding$1;const n=new CubeCopy(e.texture);return n.render(this.renderer,t),n.dispose(),this._disposeEnvLightProbe(),this._envLightProbe=LightProbeGenerator.fromCubeRenderTarget(this.renderer,t),this.scene.add(this._envLightProbe),t.dispose(),null}}t.update(e,this.renderer),this.renderer.compatSettings.useSpecEnvBlenderApprox=0===this._envIBLMode}_updateMaterialsFromGLTF(e){const t=this;e.scene&&e.scene.traverse((function(e){const n=e.material;if(n&&t.useHDR&&(n.toneMapped=!1,n.useFloatTex=Detector.checkFloatTex(t.renderer,!0),n.isMeshNodeMaterial)){const e=n.nodeTexCoordObject;n.updateNodeGraph(),n.nodeTexCoordObject=e}}))}_updateAnimationsFromGLTF(e,t){const n=this;!n.mixer&&e.animations&&e.animations.length&&(n.mixer=new AnimationMixer(n.scene)),(e.animations||[]).forEach((function(e){const r=t.getObjectById(e.nodeId);if(r){let o;o=r.id==t.id||""!==r.name&&"root"!==r.name&&"."!==r.name&&r.name!==t.name&&r.name!==t.uuid?n.mixer.clipAction(e.clip,t):n.mixer.clipAction(e.clip,r),o.setLoop(e.loop,e.repetitions),o.startAt(e.startAt+n.mixer.time),o.clampWhenFinished=!0,e.auto?o.play():(o.stop(),o.paused=!0),n.actions.push(o)}}))}_traverseSceneForTexUniforms(e,t){e.traverse((function(e){if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((function(n){void 0!==n.program&&t(e,n,n.program.getTexUniformCount())}))}}))}_checkMSAA(e,t){return Math.min(t,e.capabilities.maxSamples)}_precompileSceneAsync(e,t,n,r){const o=this,i=o.compileCallbacks;for(let e=0;e=1&&o.renderer.setRenderTarget(a),r&&r(100*e)}))}_handleAlphaToCoverage(e){this.scene.traverse((function(t){const n=t.material;n&&n.alphaToCoverage&&(e>0?(n.transparent=!1,n.premultipliedAlpha=!1,n.blending=NoBlending):n.alphaToCoverage=!1)}))}_onContextRestore(e){this.scene&&this.scene.worldMaterial&&(this.updateEnvironment(this.scene.worldMaterial),this.updateReflectionProbes(this.scene))}assignClippingPlanes(e){const t=this;let n=[],r=[],o=[],i=-1e3;e.traverse((function(t){t.isClippingPlaneObject&&(n.push(t),r.push(t.plane),e.traverse((function(e){t.needsClippingPlane(e)&&t.assignToObject(e,i++)})),o.push(i++))}));for(let e=0;e8&&console.warn(`v3d.App: Material "${t.name}" on object "${e.name}" exceeds iOS limit of 8 textures (has ${n}).`)})),o.removeEventListener("afterFirstRender",a)},s=o.postprocessing?o.postprocessing.composer.renderTarget1:null;o._precompileSceneAsync(o.scene,o.camera,s,(function(r){const i=(60+.4*r)/1;n&&n(i),o.preloader&&o.preloader.onUpdate(i),i>=100&&(o._updateMeshesRaycastFromGLTF(e),o.addEventListener("afterFirstRender",a),t&&setTimeout((function(){o.scene.visible=!0,o.scene.disableChildRendering=!1,o.updateReflectionProbes(o.scene),o._loadingTime=performance.now()-o._loadingTime,o.dispatchEvent({..._sceneLoadEvent}),t(o.scene)}),16),e=null)})),o.clearBkgOnLoad&&(o.scene.background=null),o._tripleP=new RepeatedKeyListener(window,Keys.P,(function(){AppUtils.printPerformanceInfo(o,1)}),3,1),o._tripleF=new RepeatedKeyListener(window,Keys.F,(function(){o.stats?o.hideFPS():o.showFPS()}),3,1),o._tripleH=new RepeatedKeyListener(window,Keys.H,(function(){o.enableRender?o.disableRendering():o.enableRendering()}),3,1)}),(function(e){const t=.6*e/1;n&&n(t),o.preloader&&o.preloader.onUpdate(t)}),(function(e){console.error(e),r&&r(e)})),window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=function(){o.onResize&&o.onResize()},window.addEventListener("resize",this._resizeCb,!1)):r&&r("WebGL not found")}appendScene(e,t,n,r,o,i){const a=this;a.renderer?(void 0===o&&(o=!0),void 0===i&&(i=!0),a.preloader&&a.preloader.onUpdate(0),this.loader.load(e,(function(e){const r=e.scene||new Scene,s=[];r.traverse((function(e){(e.isCamera&&!o||e.isLight&&!i)&&s.push(e)})),s.forEach((function(e){a.unload(e)})),a.scene&&(a.scene.add(r),a._prepareReflProbesFromGLTF(e),a._updateMaterialsFromGLTF(e),a._updateAnimationsFromGLTF(e,r),a.scene.updateMatrixWorld());const l=a.postprocessing?a.postprocessing.composer.renderTarget1:null,c=a.scene||r;a.assignClippingPlanes(c),a.updateConstraints(c),r.visible=!1,r.disableChildRendering=!0,a._precompileSceneAsync(c,a.camera||new Camera,l,(function(o){const i=(60+.4*o)/1;n&&n(i),a.preloader&&a.preloader.onUpdate(i),i>=100&&(a._updateMeshesRaycastFromGLTF(e),a._traverseSceneForTexUniforms(r,(function(e,t,n){n>8&&console.warn(`v3d.App: Material "${t.name}" on object "${e.name}" exceeds iOS limit of 8 textures (has ${n}).`)})),t&&setTimeout((function(){r.visible=!0,r.disableChildRendering=!1,a.updateReflectionProbes(a.scene),t(r)}),16),e=null)}))}),(function(e){const t=.6*e/1;n&&n(t),a.preloader&&a.preloader.onUpdate(t)}),(function(e){console.error(e),r&&r(e)}))):r&&r("WebGL not found")}unload(e){const t=this;function n(e){if(e.isAnnotation)e.dispose();else if(e.isLight&&e.shadow&&e.shadow.isLightShadow)e.shadow.dispose();else if(e.isCamera&&e.controls&&e.controls.orbitTarget)n(e.controls.orbitTarget);else if(e.isScene){const t=e.worldMaterial;null!==t&&(MaterialUtils.disposeTextures(t),t.dispose()),null!==e.worldEnvMapProbe&&(e.worldEnvMapProbe.dispose(),e.worldEnvMapProbe=null)}else if(e.isMesh){e.geometry.dispose(),e.geometry.disposeBoundsTree&&e.geometry.disposeBoundsTree();const t=e.material;MaterialUtils.disposeTextures(t),t.dispose()}}if(e||(e=t.scene),e===t.scene){if(t.scene&&(t.scene.traverse(n),t.disposeEnvironment(),t.worldMaterial=null),t.scene=null,t.controls&&t.controls.dispose&&t.controls.dispose(),t.controls=null,t.camera=null,t.mixer&&(t.mixer.stopAllAction(),t.actions.forEach((function(e){t.mixer.uncacheAction(e.getClip(),e.getRoot())}))),t.mixer=null,t.actions=[],t.postprocessing){if(t.postprocessing.composer)for(let e in t.postprocessing){const n=t.postprocessing[e];(n instanceof Pass||n instanceof EffectComposer)&&n.dispose()}t.disablePostprocessing()}t.postprocessing=null,FullScreenQuad.dispose(),t.renderer&&t.renderer.disposeInternalCaches(),t._tripleP&&t._tripleP.dispose(),t._tripleF&&t._tripleF.dispose(),t._tripleH&&t._tripleH.dispose(),t.useHiDPIRenderPass=!1,t.renderer.setPixelRatio(1)}else if(t.scene&&(e.traverse(n),e.parent&&e.parent.remove(e)),t.mixer)for(let e=t.actions.length-1;e>=0;e--){const n=t.actions[e];checkActionIsUsed(t.scene,n)||(n.stop(),t.mixer.uncacheAction(n.getClip(),n.getRoot()),t.actions.splice(e,1))}}dispose(){this.scene&&this.unload(),this.renderer&&(this.renderer.forceContextLoss(),this.renderer.dispose(),this.renderer.domElement.removeEventListener("webglcontextrestored",this._onContextRestoreCb),this._onContextRestoreCb=null,this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement)),this.renderer=null,this.loader=null,window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=null,this.renderCallbacks.length=0,this.compileCallbacks.length=0,AppUtils.removeFromAppList(this),Cache.clear(),this.dispatchEvent({..._disposeEvent}),delete this._listeners}getWidth(){return this.container.offsetWidth}getHeight(){return this.container.offsetHeight}onResize(){if(!this.renderer)return;this.enableRender&&!this.ssaaOnPause||(this.enableRendering(),this.disableRendering(1));const e=this.getWidth(),t=this.getHeight();if(this.renderer.setSize(e,t),this.postprocessing&&(this.postprocessing.gtaoGenerator&&this.postprocessing.gtaoGenerator.setSize(e,t),this.postprocessing.composer.setSize(e,t)),this.scene){this.scene.traverse((n=>{n.isPlaneReflectionProbe&&n.setSize(e,t)}));const n=e/t,r=this.camera;if(r.isPerspectiveCamera){const e=r.aspect{e.isPlaneReflectionProbe&&e.update(this.scene,this.camera,this.renderer)})),this.renderer.gtaoMapEnabled=!0,this.postprocessing){const e=this.postprocessing.gtaoGenerator;e&&e.render(this.renderer);this.postprocessing.composer.render(this.elapsed)}else e&&this.renderer.render(this.scene,this.camera);if(e&&this.useHiDPIRenderPass){const e=this.camera.layers.mask,t=this.scene.background,n=this.renderer.autoClear,r=this.renderer.useOIT;this.camera.layers.set(7),this.scene.background=null,this.renderer.autoClear=!1,this.renderer.useOIT=!1,this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera),this.camera.layers.mask=e,this.scene.background=t,this.renderer.autoClear=n,this.renderer.useOIT=r}this.renderer.gtaoMapEnabled=!1,this.dispatchEvent({..._afterRenderEvent})}enableControls(e){const t=this.camera;if(t.controls){if(this.controls&&t===this.controls.object&&(this.controls instanceof OrbitControls&&"ORBIT"===t.controls.type||this.controls instanceof FlyingControls&&"FLYING"===t.controls.type||this.controls instanceof FirstPersonControls&&"FIRST_PERSON"===t.controls.type));else switch(this.controls&&this.controls.dispose(),t.controls.type){case"ORBIT":this.controls=new OrbitControls(t,e||this.renderer.domElement);break;case"FLYING":this.controls=new FlyingControls(t,this.renderer.domElement);break;case"FIRST_PERSON":this.controls=new FirstPersonControls(t,this.renderer.domElement);break;default:this.controls=null}this.controls&&(t.controls.assignToControls(this.controls,this.scene),this.controls.update())}}setCamera(e){if(this.camera=e,this.postprocessing){const t=this.postprocessing.composer.passes;for(let n=0;n{h.removeEventListener("dispose",e),this.renderer.disposeGTAO()};h.addEventListener("dispose",e),this.renderer.gtaoMap=h.renderTarget.texture}h.distance=o.distance,h.factor=o.factor,h.precision=o.precision,h.bentNormals=o.bentNormals??!1,h.bounceApprox=o.bounceApprox;break;case"outline":let p;this.postprocessing.outlinePass?p=this.postprocessing.outlinePass:(p=new OutlinePass(new Vector2(this.getWidth(),this.getHeight()),this.scene,this.camera),n.insertPass(p,i),this.postprocessing.outlinePass=p),p.edgeStrength=o.edgeStrength,p.edgeGlow=o.edgeGlow,p.edgeThickness=o.edgeThickness,p.pulsePeriod=o.pulsePeriod,p.visibleEdgeColor.fromArray(o.visibleEdgeColor),p.hiddenEdgeColor.fromArray(o.hiddenEdgeColor),p.hiddenEdgeColor.setW(Number(o.renderHiddenEdge));break;case"ssr":if(!Detector.checkHalfFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSR since your hardware does not support half float textures");break}let f,m=!1;isDef(o.useRefract)&&(m=o.useRefract),(m?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect)?f=m?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect:(f=new SSRPass(this.scene,this.camera),n.insertPassAfter(f,[this.postprocessing.renderPass,this.postprocessing.ssrPassRefract,this.postprocessing.ssrPassReflect]),m?this.postprocessing.ssrPassRefract=f:this.postprocessing.ssrPassReflect=f),f.useRefract=m,isDef(o.objects)&&(f.objects=o.objects),isDef(o.intensity)&&(f.intensity=o.intensity),isDef(o.steps)&&(f.steps=o.steps),isDef(o.stride)&&(f.stride=o.stride),isDef(o.binarySearchSteps)&&(f.binarySearchSteps=o.binarySearchSteps),isDef(o.renderTargetScale)&&(f.renderTargetScale=o.renderTargetScale),isDef(o.thickness)&&(f.thickness=o.thickness),isDef(o.maxDistance)&&(f.maxDistance=o.maxDistance),isDef(o.jitter)&&(f.jitter=o.jitter),isDef(o.renderAfter)&&(f.renderAfter=o.renderAfter),isDef(o.simpleRefraction)&&(f.simpleRefraction=o.simpleRefraction),this.onResize&&this.onResize();break;default:console.error(`v3d.App: wrong postprocessing effect "${o.type}"`)}}if(1==n.passes.length){const e=new ShaderPass(ShaderLib.copy);n.passes.push(e),this.postprocessing.copyPass=e}}disablePostprocessing(e,t){if(!this.postprocessing)return;const n=this.postprocessing.gtaoGenerator;!t&&n&&(n.dispose(),this.postprocessing.gtaoGenerator=null);const r=["afterimagePass","bloomPass","brightnessContrastPass","bokehPass","grayscalePass","ssrPassReflect","ssrPassRefract"];e||r.push("outlinePass");const o=this.postprocessing.composer;for(let e=0;e0&&(this.postprocessing.ssrPassRefract||this.postprocessing.ssrPassReflect))return;const n=this;this.scene.traverse((function(t){t.isAnnotationControl&&(t.update(n.camera),t.doUpdate=!Boolean(e))}));const r=this.postprocessing.composer;if(e>0&&r.passes[0]instanceof RenderPass){let o;this.postprocessing.ssaaRenderPass?o=this.postprocessing.ssaaRenderPass:(o=new SSAARenderPass(this.scene,this.camera),this.postprocessing.ssaaRenderPass=o,t&&o.addEventListener("iteration",(function(t){t.frame==e*e-1&&(r.enableAllPasses(),r.renderToScreen=!0,r.passes[r.passes.length-1].renderToScreen=!0,n.disableRenderTrigger=1)}))),o.sampleLevel=e||4,r.passes[0]=o,this.postprocessing.fxaaPass&&r.passes.splice(r.passes.length-1,1),t&&(o.iterative=!0,o.iterativeFrame=0,r.disableAllPasses(),r.renderToScreen=!1,o.enabled=!0)}else e>0?(r.passes[0].sampleLevel=e||4,t&&(ssaaRenderPass.iterative=!0,ssaaRenderPass.iterativeFrame=0,r.disableAllPasses(),r.renderToScreen=!1,ssaaRenderPass.enabled=!0)):0==e&&r.passes[0]instanceof SSAARenderPass&&(r.passes[0]=this.postprocessing.renderPass,this.postprocessing.fxaaPass&&r.passes.push(this.postprocessing.fxaaPass),r.enableAllPasses(),r.renderToScreen=!0)}updateEnvironment(e){const t=this.renderer.xr.enabled;if(this.renderer.xr.enabled=!1,this.disposeEnvironment(),e.toneMapped=!1,null!==this.scene.background){const t=this.renderer.toneMapping===NoToneMapping?e.worldMaterialColor():null;null!==t?this.scene.background=t:(this.scene.background=renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,{encoding:sRGBEncoding$1,format:RGBAFormat,generateMipmaps:!0,minFilter:LinearMipmapLinearFilter,type:HalfFloatType}).texture,this.scene.backgroundToneMapped=!this.useHDR)}0===this._envIBLMode&&new PMREMGenerator(this.renderer,this._pmremMaxTileSize,!0).compileCubemapShader(),this._prepareEnvMapProbeWorld(),this.renderer.xr.enabled=t}disposeEnvironment(){this._disposeEnvLightProbe();let e=this.scene.background;e&&e&&(e.isTexture||e.isCubeTexture)&&e.dispose()}_disposeEnvLightProbe(){null!==this._envLightProbe&&(this.scene.remove(this._envLightProbe),this._envLightProbe=null)}updateReflectionProbes(e){e.traverse((e=>{e.isCubeReflectionProbe&&e.update(this.scene,this.renderer)}))}generateRTargetPMREM(e){if(!e.isWebGLCubeRenderTarget)return null;const t=new PMREMGenerator(this.renderer,this._pmremMaxTileSize,!0);t.flipCubemapX=!1;const n=t.fromCubemap(e.texture);return t.dispose(),n}initWebXR(e,t,n,r,o,i){n=n||function(){},r=r||function(){},o=o||function(){},i=i||{};const a=this;function s(e){a.xrSession.removeEventListener("end",s),o();for(let e=0;e=0;e--){const n=t.children[e];n.name.indexOf(t.name)>-1&&(n.geometry.dispose(),n.material.dispose(),t.remove(n))}}const u={optionalFeatures:[t]};"immersive-ar"==e&&(u.optionalFeatures.push("hit-test"),i.domOverlay&&(u.optionalFeatures.push("dom-overlay"),u.domOverlay={root:a.container})),navigator.xr.requestSession(e,u).then((function(r){a._postprocessingSave=a.postprocessing,a.postprocessing=null,a.renderer.xr.setReferenceSpaceType(t),a.xrSession=r,r.addEventListener("end",s);const o="immersive-vr"==e?2:1;for(let e=0;em?(_=p>u?Math.min(l.bottom+this.offset,p):Math.max(l.top-this.offset,p),g=(_-p)/f+h):(g=h=0;--n){if(e[n].src.search(/ammo.wasm.js/)>-1){t=!0;break}}return new Promise((function(e,n){if(t&&window.Ammo)console.warn("You have ammo.wasm.js assigned in app html, please remove it"),e();else if(t&&!window.Ammo){console.warn("You have ammo.wasm.js assigned in app html, please remove it and resave Puzzles");const t=findModulePath("ammo.wasm.js");import(/* webpackIgnore: true */t).then((t=>{let r=t.default;r?(new r).then((t=>{window.Ammo=t,e()})):n(new Error("Failed to load physics module"))}))}else e()}))},loadLogic:async function(e,t,n){try{const n=await this._getLogicPromise(e);return await this._getAmmoJSPromise(),t&&t(),n}catch(e){console.error(e),n&&n(e)}},loadEditorWithLogic:async function(e,t,n,r){try{let r=null;await this._getEditorPromise(e+EDITOR_JS_FILE);try{r=await this._getLogicViaEditorPromise(e,t)}catch(e){if("LogicFileLoadError"!==e.name)throw e}return await this._getAmmoJSPromise(),n&&n(),r}catch(e){console.error(e),r&&r(e)}}}),CubeTextureHelper.prototype=Object.create(Mesh.prototype),CubeTextureHelper.prototype.constructor=CubeTextureHelper;class AnnotationControl extends Object3D{constructor(e){super(),this.doUpdate=!0,this.projected=new Vector3,this.container=e,this.updatedCallback=null}clone(){return new this.constructor(this.container).copy(this)}update(e){if(this.doUpdate){var t=this.projected;this.getWorldPosition(t).project(e);var n=this.container.offsetWidth,r=this.container.offsetHeight,o=(.5+t.x/2)*n,i=(.5-t.y/2)*r;t.x=o,t.y=i;var a=t.z<=1&&o>=0&&o<=n&&i>=0&&i<=r;this.visible=a,this.updatedCallback&&this.updatedCallback(t.x,t.y,a)}}}AnnotationControl.prototype.isAnnotationControl=!0;var _raycaster=new Raycaster,_camPos=new Vector3,_annoPos=new Vector3,_dir=new Vector3;class Annotation extends AnnotationControl{constructor(e,t,n){super(e),this.type="Annotation",this.character=t,this.dialogContents=n,this.annotation=document.createElement("div"),this.annotation.innerHTML=t,this.annotation.className="v3d-annotation",this.container.appendChild(this.annotation),this.annotationDialogVisible=!1,this.annotationDialog=document.createElement("div"),this.annotationDialog.innerHTML=n,this.annotationDialog.className="v3d-annotation-dialog",this.annotation.appendChild(this.annotationDialog),this.fadeObscured=!0,this.obscured=!1;var r=!1,o=this;function i(e){e.target==o.annotation?0==o.annotationDialog.innerHTML.length||o.obscured||(o.annotationDialogVisible=!o.annotationDialogVisible,o.annotationDialog.style.visibility=o.annotationDialogVisible?"visible":"hidden",o.annotationDialogVisible?o.annotation.style.zIndex="2":o.annotation.style.zIndex="1"):e.target.className.indexOf("v3d-annotation")>-1&&(o.annotationDialogVisible=!1,o.annotationDialog.style.visibility="hidden",o.annotation.style.zIndex=o.obscured?"auto":"1")}this._touchstartCb=function(e){i(e),r=!0},document.body.addEventListener("touchstart",this._touchstartCb,!1),this._mousedownCb=function(e){r||i(e),r=!1},document.body.addEventListener("mousedown",this._mousedownCb,!1)}raycast(){}clone(){return new this.constructor(this.container,this.character,this.dialogContents).copy(this)}update(e){if(super.update(e),this.doUpdate){var t=this.projected,n=this.annotation;if(n.style.transform="translate("+t.x+"px, "+t.y+"px)",n.style.visibility=this.visible?"visible":"hidden",this.annotationDialog.style.visibility=this.visible&&this.annotationDialogVisible?"visible":"hidden",this.fadeObscured){e.getWorldPositionNU(_camPos),this.getWorldPositionNU(_annoPos),_dir.copy(_annoPos).sub(_camPos).normalize(),_raycaster.set(_camPos,_dir),_raycaster.far=_camPos.distanceTo(_annoPos);var r=_raycaster.intersectObject(this.findRoot(),!0);r.length>1||1==r.length&&r[0].object!=this.parent?(n.classList.add("v3d-annotation-transparent"),this.obscured=!0,n.style.zIndex="auto",this.annotationDialog.style.visibility="hidden"):(n.classList.remove("v3d-annotation-transparent"),n.style.zIndex="visible"==this.annotationDialog.style.visibility?"2":"1",this.obscured=!1)}}}setDialogVisibility(e){e?(this.annotationDialogVisible=!0,this.annotationDialog.style.visibility="visible",this.annotation.style.zIndex="2"):(this.annotationDialogVisible=!1,this.annotationDialog.style.visibility="hidden",this.annotation.style.zIndex="1")}dispose(){var e=this.annotation.parentElement;e&&e.removeChild(this.annotation),document.body.removeEventListener("touchstart",this._touchstartCb,!1),document.body.removeEventListener("mousedown",this._mousedownCb,!1)}}Annotation.prototype.isAnnotation=!0;const _vec3Tmp=new Vector3,_quatTmp=new Quaternion,_quatTmp2=new Quaternion;function translateVRCamera(e,t,n){const r=e.parent;r&&!r.isScene&&(_vec3Tmp.copy(t).applyQuaternion(e.quaternion).applyQuaternion(r.quaternion),r.position.add(_vec3Tmp.multiplyScalar(n)))}function rotateVRCamera(e,t,n){const r=e.parent;r&&!r.isScene&&(_quatTmp.setFromAxisAngle(t,n),_quatTmp.premultiply(e.quaternion),_quatTmp.premultiply(r.quaternion),r.quaternion.multiplyQuaternions(_quatTmp,_quatTmp2.copy(e.quaternion).invert()))}var WebXRUtils=Object.freeze({__proto__:null,rotateVRCamera:rotateVRCamera,translateVRCamera:translateVRCamera});class GLTFExporter{constructor(){this.pluginCallbacks=[],this.register((function(e){return new GLTFLightExtension(e)})),this.register((function(e){return new GLTFMaterialsUnlitExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){const o=new GLTFWriter,i=[];for(let e=0,t=this.pluginCallbacks.length;e4?n=e.array[o*e.itemSize+t]:(0===t?n=e.getX(o):1===t?n=e.getY(o):2===t?n=e.getZ(o):3===t&&(n=e.getW(o)),!0===e.normalized&&(n=normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function getPaddedBufferSize(e){return 4*Math.ceil(e/4)}function getPaddedArrayBuffer(e,t=0){const n=getPaddedBufferSize(e.byteLength);if(n!==e.byteLength){const r=new Uint8Array(n);if(r.set(new Uint8Array(e)),0!==t)for(let o=e.byteLength;oe.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class GLTFWriter{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"v3d.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,o=r.buffers,i=r.json;n=r.options;const a=r.extensionsUsed,s=new Blob(o,{type:"application/octet-stream"}),l=Object.keys(a);if(l.length>0&&(i.extensionsUsed=l),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=s.size),!0===n.binary){const e=new FileReader;e.readAsArrayBuffer(s),e.onloadend=function(){const n=getPaddedArrayBuffer(e.result),r=new DataView(new ArrayBuffer(8));r.setUint32(0,n.byteLength,!0),r.setUint32(4,5130562,!0);const o=getPaddedArrayBuffer(stringToArrayBuffer(JSON.stringify(i)),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,1313821514,!0);const s=new ArrayBuffer(12),l=new DataView(s);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0);const c=12+a.byteLength+o.byteLength+r.byteLength+n.byteLength;l.setUint32(8,c,!0);const u=new Blob([s,a,o,r,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(i.buffers&&i.buffers.length>0){const e=new FileReader;e.readAsDataURL(s),e.onloadend=function(){const n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,r=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&o.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in o.gltfExtensions)t.extensions[e]=o.gltfExtensions[e],r[e]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(t){console.warn("v3d.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new Vector3;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),r=new Vector3;for(let e=0,t=n.count;e4?r=e.array[o*e.itemSize+n]:(0===n?r=e.getX(o):1===n?r=e.getY(o):2===n?r=e.getZ(o):3===n&&(r=e.getW(o)),!0===e.normalized&&(r=normalize(r,e.array))),t===WEBGL_CONSTANTS.FLOAT?l.setFloat32(c,r,!0):t===WEBGL_CONSTANTS.UNSIGNED_INT?l.setUint32(c,r,!0):t===WEBGL_CONSTANTS.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===WEBGL_CONSTANTS.UNSIGNED_BYTE&&l.setUint8(c,r),c+=a}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};void 0!==o&&(u.target=o),o===WEBGL_CONSTANTS.ARRAY_BUFFER&&(u.byteStride=e.itemSize*a),this.byteOffset+=s,i.bufferViews.push(u);return{id:i.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(r){const o=new FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const e=getPaddedArrayBuffer(o.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(i)-1)}}))}processAccessor(e,t,n,r){const o=this.json;let i;if(e.array.constructor===Float32Array)i=WEBGL_CONSTANTS.FLOAT;else if(e.array.constructor===Uint32Array)i=WEBGL_CONSTANTS.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)i=WEBGL_CONSTANTS.UNSIGNED_SHORT;else{if(e.array.constructor!==Uint8Array)throw new Error("v3d.GLTFExporter: Unsupported bufferAttribute component type.");i=WEBGL_CONSTANTS.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===r&&(r=e.count),0===r)return null;const a=getMinMax(e,n,r);let s;void 0!==t&&(s=e===t.index?WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER:WEBGL_CONSTANTS.ARRAY_BUFFER);const l=this.processBufferView(e,i,n,r,s),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(c)-1}processImage(e,t,n,r="image/png"){if(null!==e){const o=this,i=o.cache,a=o.json,s=o.options,l=o.pending;i.images.has(e)||i.images.set(e,{});const c=i.images.get(e),u=r+":flipY/"+n.toString();if(void 0!==c[u])return c[u];a.images||(a.images=[]);const d={mimeType:r},h=getCanvas();h.width=Math.min(e.width,s.maxTextureSize),h.height=Math.min(e.height,s.maxTextureSize);const p=h.getContext("2d");if(!0===n&&(p.translate(0,h.height),p.scale(1,-1)),void 0!==e.data){t!==RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;to.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==h.toDataURL?d.uri=h.toDataURL(r):l.push(getToBlobPromise(h,r).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const f=a.images.push(d)-1;return c[u]=f,f}throw new Error("v3d.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:V3D_TO_WEBGL[e.magFilter],minFilter:V3D_TO_WEBGL[e.minFilter],wrapS:V3D_TO_WEBGL[e.wrapS],wrapT:V3D_TO_WEBGL[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,o)}));const i=n.textures.push(o)-1;return t.textures.set(e,i),i}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: v3d.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(equalArray(o,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(t.multiplyScalar(1/n),console.warn("v3d.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(r.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===DoubleSide&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,r)}));const i=n.materials.push(r)-1;return t.materials.set(e,i),i}processMesh(e){const t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){const n=[],r=[],o={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)o[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(s.extras={},s.extras.targetNames=r)}const f=Array.isArray(e.material);if(f&&0===i.groups.length)return null;const m=f?e.material:[e.material],g=f?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=g.length;e0&&(n.targets=u),null!==i.index){let r=this.getUID(i.index);void 0===g[e].start&&void 0===g[e].count||(r+=":"+g[e].start+":"+g[e].count),t.attributes.has(r)?n.indices=t.attributes.get(r):(n.indices=this.processAccessor(i.index,i,g[e].start,g[e].count),t.attributes.set(r,n.indices)),null===n.indices&&delete n.indices}const r=this.processMaterial(m[g[e].materialIndex]);null!==r&&(n.material=r),c.push(n)}s.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,s)}));const _=n.meshes.push(s)-1;return t.meshes.set(o,_),_}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){const n=this.json,r=this.nodeMap;n.animations||(n.animations=[]);const o=(e=GLTFExporter.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,i=[],a=[];for(let e=0;e0){const t=[];for(let n=0,r=e.children.length;n0&&(i.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,i)}));const a=t.nodes.push(i)-1;return r.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);const o=[];for(let t=0,r=e.children.length;t0&&(r.nodes=o),this.serializeUserData(e,r)}processObjects(e){const t=new Scene;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,i.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("v3d.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("v3d.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},o[this.name]=!0);const a=r.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class GLTFMaterialsUnlitExtension{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class GLTFMaterialsClearcoatExtension{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),o.clearcoatTexture=t}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),o.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class GLTFMaterialsIridescenceExtension{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),o.iridescenceTexture=t}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class GLTFMaterialsTransmissionExtension{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),o.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class GLTFMaterialsVolumeExtension{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),o.thicknessTexture=t}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}GLTFExporter.Utils={insertKeyframe:function(e,t){const n=.001,r=e.getValueSize(),o=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+r),a=e.createInterpolant(new e.ValueBufferType(r));let s;if(0===e.times.length){o[0]=t;for(let e=0;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)t){o.set(e.times.slice(0,l+1),0),o[l+1]=t,o.set(e.times.slice(l+1),l+2),i.set(e.values.slice(0,(l+1)*r),0),i.set(a.evaluate(t),(l+1)*r),i.set(e.values.slice((l+1)*r),(l+2)*r),s=l+1;break}}return e.times=o,e.values=i,s},mergeMorphTargetTracks:function(e,t){const n=[],r={},o=e.tracks;for(let e=0;e