// Verge3D 4.11.0 © 2017-2025 Soft8Soft - v3d.net/eula const REVISION="4.11.0",MOD_SUITE="ALL",REVISION_EXPORT_MIN={BLENDER:"4.11.0",MAX:"4.9.0",MAYA:"4.9.0"},V3DL="__V3DL__0000000000",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,BilinearShadowMap=1,PCFShadowMap=2,ESMShadowMap=3,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,PbrNeutralToneMapping=10,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,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=3e3,sRGBEncoding=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,ViewportFitNone=0,ViewportFitVertical=1,ViewportFitHorizontal=2,ViewportFitAuto=3,ViewportFitFill=4,ViewportFitOverscan=5,IBLEnvironmentPMREM=0,IBLEnvironmentProbe=1,IBLEnvironmentNone=2,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,o=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&o]+_lut[o>>8&255]+_lut[o>>16&255]+_lut[o>>24&255]).toLowerCase()}function checkUUID(e){return UUID_PATTERN.test(e)}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,o,r){return o+(e-t)*(r-o)/(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,o){return lerp(e,t,1-Math.exp(-n*o))}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!(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,o,r){const i=Math.cos,a=Math.sin,s=i(n/2),l=a(n/2),c=i((t+o)/2),u=a((t+o)/2),d=i((t-o)/2),h=a((t-o)/2),p=i((o-t)/2),f=a((o-t)/2);switch(r){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: "+r)}}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,o){let r=Math.exp(-n/o);return e*r+(1-r)*t}function expAverageClamp(e,t,n,o,r){let i=expAverage(e,t,n,o);return Math.abs(e-t)r&&(o=ot&&(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}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function probeAsync(e,t,n){return new Promise(function(o,r){setTimeout(function i(){switch(e.clientWaitSync(t,1,0)){case 37149:r();break;case 37147:setTimeout(i,n);break;default:o()}},n)})}function isDef(e){return void 0!==e}function clampArray(e,t,n){for(let o=0;o1&&(i=r.minor-o.minor,0===i&&n>2&&(i=r.patch-o.patch,0===i&&n>3&&(i=engineVersionPreToNumber(r.pre)-engineVersionPreToNumber(o.pre),isNaN(i)&&(i=0)))),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 o=t.length-1;o>=0;--o){const r=t[o].src,i=r.search(/\/v3d[\w.]+js/);i>-1&&(n=r.substr(0,i)+"/"+e)}return n}function loadModule(e,t=function(e){},n=function(e){}){modulesInfo[e]=modulesInfo[e]||{status:0,loadCallbacks:[],errorCallbacks:[]};const o=modulesInfo[e];if(4==o.status)return void t(e);if(o.loadCallbacks.push(t),o.errorCallbacks.push(n),o.status>0)return;let r=findModulePath(e);const i=document.createElement("script");i.type="text/javascript",i.src=r,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),o.status=3}function arrayForEachPromise(e,t,n=0){const o=function(e,o,r,i){const a=performance.now();return t(e,o,r),a-i>n?(i=a,new Promise(function(e){setTimeout(function(){e(i)},1)})):i};let r=Promise.resolve(performance.now());return e.forEach(function(e,t,n){r=r.then(o.bind(null,e,t,n))}),r}function checkDevTools(){return"undefined"!=typeof __V3D_DEVTOOLS__}function sendDevTools(e,t){checkDevTools()&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent(e,{detail:t}))}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"srgb-linear"},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 o=FN[t][n];return e.r=o(e.r),e.g=o(e.g),e.b=o(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="srgb"){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,o=ColorManagement.workingColorSpace){return this.r=e,this.g=t,this.b=n,ColorManagement.toWorkingColorSpace(this,o),this}setHSL(e,t,n,o=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 o=n<=.5?n*(1+t):n+t-n*t,r=2*n-o;this.r=hue2rgb(r,o,e+1/3),this.g=hue2rgb(r,o,e),this.b=hue2rgb(r,o,e-1/3)}return ColorManagement.toWorkingColorSpace(this,o),this}setStyle(e,t="srgb"){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("v3d.Color: Alpha component of "+e+" will be ignored.")}let o;if(o=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const r=o[1],i=o[2];switch(r){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 o=parseFloat(e[1])/360,r=parseFloat(e[2])/100,i=parseFloat(e[3])/100;return n(e[4]),this.setHSL(o,r,i,t)}}}else if(o=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=o[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="srgb"){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="srgb"){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)}getHexString(e="srgb"){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,o=_rgb$1.g,r=_rgb$1.b,i=Math.max(n,o,r),a=Math.min(n,o,r);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=(o-r)/e+(o2048||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 o=n.getImageData(0,0,e.width,e.height),r=o.data;for(let e=0;e1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002: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 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002: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,o=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=o}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,o){return this.x=e,this.y=t,this.z=n,this.w=o,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,o=this.z,r=this.w,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*o+i[12]*r,this.y=i[1]*t+i[5]*n+i[9]*o+i[13]*r,this.z=i[2]*t+i[6]*n+i[10]*o+i[14]*r,this.w=i[3]*t+i[7]*n+i[11]*o+i[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,o,r;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,o=1-t*t;if(o>Number.EPSILON){const r=Math.sqrt(o),i=Math.atan2(r,t*n);e=Math.sin(e*i)/r,a=Math.sin(a*i)/r}const r=a*n;if(s=s*e+d*r,l=l*e+h*r,c=c*e+p*r,u=u*e+f*r,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,o,r,i){const a=n[o],s=n[o+1],l=n[o+2],c=n[o+3],u=r[i],d=r[i+1],h=r[i+2],p=r[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,o){return this._x=e,this._y=t,this._z=n,this._w=o,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,o=e._y,r=e._z,i=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(o/2),u=a(r/2),d=s(n/2),h=s(o/2),p=s(r/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,o=Math.sin(n);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],o=t[4],r=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=(r-l)*e,this._z=(i-o)*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=(o+i)/e,this._z=(r+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(r-l)/e,this._x=(o+i)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(i-o)/e,this._x=(r+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 o=Math.min(1,t/n);return this.slerp(e,o),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,o=e._y,r=e._z,i=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+i*a+o*l-r*s,this._y=o*c+i*s+r*a-n*l,this._z=r*c+i*l+n*s-o*a,this._w=i*c-n*a-o*s-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,o=this._y,r=this._z,i=this._w;let a=i*e._w+n*e._x+o*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=i,this._x=n,this._y=o,this._z=r,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*o+t*this._y,this._z=e*r+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=o*u+this._y*d,this._z=r*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),o=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(o),n*Math.sin(r),n*Math.cos(r),t*Math.sin(o))}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$5.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_quaternion$5.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,o=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*o,this.y=r[1]*t+r[4]*n+r[7]*o,this.z=r[2]*t+r[5]*n+r[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,o=this.z,r=e.elements,i=1/(r[3]*t+r[7]*n+r[11]*o+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*o+r[12])*i,this.y=(r[1]*t+r[5]*n+r[9]*o+r[13])*i,this.z=(r[2]*t+r[6]*n+r[10]*o+r[14])*i,this}applyQuaternion(e){const t=this.x,n=this.y,o=this.z,r=e.x,i=e.y,a=e.z,s=e.w,l=s*t+i*o-a*n,c=s*n+a*t-r*o,u=s*o+r*n-i*t,d=-r*t-i*n-a*o;return this.x=l*s+d*-r+c*-a-u*-i,this.y=c*s+d*-i+u*-r-l*-a,this.z=u*s+d*-a+l*-i-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,o=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*o,this.y=r[1]*t+r[5]*n+r[9]*o,this.z=r[2]*t+r[6]*n+r[10]*o,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,o=e.y,r=e.z,i=t.x,a=t.y,s=t.z;return this.x=o*s-r*a,this.y=r*i-n*s,this.z=n*a-o*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$a.copy(this).projectOnVector(e),this.sub(_vector$a)}reflect(e){return this.sub(_vector$a.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,o=this.z-e.z;return t*t+n*n+o*o}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 o=Math.sin(t)*e;return this.x=o*Math.sin(n),this.y=Math.cos(t)*e,this.z=o*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(),o=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=o,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$a=new Vector3,_quaternion$5=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,o=1/0,r=-1/0,i=-1/0,a=-1/0;for(let s=0,l=e.length;sr&&(r=l),c>i&&(i=c),u>a&&(a=u)}return this.min.set(t,n,o),this.max.set(r,i,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,o=1/0,r=-1/0,i=-1/0,a=-1/0;for(let s=0,l=e.count;sr&&(r=l),c>i&&(i=c),u>a&&(a=u)}return this.min.set(t,n,o),this.max.set(r,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$9),_vector$9.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$8.subVectors(e.b,_center),_v2$5.subVectors(e.c,_center),_f0.subVectors(_v1$8,_v0$2),_f1.subVectors(_v2$5,_v1$8),_f2.subVectors(_v0$2,_v2$5);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$8,_v2$5,_extents)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,_v0$2,_v1$8,_v2$5,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),t=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(t,_v0$2,_v1$8,_v2$5,_extents)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$9.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(_vector$9).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$9=new Vector3,_box$4=new Box3,_v0$2=new Vector3,_v1$8=new Vector3,_v2$5=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,o,r){for(let i=0,a=e.length-3;i<=a;i+=3){_testAxis.fromArray(e,i);const a=r.x*Math.abs(_testAxis.x)+r.y*Math.abs(_testAxis.y)+r.z*Math.abs(_testAxis.z),s=t.dot(_testAxis),l=n.dot(_testAxis),c=o.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$7=new Vector3,_v2$4=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 o=0;for(let t=0,r=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$7.subVectors(e,this.center);const t=_v1$7.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(_v1$7,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$4.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_v1$7.copy(e.center).add(_v2$4)),this.expandByPoint(_v1$7.copy(e.center).sub(_v2$4))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const _vector$8=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$8)),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$8.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_vector$8.copy(this.direction).multiplyScalar(t).add(this.origin),_vector$8.distanceToSquared(e))}distanceSqToSegment(e,t,n,o){_segCenter.copy(e).add(t).multiplyScalar(.5),_segDir.copy(t).sub(e).normalize(),_diff.copy(this.origin).sub(_segCenter);const r=.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=r*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=r,u=Math.max(0,-(i*d+a)),h=-u*u+d*(d+2*s)+l;else d=-r,u=Math.max(0,-(i*d+a)),h=-u*u+d*(d+2*s)+l;else d<=-p?(u=Math.max(0,-(-i*r+a)),d=u>0?-r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-s),r),h=d*(d+2*s)+l):(u=Math.max(0,-(i*r+a)),d=u>0?r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+l);else d=i>0?-r:r,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),o&&o.copy(_segDir).multiplyScalar(d).add(_segCenter),h}intersectSphere(e,t){_vector$8.subVectors(e.center,this.origin);const n=_vector$8.dot(this.direction),o=_vector$8.dot(_vector$8)-n*n,r=e.radius*e.radius;if(o>r)return null;const i=Math.sqrt(r-o),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,o,r,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,o=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,o=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,i=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,i=(e.min.y-d.y)*c),n>i||r>o?null:((r>n||isNaN(n))&&(n=r),(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>o?null:((a>n||n!=n)&&(n=a),(s=0?n:o,t)))}intersectsBox(e){return null!==this.intersectBox(e,_vector$8)}intersectTriangle(e,t,n,o,r){_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(o)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,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class 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,o,r,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]=o,g[1]=r,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,o=1/_v1$6.setFromMatrixColumn(e,0).length(),r=1/_v1$6.setFromMatrixColumn(e,1).length(),i=1/_v1$6.setFromMatrixColumn(e,2).length();return t[0]=n[0]*o,t[1]=n[1]*o,t[2]=n[2]*o,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*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,o=e.y,r=e.z,i=Math.cos(n),a=Math.sin(n),s=Math.cos(o),l=Math.sin(o),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=i*c,n=i*u,o=a*c,r=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+o*l,t[5]=e-r*l,t[9]=-a*s,t[2]=r-e*l,t[6]=o+n*l,t[10]=i*s}else if("YXZ"===e.order){const e=s*c,n=s*u,o=l*c,r=l*u;t[0]=e+r*a,t[4]=o*a-n,t[8]=i*l,t[1]=i*u,t[5]=i*c,t[9]=-a,t[2]=n*a-o,t[6]=r+e*a,t[10]=i*s}else if("ZXY"===e.order){const e=s*c,n=s*u,o=l*c,r=l*u;t[0]=e-r*a,t[4]=-i*u,t[8]=o+n*a,t[1]=n+o*a,t[5]=i*c,t[9]=r-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,o=a*c,r=a*u;t[0]=s*c,t[4]=o*l-n,t[8]=e*l+r,t[1]=s*u,t[5]=r*l+e,t[9]=n*l-o,t[2]=-l,t[6]=a*s,t[10]=i*s}else if("YZX"===e.order){const e=i*s,n=i*l,o=a*s,r=a*l;t[0]=s*c,t[4]=r-e*u,t[8]=o*u+n,t[1]=u,t[5]=i*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+o,t[10]=e-r*u}else if("XZY"===e.order){const e=i*s,n=i*l,o=a*s,r=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=i*c,t[9]=n*u-o,t[2]=o*u-n,t[6]=a*c,t[10]=r*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 o=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),o[0]=_x.x,o[4]=_y.x,o[8]=_z.x,o[1]=_x.y,o[5]=_y.y,o[9]=_z.y,o[2]=_x.z,o[6]=_y.z,o[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,o=t.elements,r=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],A=n[7],v=n[11],x=n[15],y=o[0],b=o[4],C=o[8],S=o[12],E=o[1],M=o[5],T=o[9],I=o[13],w=o[2],R=o[6],L=o[10],B=o[14],P=o[3],N=o[7],D=o[11],O=o[15];return r[0]=i*y+a*E+s*w+l*P,r[4]=i*b+a*M+s*R+l*N,r[8]=i*C+a*T+s*L+l*D,r[12]=i*S+a*I+s*B+l*O,r[1]=c*y+u*E+d*w+h*P,r[5]=c*b+u*M+d*R+h*N,r[9]=c*C+u*T+d*L+h*D,r[13]=c*S+u*I+d*B+h*O,r[2]=p*y+f*E+m*w+g*P,r[6]=p*b+f*M+m*R+g*N,r[10]=p*C+f*T+m*L+g*D,r[14]=p*S+f*I+m*B+g*O,r[3]=_*y+A*E+v*w+x*P,r[7]=_*b+A*M+v*R+x*N,r[11]=_*C+A*T+v*L+x*D,r[15]=_*S+A*I+v*B+x*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],o=e[8],r=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]*(+r*s*u-o*l*u-r*a*d+n*l*d+o*a*h-n*s*h)+e[7]*(+t*s*h-t*l*d+r*i*d-o*i*h+o*l*c-r*s*c)+e[11]*(+t*l*u-t*a*h-r*i*u+n*i*h+r*a*c-n*l*c)+e[15]*(-o*a*c-t*s*u+t*a*d+o*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 o=this.elements;return e.isVector3?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=t,o[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],o=e[2],r=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,A=p*d*l-c*m*l-p*s*h+i*m*h+c*s*g-i*d*g,v=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*A+o*v+r*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*r-u*m*r-f*o*h+n*m*h+u*o*g-n*d*g)*b,e[2]=(a*m*r-f*s*r+f*o*l-n*m*l-a*o*g+n*s*g)*b,e[3]=(u*s*r-a*d*r-u*o*l+n*d*l+a*o*h-n*s*h)*b,e[4]=A*b,e[5]=(c*m*r-p*d*r+p*o*h-t*m*h-c*o*g+t*d*g)*b,e[6]=(p*s*r-i*m*r-p*o*l+t*m*l+i*o*g-t*s*g)*b,e[7]=(i*d*r-c*s*r+c*o*l-t*d*l-i*o*h+t*s*h)*b,e[8]=v*b,e[9]=(p*u*r-c*f*r-p*n*h+t*f*h+c*n*g-t*u*g)*b,e[10]=(i*f*r-p*a*r+p*n*l-t*f*l-i*n*g+t*a*g)*b,e[11]=(c*a*r-i*u*r-c*n*l+t*u*l+i*n*h-t*a*h)*b,e[12]=x*b,e[13]=(c*f*o-p*u*o+p*n*d-t*f*d-c*n*m+t*u*m)*b,e[14]=(p*a*o-i*f*o-p*n*s+t*f*s+i*n*m-t*a*m)*b,e[15]=(i*u*o-c*a*o+c*n*s-t*u*s-i*n*d+t*a*d)*b,this}scale(e){const t=this.elements,n=e.x,o=e.y,r=e.z;return t[0]*=n,t[4]*=o,t[8]*=r,t[1]*=n,t[5]*=o,t[9]*=r,t[2]*=n,t[6]*=o,t[10]*=r,t[3]*=n,t[7]*=o,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],o=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,o))}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),o=Math.sin(t),r=1-n,i=e.x,a=e.y,s=e.z,l=r*i,c=r*a;return this.set(l*i+n,l*a-o*s,l*s+o*a,0,l*a+o*s,c*a+n,c*s-o*i,0,l*s-o*a,c*s+o*i,r*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,o,r,i){return this.set(1,n,r,0,e,1,i,0,t,o,1,0,0,0,0,1),this}compose(e,t,n){const o=this.elements,r=t._x,i=t._y,a=t._z,s=t._w,l=r+r,c=i+i,u=a+a,d=r*l,h=r*c,p=r*u,f=i*c,m=i*u,g=a*u,_=s*l,A=s*c,v=s*u,x=n.x,y=n.y,b=n.z;return o[0]=(1-(f+g))*x,o[1]=(h+v)*x,o[2]=(p-A)*x,o[3]=0,o[4]=(h-v)*y,o[5]=(1-(d+g))*y,o[6]=(m+_)*y,o[7]=0,o[8]=(p+A)*b,o[9]=(m-_)*b,o[10]=(1-(d+f))*b,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,t,n){const o=this.elements;let r=_v1$6.set(o[0],o[1],o[2]).length();const i=_v1$6.set(o[4],o[5],o[6]).length(),a=_v1$6.set(o[8],o[9],o[10]).length();this.determinant()<0&&(r=-r),e.x=o[12],e.y=o[13],e.z=o[14],_m1$2.copy(this);const s=1/r,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=r,n.y=i,n.z=a,this}makePerspective(e,t,n,o,r,i){const a=this.elements,s=2*r/(t-e),l=2*r/(n-o),c=(t+e)/(t-e),u=(n+o)/(n-o),d=-(i+r)/(i-r),h=-2*i*r/(i-r);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,o,r,i){const a=this.elements,s=1/(t-e),l=1/(n-o),c=1/(i-r),u=(t+e)*s,d=(n+o)*l,h=(i+r)*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 o=this.elements;this.makeRotationFromEuler(t);const r=n.x,i=n.y,a=n.z;return o[0]*=r,o[1]*=r,o[2]*=r,o[3]=0,o[4]*=i,o[5]*=i,o[6]*=i,o[7]=0,o[8]*=a,o[9]*=a,o[10]*=a,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decomposeE(e,t,n,o=t.order){const r=this.elements;let i=_v1$6.set(r[0],r[1],r[2]).length();const a=_v1$6.set(r[4],r[5],r[6]).length(),s=_v1$6.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[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,o),n.x=i,n.y=a,n.z=s,this}}const _v1$6=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$3=new Matrix4,_quaternion$4=new Quaternion;class Euler{constructor(e=0,t=0,n=0,o=Euler.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=o}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,o=this._order){return this._x=e,this._y=t,this._z=n,this._order=o,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 o=e.elements,r=o[0],i=o[4],a=o[8],s=o[1],l=o[5],c=o[9],u=o[2],d=o[6],h=o[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,r)):(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,r),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,r));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,r)):(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,r)):(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,r)):(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$3.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_matrix$3,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _quaternion$4.setFromEuler(this),this.setFromQuaternion(_quaternion$4,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(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$4,e,_scale$b),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$4,_quaternion$3,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,o=t.length;n0?o.multiplyScalar(1/Math.sqrt(r)):o.set(0,0,0)}static getBarycoord(e,t,n,o,r){_v0$1.subVectors(o,t),_v1$4.subVectors(n,t),_v2$3.subVectors(e,t);const i=_v0$1.dot(_v0$1),a=_v0$1.dot(_v1$4),s=_v0$1.dot(_v2$3),l=_v1$4.dot(_v1$4),c=_v1$4.dot(_v2$3),u=i*l-a*a;if(0===u)return r.set(0,0,0),null;const d=1/u,h=(l*s-a*c)*d,p=(i*c-a*s)*d;return r.set(1-h-p,p,h)}static containsPoint(e,t,n,o){return null!==this.getBarycoord(e,t,n,o,_v3$1)&&(_v3$1.x>=0&&_v3$1.y>=0&&_v3$1.x+_v3$1.y<=1)}static getInterpolation(e,t,n,o,r,i,a,s){return null===this.getBarycoord(e,t,n,o,_v3$1)?(s.x=0,s.y=0,"z"in s&&(s.z=0),"w"in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(r,_v3$1.x),s.addScaledVector(i,_v3$1.y),s.addScaledVector(a,_v3$1.z),s)}static getInterpolatedAttribute(e,t,n,o,r,i){return _v40.setScalar(0),_v41.setScalar(0),_v42.setScalar(0),_v40.fromBufferAttribute(e,t),_v41.fromBufferAttribute(e,n),_v42.fromBufferAttribute(e,o),i.setScalar(0),i.addScaledVector(_v40,r.x),i.addScaledVector(_v41,r.y),i.addScaledVector(_v42,r.z),i}static isFrontFacing(e,t,n,o){return _v0$1.subVectors(n,t),_v1$4.subVectors(e,t),_v0$1.cross(_v1$4).dot(o)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,o){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[o]),this}setFromAttributeAndIndices(e,t,n,o){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,o),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$4.subVectors(this.a,this.b),.5*_v0$1.cross(_v1$4).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)}getInterpolation(e,t,n,o,r){return Triangle.getInterpolation(e,this.a,this.b,this.c,t,n,o,r)}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,o=this.b,r=this.c;let i,a;_vab.subVectors(o,n),_vac.subVectors(r,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,o);const c=_vab.dot(_vbp),u=_vac.dot(_vbp);if(c>=0&&u<=c)return t.copy(o);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,r);const h=_vab.dot(_vcp),p=_vac.dot(_vcp);if(p>=0&&h<=p)return t.copy(r);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(r,o),a=(u-c)/(u-c+(h-p)),t.copy(o).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=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=0,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=new Set,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 o=this[t];void 0!==o?o&&o.isColor?o.set(n):o&&o.isVector3&&n&&n.isVector3?o.copy(n):this[t]=n:console.warn("v3d."+this.type+": '"+t+"' is not a property of this material.")}}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 o=0;o!==e;++o)n[o]=t[o].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=new Set(e.definesFragOnly),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.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=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.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.fog=e.fog,this}}const _vector$7=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.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let o=0,r=this.itemSize;o0){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,o,r,i,a,s,l,c,u,d){_vA$2.fromBufferAttribute(r,c),_vB$2.fromBufferAttribute(r,u),_vC$2.fromBufferAttribute(r,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),E+=1}}for(let e=0;e\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 "},o=new BoxGeometry(5,5,5),r=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const i=new Mesh(o,r),a=t.minFilter;1008===t.minFilter&&(t.minFilter=1006);return new CubeCamera(1,10,this).update(e,i),t.minFilter=a,i.geometry.dispose(),i.material.dispose(),this}clear(e,t,n,o){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,o);e.setRenderTarget(r)}}const Detector={checkWebGL:function(){try{const e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))}catch(e){return!1}},checkWebGL2:function(){try{const e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},checkWorkers:function(){return!!window.Worker},checkFileAPI:function(){return window.File&&window.FileReader&&window.FileList&&window.Blob},genWebGLErrorMessage:function(e){const t=document.createElement("div");t.setAttribute("class","v3d-webgl-error-container");const n=document.createElement("div");n.setAttribute("class","v3d-webgl-error-image"),t.appendChild(n);const o=document.createElement("div");return o.setAttribute("class","v3d-webgl-error"),o.innerHTML=e,t.appendChild(o),t},showWebGLErrorMessage:function(e,t){(e=e||document.body).appendChild(Detector.genWebGLErrorMessage(t));const n=document.getElementById("v3d_preloader_container");n&&(n.style.visibility="hidden")},checkIOS:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!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");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");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()},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}},_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,o){return this.normal.set(e,t,n),this.constant=o,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const o=_vector1.subVectors(n,t).cross(_vector2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(o,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),o=this.normal.dot(n);if(0===o)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/o;return r<0||r>1?null:t.copy(n).multiplyScalar(r).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),o=this.coplanarPoint(_vector1).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-o.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const _sphere$3=new Sphere,_vector$5=new Vector3;class Frustum{constructor(e=new Plane,t=new Plane,n=new Plane,o=new Plane,r=new Plane,i=new Plane){this.planes=[e,t,n,o,r,i]}set(e,t,n,o,r,i){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(o),a[4].copy(r),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,o=n[0],r=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],A=n[15];return t[0].setComponents(a-o,u-s,f-d,A-m).normalize(),t[1].setComponents(a+o,u+s,f+d,A+m).normalize(),t[2].setComponents(a+r,u+l,f+h,A+g).normalize(),t[3].setComponents(a-r,u-l,f-h,A-g).normalize(),t[4].setComponents(a-i,u-c,f-p,A-_).normalize(),t[5].setComponents(a+i,u+c,f+p,A+_).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,o=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,_vector$5.y=o.normal.y>0?e.max.y:e.min.y,_vector$5.z=o.normal.z>0?e.max.z:e.min.z,o.distanceToPoint(_vector$5)<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)}}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,sendDevTools("observe",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}dispose(){this.dispatchEvent({type:"dispose"})}}function WebGLAnimation(){let e=null,t=!1,n=null,o=null;function r(t,i){n(t,i),o=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(o=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(o),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const n=t.isWebGL2;let o=new WeakMap;return{get:function(e){return o.get(e)},remove:function(t){const n=o.get(t);n&&(e.deleteBuffer(n.buffer),o.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=o.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||306===m.mapping)?(void 0===c&&(c=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({type:"BackgroundCubeMaterial",uniforms:cloneUniforms(ShaderLib.backgroundCube.uniforms),vertexShader:ShaderLib.backgroundCube.vertexShader,fragmentShader:ShaderLib.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){const o=n.far;this.matrixWorld.makeScale(o,o,o),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=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(),o.unshift(c,c.geometry,c.material,0,0,null)):m&&m.isTexture&&(void 0===l&&(l=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({type:"BackgroundMaterial",uniforms:cloneUniforms(ShaderLib.background.uniforms),vertexShader:ShaderLib.background.vertexShader,fragmentShader:ShaderLib.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=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(),o.unshift(l,l.geometry,l.material,0,0,null))}}}function WebGLBindingStates(e,t,n,o){const r=e.getParameter(34921),i=o.isWebGL2?null:t.get("OES_vertex_array_object"),a=o.isWebGL2||null!==i,s={},l=p(null);let c=l,u=!1;function d(t){return o.isWebGL2?e.bindVertexArray(t):i.bindVertexArrayOES(t)}function h(t){return o.isWebGL2?e.deleteVertexArray(t):i.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],o=[];for(let e=0;e=0){const n=r[t];let o=i[t];if(void 0===o&&("instanceMatrix"===t&&e.instanceMatrix&&(o=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(o=e.instanceColor)),void 0===n)return!0;if(n.attribute!==o)return!0;if(o&&n.data!==o.data)return!0;a++}}return c.attributesNum!==a||c.index!==o}(r,v,h,x),y&&function(e,t,n,o){const r={},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 o={};o.attribute=n,n&&n.data&&(o.data=n.data),r[t]=o,a++}}c.attributes=r,c.attributesNum=a,c.index=o}(r,v,h,x)}else{const e=!0===l.wireframe;c.geometry===v.id&&c.program===h.id&&c.wireframe===e||(c.geometry=v.id,c.program=h.id,c.wireframe=e,y=!0)}null!==x&&n.update(x,34963),(y||u)&&(u=!1,function(r,i,a,s){if(!1===o.isWebGL2&&(r.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 i=c[t];if(i.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const u=c.buffer,d=c.type,h=c.bytesPerElement,p=!0===o.isWebGL2&&(5124===d||5125===d||1013===a.gpuType);if(a.isInstancedBufferAttribute){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=r(a);s!==a&&(console.warn("v3d.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=!0===n.logarithmicDepthBuffer,c=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),h=e.getParameter(34076),p=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),_=u>0,A=i||t.has("OES_texture_float");return{isWebGL2:i,getMaxAnisotropy:function(){if(void 0!==o)return o;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");o=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else o=0;return o},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:_,floatFragmentTextures:A,floatVertexTextures:_&&A,maxSamples:i?e.getParameter(36183):0}}function WebGLClipping(e){const t=this;let n=null,o=0,r=!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=o>0),t.numPlanes=o,t.numIntersection=0}function u(e,n,o,r){const i=null!==e?e.length:0;let c=null;if(0!==i){if(c=l.value,!0!==r||null===c){const t=o+4*i,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===c||c.length0){const a=new WebGLCubeRenderTarget(i.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",o),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,n=1,o=-1,r=.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=o,this.near=r,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,o,r,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=o,this.view.width=r,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,o=(this.top+this.bottom)/2;let r=n-e,i=n+e,a=o+t,s=o-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,i=r+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,i,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}}class RawShaderMaterial extends ShaderMaterial{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}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=!1,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,o=100){_oldTarget=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,o,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return e.magFilter=1006,e.minFilter=1006,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:1006,minFilter:1006,generateMipmaps:!1,type:e?e.type:1016,format:e?e.format:1023,encoding:e?e.encoding:3e3,depthBuffer:!1,stencilBuffer:!1};void 0!==t&&Object.assign(n,t);const o=_createRenderTarget(n);return o.depthBuffer=!e,null===this._pingPongRenderTarget&&(this._pingPongRenderTarget=_createRenderTarget(n)),o}_compileMaterial(e){const t=new Scene;t.add(new Mesh(_lodPlanes[0],e)),this._renderer.compile(t,_flatCamera)}_sceneToCubeUV(e,t,n,o){const r=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=1,s.toneMappingExposure=1,s.outputEncoding=3e3,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 o=(n+128)/255;s.setClearColor(h,o),e.background=null}for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,i[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,i[t]),r.lookAt(0,a[t],0)):(r.up.set(0,i[t],0),r.lookAt(0,0,a[t]));const l=_getLodTileSize(0);_setViewport(o,n*l,t>2?l:0,l,l),s.setRenderTarget(o),s.render(e,r)}s.toneMapping=c,s.toneMappingExposure=u,s.outputEncoding=l,s.setClearColor(_clearColor$2,d),e.scale.z*=-1}_textureToCubeUV(e,t,n){const o=this._renderer,r=new Scene;e.isCubeTexture?null===this._cubemapShader&&(this._cubemapShader=_getCubemapShader()):null===this._equirectShader&&(this._equirectShader=_getEquirectShader());const i=e.isCubeTexture?this._cubemapShader:this._equirectShader;r.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),o.setRenderTarget(t),o.render(r,_flatCamera)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&(f=20,p=19/3,h=r/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,o=[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(o,18*e),s.set(i,12*e);const r=[e,e,e,e,e,e];l.set(r,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=306,n.texture.name="PMREM.cubeUV",n.scissorTest=!0,n}function _setViewport(e,t,n,o,r){e.viewport.set(t,n,o,r),e.scissor.set(t,n,o,r)}function _getBlurShader(e,t){const n=new Float32Array(e),o=new Vector3(0,1,0),r=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:o}},vertexShader:ShaderChunk.pmrem_common_vert,fragmentShader:ShaderChunk.pmrem_blur_frag,blending:0,depthTest:!1,depthWrite:!1});return r.type="SphericalGaussianBlur",r}function _getEquirectShader(){const e=new Vector2(1,1),t=new RawShaderMaterial({uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:ShaderChunk.pmrem_common_vert,fragmentShader:ShaderChunk.pmrem_equirect_frag,blending:0,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function _getCubemapShader(){const e=new RawShaderMaterial({uniforms:{envMap:{value:null},flipCubemapX:{value:!1}},vertexShader:ShaderChunk.pmrem_common_vert,fragmentShader:ShaderChunk.pmrem_cubemap_frag,blending:0,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function WebGLCubeUVMaps(e){let t=new WeakMap,n=null;function o(e){const n=e.target;n.removeEventListener("dispose",o);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const i=r.mapping,a=303===i||304===i,s=301===i||302===i;if(a||s){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let o=t.get(r);return null===n&&(n=new PMREMGenerator(e)),o=a?n.fromEquirectangular(r,o):n.fromCubemap(r,o),t.set(r,o),o.texture}if(t.has(r))return t.get(r).texture;{const i=r.image;if(a&&i&&i.height>0||s&&i&&function(e){let t=0;const n=6;for(let o=0;o0&&(e.alphaTest.value=n.alphaTest);const o=t.get(n).envMap;let r,i;o&&(e.envMap.value=o,e.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.refractionRatio.value=n.refractionRatio),n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap&&(r=n.emissiveMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),n.aoMap?i=n.aoMap:n.lightMap&&(i=n.lightMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uv2Transform.value.copy(i.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,o,r,i){o.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.ssrStride.value=t.ssrParams.stride,e.ssrJitter.value=t.ssrParams.jitter,e.ssrMaxDistance.value=t.ssrParams.maxDistance}(e,o),o.isMeshBasicMaterial||o.isMeshLambertMaterial?n(e,o):o.isMeshStandardMaterial?(n(e,o),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 o=t.get(n).envMap;o&&(e.envMapIntensity.value=n.envMapIntensity,e.envMapParallaxType.value=n.envMapParallaxType,e.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv))}(e,o)):o.isMeshDepthMaterial?(n(e,o),function(e,t){e.slopeScaledBias.value=t.slopeScaledBias}(e,o)):o.isMeshDistanceMaterial?(n(e,o),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,o)):o.isMeshNormalMaterial?n(e,o):o.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,o),o.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,o)):o.isPointsMaterial?function(e,t,n,o){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*o,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let r;t.map?r=t.map:t.alphaMap&&(r=t.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,o,r,i):o.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,o):o.isShadowMaterial?(e.color.value.copy(o.color),e.opacity.value=o.opacity):o.isMeshMaskMaterial?(n(e,o),function(e,t){t.cameraNearFar&&(e.cameraNearFar.value=t.cameraNearFar);e.depthTexture.value=t.depthTexture,t.textureMatrix&&(e.textureMatrix.value=t.textureMatrix)}(e,o)):o.isMeshNodeMaterial?function(e,n){n.alphaTest>0&&(e.alphaTest.value=n.alphaTest);for(let t=0;tt.maxTextureSize&&(h=Math.ceil(d/t.maxTextureSize),d=t.maxTextureSize);const p=new Float32Array(d*h*4*r),f=new DataArrayTexture(p,d,h,r);f.type=1015,f.needsUpdate=!0;const m=4*u;for(let t=0;t0&&(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=1023,this.renderTargetMRTMSAA.texture[0].type=t,this.renderTargetMRTMSAA.texture[1].name="wboit_r",this.renderTargetMRTMSAA.texture[1].format=1028,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:5,blendEquation:100,blendSrc:204,blendDst:205,blendEquationAlpha:100,blendSrcAlpha:201,blendDstAlpha:205})),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,o,r){if(this.mute)return;this._ensureProperBuffersClearing(e);const i=e.getRenderTarget();if(i.isWebGLCubeRenderTarget)return void t(n,o,r);const a=o.overrideMaterial;if(a&&!this.isSupportedMaterial(a))return void t(n,o,r);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,o,r);this.scene=o,this.camera=r,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:o,material:a}];this._accumulationPass(e,t,h,n,s);const l=a.colorWrite;a.colorWrite=!1,a.needsUpdate=!0,e.setRenderTarget(i),t(n,o,r),a.colorWrite=l,a.needsUpdate=!0}else this._saveLayers(n),this._setupLayers(n),r.layers.disableAll(),r.layers.enable(2),t(n,o,r),r.layers.disableAll(),r.layers.enable(1),this._accumulationPass(e,t,h,n),e.setRenderTarget(i),this._renderOnlyDepth(e,t,n,o,r),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,o,r){r||(r=o);const i=e.getContext(),a=e.getRenderTarget(),s=e.getClearAlpha();if(this._saveMatSettings(r),this._setupMatSettings(r),e.setClearAlpha(1),a)if(n){e.setRenderTarget(this.renderTargetMRTMSAA),e.clear();const n=e.properties.get(this.renderTargetMRTMSAA).__webglDepthRenderbuffer,r=e.properties.get(a).__webglDepthRenderbuffer;if(r&&(i.framebufferRenderbuffer(36160,36096,36161,r),36053!==i.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.");t(o,this.scene,this.camera);if(e.getTextureUtils().updateMultisampleRenderTarget(this.renderTargetMRTMSAA),r&&(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,r=e.properties.get(a).__webglMultisampledFramebuffer;if(r&&(i.bindFramebuffer(36008,r),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 multisample render target.");t(o,this.scene,this.camera)}else{e.setRenderTarget(this.renderTargetMRT),e.clear();const n=e.properties.get(this.renderTargetMRT),r=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(o,this.scene,this.camera),l){if(i.framebufferRenderbuffer(36160,36096,36161,r||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,r||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(r),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;t0)return e;const r=t*n;let i=arrayCacheF32[r];if(void 0===i&&(i=new Float32Array(r),arrayCacheF32[r]=i),0!==t){o.toArray(i,0);for(let o=1,r=0;o!==t;++o)r+=n,e[o].toArray(i,r)}return i}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,o=e.length;n":" "} ${r}: ${n[e]}`)}return o.join("\n")}function getEncodingComponents(e){switch(e){case 3e3:return["Linear","(value)"];case 3001:return["sRGB","(value)"];default:return console.warn("v3d.WebGLProgram: Unsupported encoding:",e),["Linear","(value)"]}}function getShaderErrors(e,t,n){const o=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();if(o&&""===r)return"";const i=/ERROR: 0:(\d+)/.exec(r);if(i){const o=parseInt(i[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+handleSource(e.getShaderSource(t),o)}return r}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 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 5:n="Custom";break;case 6:n="LogarithmicMax";break;case 7:n="PhysicalMax";break;case 8:n="FilmicBlender";break;case 9:n="AgX";break;case 10:n="PbrNeutral";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 1===e&&(t="TONE_MAPPING_LOOK_AGX_PUNCHY"),t}function generateWebGL1Extensions(e){return[e.extensionDerivatives||e.bumpMap||e.tangentSpaceNormalMap||e.flatShading||"node"===e.shaderID||e.useSlopeScaledBias?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":""].filter(filterEmptyLine).join("\n")}function generateDefines(e,t){const n=[];for(const o in e){const r=e[o];!1===r||t&&t.has(o)||n.push("#define "+o+" "+r)}return n.join("\n")}function fetchAttributeLocations(e,t){const n={},o=e.getProgramParameter(t,35721);for(let r=0;r`,o+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((checkDevTools()?`// included: "${t}"\n`:"")+n)}function unrollLoops(e){const t=new RegExp("#pragma unroll_loop[\\s]+?for \\(int (\\w+) ?\\= ?(\\d+)\\; ?(\\w+) ?<(=?) ?(\\w+)\\; ?(\\w+)\\+\\+\\) ?\\{"),n=new RegExp("\\{|\\}","g");let o;for(;o=t.exec(e);){let t,r;t=r=n.lastIndex=o.index+o[0].length;let i,a=1;do{(i=n.exec(e))&&("{"==i[0]?a++:"}"==i[0]&&a--,r=i.index)}while(i&&a>0);if(0==a){const i=e.substring(o.index,n.lastIndex),a=e.substring(t,r),s=new RegExp(`\\[${o[1]}\\]`,"g"),l=new RegExp(`\\(${o[1]}\\)`,"g");let c="";const u=parseInt(o[2]),d=parseInt(o[5])+("="===o[4]?1:0);for(let e=u;e0&&(A+="\n"),v=[p,f].filter(filterEmptyLine).join("\n"),v.length>0&&(v+="\n")):(A=[generatePrecision(n),"#define SHADER_NAME "+n.shaderName,m,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.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",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.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"),v=[p,generatePrecision(n),"#define SHADER_NAME "+n.shaderName,f,getMaterialProfile(n.materialProfile),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 "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",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.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",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.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.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","#define UNITS_SCALE_FACTOR "+h,"uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?"#define TONE_MAPPING_LOOK "+genToneMappingLookDefine(n.toneMappingLook):"",0!==n.toneMapping?ShaderChunk.tonemapping_pars_fragment:"",0!==n.toneMapping?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.length>0&&n.isWebGL2?`#define LUT_DIR_LIGHT_SHADOWS_CSM int[](${n.dirLightShadowsCSMLUT})`:"","\n"].filter(filterEmptyLine).join("\n")),n.isWebGL2||!0===n.isRawShaderMaterial||(a="#include \n"+a,s="#include \n"+s),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&&(x="#version 300 es\n",A=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+A,v=["#define varying in",n.glslVersion===GLSL3?"":"layout(location = 0) out highp vec4 outFragColor;",n.glslVersion===GLSL3?"":"#define gl_FragColor outFragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj"].join("\n")+"\n"+v);let y=x+A+a,b=x+v+s;if(e.debug.disableCompiledShaderCache||checkDevTools()){const t=b.lastIndexOf("}");b=b.substr(0,t)+" // disable shader cache\n gl_FragColor += vec4("+1e-4*e.debug.random+");\n"+b.substr(t)}const C=WebGLShader(r,35633,y),S=WebGLShader(r,35632,b);sendDevTools("observe",{shaderName:n.shaderName,materialName:n.materialName,vertex:y,fragment:b}),r.attachShader(g,C),r.attachShader(g,S),void 0!==n.index0AttributeName?r.bindAttribLocation(g,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(g,0,"position"),r.linkProgram(g);let E,M,T=!0;function I(){if(T=!1,e.debug.checkShaderErrors){const e=r.getProgramInfoLog(g).trim(),t=r.getShaderInfoLog(C).trim(),n=r.getShaderInfoLog(S).trim();let o=!0,i=!0;if(!1===r.getProgramParameter(g,35714)){o=!1;const t=getShaderErrors(r,C,"vertex"),n=getShaderErrors(r,S,"fragment");console.error("v3d.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(g,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(i=!1);i&&(_.diagnostics={runnable:o,programLog:e,vertexShader:{log:t,prefix:A},fragmentShader:{log:n,prefix:v}})}r.deleteShader(C),r.deleteShader(S)}return this.getUniforms=function(){return void 0===E&&(T&&I(),E=new WebGLUniforms(r,g)),E},this.getAttributes=function(){return void 0===M&&(T&&I(),M=fetchAttributeLocations(r,g)),M},this.destroy=function(){o.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.name=n.shaderName,this.id=programIdCount++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=C,this.fragmentShader=S,this.profile={calcRenderTime:!1,renderTime:0,timerQueries:[],materials:new Set},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 o;t?(o=e.createQuery(),e.beginQuery(n.TIME_ELAPSED_EXT,o)):(o=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,o)),this.profile.timerQueries.push(o)},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 o=this.profile.timerQueries;for(let r=o.length-1;r>=0;r--){const i=o[r],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,o.splice(r,1)}}},this}function WebGLPrograms(e,t,n,o,r,i,a){const s=new Layers,l=[],c=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures;let h=r.precision,p=0;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshStandardMaterial:"standard",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite",MeshMaskMaterial:"mask",MeshNodeMaterial:"node"};return{getParameters:function(i,s,l,p,m,g){const _=p.fog,A=m.geometry,v=i.isMeshNodeMaterial||i.isMeshStandardMaterial?p.environment:null,x=(i.isMeshNodeMaterial||i.isMeshStandardMaterial?n:t).get(i.envMap||v),y=f[i.type];null!==i.precision&&(h=r.getMaxPrecision(i.precision),h!==i.precision&&console.warn("v3d.WebGLProgram.getParameters:",i.precision,"not supported, using",h,"instead."));const b=A.morphAttributes.position||A.morphAttributes.normal,C=void 0!==b?b.length:0;let S,E,M=0;if(void 0!==A.morphAttributes.position&&(M=1),void 0!==A.morphAttributes.normal&&(M=2),y){const e=ShaderLib[y];S=e.vertexShader,E=e.fragmentShader}else S=i.vertexShader,E=i.fragmentShader;const T=e.getRenderTarget(),I=i.alphaTest>0;return{isWebGL2:c,shaderID:y,shaderName:i.type,vertexShader:S,fragmentShader:E,defines:i.defines,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:h,instancing:!0===m.isInstancedMesh,instancingColor:!0===m.isInstancedMesh&&null!==m.instanceColor,supportsVertexTextures:d,outputEncoding:null===T?e.outputEncoding:!0===T.isXRRenderTarget?T.texture.encoding:3e3,map:!!i.map,envMap:!!x,envMapMode:x&&x.mapping,lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,objectSpaceNormalMap:1===i.normalMapType,tangentSpaceNormalMap:0===i.normalMapType,decodeVideoTexture:!!i.map&&!0===i.map.isVideoTexture&&3001===i.map.encoding,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,opaque:!1===i.transparent&&1===i.blending,alphaMap:!!i.alphaMap,alphaTest:I,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.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.displacementMap),uvsVertexOnly:!(i.map||i.bumpMap||i.normalMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||!i.displacementMap),fog:!!_,useFog:!0===i.fog,fogExp2:_&&_.isFogExp2,flatShading:!!i.flatShading,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===m.isSkinnedMesh,morphTargets:void 0!==A.morphAttributes.position,morphNormals:void 0!==A.morphAttributes.normal,morphTargetsCount:C,morphTextureStride:M,numDirLights:s?s.directional.length:0,numPointLights:s?s.point.length:0,numSpotLights:s?s.spot.length:0,numRectAreaLights:s?s.rectArea.length:0,numPointLightShadows:s?s.pointShadowMap.length:0,numSpotLightShadows:s?s.spotShadowMap.length:0,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:i.toneMapped?e.toneMapping:0,toneMappingLook:i.toneMapped?e.toneMappingLook:0,premultipliedAlpha:i.premultipliedAlpha,doubleSided:2===i.side,flipSided:1===i.side,useDepthPacking:!!i.depthPacking,depthPacking:i.depthPacking||0,envMapCubeUVTileSize:x&&306===x.mapping&&void 0!==x.image?x.image.width/3:0,distancePacking:void 0!==i.distancePacking&&i.distancePacking,useSlopeScaledBias:void 0!==i.useSlopeScaledBias&&i.useSlopeScaledBias,esmDistanceScale:e.shadowMap.esmDistanceScale,numRectAreaLightShadows:s?s.rectAreaShadowMap.length:0,numDirLightShadowsCSM:s?s.directionalShadowCSM.length:0,numDirLightShadowCSMCascades:s?s.directionalShadowCSMCascade.length:0,numDirLightShadowsCSMWithFade:s?s.numDirectionalShadowsCSMWithFade:0,dirLightShadowsCSMLUT:s?s.directionalShadowCSMLUT:[],planeReflProbe:!!g,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:e.canUseGTAO()&&i.isMeshNodeMaterial&&i.canUseGTAO(),index0AttributeName:i.index0AttributeName,extensionDerivatives:i.extensions&&i.extensions.derivatives,extensionFragDepth:i.extensions&&i.extensions.fragDepth,rendererExtensionFragDepth:c||o.has("EXT_frag_depth"),customProgramCacheKey:i.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];t.shaderID?n.push(t.shaderID):(n.push(hashString(t.vertexShader)),n.push(hashString(t.fragmentShader)));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!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),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.numRectAreaLights),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),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.envMapCubeUVTileSize),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.envMap&&s.enable(5);t.lightMap&&s.enable(6);t.aoMap&&s.enable(7);t.emissiveMap&&s.enable(8);t.bumpMap&&s.enable(9);t.normalMap&&s.enable(10);t.objectSpaceNormalMap&&s.enable(11);t.tangentSpaceNormalMap&&s.enable(12);t.displacementMap&&s.enable(17);t.roughnessMap&&s.enable(19);t.metalnessMap&&s.enable(20);t.alphaMap&&s.enable(21);t.alphaTest&&s.enable(22);t.vertexColors&&s.enable(23);t.vertexAlphas&&s.enable(24);t.vertexUvs&&s.enable(25);t.vertexTangents&&s.enable(26);t.uvsVertexOnly&&s.enable(27);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.premultipliedAlpha&&s.enable(7);t.shadowMapEnabled&&s.enable(8);t.doubleSided&&s.enable(9);t.flipSided&&s.enable(10);t.useDepthPacking&&s.enable(11);t.dithering&&s.enable(12);t.decodeVideoTexture&&s.enable(18);t.opaque&&s.enable(19);t.distancePacking&&s.enable(20);t.useSlopeScaledBias&&s.enable(21);t.useGTAO&&s.enable(22);t.planeReflProbe&&s.enable(23);t.alphaToCoverage&&s.enable(24);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 o;for(let e=0,t=l.length;e1&&n.sort(e||painterSortStable),o.length>1&&o.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function(t,n){const o=e.get(t);let r;return void 0===o?(r=new WebGLRenderList,e.set(t,[r])):n>=o.length?(r=new WebGLRenderList,o.push(r)):r=o[n],r},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"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,o=t.shadow;let r=0;return n&&n.isDirectionalLightShadowCSM&&o&&o.isDirectionalLightShadowCSM&&(r+=(0!=o.fade?1:0)-(0!=n.fade?1:0)),(t.castShadow?4:0)-(e.castShadow?4:0)+(t.map?2:0)-(e.map?2:0)+r}function WebGLLights(e,t){const n=new UniformsCache,o=ShadowUniformsCache(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,numPointShadows:-1,numSpotShadows:-1,numRectAreaShadows:-1,numDirectionalShadowsCSM:-1,numDirectionalShadowsCSMCascade:-1,numDirectionalShadowsCSMWithFade:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],rectAreaShadow:[],rectAreaShadowMap:[],rectAreaShadowMatrix:[],directionalShadowCSM:[],directionalShadowCSMMap:[],directionalShadowCSMMatrix:[],directionalShadowCSMCascade:[],directionalShadowCSMLUT:[],numDirectionalShadowsCSMWithFade:0};for(let e=0;e<9;e++)r.probe.push(new Vector3);const i=new Vector3,a=new Matrix4,s=new Matrix4;return{setup:function(i){let a=0,s=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,d=0,h=0,p=0,f=0,m=0,g=0,_=0,A=0;i.sort(sortOrderOfLights);for(let e=0,t=i.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=UniformsLib.LTC_FLOAT_1,r.rectAreaLTC2=UniformsLib.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=UniformsLib.LTC_HALF_1,r.rectAreaLTC2=UniformsLib.LTC_HALF_2):console.error("v3d.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=a,r.ambient[1]=s,r.ambient[2]=l;const v=r.hash;v.directionalLength===c&&v.pointLength===u&&v.spotLength===d&&v.rectAreaLength===h&&v.numPointShadows===p&&v.numSpotShadows===f&&v.numRectAreaShadows===m&&v.numDirectionalShadowsCSM===g&&v.numDirectionalShadowsCSMCascade===A&&v.numDirectionalShadowsCSMWithFade===_||(r.directional.length=c,r.spot.length=d,r.rectArea.length=h,r.point.length=u,r.pointShadow.length=p,r.pointShadowMap.length=p,r.spotShadow.length=f,r.spotShadowMap.length=f,r.pointShadowMatrix.length=p,r.spotShadowMatrix.length=f,v.directionalLength=c,v.pointLength=u,v.spotLength=d,v.rectAreaLength=h,v.numPointShadows=p,v.numSpotShadows=f,r.rectAreaShadow.length=m,r.rectAreaShadowMap.length=m,r.rectAreaShadowMatrix.length=m,r.directionalShadowCSM.length=g,r.directionalShadowCSMMap.length=A,r.directionalShadowCSMMatrix.length=A,r.directionalShadowCSMCascade.length=A,r.directionalShadowCSMLUT.length=A,r.numDirectionalShadowsCSMWithFade=_,v.numRectAreaShadows=m,v.numDirectionalShadowsCSM=g,v.numDirectionalShadowsCSMCascade=A,v.numDirectionalShadowsCSMWithFade=_,r.version=nextVersion++)},setupView:function(e,t){let n=0,l=0,c=0,u=0,d=0;const h=t.matrixWorldInverse;for(let p=0,f=e.length;pe.influenceDistance-t.influenceDistance)},pushPlaneReflProbe:function(e){a.push(e)}}}function WebGLRenderStates(e,t){let n=new WeakMap;return{get:function(o,r=0){const i=n.get(o);let a;return void 0===i?(a=new WebGLRenderState(e,t),n.set(o,[a])):r>=i.length?(a=new WebGLRenderState(e,t),i.push(a)):a=i[r],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=3301,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.mapSize=new Vector2(512,512),this.map=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(),null!==this._additionalMap2D&&this._additionalMap2D.dispose(),null!==this._additionalMapCube&&this._additionalMapCube.dispose()}removeMaps(){this.map=null,this._additionalMap2D=null,this._additionalMapCube=null}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)}}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,o=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(),o.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,o=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&o===t.aspect&&r===t.far||(t.fov=n,t.aspect=o,t.far=r,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 o=new Frustum;const r=new Vector2,i=new Vector2,a=new Vector4,s=new MeshDepthMaterial({depthPacking:3201}),l=new MeshDistanceMaterial,c={},u=n.maxTextureSize,d=n.isWebGL2,h={0:1,1:0,2:2},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)],A=[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 v=new Mesh(new PlaneGeometry(1,1,1,1));v.name="esmFarPlane",v.castShadow=!0,v.material.shadowSide=0;const x=new OrthographicCamera(-1,1,1,-1,0,10),y=new Mesh(new PlaneGeometry(2,2)),b=new ShaderMaterial({type:"ShadowCubeOctahedral",defines:Object.assign({},ShaderLib.cubeOctahedral.defines),uniforms:UniformsUtils.clone(ShaderLib.cubeOctahedral.uniforms),vertexShader:ShaderLib.cubeOctahedral.vertexShader,fragmentShader:ShaderLib.cubeOctahedral.fragmentShader}),C={},S={},E=this;function M(t,n,o,r,i,a,u,d,p){let f=null;const m=d||3===u?t.customDistanceMaterial:t.customDepthMaterial;if(f=void 0!==m?m:d||3===u?l:s,e.localClippingEnabled&&!0===o.clipShadows&&Array.isArray(o.clippingPlanes)&&0!==o.clippingPlanes.length||o.displacementMap&&0!==o.displacementScale||o.alphaMap&&o.alphaTest>0||o.map&&o.alphaTest>0){const e=f.uuid,t=o.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let r=n[t];void 0===r&&(r=f.clone(),n[t]=r),f=r}f.visible=o.visible,f.wireframe=o.wireframe,f.side=null!==o.shadowSide?o.shadowSide:h[o.side],f.alphaMap=o.alphaMap,f.alphaTest=o.alphaTest,f.map=o.map,f.clipShadows=o.clipShadows,f.clippingPlanes=o.clippingPlanes,f.clipIntersection=o.clipIntersection,f.displacementMap=o.displacementMap,f.displacementScale=o.displacementScale,f.displacementBias=o.displacementBias,f.wireframeLinewidth=o.wireframeLinewidth,f.linewidth=o.linewidth;const g=(d||3===u)&&!0===f.isMeshDistanceMaterial;switch(g&&(f.referencePosition.copy(p),f.nearDistance=i,f.farDistance=a,f.distancePacking=3===u?3302:3301),3===u&&(f.defines.DISTANCE_SCALE=shaderFloatStr(E.esmDistanceScale)),r.shadow.isDirectionalLightShadowCascade&&r.shadow.pancakeDepth&&(f.defines.PANCAKE_DEPTH="",g&&(f.defines.CAM_WIDTH=shaderFloatStr(r.shadow.camera.right),f.defines.CAM_HEIGHT=shaderFloatStr(r.shadow.camera.top))),u){case 0:case 1:case 2:f.useSlopeScaledBias=!0,f.slopeScaledBias=r.shadow.slopeScaledBias;break;case 3:f.useSlopeScaledBias=!0,f.slopeScaledBias=.5}return f}function T(n,r,i,a,s,l){if(!1===n.visible)return;if((r.ignoreShadowLayers||n.layers.test(r.layers))&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||o.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,n.matrixWorld);const o=t.update(n),r=n.material;if(Array.isArray(r)){const t=o.groups;for(let c=0,u=t.length;cu||r.y>u)&&(r.x>u&&(i.x=Math.floor(u/h.x),r.x=i.x*h.x,c.mapSize.x=i.x),r.y>u&&(i.y=Math.floor(u/h.y),r.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:1003,magFilter:1003,format:1023};c.map=new WebGLRenderTarget(r.x,r.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 r=0;r=1):-1!==L.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),w=R>=2);let B=null,P={};const N=e.getParameter(3088),D=e.getParameter(2978),O=(new Vector4).fromArray(N),F=(new Vector4).fromArray(D);function V(t,n,o){const r=new Uint8Array(4),i=e.createTexture();e.bindTexture(t,i),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;to||e.height>o)&&(r=o/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const o=t?floorPowerOfTwo:Math.floor,i=o(r*e.width),a=o(r*e.height);void 0===m&&(m=A(i,a));const s=n?A(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&&1003!==e.minFilter&&1006!==e.minFilter}function b(t){e.generateMipmap(t)}function C(n,o,r,i,a=!1){if(!1===s)return o;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=o;return 6403===o&&(5126===r&&(l=33326),5131===r&&(l=33325),5121===r&&(l=33321)),36244===o&&(5121===r&&(l=33330),5123===r&&(l=33332),5125===r&&(l=33334),5120===r&&(l=33329),5122===r&&(l=33331),5124===r&&(l=33333)),33319===o&&(5126===r&&(l=33328),5131===r&&(l=33327),5121===r&&(l=33323)),33320===o&&(5121===r&&(l=33336),5123===r&&(l=33338),5125===r&&(l=33340),5120===r&&(l=33335),5122===r&&(l=33337),5124===r&&(l=33339)),36248===o&&(5121===r&&(l=36221),5123===r&&(l=36215),5125===r&&(l=36209),5120===r&&(l=36239),5122===r&&(l=36233),5124===r&&(l=36227)),36249===o&&(5121===r&&(l=36220),5123===r&&(l=36214),5125===r&&(l=36208),5120===r&&(l=36238),5122===r&&(l=36232),5124===r&&(l=36226)),6407===o&&35902===r&&(l=35901),6408===o&&(5126===r&&(l=34836),5131===r&&(l=34842),5121===r&&(l=3001===i&&!1===a?35907:32856),32819===r&&(l=32854),32820===r&&(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&&1003!==e.minFilter&&1006!==e.minFilter?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 E(e){return 1003===e||1004===e||1005===e?9728:9729}function M(e){const t=e.target;t.removeEventListener("dispose",M),function(e){const t=o.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const o=r[t.__cacheKey];o.usedTimes--,0===o.usedTimes&&I(e),0===Object.keys(r).length&&g.delete(n)}o.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,r=o.get(t),i=o.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(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t0&&r.__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 D(r,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(3553,r.__webglTexture,33984+t)}const L={[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,L[i.wrapS]),e.texParameteri(n,10243,L[i.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,L[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),1001===i.wrapS&&1001===i.wrapT||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,E(i.magFilter)),e.texParameteri(n,10241,E(i.minFilter)),1003!==i.minFilter&&1006!==i.minFilter&&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(1003===i.magFilter)return;if(1005!==i.minFilter&&1008!==i.minFilter)return;if(1015===i.type&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&1016===i.type&&!1===t.has("OES_texture_half_float_linear"))return;(i.anisotropy>1||o.get(i).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,r.getMaxAnisotropy())),o.get(i).__currentAnisotropy=i.anisotropy)}}function N(t,n){let o=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",M));const r=n.source;let i=g.get(r);void 0===i&&(i={},g.set(r,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),o=!0),i[s].usedTimes++;const r=i[t.__cacheKey];void 0!==r&&(i[t.__cacheKey].usedTimes--,0===r.usedTimes&&I(n)),t.__cacheKey=s,t.__webglTexture=i[s].texture}return o}function D(t,r,a){let l=3553;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=35866),r.isData3DTexture&&(l=32879);const c=N(t,r),d=r.source;n.bindTexture(l,t.__webglTexture,33984+a);const h=o.get(d);if(d.version!==h.__version||!0===c){n.activeTexture(33984+a),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(1001!==e.wrapS||1001!==e.wrapT||1003!==e.minFilter&&1006!==e.minFilter)}(r)&&!1===x(r.image);let o=v(r.image,t,!1,u);o=z(r,o);const p=x(o)||s,f=i.convert(r.format,r.encoding);let m,g=i.convert(r.type),_=C(r.internalFormat,f,g,r.encoding,r.isVideoTexture);P(l,r,p);const A=r.mipmaps,E=s&&!0!==r.isVideoTexture,M=void 0===h.__version||!0===c,T=S(r,o,p);if(r.isDepthTexture)_=6402,s?_=1015===r.type?36012:1014===r.type?33190:1020===r.type?35056:33189:1015===r.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===r.format&&6402===_&&1012!==r.type&&1014!==r.type&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=1014,g=i.convert(r.type)),1027===r.format&&6402===_&&(_=34041,1020!==r.type&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=1020,g=i.convert(r.type))),M&&(E?n.texStorage2D(3553,1,_,o.width,o.height):n.texImage2D(3553,0,_,o.width,o.height,0,f,g,null));else if(r.isDataTexture)if(A.length>0&&p){E&&M&&n.texStorage2D(3553,T,_,A[0].width,A[0].height);for(let e=0,t=A.length;e>=1,t>>=1}}else if(A.length>0&&p){E&&M&&n.texStorage2D(3553,T,_,A[0].width,A[0].height);for(let e=0,t=A.length;e=34069&&l<=34074)&&e.framebufferTexture2D(36160,s,l,o.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function F(t,n,o){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let r=33189;if(s&&(r=33190),o||G(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(1015===t.type?r=36012:1014===t.type&&(r=33190));const o=U(n);G(n)?h.renderbufferStorageMultisampleEXT(36161,o,r,n.width,n.height):e.renderbufferStorageMultisample(36161,o,r,n.width,n.height)}else e.renderbufferStorage(36161,r,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=U(n);o&&!1===G(n)?e.renderbufferStorageMultisample(36161,r,35056,n.width,n.height):G(n)?h.renderbufferStorageMultisampleEXT(36161,r,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 r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(e,n){const o=e.encoding,r=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||1035===e.format||3e3!==o&&(3001===o?!1===s?!0===t.has("EXT_sRGB")&&1023===r?(e.format=1035,e.minFilter=1006,e.generateMipmaps=!1):n=ImageUtils.sRGBToLinear(n):1023===r&&1009===i||console.warn("v3d.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType. Perhaps you've set sRGB color space for an HDR image?"):console.error("v3d.WebGLTextures: Unsupported texture encoding:",o)),n}this.allocateTextureUnit=function(){const e=w;return e>=l&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),w+=1,e},this.resetTextureUnits=function(){w=0},this.setTexture2D=R,this.setTexture2DArray=function(e,t){const r=o.get(e);e.version>0&&r.__version!==e.version?D(r,e,t):n.bindTexture(35866,r.__webglTexture,33984+t)},this.setTexture3D=function(e,t){const r=o.get(e);e.version>0&&r.__version!==e.version?D(r,e,t):n.bindTexture(32879,r.__webglTexture,33984+t)},this.setTextureCube=function(t,r){const a=o.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),u=r.source;n.bindTexture(34067,t.__webglTexture,33984+a);const d=o.get(u);if(u.version!==d.__version||!0===l){n.activeTexture(33984+a),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,o=r.image[0]&&r.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=t||o?o?r.image[e].image:r.image[e]:v(r.image[e],!1,!0,c),h[e]=z(r,h[e]);const p=h[0],f=x(p)||s,m=i.convert(r.format,r.encoding),g=i.convert(r.type),_=C(r.internalFormat,m,g,r.encoding),A=s&&!0!==r.isVideoTexture,E=void 0===d.__version||!0===l;let M,T=S(r,p,f);if(P(34067,r,f),t){A&&E&&n.texStorage2D(34067,T,_,p.width,p.height);for(let e=0;e<6;e++){M=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(o){A?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 o=h?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n0&&!1===G(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],i=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=o.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;t0){r=n%o;0!==r&&o-r-a.boundary<0&&(n+=o-r,i.__offset=n)}n+=a.storage}r=n%o,r>0&&(n+=o-r);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;es+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&&(r=t.getPose(e.gripSpace,n),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1));null!==a&&(o=t.getPose(e.targetRaySpace,n),null===o&&null!==r&&(o=r),null!==o&&(a.matrix.fromArray(o.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),o.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(o.linearVelocity)):a.hasLinearVelocity=!1,o.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(o.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent)))}return null!==a&&(a.visible=null!==o),null!==s&&(s.visible=null!==r),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 Raycaster{constructor(e,t,n=0,o=1/0){this.ray=new Ray(e,t),this.near=n,this.far=o,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 o=0,r=e.length;o=0&&(_[o]=null,g[o].disconnect(n))}for(let t=0;t=_.length){_.push(n),o=e;break}if(null===_[e]){_[e]=n,o=e;break}}if(-1===o)break}const r=g[o];r&&r.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){r=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 o},this.setSession=async function(l){if(o=l,null!==o){if(f=e.getRenderTarget(),o.addEventListener("select",D),o.addEventListener("selectstart",D),o.addEventListener("selectend",D),o.addEventListener("squeeze",D),o.addEventListener("squeezestart",D),o.addEventListener("squeezeend",D),o.addEventListener("end",O),o.addEventListener("inputsourceschange",F),!0!==p.xrCompatible&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(x),void 0===o.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==o.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(o,t,n),o.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),m=new WebGLRenderTarget(d.framebufferWidth,d.framebufferHeight,{format:1023,type:1009,encoding:e.outputEncoding,stencilBuffer:p.stencil})}else{let n=null,i=null,a=null;p.depth&&(a=p.stencil?35056:33190,n=p.stencil?1027:1026,i=p.stencil?1020:1014);const s={colorFormat:32856,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(o,t),u=c.createProjectionLayer(s),o.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),m=new WebGLRenderTarget(u.textureWidth,u.textureHeight,{format:1023,type:1009,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 o.requestReferenceSpace(a),k.setContext(o),k.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const V=new Vector3,U=new Vector3;function G(e,t){if(null===t)e.matrixWorld.copy(e.matrix),L.identity(),s=null;else{e.matrixWorld.copy(e.matrix),L.copy(t.matrixWorld).invert().decompose(B,N,P);var n=new XRRigidTransform({x:B.x,y:B.y,z:B.z},{x:N.x,y:N.y,z:N.z,w:N.w});s=i.getOffsetReferenceSpace(n)}e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===o)return;E.near=C.near=b.near=e.near,E.far=C.far=b.far=e.far,M===E.near&&T===E.far||(o.updateRenderState({depthNear:E.near,depthFar:E.far}),M=E.near,T=E.far);const t=e.parent,n=E.cameras;G(E,t);for(let e=0;et&&(v.set(e,e.lastChangedTime),n.dispatchEvent({type:"planechanged",data:e}))}else A.add(e),v.set(e,o.lastChangedTime),n.dispatchEvent({type:"planeadded",data:e})}h=null}),this.setAnimationLoop=function(e){z=e},this.dispose=function(){},this.arHitTest=function(e,t,n,r){if(!o||!XRSession.prototype.requestHitTestSource)return;w=n||function(){},R=r||function(){},this.raycaster=this.raycaster||new Raycaster,this.raycaster.setFromCamera({x:e,y:t},S[0]);const i=this.raycaster.ray;new XRRay(i.origin,i.direction),o.requestReferenceSpace("viewer").then(function(e){const t={space:e};o.requestHitTestSource(t).then(function(e){I=e})})}}}const PRINT_VERGE3D_LINE=!0,ASYNC_COMPILE_THRESHOLD=16,PARALLEL_COMPILE_CHECK_INTERVAL=16;function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}function WebGLRenderer(e={}){this.isWebGLRenderer=!0;const t=void 0!==e.canvas?e.canvas:createCanvasElement(),n=void 0!==e.context?e.context:null,o=void 0===e.depth||e.depth,r=void 0===e.stencil||e.stencil,i=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,s=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",c=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;const d=new Uint32Array(4),h=new Int32Array(4);let p=null,f=null;const m=[],g=[];this.domElement=t,this.debug={checkShaderErrors:!0,disableCompiledShaderCache:!1,random:Math.random()},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=3e3,this.unitsScaleFactor=1,this.toneMapping=0,this.toneMappingLook=0,this.toneMappingExposure=1,this.gtaoMap=null,this.gtaoMapEnabled=!1,this.compatSettings={gtaoDisableBkgFix:!1};const _=this;let A=!1,v=0,x=0,y=null,b=-1,C=null;const S=new Vector4,E=new Vector4;let M=null,T=t.width,I=t.height,w=1,R=null,L=null;const B=new Vector4(0,0,T,I),P=new Vector4(0,0,T,I);let N=!1;const D=new Frustum;let O=!1,F=!1;const V=new Matrix4,U=new Vector2,G=new Vector3,z=new Scene,k=new Matrix4,W=new Matrix4,Q=new Vector4,H=new Matrix4;new Box3;let X=!1;function Y(){return null===y?w:1}this.oitRenderer=new WebGLOITRenderer(new Vector2(T,I));let j,$,K,q,Z,J,ee,te,ne,oe,re,ie,ae,se,le,ce,ue,de,he,pe,fe,me,ge,_e,Ae=n;function ve(e,n){for(let o=0;o{if(null===e.influenceGroup)return e.intersectsMesh(r);return r.groupNames.includes(e.influenceGroup)^e.influenceGroupInv})||t.worldEnvMapProbe;if(e){o.envMap=e.renderTarget?.texture||null;const t=e.parallaxDistance;o.envMapParallaxMatrix.copy(e.matrixWorldInverse).premultiply(H.makeScale(1/t,1/t,1/t)),o.envMapParallaxMatrixInv.copy(e.matrixWorld).multiply(H.makeScale(t,t,t)),o.envMapParallaxType=e.parallaxType}}const l=(o.isMeshNodeMaterial||o.isMeshStandardMaterial?te:ee).get(o.envMap||a),c=!0===o.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!o.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,p=o.toneMapped?_.toneMapping:0,m=n.morphAttributes.position||n.morphAttributes.normal,g=void 0!==m?m.length:0,A=1===o.side,v=Z.get(o),x=f.state.lights;if(!0===O&&(!0===F||e!==C)){const t=e===C&&o.id===b;ce.setState(o,e,t)}const E=Fe(r,o,f),M=_.canUseGTAO()&&o.isMeshNodeMaterial&&o.canUseGTAO();let R=!1,L=!1;o.version===v.__version?v.needsLights&&v.lightsStateVersion!==x.state.version||v.outputEncoding!==s||r.isInstancedMesh&&!1===v.instancing?R=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?R=!0:r.isSkinnedMesh||!0!==v.skinning?v.envMap!==l?(R=!0,L=!0):!0===o.fog&&v.fog!==i?R=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ce.numPlanes&&v.numIntersection===ce.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==u||v.morphTargets!==d||v.morphNormals!==h||v.toneMapping!==p||!0===$.isWebGL2&&v.morphTargetsCount!==g||v.planeReflProbe!==E||o.isMeshNormalMaterial&&v.flipSided!==A||v.useGTAO!==M)&&(R=!0):R=!0:R=!0:R=!0:R=!0;let B=v.currentProgram;!0===R&&(B=Ne(o,t,r,f));let P=!1,N=!1,D=!1;const V=B.getUniforms(),X=v.uniforms;K.useProgram(B.program)&&(P=!0,N=!0,D=!0);o.id!==b&&(b=o.id,N=!0);L&&(N=!0);if(P||C!==e){if(V.setValue(Ae,"projectionMatrix",e.projectionMatrix),$.logarithmicDepthBuffer&&V.setValue(Ae,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),C!==e&&(C=e,N=!0,D=!0),o.isMeshNodeMaterial||o.isShaderMaterial||o.isMeshStandardMaterial||o.envMap){const t=V.map.cameraPosition;void 0!==t&&t.setValue(Ae,G.setFromMatrixPosition(e.matrixWorld))}(o.isMeshNodeMaterial||o.isMeshLambertMaterial||o.isMeshBasicMaterial||o.isMeshStandardMaterial||o.isShaderMaterial)&&V.setValue(Ae,"isOrthographic",!0===e.isOrthographicCamera),(o.isMeshNodeMaterial||o.isMeshLambertMaterial||o.isMeshBasicMaterial||o.isMeshStandardMaterial||o.isShaderMaterial||o.isShadowMaterial||r.isSkinnedMesh)&&V.setValue(Ae,"viewMatrix",e.matrixWorldInverse),(o.isMeshNodeMaterial||o.isMeshLambertMaterial||o.isMeshStandardMaterial||o.isShadowMaterial)&&V.setValue(Ae,"invViewMatrix",e.matrixWorld)}if(r.isSkinnedMesh){V.setOptional(Ae,r,"bindMatrix"),V.setOptional(Ae,r,"bindMatrixInverse");const e=r.skeleton;e&&($.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),V.setValue(Ae,"boneTexture",e.boneTexture,J),V.setValue(Ae,"boneTextureSize",e.boneTextureSize)):console.warn("v3d.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const Y=n.morphAttributes;void 0===Y.position&&void 0===Y.normal||he.update(r,n,o,B);(N||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,V.setValue(Ae,"receiveShadow",r.receiveShadow));if(N){if(V.setValue(Ae,"toneMappingExposure",_.toneMappingExposure),6==_.toneMapping?(V.setValue(Ae,"toneMappingBrightness",_.toneMappingBrightness),V.setValue(Ae,"toneMappingContrast",_.toneMappingContrast),V.setValue(Ae,"toneMappingMidTones",_.toneMappingMidTones),V.setValue(Ae,"toneMappingPhysicalScale",_.toneMappingPhysicalScale),V.setValue(Ae,"toneMappingChromaticAdaptation",_.toneMappingChromaticAdaptation),V.setValue(Ae,"toneMappingWhiteColor",_.toneMappingWhiteColor),V.setValue(Ae,"toneMappingColorDifferentiation",_.toneMappingColorDifferentiation),V.setValue(Ae,"toneMappingExteriorDaylight",_.toneMappingExteriorDaylight)):7==_.toneMapping&&(V.setValue(Ae,"toneMappingResolution",U.set(T,I)),V.setValue(Ae,"toneMappingWhiteBalance",_.toneMappingWhiteBalance),V.setValue(Ae,"toneMappingHighlights",_.toneMappingHighlights),V.setValue(Ae,"toneMappingMidTones",_.toneMappingMidTones),V.setValue(Ae,"toneMappingShadows",_.toneMappingShadows),V.setValue(Ae,"toneMappingSaturation",_.toneMappingSaturation),V.setValue(Ae,"toneMappingPhysicalScale",_.toneMappingPhysicalScale),V.setValue(Ae,"toneMappingAperture",_.toneMappingAperture),V.setValue(Ae,"toneMappingShutter",_.toneMappingShutter),V.setValue(Ae,"toneMappingISO",_.toneMappingISO),V.setValue(Ae,"toneMappingVignetting",_.toneMappingVignetting)),v.needsLights&&(q=D,(j=X).ambientLightColor.needsUpdate=q,j.lightProbe.needsUpdate=q,j.directionalLights.needsUpdate=q,j.directionalLightShadowsCSM.needsUpdate=q,j.directionalLightShadowsCSMCascade.needsUpdate=q,j.pointLights.needsUpdate=q,j.pointLightShadows.needsUpdate=q,j.spotLights.needsUpdate=q,j.spotLightShadows.needsUpdate=q,j.rectAreaLights.needsUpdate=q,j.rectAreaLightShadows.needsUpdate=q),i&&!0===o.fog&&ae.refreshFogUniforms(X,i),v.useGTAO){const e=y?.width??T,t=y?.height??I;V.setValue(Ae,"currResolution",U.set(e,t)),ae.refreshGTAOUniforms(X,_.gtaoMap)}if(ae.refreshMaterialUniforms(X,o,w,I),E&&ae.refreshPlaneReflProbeUniforms(X,E),o.isMeshNodeMaterial)for(const e in o.nodeTextures)V.setValue(Ae,e,o.nodeTextures[e],J);o.isMeshLineMaterial&&V.setValue(Ae,"resolution",U.set(T,I)),WebGLUniforms.upload(Ae,De(v),X,J)}var j,q;o.isShaderMaterial&&!0===o.uniformsNeedUpdate&&(WebGLUniforms.upload(Ae,De(v),X,J),o.uniformsNeedUpdate=!1);o.isSpriteMaterial&&V.setValue(Ae,"center",r.center);if(o.isMeshNodeMaterial){o.needsBoundingBox&&(null===n.boundingBox&&n.computeBoundingBox(),V.setValue(Ae,"boundingBoxMin",n.boundingBox.min),V.setValue(Ae,"boundingBoxMax",n.boundingBox.max)),V.setValue(Ae,"viewWidthHeight",U.set(S.z-S.x,S.w-S.y));const e=V.map.invModelMatrix;(e||o.nodeTexCoordObject.includes(null))&&(k.copy(r.matrixWorld).invert(),e&&e.setValue(Ae,k)),o.nodeTexCoordObject.forEach(function(e,t){(null===e?k:W.copy(e.matrixWorld).invert()).toArray(v.nodeTexCoordObjectMatrices,16*t)}),V.setValue(Ae,"nodeTexCoordObjectMatrices",v.nodeTexCoordObjectMatrices),V.setValue(Ae,"objectIndex",r.objectIndex);const t=r.objectColor;V.setValue(Ae,"objectColor",Q.set(t.r,t.g,t.b,r.objectAlpha)),V.setValue(Ae,"objectRandom",hashString(r.uuid)/Math.pow(2,32))}if(V.setValue(Ae,"modelViewMatrix",r.modelViewMatrix),V.setValue(Ae,"normalMatrix",r.normalMatrix),V.setValue(Ae,"modelMatrix",r.matrixWorld),o.isShaderMaterial||o.isRawShaderMaterial){const e=o.uniformsGroups;for(let t=0,n=e.length;t{e.isLight?(n.pushLight(e),e.castShadow&&n.pushShadow(e)):e.isCubeReflectionProbe?n.pushEnvMapProbe(e):e.isPlaneReflectionProbe&&(n.pushPlaneReflProbe(e),e.calcLocalBounding())}),n.setupLights(),n.sortEnvMapProbes();let o=null;return e.worldEnvMapProbe&&null!==e.worldEnvMapProbe.renderTarget&&(o=e.worldEnvMapProbe.renderTarget.texture),e.traverse(e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach(t=>{(t.isMeshNodeMaterial||t.isMeshStandardMaterial)&&(e.material.envMap=o,e.material.needsUpdate=!0)})}}),n},this.compile=function(e,t){this.gtaoMapEnabled=!0;const n=le.get(e,g.length);this._compilePrepareRenderState(e,t,n);const o={};e.traverse(function(t){const r=t.material;if(r)if(Array.isArray(r))for(let i=0;i0&&Be(r,t,n),i.length>0&&(X&&0!==_.oitRenderer.method?_.oitRenderer.render(_,Be,i,t,n):Be(i,t,n)),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function Be(e,t,n){const o=!0===t.isScene?t.overrideMaterial:null;for(let r=0,i=e.length;rt.intersectsMesh(e))||null}we.setAnimationLoop(function(e){Me&&Me(e)}),"undefined"!=typeof self&&we.setContext(self),this.setAnimationLoop=function(e){Me=e,ye.setAnimationLoop(e),null===e?we.stop():we.start()},ye.addEventListener("sessionstart",Te),ye.addEventListener("sessionend",Ie),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===A)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===ye.enabled&&!0===ye.isPresenting&&(!0===ye.cameraAutoUpdate&&ye.updateCamera(t),t=ye.getCamera()),!0===e.isScene&&e.onBeforeRender(_,e,t,y),f=le.get(e,g.length),f.init(),g.push(f),V.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),D.setFromProjectionMatrix(V),F=this.localClippingEnabled,O=ce.init(this.clippingPlanes,F,t),p=se.get(e,m.length),p.init(),m.push(p),Re(e,t,0,_.sortObjects),p.finish(),!0===_.sortObjects&&p.sort(R,L),!0===O&&ce.beginShadows();const n=f.state.shadowsArray;if(ue.render(n,e,t),!0===O&&ce.endShadows(),this.info.render.frame++,de.render(p,e),f.setupLights(),f.sortEnvMapProbes(),t.isArrayCamera){const n=t.cameras;for(let t=0,o=n.length;t0?g[g.length-1]:null,m.pop(),p=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return y},this.setRenderTargetTextures=function(e,t,n){Z.get(e.texture).__webglTexture=t,Z.get(e.depthTexture).__webglTexture=n;const o=Z.get(e);o.__hasExternalTextures=!0,o.__autoAllocateDepthBuffer=void 0===n,o.__autoAllocateDepthBuffer||!0===j.has("WEBGL_multisampled_render_to_texture")&&(console.warn("v3d.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),o.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){const n=Z.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){y=e,v=t,x=n;let o=!0,r=null,i=!1,a=!1;if(e){const n=Z.get(e);void 0!==n.__useDefaultFramebuffer?(K.bindFramebuffer(36160,null),o=!1):void 0===n.__webglFramebuffer?J.setupRenderTarget(e):n.__hasExternalTextures&&J.rebindTextures(e,Z.get(e.texture).__webglTexture,Z.get(e.depthTexture).__webglTexture);const s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);const l=Z.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],i=!0):r=$.isWebGL2&&e.samples>0&&!1===J.useMultisampledRTT(e)?Z.get(e).__webglMultisampledFramebuffer:l,S.copy(e.viewport),E.copy(e.scissor),M=e.scissorTest}else S.copy(B).multiplyScalar(w).floor(),E.copy(P).multiplyScalar(w).floor(),M=N;if(K.bindFramebuffer(36160,r)&&$.isWebGL2&&o&&K.drawBuffers(e,r),K.viewport(S),K.scissor(E),K.setScissorTest(M),i){const o=Z.get(e.texture);Ae.framebufferTexture2D(36160,36064,34069+t,o.__webglTexture,n)}else if(a){const o=Z.get(e.texture),r=t||0;Ae.framebufferTextureLayer(36160,36064,o.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,o,r,i,a){if(!e||!e.isWebGLRenderTarget)return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not v3d.WebGLRenderTarget.");let s=Z.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(1023!==s&&me.convert(s)!==Ae.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=1016===l&&(j.has("EXT_color_buffer_half_float")||$.isWebGL2&&j.has("EXT_color_buffer_float"));if(!(1009===l||me.convert(l)===Ae.getParameter(35738)||1015===l&&($.isWebGL2||j.has("OES_texture_float")||j.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-o&&n>=0&&n<=e.height-r&&Ae.readPixels(t,n,o,r,me.convert(s),me.convert(l),i)}finally{const e=null!==y?Z.get(y).__webglFramebuffer:null;K.bindFramebuffer(36160,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,o,r,i,a){if(!e||!e.isWebGLRenderTarget)throw new Error("v3d.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not v3d.WebGLRenderTarget.");let s=Z.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){if(t>=0&&t<=e.width-o&&n>=0&&n<=e.height-r){K.bindFramebuffer(36160,s);const a=e.texture,l=a.format,c=a.type;if(1023!==l&&me.convert(l)!==Ae.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");const u=1016===c&&(j.has("EXT_color_buffer_half_float")||$.isWebGL2&&j.has("EXT_color_buffer_float"));if(!(1009===c||me.convert(c)===Ae.getParameter(35738)||1015===c&&($.isWebGL2||j.has("OES_texture_float")||j.has("WEBGL_color_buffer_float"))||u))return void console.error("v3d.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=Ae.createBuffer();Ae.bindBuffer(35051,d),Ae.bufferData(35051,i.byteLength,35041),Ae.readPixels(t,n,o,r,me.convert(l),me.convert(c),0);const h=null!==y?Z.get(y).__webglFramebuffer:null;K.bindFramebuffer(36160,h);const p=Ae.fenceSync(37143,0);return Ae.flush(),await probeAsync(Ae,p,4),Ae.bindBuffer(35051,d),Ae.getBufferSubData(35051,0,i),Ae.deleteBuffer(d),Ae.deleteSync(p),i}throw new Error("v3d.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t,n=0){const o=Math.pow(2,-n),r=Math.floor(t.image.width*o),i=Math.floor(t.image.height*o);J.setTexture2D(t,0),Ae.copyTexSubImage2D(3553,n,0,0,e.x,e.y,r,i),K.unbindTexture()},this.copyTextureToTexture=function(e,t,n,o=0){const r=t.image.width,i=t.image.height,a=me.convert(n.format),s=me.convert(n.type);J.setTexture2D(n,0),Ae.pixelStorei(37440,n.flipY),Ae.pixelStorei(37441,n.premultiplyAlpha),Ae.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?Ae.texSubImage2D(3553,o,e.x,e.y,r,i,a,s,t.image.data):t.isCompressedTexture?Ae.compressedTexSubImage2D(3553,o,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Ae.texSubImage2D(3553,o,e.x,e.y,a,s,t.image),0===o&&n.generateMipmaps&&Ae.generateMipmap(3553),K.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,o,r=0){if(!$.isWebGL2)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=me.convert(o.format),c=me.convert(o.type);let u;if(o.isData3DTexture)J.setTexture3D(o,0),u=32879;else{if(!o.isDataArrayTexture)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: only supports v3d.DataTexture3D and v3d.DataTexture2DArray.");J.setTexture2DArray(o,0),u=35866}Ae.pixelStorei(37440,o.flipY),Ae.pixelStorei(37441,o.premultiplyAlpha),Ae.pixelStorei(3317,o.unpackAlignment);const d=Ae.getParameter(3314),h=Ae.getParameter(32878),p=Ae.getParameter(3316),f=Ae.getParameter(3315),m=Ae.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Ae.pixelStorei(3314,g.width),Ae.pixelStorei(32878,g.height),Ae.pixelStorei(3316,e.min.x),Ae.pixelStorei(3315,e.min.y),Ae.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?Ae.texSubImage3D(u,r,t.x,t.y,t.z,i,a,s,l,c,g.data):n.isCompressedArrayTexture?(console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Ae.compressedTexSubImage3D(u,r,t.x,t.y,t.z,i,a,s,l,g.data)):Ae.texSubImage3D(u,r,t.x,t.y,t.z,i,a,s,l,c,g),Ae.pixelStorei(3314,d),Ae.pixelStorei(32878,h),Ae.pixelStorei(3316,p),Ae.pixelStorei(3315,f),Ae.pixelStorei(32877,m),0===r&&o.generateMipmaps&&Ae.generateMipmap(u),K.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?J.setTextureCube(e,0):e.isData3DTexture?J.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?J.setTexture2DArray(e,0):J.setTexture2D(e,0),K.unbindTexture()},this.resetState=function(){v=0,x=0,y=null,K.reset(),ge.reset()},sendDevTools("observe",this),this.updateGeometry=function(e){return re.update(e)},this.setOIT=function(e,t){this.oitRenderer.setSize(T,I),this.oitRenderer.texType=null!==me.convert(1016)?1016:1009;let n=t||(!0===i?4:0);this.oitRenderer.isMethodCompatible(e,$)?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 X},set:function(e){this.setTransparentSort(e?function(){}:null),X=e}})}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)}}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)}}class SpriteMaterial extends Material{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let _geometry;const _intersectPoint=new Vector3,_worldScale$1=new Vector3,_mvPosition=new Vector3,_alignedPosition=new Vector2,_rotatedPosition=new Vector2,_viewWorldMatrix=new Matrix4,_vA$1=new Vector3,_vB$1=new Vector3,_vC$1=new Vector3,_uvA$1=new Vector2,_uvB$1=new Vector2,_uvC$1=new Vector2;class Sprite extends Object3D{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===_geometry){_geometry=new BufferGeometry;const e=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),t=new Float32Array([0,0,1,0,1,1,0,1]);_geometry.setIndex([0,1,2,0,2,3]),_geometry.setAttribute("position",new BufferAttribute(e,3)),_geometry.setAttribute("uv",new BufferAttribute(t,2))}this.geometry=_geometry,this.material=void 0!==e?e:new SpriteMaterial,this.center=new Vector2(.5,.5)}raycast(e,t){if(null===e.camera)return void console.error('v3d.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');_worldScale$1.setFromMatrixScale(this.matrixWorld),_viewWorldMatrix.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_mvPosition.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&_worldScale$1.multiplyScalar(-_mvPosition.z);const n=this.material.rotation;let o,r;0!==n&&(r=Math.cos(n),o=Math.sin(n));const i=this.center;transformVertex(_vA$1.set(-.5,-.5,0),_mvPosition,i,_worldScale$1,o,r),transformVertex(_vB$1.set(.5,-.5,0),_mvPosition,i,_worldScale$1,o,r),transformVertex(_vC$1.set(.5,.5,0),_mvPosition,i,_worldScale$1,o,r),_uvA$1.set(0,0),_uvB$1.set(1,0),_uvC$1.set(1,1);let a=e.ray.intersectTriangle(_vA$1,_vB$1,_vC$1,!1,_intersectPoint);if(null===a&&(transformVertex(_vB$1.set(-.5,.5,0),_mvPosition,i,_worldScale$1,o,r),_uvB$1.set(0,1),a=e.ray.intersectTriangle(_vA$1,_vC$1,_vB$1,!1,_intersectPoint),null===a))return;const s=e.ray.origin.distanceTo(_intersectPoint);se.far||t.push({distance:s,point:_intersectPoint.clone(),uv:Triangle.getInterpolation(_intersectPoint,_vA$1,_vB$1,_vC$1,_uvA$1,_uvB$1,_uvC$1,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,o,r,i){_alignedPosition.subVectors(e,n).addScalar(.5).multiply(o),void 0!==r?(_rotatedPosition.x=i*_alignedPosition.x-r*_alignedPosition.y,_rotatedPosition.y=r*_alignedPosition.x+i*_alignedPosition.y):_rotatedPosition.copy(_alignedPosition),e.copy(t),e.x+=_rotatedPosition.x,e.y+=_rotatedPosition.y,e.applyMatrix4(_viewWorldMatrix)}const _v1$3=new Vector3,_v2$2=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,o;for(n=1,o=t.length;n0){_v1$3.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(_v1$3);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){_v1$3.setFromMatrixPosition(e.matrixWorld),_v2$2.setFromMatrixPosition(this.matrixWorld);const n=_v1$3.distanceTo(_v2$2)/e.zoom;let o,r;for(t[0].object.visible=!0,o=1,r=t.length;o=e))break;t[o-1].object.visible=!1,t[o].object.visible=!0}for(this._currentLevel=o-1;os)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),o=Math.min(f.count,i.start+i.count)-1;ns)continue;d.applyMatrix4(this.matrixWorld);const o=e.ray.origin.distanceTo(d);oe.far||t.push({distance:o,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;er.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,o,r,i,a,s,l){super(e,t,n,o,r,i,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==i?i:1006,this.magFilter=void 0!==r?r:1006,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=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class CompressedTexture extends Texture{constructor(e,t,n,o,r,i,a,s,l,c,u,d){super(null,i,a,s,l,c,o,r,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,o,r,i){super(e,t,n,r,i),this.isCompressedArrayTexture=!0,this.image.depth=o,this.wrapR=1001}}class CanvasTexture extends Texture{constructor(e,t,n,o,r,i,a,s,l){super(e,t,n,o,r,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,o=this.getPoint(0),r=0;t.push(0);for(let i=1;i<=e;i++)n=this.getPoint(i/e),r+=n.distanceTo(o),t.push(r),o=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let o=0;const r=n.length;let i;i=t||e*n[r-1];let a,s=0,l=r-1;for(;s<=l;)if(o=Math.floor(s+(l-s)/2),a=n[o]-i,a<0)s=o+1;else{if(!(a>0)){l=o;break}l=o-1}if(o=l,n[o]===i)return o/(r-1);const c=n[o];return(o+(i-c)/(n[o+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let o=e-n,r=e+n;o<0&&(o=0),r>1&&(r=1);const i=this.getPoint(o),a=this.getPoint(r),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,o=[],r=[],i=[],a=new Vector3,s=new Matrix4;for(let t=0;t<=e;t++){const n=t/e;o[t]=this.getTangentAt(n,new Vector3)}r[0]=new Vector3,i[0]=new Vector3;let l=Number.MAX_VALUE;const c=Math.abs(o[0].x),u=Math.abs(o[0].y),d=Math.abs(o[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(o[0],n).normalize(),r[0].crossVectors(o[0],a),i[0].crossVectors(o[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),i[t]=i[t-1].clone(),a.crossVectors(o[t-1],o[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(clamp(o[t-1].dot(o[t]),-1,1));r[t].applyMatrix4(s.makeRotationAxis(a,e))}i[t].crossVectors(o[t],r[t])}if(!0===t){let t=Math.acos(clamp(r[0].dot(r[e]),-1,1));t/=e,o[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(o[n],t*n)),i[n].crossVectors(o[n],r[n])}return{tangents:o,normals:r,binormals:i}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class EllipseCurve extends Curve{constructor(e=0,t=0,n=1,o=1,r=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=o,this.aStartAngle=r,this.aEndAngle=i,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new Vector2,o=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const i=Math.abs(r)o;)r-=o;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=o[(l-1)%r]:(tmp$1.subVectors(o[0],o[1]).add(o[0]),a=tmp$1);const u=o[l%r],d=o[(l+1)%r];if(this.closed||l+2o.length-2?o.length-1:i+1],u=o[i>o.length-3?o.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=o[r]-n,i=this.curves[r],a=i.getLength(),s=0===a?0:1-e/a;return i.getPointAt(s,t)}r++}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,o=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}}class LatheGeometry extends BufferGeometry{constructor(e=[new Vector2(0,-.5),new Vector2(.5,0),new Vector2(0,.5)],t=12,n=0,o=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:o},t=Math.floor(t),o=clamp(o,0,2*Math.PI);const r=[],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 r=0;r<=t;r++){const h=n+r*c*o,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=r/t,d.y=n/(e.length-1),a.push(d.x,d.y);const o=s[3*n+0]*p,c=s[3*n+1],h=s[3*n+0]*f;l.push(o,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))}}class ConeGeometry extends CylinderGeometry{constructor(e=1,t=1,n=32,o=1,r=!1,i=0,a=2*Math.PI){super(0,e,t,n,o,r,i,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:o,openEnded:r,thetaStart:i,thetaLength:a}}}const _v0=new Vector3,_v1$2=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,o=Math.pow(10,n),r=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,o,r){let i,a;if(r===signedArea(e,t,n,o)>0)for(i=t;i=t;i-=o)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,o=e;do{if(n=!1,o.steiner||!equals(o,o.next)&&0!==area(o.prev,o,o.next))o=o.next;else{if(removeNode(o),o=t=o.prev,o===o.next)break;n=!0}}while(n||o!==t);return t}function earcutLinked(e,t,n,o,r,i,a){if(!e)return;!a&&i&&indexCurve(e,o,r,i);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,i?isEarHashed(e,o,r,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,o,r,i,2):2===a&&splitEarcut(e,t,n,o,r,i):earcutLinked(filterPoints(e),t,n,o,r,i,1);break}}function isEar(e){const t=e.prev,n=e,o=e.next;if(area(t,n,o)>=0)return!1;const r=t.x,i=n.x,a=o.x,s=t.y,l=n.y,c=o.y,u=ri?r>a?r:a:i>a?i:a,p=s>l?s>c?s:c:l>c?l:c;let f=o.next;for(;f!==t;){if(f.x>=u&&f.x<=h&&f.y>=d&&f.y<=p&&pointInTriangle(r,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,o){const r=e.prev,i=e,a=e.next;if(area(r,i,a)>=0)return!1;const s=r.x,l=i.x,c=a.x,u=r.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,o),A=zOrder(m,g,t,n,o);let v=e.prevZ,x=e.nextZ;for(;v&&v.z>=_&&x&&x.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==a&&pointInTriangle(s,u,l,d,c,h,v.x,v.y)&&area(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&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(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==a&&pointInTriangle(s,u,l,d,c,h,v.x,v.y)&&area(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=A;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&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 o=e;do{const r=o.prev,i=o.next.next;!equals(r,i)&&intersects(r,o,o.next,i)&&locallyInside(r,i)&&locallyInside(i,r)&&(t.push(r.i/n|0),t.push(o.i/n|0),t.push(i.i/n|0),removeNode(o),removeNode(o.next),o=e=i),o=o.next}while(o!==e);return filterPoints(o)}function splitEarcut(e,t,n,o,r,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,o,r,i,0),void earcutLinked(s,t,n,o,r,i,0)}e=e.next}a=a.next}while(a!==e)}function eliminateHoles(e,t,n,o){const r=[];let i,a,s,l,c;for(i=0,a=t.length;i=o.next.y&&o.next.y!==o.y){const e=o.x+(a-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(e<=i&&e>r&&(r=e,n=o.x=o.x&&o.x>=l&&i!==o.x&&pointInTriangle(an.x||o.x===n.x&§orContainsSector(n,o)))&&(n=o,d=u)),o=o.next}while(o!==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,o){let r=e;do{0===r.z&&(r.z=zOrder(r.x,r.y,t,n,o)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n,o,r,i,a,s,l,c=1;do{for(n=e,e=null,i=null,a=0;n;){for(a++,o=n,s=0,t=0;t0||l>0&&o;)0!==s&&(0===l||!o||n.z<=o.z)?(r=n,n=n.nextZ,s--):(r=o,o=o.nextZ,l--),i?i.nextZ=r:e=r,r.prevZ=i,i=r;n=o}i.nextZ=null,c*=2}while(a>1);return e}function zOrder(e,t,n,o,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-o)*r|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)*(o-s)>=(n-a)*(t-s)&&(n-a)*(i-s)>=(r-a)*(o-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,o){const r=sign(area(e,t,n)),i=sign(area(e,t,o)),a=sign(area(n,o,e)),s=sign(area(n,o,t));return r!==i&&a!==s||(!(0!==r||!onSegment(e,n,t))||(!(0!==i||!onSegment(e,o,t))||(!(0!==a||!onSegment(n,e,o))||!(0!==s||!onSegment(n,t,o)))))}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,o=!1;const r=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&r<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next}while(n!==e);return o}function splitPolygon(e,t){const n=new Node(e.i,e.x,e.y),o=new Node(t.i,t.x,t.y),r=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,o.next=n,n.prev=o,i.next=o,o.prev=i,o}function insertNode(e,t,n,o){const r=new Node(e,t,n);return o?(r.next=o.next,r.prev=o,o.next.prev=r,o.next=r):(r.prev=r,r.next=r),r}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,o){let r=0;for(let i=t,a=n-o;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);o=p+a*m-e.x,r=f+s*m-e.y;const g=o*o+r*r;if(g<=2)return new Vector2(o,r);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?(o=-s,r=a,i=Math.sqrt(u)):(o=a,r=s,i=Math.sqrt(u/2))}return new Vector2(o/i,r/i)}const L=[];for(let e=0,t=M.length,n=t-1,o=e+1;e=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),o=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=M.length;e=0;){const o=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*p;e.9&&a<.1&&(t<.2&&(i[e+0]+=1),n<.2&&(i[e+2]+=1),o<.2&&(i[e+4]+=1))}}()}(),this.setAttribute("position",new Float32BufferAttribute(r,3)),this.setAttribute("normal",new Float32BufferAttribute(r.slice(),3)),this.setAttribute("uv",new Float32BufferAttribute(i,2)),0===o?this.computeVertexNormals():this.normalizeNormals()}}class IcosahedronGeometry extends PolyhedronGeometry{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}}class RingGeometry extends BufferGeometry{constructor(e=.5,t=1,n=32,o=1,r=0,i=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:o,thetaStart:r,thetaLength:i},n=Math.max(3,n);const a=[],s=[],l=[],c=[];let u=e;const d=(t-e)/(o=Math.max(1,o)),h=new Vector3,p=new Vector2;for(let e=0;e<=o;e++){for(let e=0;e<=n;e++){const o=r+e/n*i;h.x=u*Math.cos(o),h.y=u*Math.sin(o),s.push(h.x,h.y,h.z),l.push(0,0,1),p.x=(h.x/t+1)/2,p.y=(h.y/t+1)/2,c.push(p.x,p.y)}u+=d}for(let e=0;e0)&&h.push(t,r,l),(e!==n-1||s!(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,$=0,K=0,q=0;for(let e=r?0:20;e=28){for(let t=0;t<3;t++){for(let n=0;n<4;n++)for(let o=0;o<4;o++)A[4*o+n]=l[3*s[16*e+4*n+o]+t],i&&e>=20&&e<28&&2!==t&&(A[4*o+n]*=1.077),a||2!==t||(A[4*o+n]*=1.3);D.set(A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11],A[12],A[13],A[14],A[15]),O.multiplyMatrices(D,_),C[t].multiplyMatrices(W,O)}for(let e=0;e<=t;e++){const n=e/t;for(let e=0;e<=t;e++){const o=e/t;for(L=4,w=R=1;L--;)v[L]=w,x[L]=R,w*=n,R*=o,3===L?(y[L]=b[L]=0,B=P=1):(y[L]=B*(3-L),b[L]=P*(3-L),B*=n,P*=o);F.fromArray(v),V.fromArray(x),U.fromArray(y),G.fromArray(b);for(let e=0;e<3;e++)I=F.clone(),I.applyMatrix4(C[e]),S[e]=I.dot(V),I=U.clone(),I.applyMatrix4(C[e]),E[e]=I.dot(V),I=F.clone(),I.applyMatrix4(C[e]),M[e]=I.dot(G);z.fromArray(E),k.fromArray(M),T.crossVectors(k,z),T.normalize(),0===S[0]&&0===S[1]?N.set(0,S[2]>c?1:-1,0):N.set(T.x,T.z,-T.y),f[j++]=u*S[0],f[j++]=u*(S[2]-c),f[j++]=-u*S[1],m[$++]=N.x,m[$++]=N.y,m[$++]=N.z,g[K++]=1-o,g[K++]=1-n}}for(let e=0;e=r)){const a=t[1];e=r)break t}i=n,n=0;break n}break e}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,o=e=>e,r=e=>e){const i=this.V,a=e.V;for(let t=0;t "+o[e]+";"}}t+="}",console.log(t)};const Edge=function(e,t,n=0){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=1e4&&e<25e3?t=1/15e3*e-2/3:e>=25e3&&e<4e4&&(t=-(1/15e3*e-8/3)),t}function phaseRayleigh(e){return 3/(16*Math.PI)*(1+Math.pow(e,2))}function phaseMie(e){return 3*.4224*(1+Math.pow(e,2))/(8*Math.PI*2.5776*Math.pow(1.5776-1.52*e,1.5))}function surfaceIntersection(e,t){if(t.z>=0)return!1;const n=-2*t.dot(_vec3Tmp$8.copy(e).negate());return n*n-4*(e.lengthSq()-Math.pow(636e4,2))>=0}function atmosphereIntersection(e,t,n){const o=-2*t.dot(_vec3Tmp$8.copy(e).negate()),r=e.lengthSq()-Math.pow(642e4,2),i=(-o+Math.sqrt(o*o-4*r))/2;return n.set(e.x+t.x*i,e.y+t.y*i,e.z+t.z*i)}function rayOpticalDepth(e,t,n){atmosphereIntersection(e,t,_rayEnd);const o=e.distanceTo(_rayEnd),r=_segmentROD.copy(t).multiplyScalar(o);n.set(0,0,0);const i=_vec3Tmp$8,a=_vec3Tmp2$6;for(let t=0;t<8;t++){i.copy(e).addScaledVector(r,QUADRATURE_NODES[t]);const o=i.length()-636e4;a.set(densityRayleigh(o),densityMie(o),densityOzone(o)),n.addScaledVector(a,QUADRATURE_WEIGHTS[t])}return n.multiplyScalar(o)}function compSum(e){return e.x+e.y+e.z}function singleScattering(e,t,n,o,r,i,a){atmosphereIntersection(n,e,_rayEnd);const s=n.distanceTo(_rayEnd)/32,l=_segmentSS.copy(e).multiplyScalar(s);_opticalDepth.set(0,0,0);for(let e=0;e<21;e++)a[e]=0;const c=e.dot(t);_phaseFunction.set(phaseRayleigh(c),phaseMie(c),0),_densityScale.set(o,r,i),_P.copy(n).addScaledVector(l,.5);for(let e=0;e<32;e++){const e=_P.length()-636e4;if(_density.set(densityRayleigh(e),densityMie(e),densityOzone(e)),_density.multiply(_densityScale),_opticalDepth.addScaledVector(_density,s),!surfaceIntersection(_P,t)){rayOpticalDepth(_P,t,_lightOpticalDepth).multiply(_densityScale);const e=_lightOpticalDepth.add(_opticalDepth);for(let t=0;t<21;t++){_extinctionDensity.set(RAYLEIGH_COEFF[t],1.11*2e-5,OZONE_COEFF[t]).multiply(e);const n=Math.exp(-compSum(_extinctionDensity));_scatteringDensity.set(RAYLEIGH_COEFF[t],2e-5,0).multiply(_density),a[t]+=n*compSum(_scatteringDensity.multiply(_phaseFunction))*IRRADIANCE[t]*s}}_P.add(l)}}function precomputeTexture(e,t,n,o,r,i,a,s){const l=Array(21),c=t/2,u=new Vector3(0,0,636e4+r),d=new Vector3;geographicalToDirection(o,0,d);const h=Math.PI/2/n,p=2*Math.PI/t,f=h/2,m=new Vector3,g=new Vector3;for(let o=0;o-1){o.removedNodes.push(r+e.len());const i=e.findInEdges(n),s=t.findOutEdges(r);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){return t.nodeUVAliases[e]||"uv"}function _(e,n){return n=isDef(n)?n:"color",t.nodeVCAliases[e]||n}function A(e,t,n,o){const r=new DataTexture(e,t,1,n,o,Texture.DEFAULT_MAPPING,1001,1001,1006,1006);return r.name="Node.parametric",r.needsUpdate=!0,r}function v(e){return!0===e.isVideoTexture&&3001===e.encoding?"1":!e.isDataTexture||3001!==e.encoding||1015!=e.type&&1016!=e.type?"0":"1"}function x(e,t,n,o,r){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?i="float("+e+")":"int"==t&&"vec3"==n?i="vec3("+[e,e,e].join(",")+")":"int"==t&&"vec4"==n?i="vec4("+[e,e,e,e].join(",")+")":"bool"==t&&"float"==n?i="float("+e+")":console.error("MeshNodeMaterial: Missing type conversion: "+t+" -> "+n),(r<1||1!=r&&"normal"==o)&&(i="mix("+o+","+i+","+N(r)+")","normal"==o&&(i="normalize("+i+")")),i}function y(e,t,n,o,r){let i;const a=[],s=B(n),l=B(o);for(let n=0;n0||isConnInput(e,l,N_IN[d].clearcoat))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[N_IN[d].sheen]>0||isConnInput(e,l,N_IN[d].sheen))&&(t.defines.USE_SHEEN=""),c.inputFactors.length=0;break;case"TRIGO_AR":c.params.push(T(u.function)),c.params.push(T(u.units));break;case"TRIPLANAR_AR":c.params.push(T(u.coordSpace)),c.params.push(M(u.inputPerAxis)),c.params.push(M(u.flipOnOppositeDirection)),c.params.push(C(u.blendFactor));break;case"TRIPLANAR_UV_AR":c.params.push(M(u.flipOnOppositeDirection)),void 0!==u.blendFactor&&c.params.push(C(u.blendFactor)),void 0!==u.projectionAxis&&c.params.push(T(u.projectionAxis));break;case"TWO_SIDED_AR":c.params.push(T("faceDirection"));break;case"USER_DATA_COLOR_AR":h=_(u.colorLayer,""),h?(p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(T(P("vec4",u.defaultColor)));break;case"UV_PROJECTION_AR":c.params.push(T(u.projectionType)),c.params.push(T(u.coordSpace));break;case"ATTRIBUTE_BL":case"VERTEX_COLOR_BL":h=_(u.colorLayer,""),h?(p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(T("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BSDF_METALLIC_BL":c.params.push(T("geometryNormal")),c.params.push(T("BSDF_METALLIC_"+u.distribution)),c.params.push(M("PHYSICAL_CONDUCTOR"===u.fresnelType));break;case"BSDF_PRINCIPLED_BL":c.params.push(T("geometryNormal"));const R=getNodeTypeCompat(c);(u.inputs[N_IN[R].clearcoat]>0||isConnInput(e,l,N_IN[R].clearcoat))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[N_IN[R].sheen]>0||isConnInput(e,l,N_IN[R].sheen))&&(t.defines.USE_SHEEN_BLENDER="");break;case"BSDF_REFRACTION_BL":c.params.push(T("geometryNormal")),c.params.push(T("BSDF_REFRACTION_"+u.distribution));break;case"BUMP_BL":c.params.push(C(u.invert));break;case"CAMERA_BL":c.params.push(T("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(T("RANGE"==u.clampType));break;case"COMBINE_COLOR_BL":c.params.push(T("NODE_COMB_COL_"+u.mode));break;case"CURVE_FLOAT_BL":t.useFloatTex?(f=new Float32Array(1024),m=1):(f=new Uint8Array(1024),m=255);for(let e=0;e<256;e++){let t=m*(u.curveData[e]/2+.5);f[4*e]=clamp(t,0,m)}y=A(f,256,1023,t.useFloatTex?1015:1009),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++;break;case"CURVE_RGB_BL":case"CURVE_VEC_BL":t.useFloatTex?(f=new Float32Array(1024),m=1):(f=new Uint8Array(1024),m=255);for(let e=0;e<256;e++){let t,n,o,r;B=u.curveData.length/256,B>3?(t=m*u.curveData[B*e],n=m*u.curveData[B*e+1],o=m*u.curveData[B*e+2],r=m*u.curveData[B*e+3]):(t=m*(u.curveData[B*e]/2+.5),n=m*(u.curveData[B*e+1]/2+.5),o=m*(u.curveData[B*e+2]/2+.5),r=m),f[4*e]=clamp(t,0,m),f[4*e+1]=clamp(n,0,m),f[4*e+2]=clamp(o,0,m),f[4*e+3]=clamp(r,0,m)}y=A(f,256,1023,t.useFloatTex?1015:1009),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++;break;case"EEVEE_SPECULAR_BL":c.params.push(T("geometryNormal")),(u.inputs[N_IN[d].clearcoat]>0||isConnInput(e,l,N_IN[d].clearcoat))&&(t.defines.USE_CLEARCOAT="");break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":case"INCIDENT":case"POSITION":c.params.push(T("vViewPosition"));break;case"GRADIENT_MX":c.params.push(T(P("float",u.color2Pos))),c.params.push(T(P("int",u.gradientType))),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(T("vViewPosition")),c.params.push(T("MAPPING_"+u.mapping)),c.params.push(T("AXIS_"+u.axis)),c.params.push(T(P("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])])));break;case"GRADIENT_RAMP_MX":t.useFloatTex?(f=new Float32Array(2048),m=1):(f=new Uint8Array(2048),m=255);for(let e=0;e<512;e++){let t,n,o,r;t=m*u.gradientData[3*e],n=m*u.gradientData[3*e+1],o=m*u.gradientData[3*e+2],r=1,f[4*e]=clamp(t,0,m),f[4*e+1]=clamp(n,0,m),f[4*e+2]=clamp(o,0,m),f[4*e+3]=clamp(r,0,m)}y=A(f,512,1023,t.useFloatTex?1015:1009),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++,c.params.push(T(P("int",u.gradientType))),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(T("geometryNormal")),c.params.push(T("vViewPosition")),["SPHERICAL_ENVIRONMENT","CYLINDRICAL_ENVIRONMENT","SHRINK_WRAP_ENVIRONMENT","SCREEN"].indexOf(u.mapping)>-1?c.params.push(T("MAPPING_EXPLICIT_MAP_CHANNEL")):c.params.push(T("MAPPING_"+u.mapping)),c.params.push(T("AXIS_"+u.axis)),c.params.push(T(P("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])])));break;case"MAPPING_BL":c.params.push(T("NODE_MAPPING_"+u.vectorType));break;case"MAP_RANGE_BL":isDef(u.dataType)&&c.params.push(T("NODE_MAP_RANGE_TYPE_"+u.dataType)),c.params.push(T("NODE_MAP_RANGE_INTERP_"+u.interpolationType)),c.params.push(M(u.clamp));break;case"NEW_GEOMETRY_BL":c.params.push(T("faceDirection")),c.params.push(T("vViewPosition")),c.params.push(T("normal")),isConnOutput(e,l,N_OUT.NEW_GEOMETRY_BL.tangent)&&(t.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":h="tangent",p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(T("vNormal"));break;case"SEPARATE_COLOR_BL":c.params.push(T("NODE_SEP_COL_"+u.mode));break;case"TANGENT_BL":"RADIAL"===u.directionType?(c.params.push(T("TANGENT_AXIS_"+u.axis)),c.params.push(T("vViewPosition")),c.params.push(T("normal")),t.needsBoundingBox=!0):"UV_MAP"===u.directionType&&(h="tangent",p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"TEX_BRICK_BL":c.params.push(T(P("float",u.offset))),c.params.push(T(P("int",u.offsetFrequency))),c.params.push(T(P("float",u.squash))),c.params.push(T(P("int",u.squashFrequency)));break;case"TEX_COORD_BL":c.params.push(T(`nodeTexCoordObjectMatrices[${a}]`)),c.params.push(T("vViewPosition")),c.params.push(T("normal")),h="uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),isConnOutput(e,l,N_OUT.TEX_COORD_BL.generated)&&(t.needsBoundingBox=!0),t.nodeTexCoordObject.push(null),t.nodeTexCoordObjectMap[u.name]=a,a++;break;case"TEX_ENVIRONMENT_BL":case"TEX_IMAGE_BL":if(y=u.texture,t.nodeTextures[nodeTexUniName(d,n)]=y,c.params.push(S(d,n)),n++,c.params.push(T(v(y))),"TEX_ENVIRONMENT_BL"==d){const e=u.projection;c.params.push(T("TEX_PROJ_"+e))}else if("TEX_IMAGE_BL"==d){let t;switch(u.alphaMode){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(T(t)),c.params.push(T("normal"));const n=u.projection;c.params.push(T("TEX_PROJ_"+n)),c.params.push(C(u.projectionBlend)),c.params.push(M(u.clampToEdgeNoExtend))}break;case"TEX_GABOR_BL":c.params.push(T("TEX_GABOR_"+u.gaborType));break;case"TEX_GRADIENT_BL":c.params.push(T("TEX_GRAD_"+u.gradientType));break;case"TEX_MAGIC_BL":c.params.push(E(u.turbulenceDepth??2));break;case"TEX_NOISE_BL":isDef(u.noiseType)&&c.params.push(T("TEX_NOISE_"+u.noiseType)),c.params.push(T(P("float",u.falloffFactor))),c.params.push(T(P("float",u.dispersionFactor)));break;case"TEX_SKY_BL":if("PREETHAM"==u.skyType||"HOSEK_WILKIE"==u.skyType){let e,t,n,o,r,i;if(D=(new Vector3).fromArray(u.sunDirection).angleTo(new Vector3(0,0,1)),"PREETHAM"==u.skyType)e=getDistParams(u.turbidity,0).concat([0,0,0,0]),t=getDistParams(u.turbidity,1).concat([0,0,0,0]),n=getDistParams(u.turbidity,2).concat([0,0,0,0]),o=getZenithParams(u.turbidity,D,0),r=getZenithParams(u.turbidity,D,1),i=getZenithParams(u.turbidity,D,2);else{const a=Math.max(Math.PI/2-D,0);e=getDistParams$1(u.turbidity,u.groundAlbedo,a,0),t=getDistParams$1(u.turbidity,u.groundAlbedo,a,1),n=getDistParams$1(u.turbidity,u.groundAlbedo,a,2),o=getRadiance(u.turbidity,u.groundAlbedo,a,0),r=getRadiance(u.turbidity,u.groundAlbedo,a,1),i=getRadiance(u.turbidity,u.groundAlbedo,a,2)}c.params.push(T("TEX_SKY_"+u.skyType)),c.params.push(C([e[0],t[0],n[0]])),c.params.push(C([e[1],t[1],n[1]])),c.params.push(C([e[2],t[2],n[2]])),c.params.push(C([e[3],t[3],n[3]])),c.params.push(C([e[4],t[4],n[4]])),c.params.push(C([e[5],t[5],n[5]])),c.params.push(C([e[6],t[6],n[6]])),c.params.push(C([e[7],t[7],n[7]])),c.params.push(C([e[8],t[8],n[8]])),c.params.push(C([o,r,i])),c.params.push(C(u.sunDirection))}else{f=new Float32Array(65536),precomputeTexture(f,256,64,u.sunElevation,u.altitude,u.airDensity,u.aerosolDensity,u.ozoneDensity),y=new DataTexture(f,256,64,1023,1015,Texture.DEFAULT_MAPPING,1e3,1001,1006,1006),y.name="Node.nishita",y.needsUpdate=!0,b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++;let e=angleToRange_0_2Pi(u.sunRotation);e=2*Math.PI-e,c.params.push(C(e))}break;case"TEX_VORONOI_BL":c.params.push(T("DISTANCE_"+u.distance)),c.params.push(T("FEATURE_"+u.feature));break;case"TEX_WAVE_BL":c.params.push(T("TEX_WAVE_TYPE_"+u.waveType)),c.params.push(T("TEX_WAVE_PROFILE_"+u.waveProfile)),c.params.push(T(`TEX_WAVE_BANDS_DIR_${u.bandsDirection}`)),c.params.push(T(`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_SHADER_BL":let O=-1;for(let t=1;t<3;t++){const n=findConnectedNode(e,l,t);n&&"BSDF_TRANSPARENT_BL"==n.originData.type&&(O=t-1)}c.params.push(T(String(O)));break;case"NORMAL_BL":c.params.push(C(u.outputs[0]));break;case"RGB_BL":case"RGB_MX":L=(new Vector4).fromArray(u.outputs[0]),t.nodeRGB.push(L),t.nodeRGBMap[u.name]=r,c.params.push(T("nodeRGB["+r+"]")),r++;break;case"SUB_TRANSFORM_MX":case"SUB_TRANSFORM_MY":c.params.push(T(u.coordSpace));break;case"UVMAP_BL":h=g(u.uvLayer),p=I(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":L=u.outputs[0],t.nodeValue.push(L),t.nodeValueMap[u.name]=s,c.params.push(T("nodeValue["+s+"]")),s++;break;case"VALTORGB_BL":N=u.curve;const F=new("STEP"==N.interpolation?DiscreteInterpolant:LinearInterpolant)(new Float32Array(N.input),new Float32Array(N.output),4);t.useFloatTex?(f=new Float32Array(1024),m=1):(f=new Uint8Array(1024),m=255);for(let e=0;e<256;e++){const t=F.evaluate(e/255);f[4*e]=m*t[0],f[4*e+1]=m*t[1],f[4*e+2]=m*t[2],f[4*e+3]=m*t[3]}y=A(f,256,1023,t.useFloatTex?1015:1009),"STEP"==N.interpolation&&(y.minFilter=1003,y.magFilter=1003),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++;break;case"VECTOR_ROTATE_BL":c.params.push(T(P("float",u.invert?-1:1)));break;case"VECT_TRANSFORM_BL":const V=u.vectorType,U=u.convertFrom,G=u.convertTo;"NORMAL"==V&&(c.outputs[0].normalize=!0);let z="";U==G?z="VEC_TRANS_NONE":(z="VEC_TRANS_"+U[0]+"_"+G[0],"VECTOR"!=V&&"NORMAL"!=V||(z+="_DIR")),c.params.push(T(z)),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(y=u.texture,t.nodeTextures[nodeTexUniName(d,n)]=y,c.params.push(S(d,n)),n++,"BITMAP_MX"==d){h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(T("MAPPING_"+u.mapping)),c.params.push(T("AXIS_"+u.axis));const e=P("ivec2",[w(u.clampToEdgeNoExtend[0]),w(u.clampToEdgeNoExtend[1])]);c.params.push(T(e))}else c.params.push(T(u.reflectMode)),c.params.push(C(u.IOR));c.params.push(T(v(y))),"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(C(u.curveLower)),c.params.push(C(u.curveUpper));break;case"BUMP_MX":y=u.texture,t.nodeTextures[nodeTexUniName(d,n)]=y,c.params.push(S(d,n)),n++,c.params.push(T("-vViewPosition")),c.params.push(T("normal")),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"COLOR_CORRECTION_MX":const k=P("ivec4",[u.rewireR,u.rewireG,u.rewireB,u.rewireA]);c.params.push(T(k)),u.gainPivotGammaLift&&(c.params.push(C(u.gainPivotGammaLift)),c.params.push(M(u.enableR)),c.params.push(M(u.enableG)),c.params.push(M(u.enableB)),c.params.push(E(u.exposureMode)),c.params.push(C(u.printerLights)));break;case"COMPOSITE_LAYER_MX":c.params.push(T(P("int",u.blendMode)));const W=isConnInput(e,l,1)?u.opacity:0;c.params.push(C(W));break;case"COLOR_MAP_MX":c.params.push(M(u.reverseGamma));break;case"FALLOFF_MX":if(c.params.push(T("-vViewPosition")),4!=u.falloffType)c.params.push(C(u.IOR)),c.params.push(E(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(C(t)),c.params.push(C(n))}break;case"MASK_MX":c.params.push(M(u.maskInverted));break;case"MATERIAL_MX":c.params.push(C(u.inputFactors[N_IN[d].reflection])),c.params.push(C(u.inputFactors[N_IN[d].refraction])),u.inputFactors[N_IN[d].reflection]=1,u.inputFactors[N_IN[d].refraction]=1,c.params.push(M(u.selfIllumColorOn));break;case"MATTE_SHADOW_MX":c.params.push(T("normal")),c.params.push(M(u.receiveShadows)),c.params.push(C(u.shadowBrightness)),c.params.push(C(u.color));break;case"NOISE_MX":2==u.coordType?(h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)):c.params.push(T("vViewPosition")),c.params.push(E(u.noiseType)),c.params.push(E(u.coordType));break;case"NORMAL_BUMP_MX":h="tangent",p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(T("normal"));const Q="ivec2("+w(u.flip[0])+","+w(u.flip[1])+")";c.params.push(T(Q));break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":c.params.push(T("geometryNormal")),c.params.push(M(u.thinWalled)),(u.inputs[N_IN[d].coatWeight]>0||isConnInput(e,l,N_IN[d].coatWeight))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[N_IN[d].fuzzWeight]>0||isConnInput(e,l,N_IN[d].fuzzWeight))&&(t.defines.USE_SHEEN="");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,f=new Float32Array(1024),m=1):(x=clampArray(u.colorMap.slice(),0,1),f=new Uint8Array(1024),m=255),B=x.length/256;for(let e=0;e<256;e++)f[4*e]=m*x[B*e],3==B?(f[4*e+1]=m*x[B*e+1],f[4*e+2]=m*x[B*e+2]):(f[4*e+1]=f[4*e],f[4*e+2]=f[4*e]),f[4*e+3]=m;y=A(f,256,1023,t.useFloatTex?1015:1009),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++}break;case"PHYSICAL_MX":c.params.push(T("geometryNormal")),c.params.push(C(u.emitLuminance));const H=void 0===u.brdfMode||u.brdfMode,X=void 0===u.brdfLow?0:u.brdfLow,Y=void 0===u.brdfHigh?0:u.brdfHigh,j=void 0===u.brdfCurve?0:u.brdfCurve;c.params.push(M(!H)),c.params.push(T(P("float",X))),c.params.push(T(P("float",Y))),c.params.push(T(P("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[N_IN[d].clearcoat]>0||isConnInput(e,l,N_IN[d].clearcoat))&&(t.defines.USE_CLEARCOAT="");break;case"PHY_SUN_SKY_ENV_MX":const $=15*u.haze+2,K=new Spherical;D=Math.PI/2-u.sunPolarAngle;const q=Math.PI-u.sunAzimuthAngle;K.phi=D,K.theta=q;const Z=(new Vector3).setFromSpherical(K).toArray();let J,ee,te,ne,oe,re;J=getDistParams($,0),ee=getDistParams($,1),te=getDistParams($,2),ne=getZenithParams($,D,0),oe=getZenithParams($,D,1),re=getZenithParams($,D,2),ne/=.06,ne*=1e3,c.params.push(C([J[0],ee[0],te[0]])),c.params.push(C([J[1],ee[1],te[1]])),c.params.push(C([J[2],ee[2],te[2]])),c.params.push(C([J[3],ee[3],te[3]])),c.params.push(C([J[4],ee[4],te[4]])),c.params.push(C([ne,oe,re]));const ie=getSunIlluminance(Z,$),ae=[0,0,0];c.params.push(C(Z)),c.params.push(C(ie)),c.params.push(C(ae)),c.params.push(C(u.globalIntensity/MAX_LIGHT_INT_MULT)),c.params.push(C(u.groundColor));break;case"REFLECT_REFRACT_COLOR_MX":L=u.outputs[0],c.params.push(C(L));break;case"VERTEX_COLOR_MX":h="color",p=I(h,3),c.attributes.push({name:h,type:"attribute vec3"}),c.params.push(p);break;case"BUMP_2D_MY":c.params.push(T("vNormal")),u.bumpInterp>0&&(h="tangent",p=I(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(T(u.operation));break;case"COLOR_CORRECT_MY":c.params.push(M(u.colClamp)),c.params.push(C(u.colClampMin)),c.params.push(C(u.colClampMax)),c.params.push(M(u.alphaClamp)),c.params.push(C(u.alphaClampMin)),c.params.push(C(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(T(u.inputRotateOrder));break;case"FILE_MY":case"ENV_SPHERE_MY":if(y=u.texture,t.nodeTextures[nodeTexUniName(d,n)]=y,c.params.push(S(d,n)),n++,c.params.push(T(v(y))),"ENV_SPHERE_MY"==d)c.params.push(T("normal"));else{const t=!1===u.fileHasAlpha;c.params.push(M(t&&isConnOutput(e,l,N_OUT.FILE_MY.alpha)))}break;case"RAMP_MY":t.useFloatTex?(f=new Float32Array(2048),m=1):(f=new Uint8Array(2048),m=255);for(let e=0;e<512;e++){const t=m*u.rampData[3*e],n=m*u.rampData[3*e+1],o=m*u.rampData[3*e+2];f[4*e]=clamp(t,0,m),f[4*e+1]=clamp(n,0,m),f[4*e+2]=clamp(o,0,m),f[4*e+3]=m}y=A(f,512,1023,t.useFloatTex?1015:1009),b=nodeTexUniName(d,o),t.nodeTextures[b]=y,c.params.push(S(d,o)),o++,c.params.push(T(P("int",u.rampType))),c.params.push(T(P("int",u.wrapS))),c.params.push(T(P("int",u.wrapT))),t.defines.RAMP_TEX_SIZE=512,t.definesFragOnly.add("RAMP_TEX_SIZE");break;case"SAMPLER_INFO_MY":c.params.push(T("faceDirection")),h="tangent",p=I(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),h="uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"UNIT_CONVERSION_MY":c.params.push(C(u.conversionFactor));break;case"VECTOR_PRODUCT_MY":c.params.push(T(u.operation)),c.params.push(M(u.normalizeOutput));break;case"OSL_NODE":isDef(u.texture)&&(y=u.texture,t.nodeTextures[nodeTexUniName(d,n)]=y,c.params.push(S(d,n)),n++);const se=u.globalVariables||[];se.indexOf("P")>-1&&c.params.push(T("oslGetP(vViewPosition)")),se.indexOf("I")>-1&&c.params.push(T("oslGetI(vViewPosition)")),se.indexOf("N")>-1&&c.params.push(T("oslGetN(normal)")),(se.indexOf("u")>-1||se.indexOf("v")>-1)&&(h="uv",c.attributes.push({name:h,type:"attribute vec2"}),se.indexOf("u")>-1&&c.params.push(I(h+"_u",1,h+".x")),se.indexOf("v")>-1&&c.params.push(I(h+"_v",1,"1.0 - "+h+".y")));break;case"RGB_ALPHA":L=(new Vector4).fromArray(u.outputs[0].concat([u.outputs[1]])),t.nodeRGB.push(L),t.nodeRGBMap[u.name]=r,c.params.push(T("nodeRGB["+r+"]")),r++;break;case"U_FLOAT":h="uv",p=I(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)}}const l={},c={};for(let t=0;t");for(let t=0;t0||isConnInput(e,t,N_IN[i].clearcoat))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,N_OUT.NORMAL.normal,t,N_IN[i].clearcoatNormal)}if("EEVEE_SPECULAR_BL"!=i||isConnInput(e,t,N_IN.EEVEE_SPECULAR_BL.ambientOcclusion)||(o.inputs[N_IN.EEVEE_SPECULAR_BL.ambientOcclusion]=1),"OSL_NODE"==i){const n=o.initializers;for(let r=0;r0||isConnInput(e,t,N_IN[i].clearcoat))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),connectNodes(e,e.len()-1,0,t,N_IN[i].clearcoatNormal)}if("MIX_BL"==i&&o.outputs.length>1){const n=[-1,-1,-1,-1,-1,-1,-1,-1],r=[-1,-1,-1];switch(o.dataType){case"RGBA":o.inputs=[o.inputs[0],o.inputs[6],o.inputs[7]],n[0]=0,n[6]=1,n[7]=2,o.outputs=[o.outputs[2]],r[2]=0;break;case"VECTOR":o.inputs=[o.inputs[0],o.inputs[1],o.inputs[4],o.inputs[5]],n[0]=0,n[1]=1,n[4]=2,n[5]=3,o.outputs=[o.outputs[1]],r[1]=0;break;case"FLOAT":o.inputs=[o.inputs[0],o.inputs[2],o.inputs[3]],n[0]=0,n[2]=1,n[3]=2,o.outputs=[o.outputs[0]],r[0]=0}const i=e.findInEdges(t);for(let e=0;e=0;e--){const o=t.connections[e];n[o.to]>-1?o.to=n[o.to]:t.connections.splice(e,1)}}const a=e.findOutEdges(t);for(let e=0;e=0;e--){const n=t.connections[e];r[n.from]>-1?n.from=r[n.from]:t.connections.splice(e,1)}}}if("BUMP_2D_MY"==r&&o.bumpInterp>0){o.inputs[N_IN.BUMP_2D_MY.bumpValue]=[0,0,0];const n=e.findInEdges(t);for(let t=0;tfindAllConnectedNodes(e,t,N_IN.TRIPLANAR_AR[n])),i="Y_UP_RIGHT"===o.coordSystem?"SUB_TRANSFORM_MY":"SUB_TRANSFORM_MX",a={originData:{name:"subTransform",type:i,inputs:n.map(e=>o.inputs[N_IN.TRIPLANAR_AR[e]]),outputs:[[0,0,0],[0,0,0]],coordSpace:o.coordSpace}};e.addNode(a);const s=e.len()-1;return r.forEach((t,o)=>{t.forEach(t=>{const r=t.nodeIdx,a=t.outputIdx,l=t.channelMatrix;connectNodes(e,r,a,s,N_IN[i][n[o]],l)})}),t=>{const n=e.node(t);"TRIPLANAR_AR"==n.originData.type?connectNodes(e,s,N_OUT[i].normal,t,N_IN.TRIPLANAR_AR.normal):"TRIPLANAR_UV_AR"==n.originData.type&&(connectNodes(e,s,N_OUT[i].vector,t,N_IN.TRIPLANAR_UV_AR.vector),connectNodes(e,s,N_OUT[i].normal,t,N_IN.TRIPLANAR_UV_AR.normal))}}();o.inputs.push([0,0,0]),n(t);const r=t=>{const r={originData:{name:"triplanarUV",type:"TRIPLANAR_UV_AR",inputs:[[0,0,0],[0,0,0]],outputs:4==t?[[0,0],[0,0],[0,0]]:[[0,0]],flipOnOppositeDirection:o.flipOnOppositeDirection}};4==t?r.originData.blendFactor=o.blendFactor:r.originData.projectionAxis=t,e.addNode(r);const i=e.len()-1;return n(i),i};if(o.inputPerAxis){const n=[N_IN.TRIPLANAR_AR.inputColor,N_IN.TRIPLANAR_AR.inputColorY,N_IN.TRIPLANAR_AR.inputColorZ];for(let o=0;o<3;o++){const i=n[o],a=findConnectedNode(e,t,i,"IMAGE_AR");if(!a){findConnectedNode(e,t,i)&&console.error("MeshNodeMaterial: TRIPLANAR_AR texture inputs accept only IMAGE_AR or color.");continue}const s=e.nodeIndex(a);disconnectInputNode(e,s,N_IN.IMAGE_AR.uvcoords);const l=r(o);connectNodes(e,l,N_OUT.TRIPLANAR_UV_AR.uv,s,N_IN.IMAGE_AR.uvcoords)}}else{const n=findConnectedNode(e,t,N_IN.TRIPLANAR_AR.inputColor,"IMAGE_AR");if(!n){findConnectedNode(e,t,N_IN.TRIPLANAR_AR.inputColor)&&console.error("MeshNodeMaterial: TRIPLANAR_AR texture inputs accept only IMAGE_AR or color.");continue}const i=e.nodeIndex(n);if(disconnectInputNode(e,i,N_IN.IMAGE_AR.uvcoords),disconnectInputNode(e,t,N_IN.TRIPLANAR_AR.inputColorY),disconnectInputNode(e,t,N_IN.TRIPLANAR_AR.inputColorZ),o.blendFactor<.001){const t=r(3);connectNodes(e,t,N_OUT.TRIPLANAR_UV_AR.uv,i,N_IN.IMAGE_AR.uvcoords)}else{const t=r(4);connectNodes(e,t,N_OUT.TRIPLANAR_UV_AR.uv,i,N_IN.IMAGE_AR.uvcoords),n.originData.inputs.push([0,0],[0,0]),connectNodes(e,t,N_OUT.TRIPLANAR_UV_AR.duvdx,i,N_IN.IMAGE_AR.duvdx),connectNodes(e,t,N_OUT.TRIPLANAR_UV_AR.duvdy,i,N_IN.IMAGE_AR.duvdy)}}}if("UV_PROJECTION_AR"==r){const n=disconnectOutputNode(e,t,N_OUT.UV_PROJECTION_AR.uv),o=disconnectInputNode(e,t,N_IN.UV_PROJECTION_AR.projectionColor,"IMAGE_AR");if(!o){console.error("MeshNodeMaterial: UV_PROJECTION_AR.projectionColor input accepts only IMAGE_AR.");continue}const r=o.node;if(n){const i=e.nodeIndex(r);connectNodes(e,i,o.outputIdx,e.nodeIndex(n.node),n.inputIdx),disconnectInputNode(e,i,N_IN.IMAGE_AR.uvcoords),connectNodes(e,t,N_OUT.UV_PROJECTION_AR.uv,i,N_IN.IMAGE_AR.uvcoords)}}}let n=0;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 o=findConnectedNode(e,e.nodeIndex(n),0);if(!o||"MIX_BL"!=o.originData.type||"RGBA"!=o.originData.dataType||"MIX"!=o.originData.blendType)return null;const r=findConnectedNode(e,e.nodeIndex(o),0);return r&&"LIGHT_PATH_BL"==r.originData.type?isConnInput(e,e.nodeIndex(o),2)?null:isConnOutput(e,e.nodeIndex(r),0)?(new Color).fromArray(o.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),o=findConnectedNode(e,e.nodeIndex(n),1);if(t&&o&&("BSDF_TRANSPARENT_BL"==t.originData.type||"BSDF_TRANSPARENT_BL"==o.originData.type))return!0}}return!1}getMainShaderNode(){const e=this.nodeGraph;if(!e)return null;let t=firstNodeType(e,"OUTPUT_MATERIAL_BL");if(t>=0){const n=findConnectedNode(e,t,N_IN.OUTPUT_MATERIAL_BL.surface);if(n)if(nodeOfType(n,"MIX_SHADER_BL")){let t=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.fac,"SEPARATE_COLOR_BL"),o=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color1,["DIFFUSE_BSDF_BL","BSDF_DIFFUSE_BL"]),r=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color2,STD_SHADER_NODES_BL);if(t&&o&&r)return r;if(t=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.fac,"LIGHT_PATH_BL"),o=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color1,"BSDF_TRANSPARENT_BL"),r=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color2,"EMISSION_BL"),t&&o&&r)return r;if(t=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.fac),o=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color1,"BSDF_TRANSPARENT_BL"),r=findConnectedNode(e,n,N_IN.MIX_SHADER_BL.color2,STD_SHADER_NODES_BL),!t&&o&&r)return r}else if(nodeOfType(n,STD_SHADER_NODES_BL))return n}if(t=firstNodeType(e,"OUTPUT_MX"),t>=0){const n=findConnectedNode(e,t,N_IN.OUTPUT_MX.color,STD_SHADER_NODES_MX);if(n)return n}if(t=firstNodeType(e,"SHADING_ENGINE_MY"),t>=0){const n=findConnectedNode(e,t,N_IN.SHADING_ENGINE_MY.surface,STD_SHADER_NODES_MY);if(n)return n}return null}getInputColor(e,t){const n=findConnectedNode(this.nodeGraph,e,t);if(!n)return(new Color).fromArray(e.originData.inputs[t]);if(nodeOfType(n,["RGB_BL","RGB_MX","RGB_ALPHA"])){const e=this.nodeRGB[this.nodeRGBMap[n.originData.name]];return(new Color).fromArray(e.toArray())}}getInputValue(e,t){const n=findConnectedNode(this.nodeGraph,e,t);if(n){if(nodeOfType(n,["VALUE_BL","VALUE_MX","VALUE"]))return this.nodeValue[this.nodeValueMap[n.originData.name]]}else{const n=e.originData.inputs[t];if("number"==typeof n)return n;console.error(`v3d.MeshNodeMaterial: Invalid ${getNodeType(e)} input value at index ${t}`)}}getInputTexture(e,t){const n=findConnectedNode(this.nodeGraph,e,t);if(n&&nodeOfType(n,["TEX_IMAGE_BL","BITMAP_MX","FILE_MY","IMAGE_AR"]))return n.originData.texture}getStandardProp(e){if(!(e in STD_PROP_DEFAULTS))return void console.error(`v3d.MeshNodeMaterial: Invalid standard property: "${e}"`);const t=this.getMainShaderNode();if(!t)return STD_PROP_DEFAULTS[e];const n=getNodeType(t),o=getNodeTypeCompat(t),r=this.nodeGraph;let i,a,s,l,c,u,d,h,p;switch(e){case"color":if(i=STD_SHADER_NODES_BL.includes(n)&&findConnectedNode(r,t,N_IN[o].baseColor??N_IN[o].color,"MIX_BL"),i&&"MULTIPLY"==i.originData.blendType){const e=findConnectedNode(r,i,N_IN.MIX_BL.fac),t=findConnectedNode(r,i,N_IN.MIX_BL.col1),n=findConnectedNode(r,i,N_IN.MIX_BL.col2);if(!e&&(t&&!n||!t&&n)){const e=this.getInputColor(i,t?N_IN.MIX_BL.col2:N_IN.MIX_BL.col1);if(e)return e}}else{let e,r;switch(n){case"BSDF_PRINCIPLED_BL":case"EEVEE_SPECULAR_BL":e=this.getInputColor(t,N_IN[o].baseColor);break;case"PHYSICAL_MX":case"STANDARD_SURFACE_AR":case"LAMBERT_AR":e=this.getInputColor(t,N_IN[o].baseColor),e||(e=STD_PROP_DEFAULTS.color.clone()),r=this.getInputValue(t,N_IN[o].base),isDef(r)&&e.multiplyScalar(r);break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":e=this.getInputColor(t,N_IN[o].baseColor),e||(e=STD_PROP_DEFAULTS.color.clone()),r=this.getInputValue(t,N_IN[o].baseWeight),isDef(r)&&e.multiplyScalar(r);break;default:e=this.getInputColor(t,N_IN[o].color)}if(e)return e}break;case"map":if(i=STD_SHADER_NODES_BL.includes(n)&&findConnectedNode(r,t,N_IN[o].baseColor??N_IN[o].color,"MIX_BL"),i&&"MULTIPLY"==i.originData.blendType){const e=findConnectedNode(r,i,N_IN.MIX_BL.fac),t=findConnectedNode(r,i,N_IN.MIX_BL.col1),n=findConnectedNode(r,i,N_IN.MIX_BL.col2);if(!e&&(t&&!n||!t&&n)){const e=this.getInputTexture(i,t?N_IN.MIX_BL.col1:N_IN.MIX_BL.col2);if(e)return e}}else if(["BSDF_PRINCIPLED_BL","EEVEE_SPECULAR_BL","PHYSICAL_MX","OPENPBR_SURFACE_MX","OPENPBR_SURFACE_MY","STANDARD_SURFACE_AR","LAMBERT_AR"].includes(n)){const e=this.getInputTexture(t,N_IN[o].baseColor);if(e)return e}else{const e=this.getInputTexture(t,N_IN[o].color);if(e)return e}break;case"opacity":if(p=firstNodeType(r,"OUTPUT_MATERIAL_BL"),p>=0){const e=findConnectedNode(r,p,N_IN.OUTPUT_MATERIAL_BL.surface,"MIX_SHADER_BL");if(e){const t=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.fac),n=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.color1,"BSDF_TRANSPARENT_BL"),o=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.color2,STD_SHADER_NODES_BL);if(!t&&n&&o){const t=this.getInputValue(e,N_IN.MIX_SHADER_BL.fac);if(isDef(t))return t}}}switch(n){case"BSDF_PRINCIPLED_BL":const e=this.getInputValue(t,N_IN[o].alpha);if(isDef(e))return e;break;case"EEVEE_SPECULAR_BL":case"PHYSICAL_MX":if(s=this.getInputValue(t,N_IN[o].transparency),isDef(s))return 1-s;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":if(l=this.getInputValue(t,N_IN[o].geometryOpacity),isDef(l))return l;break;case"LAMBERT_MY":case"SURFACE_SHADER_MY":if(s=this.getInputColor(t,N_IN[o].transparency),s)return 1-(s.r+s.g+s.b)/3;break;case"STANDARD_SURFACE_AR":case"LAMBERT_AR":if(l=this.getInputColor(t,N_IN[o].opacity),l)return(l.r+l.g+l.b)/3}break;case"metalness":if(this.getStandardProp("metalnessMap"))return 1;switch(n){case"BSDF_PRINCIPLED_BL":if(c=this.getInputValue(t,N_IN[o].metallic),isDef(c))return c;break;case"PHYSICAL_MX":case"STANDARD_SURFACE_AR":if(c=this.getInputValue(t,N_IN[o].metalness),isDef(c))return c;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":if(c=this.getInputValue(t,N_IN[o].baseMetalness),isDef(c))return c;break;case"BSDF_DIFFUSE_BL":case"DIFFUSE_BSDF_BL":case"LAMBERT_MY":case"LAMBERT_AR":case"EMISSION_BL":case"SURFACE_SHADER_MY":case"MAP_TO_MTL_AR":return 0;case"BSDF_GLOSSY_BL":case"BSDF_METALLIC_BL":return 1;case"EEVEE_SPECULAR_BL":return.5}break;case"metalnessMap":switch(n){case"BSDF_PRINCIPLED_BL":if(a=findConnectedNode(r,t,N_IN[o].metallic,"SEPARATE_COLOR_BL"),a&&(u=this.getInputTexture(a,N_IN.SEPARATE_COLOR_BL.color),u))return u;break;case"PHYSICAL_MX":case"STANDARD_SURFACE_AR":if(u=this.getInputTexture(t,N_IN[o].metalness),u)return u;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":if(u=this.getInputTexture(t,N_IN[o].baseMetalness),u)return u;break;case"BSDF_DIFFUSE_BL":case"BSDF_GLOSSY_BL":case"BSDF_METALLIC_BL":case"DIFFUSE_BSDF_BL":case"EEVEE_SPECULAR_BL":case"EMISSION_BL":case"LAMBERT_MY":case"LAMBERT_AR":case"SURFACE_SHADER_MY":case"MAP_TO_MTL_AR":return null}break;case"roughness":if(this.getStandardProp("roughnessMap"))return 1;switch(n){case"BSDF_PRINCIPLED_BL":case"BSDF_GLOSSY_BL":case"BSDF_METALLIC_BL":case"EEVEE_SPECULAR_BL":case"PHYSICAL_MX":if(d=this.getInputValue(t,N_IN[o].roughness),isDef(d))return d;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":case"STANDARD_SURFACE_AR":if(d=this.getInputValue(t,N_IN[o].specularRoughness),isDef(d))return d;break;case"BSDF_DIFFUSE_BL":case"DIFFUSE_BSDF_BL":case"LAMBERT_MY":case"LAMBERT_AR":return 1;case"EMISSION_BL":case"SURFACE_SHADER_MY":case"MAP_TO_MTL_AR":return.9}break;case"roughnessMap":switch(n){case"BSDF_PRINCIPLED_BL":case"BSDF_GLOSSY_BL":case"BSDF_METALLIC_BL":case"EEVEE_SPECULAR_BL":if(a=findConnectedNode(r,t,N_IN[o].roughness,"SEPARATE_COLOR_BL"),a&&(h=this.getInputTexture(a,N_IN.SEPARATE_COLOR_BL.color),h))return h;break;case"PHYSICAL_MX":if(h=this.getInputTexture(t,N_IN[o].roughness),h)return h;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":case"STANDARD_SURFACE_AR":if(h=this.getInputTexture(t,N_IN[o].specularRoughness),h)return h;break;case"BSDF_DIFFUSE_BL":case"DIFFUSE_BSDF_BL":case"EMISSION_BL":case"LAMBERT_MY":case"SURFACE_SHADER_MY":case"MAP_TO_MTL_AR":return null}break;case"aoMap":if(p=firstNodeType(r,"OUTPUT_MATERIAL_BL"),p>=0){const e=findConnectedNode(r,p,N_IN.OUTPUT_MATERIAL_BL.surface,"MIX_SHADER_BL");if(e){const t=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.fac,"SEPARATE_COLOR_BL"),n=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.color1,["DIFFUSE_BSDF_BL","BSDF_DIFFUSE_BL"]),o=findConnectedNode(r,e,N_IN.MIX_SHADER_BL.color2,STD_SHADER_NODES_BL);if(t&&n&&o){const e=this.getInputTexture(t,N_IN.SEPARATE_COLOR_BL.color);if(e)return e}}}else{let e;switch(n){case"PHYSICAL_MX":case"STANDARD_SURFACE_AR":if(e=this.getInputTexture(t,N_IN[o].base),e)return e;break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":if(e=this.getInputTexture(t,N_IN[o].baseWeight),e)return e}}break;case"aoMapIntensity":break;case"normalMap":if(STD_SHADER_NODES_BL.includes(n)){const e=N_IN[o].normal;if(isDef(e)){const n=findConnectedNode(r,t,e,"NORMAL_MAP_BL");if(n){const e=this.getInputTexture(n,N_IN.NORMAL_MAP_BL.normalColor);if(e)return e}}}else if(STD_SHADER_NODES_MY.includes(n)){const e=N_IN[o].normal;if(isDef(e)){const n=findConnectedNode(r,t,e,"BUMP_2D_MY");if(n){const e=this.getInputTexture(n,N_IN.BUMP_2D_MY.bumpValue);if(e)return e}}}else if("PHYSICAL_MX"==n||"OPENPBR_SURFACE_MX"==n){const e=findConnectedNode(r,t,N_IN[o].normal,"NORMAL_BUMP_MX");if(e){const t=this.getInputTexture(e,N_IN.NORMAL_BUMP_MX.normalColor);if(t)return t}}break;case"normalScale":if(STD_SHADER_NODES_BL.includes(n)){const e=N_IN[o].normal;if(isDef(e)){const n=findConnectedNode(r,t,e,"NORMAL_MAP_BL");if(n){const e=this.getInputValue(n,N_IN.NORMAL_MAP_BL.strength);if(isDef(e))return new Vector2(e,e)}}}else if(STD_SHADER_NODES_MY.includes(n)){const e=N_IN[o].normal;if(isDef(e)){const n=findConnectedNode(r,t,e,"BUMP_2D_MY");if(n){const e=this.getInputValue(n,N_IN.BUMP_2D_MY.bumpDepth);if(isDef(e))return new Vector2(e,e)}}}else if("PHYSICAL_MX"==n||"OPENPBR_SURFACE_MX"==n){const e=findConnectedNode(r,t,N_IN[o].normal,"NORMAL_BUMP_MX");if(e){const t=this.getInputValue(e,N_IN.NORMAL_BUMP_MX.normalMult);if(isDef(t))return new Vector2(t,t)}}break;case"emissive":if(this.getStandardProp("emissiveMap"))return new Color(1,1,1);let e;switch(n){case"BSDF_PRINCIPLED_BL":e=this.getInputColor(t,N_IN[o].emission);break;case"EEVEE_SPECULAR_BL":e=this.getInputColor(t,N_IN[o].emissiveColor);break;case"PHYSICAL_MX":e=this.getInputColor(t,N_IN[o].emitColor);break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":case"STANDARD_SURFACE_AR":e=this.getInputColor(t,N_IN[o].emissionColor)}if(e)return e;break;case"emissiveMap":let f;switch(n){case"BSDF_PRINCIPLED_BL":f=this.getInputTexture(t,N_IN[o].emission);break;case"EEVEE_SPECULAR_BL":f=this.getInputTexture(t,N_IN[o].emissiveColor);break;case"PHYSICAL_MX":f=this.getInputTexture(t,N_IN[o].emitColor);break;case"OPENPBR_SURFACE_MX":case"OPENPBR_SURFACE_MY":case"STANDARD_SURFACE_AR":f=this.getInputTexture(t,N_IN[o].emissionColor)}if(f)return f;break;case"emissiveIntensity":let m;switch(n){case"BSDF_PRINCIPLED_BL":m=this.getInputValue(t,N_IN[o].emissionStrength);break;case"EEVEE_SPECULAR_BL":m=1;break;case"PHYSICAL_MX":case"STANDARD_SURFACE_AR":m=this.getInputValue(t,N_IN[o].emission);break;case"OPENPBR_SURFACE_MX":m=this.getInputValue(t,N_IN[o].emissionWeight);break;case"OPENPBR_SURFACE_MY":m=this.getInputValue(t,N_IN[o].emissionLuminance/1e3)}if(isDef(m))return m}return STD_PROP_DEFAULTS[e]}isUnlit(){const e=this.getMainShaderNode();return!(!e||!nodeOfType(e,["EMISSION_BL","SURFACE_SHADER_MY","MAP_TO_MTL_AR"]))}copy(e){super.copy(e),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,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=Object.assign({},e.nodeTextures),this.nodeRGB=[];for(let t=0;t{t&&t(r),this.manager.itemEnd(e)},0),r;if(void 0!==loading[e])return void loading[e].push({onLoad:t,onProgress:n,onError:o});loading[e]=[],loading[e].push({onLoad:t,onProgress:n,onError:o});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],o=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),i=r?parseInt(r):0,a=0!==i;let s=0;const l=new ReadableStream({start(e){!function t(){o.read().then(({done:o,value:r})=>{if(o)e.close();else{s+=r.byteLength;const o=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,o=new TextDecoder(n);return e.arrayBuffer().then(e=>o.decode(e))}}}).then(t=>{Cache.add(e,t);const n=loading[e];delete loading[e];for(let e=0,o=n.length;e{const n=loading[e];if(void 0===n)throw this.manager.itemError(e),t;delete loading[e];for(let e=0,o=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 CompressedTextureLoader extends Loader{constructor(e){super(e)}load(e,t,n,o){const r=this,i=[],a=new CompressedTexture,s=new FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials);let l=0;function c(c){s.load(e[c],function(e){const n=r.parse(e,!0);i[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=1006),a.image=i,a.format=n.format,a.needsUpdate=!0,t&&t(a))},n,o)}if(Array.isArray(e))for(let t=0,n=e.length;tt.length;)t.push(new CSMFrustum);t.length=e.length;for(let o=0;othis.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,o=i.vertices.far[0].z/(t-n);u+=this.fade*Math.pow(o,2)*(t-n)}r.left=-u/2,r.right=u/2,r.top=u/2,r.bottom=-u/2,r.near=0,r.far=u+this.lightMargin,r.updateProjectionMatrix(),o.bias=this.bias,o.normalBias=this.normalBias,o.esmBlurRadius=o.radius/((r.right-r.left)/2)}}getBreaks(e){const t=e.near,n=Math.min(e.far,this.maxDistance),o=this.numCascades,r=this.exponent,i=this._breaks;i.length=0,this.customSplitsCallback?this.customSplitsCallback(o,t,n,i,r):function(e,t,n,o,r){_uniformArray.length=0,_logArray.length=0,function(e,t,n,o){for(let r=1;r0){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;e{if(0===e.times.length)return;const t=[Math.max(n/r,e.times[0]),Math.min(o/r,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,o=30){o<=0&&(o=30);const r=n.tracks.length,i=t/o;for(let t=0;t=o.times[d]){const e=d*l+s,t=e+l-s;h=arraySlice(o.values,e,t)}else{const e=o.createInterpolant(),t=s,n=l-s;e.evaluate(i),h=arraySlice(e.resultBuffer,t,n)}if("quaternion"===r){(new Quaternion).fromArray(h).normalize().conjugate().toArray(h)}const p=a.times.length;for(let e=0;et;)--i;if(++i,0!==r||i!==o){r>=i&&(i=Math.max(i,1),r=i-1);const e=this.getValueSize();this.times=arraySlice(n,r,i),this.values=arraySlice(this.values,r*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,o=this.values,r=n.length;0===r&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);let i=null;for(let t=0;t!==r;t++){const o=n[t];if("number"==typeof o&&isNaN(o)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,t,o),e=!1;break}if(null!==i&&i>o){console.error("v3d.KeyframeTrack: Out of order keys.",this,t,o,i),e=!1;break}i=o}if(void 0!==o&&isTypedArray(o))for(let t=0,n=o.length;t!==n;++t){const n=o[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(),o=2302===this.getInterpolation(),r=e.length-1;let i=1;for(let a=1;a0){e[i]=e[r];for(let e=r*n,o=i*n,a=0;a!==n;++a)t[o+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 VectorKeyframeTrack extends KeyframeTrack{}VectorKeyframeTrack.prototype.ValueTypeName="vector";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 QuaternionLinearInterpolant extends Interpolant{constructor(e,t,n,o){super(e,t,n,o)}interpolate_(e,t,n,o){const r=this.resultBuffer,i=this.sampleValues,a=this.valueSize,s=(n-t)/(o-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Quaternion.slerpFlat(r,0,i,l-a,i,l,s);return r}}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 NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";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 PropertyMixer{constructor(e,t,n){let o,r,i;switch(this.binding=e,this.valueSize=n,t){case"quaternion":o=this._slerp,r=this._slerpAdditive,i=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":o=this._select,r=this._select,i=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:o=this._lerp,r=this._lerpAdditive,i=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=o,this._mixBufferRegionAdditive=r,this._setIdentity=i,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,o=this.valueSize,r=e*o+o;let i=this.cumulativeWeight;if(0===i){for(let e=0;e!==o;++e)n[r+e]=n[e];i=t}else{i+=t;const e=t/i;this._mixBufferRegion(n,r,0,e,o)}this.cumulativeWeight=i}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,o=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,o,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,o=e*t+t,r=this.cumulativeWeight,i=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(n,o,e,1-r,t)}i>0&&this._mixBufferRegionAdditive(n,o,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,o);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,o=n*this._origIndex;e.getValue(t,o);for(let e=n,r=o;e!==r;++e)t[e]=t[o+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 o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,o){Quaternion.slerpFlat(e,t,e,t,e,n,o)}_slerpAdditive(e,t,n,o,r){const i=this._workIndex*r;Quaternion.multiplyQuaternionsFlat(e,i,e,t,e,n),Quaternion.slerpFlat(e,t,e,t,e,i,o)}_lerp(e,t,n,o,r){const i=1-o;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*i+e[n+a]*o}}_lerpAdditive(e,t,n,o,r){for(let i=0;i!==r;++i){const r=t+i;e[r]=e[r]+e[n+i]*o}}}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 o=n||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,o)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,o=this._bindings[n];void 0!==o&&o.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let o=this._targetGroup.nCachedObjects_,r=n.length;o!==r;++o)n[o].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]},o=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){const e=n.nodeName.substring(o+1);-1!==_supportedObjectNames.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,o),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 o=0;o=r){const i=r++,c=e[i];t[c.uuid]=l,e[l]=c,t[s]=i,e[i]=a;for(let e=0,t=o;e!==t;++e){const t=n[e],o=t[i],r=t[l];t[l]=o,t[i]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,o=n.length;let r=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=o;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let o=n[e];const r=this._bindings;if(void 0!==o)return r[o];const i=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);o=r.length,n[e]=o,i.push(e),a.push(t),r.push(u);for(let n=c,o=s.length;n!==o;++n){const o=s[n];u[n]=new PropertyBinding(o,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const o=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length-1,s=i[a];t[e[a]]=n,i[n]=s,i.pop(),r[n]=r[a],r.pop(),o[n]=o[a],o.pop()}}}class AnimationAction{constructor(e,t,n=null,o=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=o;const r=t.tracks,i=r.length,a=new Array(i),s={endingStart:2400,endingEnd:2400};for(let e=0;e!==i;++e){const t=r[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=!0,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0,this.autoParams={loop:2201,repetitions:1/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,n=!1){return this.loop=e,this.repetitions=t,n&&(this.autoParams.loop=e,this.autoParams.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,o=e._clip.duration,r=o/n,i=n/o;e.warp(1,r,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 o=this._mixer,r=o.time,i=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=o._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=r,s[1]=r+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,o){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const o=(e-r)*n;if(o<0||0===n)return;this._startTime=null,t=n*o}t*=this._updateTimeScale(e);const i=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let n=0,o=e.length;n!==o;++n)e[n].evaluate(i),t[n].accumulateAdditive(a);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(i),t[n].accumulate(o,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const o=n.evaluate(e)[0];t*=o,e>n.parameterPositions[1]&&(this.stopFading(),0===o&&(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!(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),o=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 r=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,r):this._setEndings(0===this.repetitions,!0,r)),a){var l=Math.floor((this.time-t)/o);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,r)}else this._setEndings(!1,!1,r);var d=(this.time-t)%o;d<0&&(d+=o),this.time=r?n-d:d+t,s||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}return this.time}_setEndings(e,t,n){const o=this._interpolantSettings;n?(o.endingStart=2401,o.endingEnd=2401):(o.endingStart=e?this.zeroSlopeAtStart?2401:2400:2402,o.endingEnd=t?this.zeroSlopeAtEnd?2401:2400:2402)}_scheduleFading(e,t,n){const o=this._mixer,r=o.time;let i=this._weightInterpolant;null===i&&(i=o._lendControlInterpolant(),this._weightInterpolant=i);const a=i.parameterPositions,s=i.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}}class AnimationClip{constructor(e,t=-1,n,o=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=o,this.uuid=generateUUID(),this.objectUUID="",this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,o=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(parseKeyframeTrack(n[e]).scale(o));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static CreateFromMorphTargetSequence(e,t,n,o){const r=t.length,i=[];for(let e=0;e1){const e=i[1];let t=o[e];t||(o[e]=t=[]),t.push(n)}}const i=[];for(const e in o)i.push(this.CreateFromMorphTargetSequence(e,o[e],t,n));return i}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,o=this.time+=e,r=Math.sign(e),i=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(o,e,r,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$3.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 o=_startEnd.dot(_startP)/n;return t&&(o=clamp(o,0,1)),o}closestPointToPoint(e,t,n){const o=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(o).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$2=new Vector3;class SpotLightHelper extends Object3D{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new BufferGeometry,o=[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})}o.visible=e}update(){const e=this.csm,t=e._sceneViewCamera;if(!t||e._needsUpdate)return;const n=e._cascades,o=n.length,r=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.updateWorldMatrix(!1,!0);s.length>o;){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({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const o=new Color,r=this.geometry.attributes.color.array;return o.set(e),o.toArray(r,0),o.toArray(r,3),o.set(t),o.toArray(r,6),o.toArray(r,9),o.set(n),o.toArray(r,12),o.toArray(r,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,o){return this.currentPath.quadraticCurveTo(e,t,n,o),this}bezierCurveTo(e,t,n,o,r,i){return this.currentPath.bezierCurveTo(e,t,n,o,r,i),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let o=!1;for(let r=n-1,i=0;iNumber.EPSILON){if(l<0&&(n=t[i],s=-s,a=t[r],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;o=!o}}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 o}const n=ShapeUtils.isClockWise,o=this.subPaths;if(0===o.length)return[];let r,i,a;const s=[];if(1===o.length)return i=o[0],a=new Shape,a.curves=i.curves,s.push(a),s;let l=!n(o[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=o.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,o[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(o[e]=t+15<<10,o[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(o[e]=31744,o[256|e]=64512,r[e]=24,r[256|e]=24):(o[e]=31744,o[256|e]=64512,r[e]=13,r[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(;!(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:o,shiftTable:r,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.textureComp.texture.name="AfterImage.comp",this.textureOld=new WebGLRenderTarget(e.x,e.y,n),this.textureOld.texture.name="AfterImage.old",this.shaderMaterial=new ShaderMaterial({type:"AfterImage",uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.compFsQuad=new FullScreenQuad(this.shaderMaterial);const o=new MeshBasicMaterial;this.copyFsQuad=new FullScreenQuad(o)}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 o=this.textureOld;this.textureOld=this.textureComp,this.textureComp=o}setSize(e,t){this.textureComp.setSize(e,t),this.textureOld.setSize(e,t)}}class BloomPass extends Pass{constructor(e,t,n,o,r){super(),this.strength=void 0!==t?t:1,this.radius=clamp(n),this.threshold=o,this.resolution=void 0!==e?new Vector2(e.x,e.y):new Vector2(256,256),r=r||{minFilter:1006,magFilter:1006,format:1023},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,r),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=normalize(n,e.array))),o.min[t]=Math.min(o.min[t],n),o.max[t]=Math.max(o.max[t],n)}return o}function getPaddedBufferSize(e){return 4*Math.ceil(e/4)}function getPaddedArrayBuffer(e,t=0){const n=getPaddedBufferSize(e.byteLength);if(n!==e.byteLength){const o=new Uint8Array(n);if(o.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;re.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:"Verge3D"}},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 o=this,r=o.buffers,i=o.json;n=o.options;const a=o.extensionsUsed,s=new Blob(r,{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),o=new DataView(new ArrayBuffer(8));o.setUint32(0,n.byteLength,!0),o.setUint32(4,5130562,!0);const r=getPaddedArrayBuffer(stringToArrayBuffer(JSON.stringify(i)),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.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+r.byteLength+o.byteLength+n.byteLength;l.setUint32(8,c,!0);const u=new Blob([s,a,r,o,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,o=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],o[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}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,o=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(),o=new Vector3;for(let e=0,t=n.count;e4?o=e.array[r*e.itemSize+n]:(0===n?o=e.getX(r):1===n?o=e.getY(r):2===n?o=e.getZ(r):3===n&&(o=e.getW(r)),!0===e.normalized&&(o=normalize(o,e.array))),t===WEBGL_CONSTANTS$1.FLOAT?l.setFloat32(c,o,!0):t===WEBGL_CONSTANTS$1.UNSIGNED_INT?l.setUint32(c,o,!0):t===WEBGL_CONSTANTS$1.UNSIGNED_SHORT?l.setUint16(c,o,!0):t===WEBGL_CONSTANTS$1.UNSIGNED_BYTE&&l.setUint8(c,o),c+=a}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};void 0!==r&&(u.target=r),r===WEBGL_CONSTANTS$1.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(o){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=getPaddedArrayBuffer(r.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,o(n.bufferViews.push(i)-1)}})}processAccessor(e,t,n,o){const r=this.json;let i;if(e.array.constructor===Float32Array)i=WEBGL_CONSTANTS$1.FLOAT;else if(e.array.constructor===Uint32Array)i=WEBGL_CONSTANTS$1.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)i=WEBGL_CONSTANTS$1.UNSIGNED_SHORT;else{if(e.array.constructor!==Uint8Array)throw new Error("v3d.GLTFExporter: Unsupported bufferAttribute component type.");i=WEBGL_CONSTANTS$1.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===o&&(o=e.count),0===o)return null;const a=getMinMax(e,n,o);let s;void 0!==t&&(s=e===t.index?WEBGL_CONSTANTS$1.ELEMENT_ARRAY_BUFFER:WEBGL_CONSTANTS$1.ARRAY_BUFFER);const l=this.processBufferView(e,i,n,o,s),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:o,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),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(e,t,n,o="image/png"){if(null!==e){const r=this,i=r.cache,a=r.json,s=r.options,l=r.pending;i.images.has(e)||i.images.set(e,{});const c=i.images.get(e),u=o+":flipY/"+n.toString();if(void 0!==c[u])return c[u];a.images||(a.images=[]);const d={mimeType:o},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){1023!==t&&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;tr.processBufferViewImage(e)).then(e=>{d.bufferView=e})):void 0!==h.toDataURL?d.uri=h.toDataURL(o):l.push(getToBlobPromise(h,o).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.options,n=this.cache,o=this.json;if(n.textures.has(e))return n.textures.get(e);o.textures||(o.textures=[]),e instanceof CompressedTexture&&(e=decompress(e,t.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");const i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(i.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,i)});const a=o.textures.push(i)-1;return n.textures.set(e,a),a}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 o={pbrMetallicRoughness:{}};!0!==e.isMeshNodeMaterial&&!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshNodeMaterial, MeshStandardMaterial, or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);equalArray(r,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=r),e.isMeshNodeMaterial?(o.pbrMetallicRoughness.metallicFactor=e.getStandardProp("metalness"),o.pbrMetallicRoughness.roughnessFactor=e.getStandardProp("roughness")):e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=.5,o.pbrMetallicRoughness.roughnessFactor=.5);const i=e.isMeshNodeMaterial?e.getStandardProp("metalnessMap"):e.metalnessMap,a=e.isMeshNodeMaterial?e.getStandardProp("roughnessMap"):e.roughnessMap;if(i||a){const e=this.buildMetalRoughTexture(i,a),t={index:this.processTexture(e)};o.pbrMetallicRoughness.metallicRoughnessTexture=t}const s=e.isMeshNodeMaterial?e.getStandardProp("map"):e.map;if(s){const e={index:this.processTexture(s)};o.pbrMetallicRoughness.baseColorTexture=e}let l=e.isMeshNodeMaterial?e.getStandardProp("emissive"):e.emissive;if(l){const t=e.isMeshNodeMaterial?e.getStandardProp("emissiveIntensity"):e.emissiveIntensity;l=l.clone().multiplyScalar(t);const n=Math.max(l.r,l.g,l.b);n>1&&(l.multiplyScalar(1/n),console.warn("v3d.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(o.emissiveFactor=l.toArray());const r=e.isMeshNodeMaterial?e.getStandardProp("emissiveMap"):e.emissiveMap;if(r){const e={index:this.processTexture(r)};o.emissiveTexture=e}}const c=e.isMeshNodeMaterial?e.getStandardProp("normalMap"):e.normalMap;if(c){const t={index:this.processTexture(c)},n=e.isMeshNodeMaterial?e.getStandardProp("normalScale"):e.normalScale;n&&1!==n.x&&(t.scale=n.x),o.normalTexture=t}const u=e.isMeshNodeMaterial?e.getStandardProp("aoMap"):e.aoMap;if(u){const t={index:this.processTexture(u),texCoord:1},n=e.isMeshNodeMaterial?e.getStandardProp("aoMapIntensity"):e.aoMapIntensity;1!==n&&(t.strength=n),o.occlusionTexture=t}e.transparent?o.alphaMode="BLEND":e.alphaTest>0&&(o.alphaMode="MASK",o.alphaCutoff=e.alphaTest),2===e.side&&(o.doubleSided=!0),""!==e.name&&(o.name=e.name),this.serializeUserData(e,o),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,o)});const d=n.materials.push(o)-1;return t.materials.set(e,d),d}processMesh(e){const t=this.cache,n=this.json,o=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){const n=[],o=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(s.extras={},s.extras.targetNames=o)}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 o=this.getUID(i.index);void 0===g[e].start&&void 0===g[e].count||(o+=":"+g[e].start+":"+g[e].count),t.attributes.has(o)?n.indices=t.attributes.get(o):(n.indices=this.processAccessor(i.index,i,g[e].start,g[e].count),t.attributes.set(o,n.indices)),null===n.indices&&delete n.indices}const o=this.processMaterial(m[g[e].materialIndex]);null!==o&&(n.material=o),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(r,_),_}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,o={type:n?"orthographic":"perspective"};return n?o.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:o.perspective={aspectRatio:e.aspect,yfov:degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(o.name=e.type),t.cameras.push(o)-1}processAnimation(e,t){const n=this.json,o=this.nodeMap;n.animations||(n.animations=[]);const r=(e=GLTFExporter.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,i=[],a=[];for(let e=0;e0){const t=[];for(let n=0,o=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 o.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const o={};""!==e.name&&(o.name=e.name),t.scenes.push(o);const r=[];for(let t=0,o=e.children.length;t0&&(o.nodes=r),this.serializeUserData(e,o)}processObjects(e){const t=new Scene;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)t){r.set(e.times.slice(0,l+1),0),r[l+1]=t,r.set(e.times.slice(l+1),l+2),i.set(e.values.slice(0,(l+1)*o),0),i.set(a.evaluate(t),(l+1)*o),i.set(e.values.slice((l+1)*o),(l+2)*o),s=l+1;break}}return e.times=r,e.values=i,s},mergeMorphTargetTracks:function(e,t){const n=[],o={},r=e.tracks;for(let e=0;e65535?Uint32Array:Uint16Array;this.geometry.setIndex(new BufferAttribute(new p(d),1))}}class OutlinePass extends Pass{constructor(e,t,n,o){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==o?o:[],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 r=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(r,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new WebGLRenderTarget(r,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new WebGLRenderTarget(Math.round(r/2),Math.round(i/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new WebGLRenderTarget(r,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new WebGLRenderTarget(Math.round(r/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(r,i),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new Vector2(Math.round(r/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:0,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:0,depthPacking:3201,side:2}),this._maskMaterial=new MeshMaskMaterial({side:2})}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),o=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,o),this.renderTargetBlurBuffer1.setSize(n,o),this.renderTargetEdgeBuffer1.setSize(n,o),this.separableBlurMaterial1.uniforms.texSize.value=new Vector2(n,o),n=Math.round(n/2),o=Math.round(o/2),this.renderTargetBlurBuffer2.setSize(n,o),this.renderTargetEdgeBuffer2.setSize(n,o),this.separableBlurMaterial2.uniforms.texSize.value=new Vector2(n,o)}saveVisibilityState(){const e=this;e.renderScene.traverse(function(t){(t.isMesh||t.isSprite||t.isPoints||t.isLine)&&e.visibilityState.set(t,t.visible)})}restoreVisibilityState(){const e=this;e.renderScene.traverse(function(t){(t.isMesh||t.isSprite||t.isPoints||t.isLine)&&(t.visible=e.visibilityState.get(t))})}changeVisibilityOfSelectedObjects(e){const t=this;function n(n){(n.isMesh||n.isSprite||n.isPoints||n.isLine)&&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,r&&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:5,blendEquation:100,blendEquationAlpha:100,blendSrc:204,blendDst:205,blendSrcAlpha:201,blendDstAlpha:201,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,o,r){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=o,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Color}render(e,t,n){const o=e.autoClear;let r,i;e.autoClear=!1,void 0!==this.overrideMaterial&&(i=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),r=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,r),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=i),e.autoClear=o}setCamera(e){this.camera=e}}class RepeatedKeyListener{constructor(e,t,n,o,r){this._domElement=e,this._keyCodes=Array.isArray(t)?t:[t],this._callback=n,this._repeats=o,this._period=r,this._timer=0,this._counter=0,this._keydownCb=function(e){this._keyCodes.includes(e.code)&&(this._timer||(this._timer=window.setTimeout(function(){this._counter=0,this._timer=null}.bind(this),1e3*r)),++this._counter>=o&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}dispose(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._timer&&window.clearTimeout(this._timer)}}const FRAMES_TIME_THRESHOLD=4;class SSAARenderPass extends Pass{constructor(e,t,n,o){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==o?o:0,this._oldClearColor=new Color;const r=ShaderLib.copy;this.copyUniformsAccum=UniformsUtils.clone(r.uniforms),this.copyMaterialAccum=new ShaderMaterial({type:"SSAACopyAccum",defines:Object.assign({},r.defines),uniforms:this.copyUniformsAccum,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new FullScreenQuad(this.copyMaterialAccum),this.copyUniformsFinal=UniformsUtils.clone(r.uniforms),this.copyMaterialFinal=new ShaderMaterial({type:"SSAACopyFinal",defines:Object.assign({},r.defines),uniforms:this.copyUniformsFinal,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:0,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 o=this._getJitterOffsets(),r=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);const i=e.getClearAlpha(),a=1/o.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=o.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=r,e.setClearColor(this._oldClearColor,i)}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=n.steps??100,this.stride=n.stride??10,this.binarySearchSteps=n.binarySearchSteps??4,this.renderTargetScale=n.renderTargetScale??.5,this.maxDistance=n.maxDistance??100,this.jitter=n.jitter??1,this.useRefract=n.useRefract??!1,this.renderAfter=n.renderAfter??[],this.simpleRefraction=n.simpleRefraction??!1,this.scene=e,this.camera=t,this._prevClearColor=new Color,this._depthBuffer=new WebGLRenderTarget(256,256,{minFilter:1003,magFilter:1003,format:1028,type:1016}),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=1,this.basic=new MeshBasicMaterial,this.fsQuad=new FullScreenQuad(null)}_setLayer(e,t){e.layers.set(t);for(let n=0;n{e.isLight&&(e.userData.oldLayersMask=e.layers.mask,e.layers.enable(this.useRefract?5:3),this.renderAfter.length&&e.layers.enable(this.useRefract?6:4))});for(let e=0;e{e.isLight&&"oldLayersMask"in e.userData&&(e.layers.mask=e.userData.oldLayersMask,delete e.userData.oldLayersMask)}),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),e.setClearColor(this._prevClearColor,i),e.autoClear=a}}class ToneMapPass extends ShaderPass{constructor(){super(ShaderLib.tonemap),this.material.type="ToneMap"}}var durl=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(durl(""))}catch(e){durl=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var u8=Uint8Array,u16=Uint16Array,u32=Uint32Array,fleb=new u8([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fdeb=new u8([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),clim=new u8([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(e,t){for(var n=new u16(31),o=0;o<31;++o)n[o]=t+=1<>>1|(21845&i)<<1;x=(61680&(x=(52428&x)>>>2|(13107&x)<<2))>>>4|(3855&x)<<4,rev[i]=((65280&x)>>>8|(255&x)<<8)>>>1}var hMap=function(e,t,n){for(var o=e.length,r=0,i=new u16(t);r>>l]=c}else for(a=new u16(o),r=0;r>>15-e[r]);return a},flt=new u8(288);for(i=0;i<144;++i)flt[i]=8;for(i=144;i<256;++i)flt[i]=9;for(i=256;i<280;++i)flt[i]=7;for(i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(i=0;i<32;++i)fdt[i]=5;var flm=hMap(flt,9,0),fdm=hMap(fdt,5,0),shft=function(e){return(e/8|0)+(7&e&&1)},slc=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var o=new(e instanceof u16?u16:e instanceof u32?u32:u8)(n-t);return o.set(e.subarray(t,n)),o},wbits=function(e,t,n){n<<=7&t;var o=t/8|0;e[o]|=n,e[o+1]|=n>>>8},wbits16=function(e,t,n){n<<=7&t;var o=t/8|0;e[o]|=n,e[o+1]|=n>>>8,e[o+2]|=n>>>16},hTree=function(e,t){for(var n=[],o=0;oh&&(h=i[o].s);var p=new u16(h+1),f=ln(n[u-1],p,0);if(f>t){o=0;var m=0,g=f-t,_=1<t))break;m+=_-(1<>>=g;m>0;){var v=i[o].s;p[v]=0&&m;--o){var x=i[o].s;p[x]==t&&(--p[x],++m)}f=t}return[new u8(p),f]},ln=function(e,t,n){return-1==e.s?Math.max(ln(e.l,t,n+1),ln(e.r,t,n+1)):t[e.s]=n},lc=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new u16(++t),o=0,r=e[0],i=1,a=function(e){n[o++]=e},s=1;s<=t;++s)if(e[s]==r&&s!=t)++i;else{if(!r&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(r),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(r);i=1,r=e[s]}return[n.subarray(0,o),t]},clen=function(e,t){for(var n=0,o=0;o>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var i=0;i4&&!M[clim[I-1]];--I);var w,R,L,B,P=c+5<<3,N=clen(r,flt)+clen(i,fdt)+a,D=clen(r,h)+clen(i,m)+a+14+3*I+clen(C,M)+(2*C[16]+3*C[17]+7*C[18]);if(P<=N&&P<=D)return wfblk(t,u,e.subarray(l,l+c));if(wbits(t,u,1+(D15&&(wbits(t,u,U[S]>>>5&127),u+=U[S]>>>12)}}}else w=flm,R=flt,L=fdm,B=fdt;for(S=0;S255){G=o[S]>>>18&31;wbits16(t,u,w[G+257]),u+=R[G+257],G>7&&(wbits(t,u,o[S]>>>23&31),u+=fleb[G]);var z=31&o[S];wbits16(t,u,L[z]),u+=B[z],z>3&&(wbits16(t,u,o[S]>>>5&8191),u+=fdeb[z])}else wbits16(t,u,w[o[S]]),u+=R[o[S]];return wbits16(t,u,w[256]),u+R[256]},deo=new u32([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),et=new u8(0),dflt=function(e,t,n,o,r,i){var a=e.length,s=new u8(o+a+5*(1+Math.ceil(a/7e3))+r),l=s.subarray(o,s.length-r),c=0;if(!t||a<8)for(var u=0;u<=a;u+=65535){var d=u+65535;d>>13,f=8191&h,m=(1<7e3||M>24576)&&B>423){c=wblk(e,l,0,y,b,C,E,M,I,u-I,c),M=S=E=0,I=u;for(var P=0;P<286;++P)b[P]=0;for(P=0;P<30;++P)C[P]=0}var N=2,D=0,O=f,F=R-L&32767;if(B>2&&w==x(u-F))for(var V=Math.min(p,B)-1,U=Math.min(32767,u),G=Math.min(258,B);F<=U&&--O&&R!=L;){if(e[u+N]==e[u+N-F]){for(var z=0;zN){if(N=z,D=F,z>V)break;var k=Math.min(F,z-2),W=0;for(P=0;PW&&(W=H,L=Q)}}}F+=(R=L)-(L=g[R])+32768&32767}if(D){y[M++]=268435456|revfl[N]<<18|revfd[D];var X=31&revfl[N],Y=31&revfd[D];E+=fleb[X]+fdeb[Y],++b[257+X],++C[Y],T=u+N,++S}else y[M++]=e[u],++b[e[u]]}}c=wblk(e,l,i,y,b,C,E,M,I,u-I,c)}return slc(s,0,o+shft(c)+r)},crct=function(){for(var e=new u32(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),crc=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o>>8;e=n},d:function(){return~e}}},dopt=function(e,t,n,o,r){return dflt(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,o,!0)},mrg=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},wbytes=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function deflateSync(e,t){return dopt(e,t||{},0,0)}var fltn=function(e,t,n,o){for(var r in e){var i=e[r],a=t+r;i instanceof u8?n[a]=[i,o]:Array.isArray(i)?n[a]=[i[0],mrg(o,i[1])]:fltn(i,a+"/",n,o)}},te="undefined"!=typeof TextEncoder&&new TextEncoder,td="undefined"!=typeof TextDecoder&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(e){}function strToU8(e,t){if(te)return te.encode(e);for(var n=e.length,o=new u8(e.length+(e.length>>1)),r=0,i=function(e){o[r++]=e},a=0;ao.length){var s=new u8(r+8+(n-a<<1));s.set(o),o=s}var l=e.charCodeAt(a);l<128||t?i(l):l<2048?(i(192|l>>6),i(128|63&l)):l>55295&&l<57344?(i(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>18),i(128|l>>12&63),i(128|l>>6&63),i(128|63&l)):(i(224|l>>12),i(128|l>>6&63),i(128|63&l))}return slc(o,0,r)}var exfl=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;if(o>65535)throw"extra field too long";t+=o+4}return t},wzh=function(e,t,n,o,r,i,a,s){var l=o.length,c=n.extra,u=s&&s.length,d=exfl(c);wbytes(e,t,null!=a?33639248:67324752),t+=4,null!=a&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==i&&8),e[t++]=r&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var h=new Date(null==n.mtime?Date.now():n.mtime),p=h.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(wbytes(e,t,p<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),t+=4,null!=i&&(wbytes(e,t,n.crc),wbytes(e,t+4,i),wbytes(e,t+8,n.size)),wbytes(e,t+12,l),wbytes(e,t+14,d),t+=16,null!=a&&(wbytes(e,t,u),wbytes(e,t+6,n.attrs),wbytes(e,t+10,a),t+=14),e.set(o,t),t+=l,d)for(var f in c){var m=c[f],g=m.length;wbytes(e,t,+f),wbytes(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},wzf=function(e,t,n,o,r){wbytes(e,t,101010256),wbytes(e,t+8,n),wbytes(e,t+10,n),wbytes(e,t+12,o),wbytes(e,t+16,r)};function zipSync(e,t){t||(t={});var n={},o=[];fltn(e,"",n,t);var r=0,i=0;for(var a in n){var s=n[a],l=s[0],c=s[1],u=0==c.level?0:8,d=(C=strToU8(a)).length,h=c.comment,p=h&&strToU8(h),f=p&&p.length,m=exfl(c.extra);if(d>65535)throw"filename too long";var g=u?deflateSync(l,c):l,_=g.length,A=crc();A.p(l),o.push(mrg(c,{size:l.length,crc:A.d(),c:g,f:C,m:p,u:d!=a.length||p&&h.length!=f,o:r,compression:u})),r+=30+d+m+_,i+=76+2*(d+m)+(f||0)+_}for(var v=new u8(i+22),x=r,y=i-r,b=0;b{if(e.isMesh){const t=e.geometry,o=e.material;if(o.isMeshNodeMaterial||o.isMeshStandardMaterial){const a="geometries/Geometry_"+t.id+".usda";if(!(a in n)){const e=buildMeshObject(t);n[a]=buildUSDFileAsString(e)}o.uuid in i||(i[o.uuid]=o),r+=buildXform(e,t,o)}else console.warn("v3d.USDZExporter: Unsupported material type (USDZ only supports MeshNodeMaterial and MeshStandardMaterial)",e)}else e.isCamera&&(r+=buildCamera(e))}),r+=buildSceneEnd(),r+=buildMaterials(i,a,t.quickLookCompatible),n[o]=strToU8(r),r=null;for(const e in a){let o=a[e];!0===o.isCompressedTexture&&(o=decompress(o));const r=imageToCanvas(o.image,o.flipY,t.maxTextureSize),i=await new Promise(e=>r.toBlob(e,"image/png",1));n[`textures/Texture_${e}.png`]=new Uint8Array(await i.arrayBuffer())}let s=0;for(const e in n){const t=n[e];s+=34+e.length;const o=63&s;if(4!==o){const r=new Uint8Array(64-o);n[e]=[t,{extra:{12345:r}}]}s=t.length}return zipSync(n,{level:0})}}function imageToCanvas(e,t,n){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const o=n/Math.max(e.width,e.height),r=document.createElement("canvas");r.width=e.width*Math.min(1,o),r.height=e.height*Math.min(1,o);const i=r.getContext("2d");return!0===t&&(i.translate(0,r.height),i.scale(1,-1)),i.drawImage(e,0,0,r.width,r.height),r}throw new Error("v3d.USDZExporter: No valid image data found. Unable to process texture.")}const PRECISION=7;function buildHeader(){return'#usda 1.0\n(\n customLayerData = {\n string creator = "Verge3D"\n }\n defaultPrim = "Root"\n metersPerUnit = 1\n upAxis = "Y"\n)\n\n'}function buildSceneStart(e){return`def Xform "Root"\n{\n def Scope "Scenes" (\n kind = "sceneLibrary"\n )\n {\n def Xform "Scene" (\n customData = {\n bool preliminary_collidesWithEnvironment = 0\n string sceneName = "Scene"\n }\n sceneName = "Scene"\n )\n {\n token preliminary:anchoring:type = "${e.ar.anchoring.type}"\n token preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"\n\n`}function buildSceneEnd(){return"\n }\n }\n}\n\n"}function buildUSDFileAsString(e){let t=buildHeader();return t+=e,strToU8(t)}function buildXform(e,t,n){const o="Object_"+e.id,r=buildMatrix(e.matrixWorld);return e.matrixWorld.determinant()<0&&console.warn("v3d.USDZExporter: USDZ does not support negative scales",e),`def Xform "${o}" (\n prepend references = @./geometries/Geometry_${t.id}.usda@\n prepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n matrix4d xformOp:transform = ${r}\n uniform token[] xformOpOrder = ["xformOp:transform"]\n\n rel material:binding = \n}\n\n`}function buildMatrix(e){const t=e.elements;return`(${buildMatrixRow(t,0)}, ${buildMatrixRow(t,4)}, ${buildMatrixRow(t,8)}, ${buildMatrixRow(t,12)})`}function buildMatrixRow(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function buildMeshObject(e){return`\ndef "Geometry"\n{\n${buildMesh(e)}\n}\n`}function buildMesh(e){const t=e.attributes,n=t.position.count;return`\n def Mesh "Geometry"\n {\n int[] faceVertexCounts = [${buildMeshVertexCount(e)}]\n int[] faceVertexIndices = [${buildMeshVertexIndices(e)}]\n normal3f[] normals = [${buildVector3Array(t.normal,n)}] (\n interpolation = "vertex"\n )\n point3f[] points = [${buildVector3Array(t.position,n)}]\n${buildPrimvars(t)}\n uniform token subdivisionScheme = "none"\n }\n`}function buildMeshVertexCount(e){const t=null!==e.index?e.index.count:e.attributes.position.count;return Array(t/3).fill(3).join(", ")}function buildMeshVertexIndices(e){const t=e.index,n=[];if(null!==t)for(let e=0;e0?n:"",r=e["uv"+o];void 0!==r&&(t+=`\n texCoord2f[] primvars:st${o} = [${buildVector2Array(r)}] (\n interpolation = "vertex"\n )`)}const n=e.color;if(void 0!==n){t+=`\n color3f[] primvars:displayColor = [${buildVector3Array(n,n.count)}] (\n interpolation = "vertex"\n )`}return t}function buildMaterials(e,t,n=!1){const o=[];for(const r in e){const i=e[r];o.push(buildMaterial(i,t,n))}return`def "Materials"\n{\n${o.join("")}\n}\n\n`}function buildMaterial(e,t,n=!1){const o=" ",r=[],i=[];function a(o,r,i){const a=o.source.id+(o.flipY?"_flipped":"");t[a]=o;const s={1e3:"repeat",1001:"clamp",1002:"mirror"},l=o.repeat.clone(),c=o.offset.clone(),u=o.rotation,d=Math.sin(u),h=Math.cos(u);return c.y=1-c.y-l.y,n?(c.x=c.x/l.x,c.y=c.y/l.y,c.x+=d/l.x,c.y+=h-1):(c.x+=d*l.x,c.y+=(1-h)*l.y),`\n def Shader "PrimvarReader_${r}"\n {\n uniform token info:id = "UsdPrimvarReader_float2"\n float2 inputs:fallback = (0.0, 0.0)\n token inputs:varname = "st"\n float2 outputs:result\n }\n\n def Shader "Transform2d_${r}"\n {\n uniform token info:id = "UsdTransform2d"\n token inputs:in.connect = \n float inputs:rotation = ${(u*(180/Math.PI)).toFixed(PRECISION)}\n float2 inputs:scale = ${buildVector2(l)}\n float2 inputs:translation = ${buildVector2(c)}\n float2 outputs:result\n }\n\n def Shader "Texture_${o.id}_${r}"\n {\n uniform token info:id = "UsdUVTexture"\n asset inputs:file = @textures/Texture_${a}.png@\n float2 inputs:st.connect = \n ${void 0!==i?"float4 inputs:scale = "+buildColor4(i):""}\n token inputs:sourceColorSpace = "${3e3===o.encoding?"raw":"sRGB"}"\n token inputs:wrapS = "${s[o.wrapS]}"\n token inputs:wrapT = "${s[o.wrapT]}"\n float outputs:r\n float outputs:g\n float outputs:b\n float3 outputs:rgb\n ${e.transparent||e.alphaTest>0?"float outputs:a":""}\n }`}2===e.side&&console.warn("v3d.USDZExporter: USDZ does not support double sided materials",e);const s=e.isMeshNodeMaterial?e.getStandardProp("map"):e.map,l=e.isMeshNodeMaterial?e.getStandardProp("color"):e.color;null!==s?(r.push(`${o}color3f inputs:diffuseColor.connect = `),e.transparent?r.push(`${o}float inputs:opacity.connect = `):e.alphaTest>0&&(r.push(`${o}float inputs:opacity.connect = `),r.push(`${o}float inputs:opacityThreshold = ${e.alphaTest}`)),i.push(a(s,"diffuse",l))):r.push(`${o}color3f inputs:diffuseColor = ${buildColor(l)}`);const c=e.isMeshNodeMaterial?e.getStandardProp("emissiveMap"):e.emissiveMap,u=e.isMeshNodeMaterial?e.getStandardProp("emissiveIntensity"):e.emissiveIntensity;let d=e.isMeshNodeMaterial?e.getStandardProp("emissive"):e.emissive;d=d.clone().multiplyScalar(u),null!==c?(r.push(`${o}color3f inputs:emissiveColor.connect = `),i.push(a(c,"emissive"))):d.getHex()>0&&r.push(`${o}color3f inputs:emissiveColor = ${buildColor(d)}`);const h=e.isMeshNodeMaterial?e.getStandardProp("normalMap"):e.normalMap;null!==h&&(r.push(`${o}normal3f inputs:normal.connect = `),i.push(a(h,"normal")));const p=e.isMeshNodeMaterial?e.getStandardProp("aoMap"):e.aoMap;null!==p&&(r.push(`${o}float inputs:occlusion.connect = `),i.push(a(p,"occlusion")));const f=e.isMeshNodeMaterial?e.getStandardProp("roughnessMap"):e.roughnessMap,m=e.isMeshNodeMaterial?e.getStandardProp("roughness"):e.roughness;null!==f&&1===m?(r.push(`${o}float inputs:roughness.connect = `),i.push(a(f,"roughness"))):r.push(`${o}float inputs:roughness = ${m}`);const g=e.isMeshNodeMaterial?e.getStandardProp("metalnessMap"):e.metalnessMap,_=e.isMeshNodeMaterial?e.getStandardProp("metalness"):e.metalness;null!==g&&1===_?(r.push(`${o}float inputs:metallic.connect = `),i.push(a(g,"metallic"))):r.push(`${o}float inputs:metallic = ${_}`);const A=e.isMeshNodeMaterial?e.getStandardProp("alphaMap"):e.alphaMap,v=e.isMeshNodeMaterial?e.getStandardProp("opacity"):e.opacity;return null!==A?(r.push(`${o}float inputs:opacity.connect = `),r.push(`${o}float inputs:opacityThreshold = 0.0001`),i.push(a(A,"opacity"))):r.push(`${o}float inputs:opacity = ${v}`),`\n def Material "Material_${e.id}"\n {\n def Shader "PreviewSurface"\n {\n uniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n int inputs:useSpecularWorkflow = 0\n token outputs:surface\n }\n\n token outputs:surface.connect = \n\n${i.join("\n")}\n\n }\n`}function buildColor(e){return`(${e.r}, ${e.g}, ${e.b})`}function buildColor4(e){return`(${e.r}, ${e.g}, ${e.b}, 1.0)`}function buildVector2(e){return`(${e.x}, ${e.y})`}function buildCamera(e){const t=e.name?e.name:"Camera_"+e.id,n=buildMatrix(e.matrixWorld);return e.matrixWorld.determinant()<0&&console.warn("v3d.USDZExporter: USDZ does not support negative scales",e),e.isOrthographicCamera?`def Camera "${t}"\n {\n matrix4d xformOp:transform = ${n}\n uniform token[] xformOpOrder = ["xformOp:transform"]\n\n float2 clippingRange = (${e.near.toPrecision(PRECISION)}, ${e.far.toPrecision(PRECISION)})\n float horizontalAperture = ${(10*(Math.abs(e.left)+Math.abs(e.right))).toPrecision(PRECISION)}\n float verticalAperture = ${(10*(Math.abs(e.top)+Math.abs(e.bottom))).toPrecision(PRECISION)}\n token projection = "orthographic"\n }\n\n `:`def Camera "${t}"\n {\n matrix4d xformOp:transform = ${n}\n uniform token[] xformOpOrder = ["xformOp:transform"]\n\n float2 clippingRange = (${e.near.toPrecision(PRECISION)}, ${e.far.toPrecision(PRECISION)})\n float focalLength = ${e.getFocalLength().toPrecision(PRECISION)}\n float focusDistance = ${e.focus.toPrecision(PRECISION)}\n float horizontalAperture = ${e.getFilmWidth().toPrecision(PRECISION)}\n token projection = "perspective"\n float verticalAperture = ${e.getFilmHeight().toPrecision(PRECISION)}\n }\n\n `}class Controls extends EventDispatcher{constructor(e,t){super(),this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.allowMouseOverIframes=!1,this.iframePointerEventsStatus=new WeakMap}lockIframeEvents(){const e=document.getElementsByTagName("iframe");for(let t=0;tMath.PI&&(t=e+Math.sign(e-t)*(2*Math.PI-n)),this.sphericalFrom.theta=e,this.sphericalTo.theta=t}return this}start(e){this.active=!0,this.duration=e,this.clock.start()}update(e=function(e,t,n){}){let t=this.clock.getElapsedTime()/this.duration;if(t=smootherstep(t,0,1),_targetTmp$1.lerpVectors(this.targetFrom,this.targetTo,t),0===this.movementType)_posTmp.lerpVectors(this.posFrom,this.posTo,t);else if(1===this.movementType){const e=lerp(this.sphericalFrom.radius,this.sphericalTo.radius,t),n=lerp(this.sphericalFrom.phi,this.sphericalTo.phi,t),o=lerp(this.sphericalFrom.theta,this.sphericalTo.theta,t);_posTmp.setFromSphericalCoords(e,n,o),_posTmp.add(_targetTmp$1)}e(t,_posTmp,_targetTmp$1),t>=1&&(this.active=!1,this.finishCb())}}const _targetTmp=new Vector3;class TweenCameraZoomToController{constructor(){this.posFrom=new Vector3,this.targetFrom=new Vector3,this.posTo=new Vector3,this.targetTo=new Vector3,this.zoomFrom=0,this.zoomTo=0,this.finishCb=function(){},this.active=!1,this.duration=0,this.clock=new Clock}setup({posFrom:e=new Vector3,targetFrom:t=new Vector3,posTo:n=new Vector3,targetTo:o=new Vector3,zoomFrom:r=0,zoomTo:i=0,finishCb:a=function(){}}){return this.posFrom.copy(e),this.targetFrom.copy(t),this.posTo.copy(n),this.targetTo.copy(o),this.zoomFrom=r,this.zoomTo=i,this.finishCb=a,this}start(e){this.active=!0,this.duration=e,this.clock.start()}update(e=function(e,t,n){}){let t=this.clock.getElapsedTime()/this.duration;t=smootherstep(t,0,1),_targetTmp.lerpVectors(this.targetFrom,this.targetTo,t);let n=lerp(this.zoomFrom,this.zoomTo,t);e(t,_targetTmp,n),t>=1&&(this.active=!1,this.finishCb())}}const DEFAULTS$2={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,enableCtrlZoom:!1,zoomInertia:.05,zoomInertiaTouch:.05,zoomSpeed:5,zoomSpeedTouch:1,enableDamping:!0,enableTurnover:!1,enableKeys:!0},ACCUM_PER_SEC_COEFF$2=60,ACCUM_CLAMP_ROTATE$2=.1,ACCUM_CLAMP_PAN$2=.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$5=new Vector3,_vec3Tmp2$4=new Vector3,_quatTmp$2=new Quaternion,_quatTmp2$1=new Quaternion,_changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"};class OrbitControls extends Controls{constructor(e,t){super(e,t),this.domElement.style.touchAction="none",this.targetObj=new Object3D,this.minDistance=DEFAULTS$2.minDistance,this.maxDistance=DEFAULTS$2.maxDistance,this.minZoom=DEFAULTS$2.minZoom,this.maxZoom=DEFAULTS$2.maxZoom,this.minPolarAngle=DEFAULTS$2.minPolarAngle,this.maxPolarAngle=DEFAULTS$2.maxPolarAngle,this.minAzimuthAngle=DEFAULTS$2.minAzimuthAngle,this.maxAzimuthAngle=DEFAULTS$2.maxAzimuthAngle,this.enableDamping=DEFAULTS$2.enableDamping,this.enableZoom=DEFAULTS$2.enableZoom,this.enableCtrlZoom=DEFAULTS$2.enableCtrlZoom,this.zoomSpeed=DEFAULTS$2.zoomSpeed,this.zoomSpeedTouch=DEFAULTS$2.zoomSpeedTouch,this.zoomInertia=DEFAULTS$2.zoomInertia,this.zoomInertiaTouch=DEFAULTS$2.zoomInertiaTouch,this.enableRotate=DEFAULTS$2.enableRotate,this.rotateSpeed=DEFAULTS$2.rotateSpeed,this.rotateSpeedTouch=DEFAULTS$2.rotateSpeedTouch,this.rotateInertia=DEFAULTS$2.rotateInertia,this.rotateInertiaTouch=DEFAULTS$2.rotateInertiaTouch,this.enablePan=DEFAULTS$2.enablePan,this.panSpeed=DEFAULTS$2.panSpeed,this.screenSpacePanning=DEFAULTS$2.screenSpacePanning,this.panSpeedKey=DEFAULTS$2.panSpeedKey,this.panInertia=DEFAULTS$2.panInertia,this.autoRotate=DEFAULTS$2.autoRotate,this.autoRotateSpeed=DEFAULTS$2.autoRotateSpeed,this.enableTurnover=DEFAULTS$2.enableTurnover,this.enableKeys=DEFAULTS$2.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:()=>I.active||w.active,set(e){I.active=e}}),this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.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$5.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(),o=STATE.NONE},this.update=function(){const e=new Vector3,t=new Vector3,d=new Vector3,h=new Quaternion;let _=!1,A=!1;return function(){const y=n.object.position;if(n.targetObj.updateWorldMatrix(!0,!1),I.active)I.update(function(t,o,r){if(y.copy(o),e.copy(r),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(w.active)w.update(function(t,o,r){if(e.copy(o),n.object.lookAt(e),n.object.zoom=r,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),r.setFromVector3(t),n.autoRotate&&o===STATE.NONE&&L(2*Math.PI/60/60*n.autoRotateSpeed),r.theta+=i.theta,r.phi+=i.phi,n.enableTurnover){_&&(r.phi-=2*i.phi),A!=_&&o==STATE.NONE&&(A=_),A&&(r.theta-=2*i.theta);const e=r.phi;(e<=0||e>=Math.PI)&&(_=!_,r.theta+=Math.PI,r.phi=e>0?2*Math.PI-e:Math.abs(e))}else isFinite(n.minAzimuthAngle)&&isFinite(n.maxAzimuthAngle)&&(r.theta=clampAngle(r.theta,n.minAzimuthAngle,n.maxAzimuthAngle)),r.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,r.phi));r.makeSafe(),n.object.isPerspectiveCamera?(r.radius*=a,r.radius=Math.max(n.minDistance,Math.min(n.maxDistance,r.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(r),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,o;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,o=e.clientHeight;if(!t||!o)return;L(2*Math.PI*p.x/t*m),r=2*Math.PI*p.y/o*m,i.phi-=r;var r}(),v.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,v.sub(x),v.multiplyScalar(n.panSpeed);for(let r in c)u.isKeyDown[r]?t=c[r]=1:(o=c[r],c[r]=expAverageClamp(c[r],0,e,n.panInertia,.1),t=o-c[r]),n.enabled&&n.enableKeys&&n.enablePan&&(t*=60*e*n.panSpeedKey,r==Keys.A||r==Keys.LEFT_ARROW?v.x+=t:r==Keys.D||r==Keys.RIGHT_ARROW?v.x-=t:r==Keys.W||r==Keys.UP_ARROW?v.y+=t:r!=Keys.S&&r!=Keys.DOWN_ARROW||(v.y-=t));(function(e,t){const o=n.domElement===document?n.domElement.body:n.domElement,r=o.clientWidth,i=o.clientHeight;if(!r||!i)return;if(n.object.isPerspectiveCamera){n.targetObj.updateWorldMatrix(!0,!1);const o=_vec3Tmp$5.setFromMatrixPosition(n.targetObj.matrixWorld),r=n.object.position;let a=_vec3Tmp2$4.copy(r).sub(o).length();a*=Math.tan(n.object.fov/2*DEG2RAD),P(2*e*a/i,n.object.matrix),N(2*t*a/i,n.object.matrix)}else n.object.isOrthographicCamera?(P(e*(n.object.right-n.object.left)/n.object.zoom/r,n.object.matrix),N(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)})(v.x,v.y),a=S,S=n.enableDamping?expAverageClamp(S,1,e,M,.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",z),n.domElement.removeEventListener("touchstart",k),n.domElement.removeEventListener("touchend",Q),n.domElement.removeEventListener("touchmove",W),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),u.dispose(),n.allowMouseOverIframes&&n.unlockIframeEvents()},this.tween=function(){const e=1e-5;return function(t,o,r,i,a){n.targetObj.updateWorldMatrix(!0,!1);const s=_vec3Tmp$5.setFromMatrixPosition(n.targetObj.matrixWorld);n.object.parent&&(t=_vec3Tmp2$4.copy(t),n.object.parent.worldToLocal(t)),t.manhattanDistanceTo(n.object.position)0?D(R()):C.y<0&&O(R()),y.copy(b),n.update()}(e);break;case STATE.PAN:if(!1===n.enablePan)return;F(e)}}function G(e){!1!==n.enabled&&(document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),n.allowMouseOverIframes&&n.unlockIframeEvents(),n.dispatchEvent(_endEvent),o=STATE.NONE)}function z(e){!1===n.enabled||!1===n.enableZoom||o!==STATE.NONE&&o!==STATE.ROTATE||n.enableCtrlZoom&&!e.ctrlKey||(e.preventDefault(),e.stopPropagation(),n.dispatchEvent(_startEvent),function(e){E=n.zoomSpeed,M=n.zoomInertia,e.deltaY<0?O(R(Math.abs(e.deltaY)/100)):e.deltaY>0&&D(R(Math.abs(e.deltaY)/100)),n.update()}(e),n.dispatchEvent(_endEvent))}function k(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),o=STATE.TOUCH_ROTATE;break;case 2:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){if(n.enableZoom){E=n.zoomSpeedTouch,M=n.zoomInertiaTouch;let t=e.touches[0].pageX-e.touches[1].pageX,o=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+o*o);y.set(0,r)}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),o=STATE.TOUCH_DOLLY_PAN;break;default:o=STATE.NONE}o!==STATE.NONE&&n.dispatchEvent(_startEvent)}}function W(e){if(!1!==n.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===n.enableRotate)return;if(o!==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(o!==STATE.TOUCH_DOLLY_PAN)return;!function(e){let t=e.touches[0].pageX-e.touches[1].pageX,o=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+o*o);b.set(0,r),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);A.set(i,a),v.subVectors(A,_),_.copy(A),n.enableZoom&&Math.abs(C.length())>Math.abs(v.length())&&(C.y>0?O(R()):C.y<0&&D(R())),n.enablePan&&Math.abs(C.length())o,set(e){o!==e&&(o=e,H())}}),Object.defineProperty(this,"inTween",{get:()=>T.active||I.active});const r=new Clock,i=1e-6,a=new Vector3,s=new Vector3,l=new Vector3,c=new Quaternion,u=new Vector3,d={};let h;d[Keys.W]=d[Keys.S]=d[Keys.A]=d[Keys.D]=d[Keys.UP_ARROW]=d[Keys.DOWN_ARROW]=d[Keys.LEFT_ARROW]=d[Keys.RIGHT_ARROW]=0;let p=!1;const f=new Spherical,m=new Spherical,g=new Vector2;let _=1,A=1;const v=new Vector2,x=new Vector2;let y=0,b=0,C=1,S=1;const E=new Vector2,M=new Vector2;const T=new TweenCameraController,I=new TweenCameraZoomToController,w={type:"change"},R={type:"start"},L={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{const 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)};const B=function(e,t){return _vec2Tmp.set((e-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-t))/n.screen.width)};function P(e){!1!==n.enabled&&(e.preventDefault(),!1!==n.enableRotate&&(x.copy(B(e.pageX,e.pageY).negate()),v.copy(x),p=!0,document.addEventListener("mousemove",N),document.addEventListener("mouseup",D),document.addEventListener("mouseleave",D),n.allowMouseOverIframes&&n.lockIframeEvents(),n.dispatchEvent(R)))}function N(e){if(!1!==n.enabled&&(e.preventDefault(),p)){if(!1===n.enableRotate)return;x.copy(B(e.pageX,e.pageY).negate()),g.add(x).sub(v),v.copy(x),_=n.rotateSpeed,A=n.rotateInertia}}function D(e){!1!==n.enabled&&(e.preventDefault(),p=!1,document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",D),document.removeEventListener("mouseleave",D),n.allowMouseOverIframes&&n.unlockIframeEvents(),n.dispatchEvent(L))}function O(e){if(!1!==n.enabled&&!1!==n.enableZoom&&(!n.enableCtrlZoom||e.ctrlKey)){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:b-=.025*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia;break;case 1:b-=.01*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia;break;default:b-=25e-5*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia}n.dispatchEvent(R),n.dispatchEvent(L)}}function F(e){if(!1===n.enabled)return;const t=e.targetTouches[0];p=!0,x.copy(B(t.pageX,t.pageY).negate()),v.copy(x),n.dispatchEvent(R)}function V(e){if(!1===n.enabled)return;e.preventDefault();const t=e.targetTouches[0];!1!==n.enableRotate&&(x.copy(B(t.pageX,t.pageY).negate()),g.add(x).sub(v),v.copy(x),_=n.rotateSpeedTouch,A=n.rotateInertiaTouch)}function U(e){if(!1!==n.enabled){if(0===e.targetTouches.length)p=!1;else{if(!1===n.enableRotate)return;p=!0,x.copy(B(e.targetTouches[0].pageX,e.targetTouches[0].pageY).negate()),v.copy(x)}n.dispatchEvent(L)}}function G(e){!1!==n.enabled&&e.preventDefault()}function z(e){n.domElement.requestPointerLock()}function k(e){document.pointerLockElement===n.domElement?(n.dispatchEvent(R),document.addEventListener("mousemove",Q)):(n.dispatchEvent(L),document.removeEventListener("mousemove",Q))}function W(e){console.error("Pointer lock failed")}function Q(e){var t,o;(e.preventDefault(),n.enabled&&n.enableRotate)&&(g.add((t=e.movementX,o=e.movementY,_vec2Tmp.set(t,-o).multiplyScalar(2/n.screen.width)).negate()),_=n.rotateSpeed,A=n.rotateInertia)}function H(){X(),n.domElement.addEventListener("contextmenu",G),n.enablePointerLock?(n.domElement.addEventListener("click",z),document.addEventListener("pointerlockchange",k),document.addEventListener("pointerlockerror",W)):n.domElement.addEventListener("mousedown",P),n.domElement.addEventListener("wheel",O,{passive:!1}),n.domElement.addEventListener("touchstart",F,{passive:!0}),n.domElement.addEventListener("touchend",U),n.domElement.addEventListener("touchmove",V,{passive:!1}),h=new KeyListener(window,n.domElement.parentElement),h.onKeyDown=function(e){n.enableKeys?e.keyCode in d&&(d[e.keyCode]=1):h.isKeyDown[e.keyCode]=!1}}function X(){n.domElement.removeEventListener("contextmenu",G),n.domElement.removeEventListener("click",z),document.removeEventListener("pointerlockchange",k),document.removeEventListener("pointerlockerror",W),document.removeEventListener("mousemove",Q),n.domElement.removeEventListener("mousedown",P),n.domElement.removeEventListener("wheel",O),n.domElement.removeEventListener("touchstart",F),n.domElement.removeEventListener("touchend",U),n.domElement.removeEventListener("touchmove",V),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",D),document.removeEventListener("mouseleave",D),h&&h.dispose()}this.update=function(){T.active?T.update(function(e,t,o){if(n.object.position.copy(t),n.object.lookAt(o),e>=1){m.set(0,0,0),g.set(0,0),y=0,b=0,E.set(0,0),M.set(0,0);for(const e in d)d[e]=0;r.getDelta()}}):I.active?I.update(function(e,t,o){if(n.object.lookAt(t),n.object.zoom=o,n.object.updateProjectionMatrix(),e>=1){m.set(0,0,0),g.set(0,0),y=0,b=0,E.set(0,0),M.set(0,0);for(let e in d)d[e]=0;r.getDelta()}}):(n.object.matrixAutoUpdate&&n.object.updateMatrix(),n.object.getLocalDirection(u),f.setFromVector3(u),f.theta+=m.theta*_,f.phi+=m.phi*_,f.makeSafe(),u.setFromSpherical(f),a.copy(u).add(n.object.position),n.object.lookAtLocal(a),n.object.isPerspectiveCamera?n.object.position.addScaledVector(u,y):n.object.isOrthographicCamera&&(n.object.zoom*=1+.15*y,n.object.updateProjectionMatrix()),s.copy(u).cross(n.object.up).setLength(-E.x),s.add(l.copy(n.object.up).setLength(E.y)),n.object.position.add(s),function(){const e=r.getDelta();m.set(m.radius,g.y,g.x),g.x=n.enableDamping?expAverageClamp(g.x,0,e,A,.001):0,g.y=n.enableDamping?expAverageClamp(g.y,0,e,A,.001):0,m.set(m.radius,m.phi-g.y,m.theta-g.x),E.copy(M),M.x=n.enableDamping?expAverageClamp(M.x,0,e,1,.001):0,M.y=n.enableDamping?expAverageClamp(M.y,0,e,1,.001):0,E.sub(M),E.multiplyScalar(1),y=b,b=n.enableDamping?expAverageClamp(b,0,e,S,.001):0,y-=b,y*=C;for(const t in d){const o=t==Keys.A||t==Keys.LEFT_ARROW||t==Keys.D||t==Keys.RIGHT_ARROW,r=t==Keys.W||t==Keys.UP_ARROW||t==Keys.S||t==Keys.DOWN_ARROW,i=o?n.panInertia:n.zoomInertia,a=o?n.panSpeedKey:n.zoomSpeedKey,s=.001;let l;if(h.isKeyDown[t])l=d[t]=1;else{const n=d[t];d[t]=expAverageClamp(d[t],0,e,i,s),l=n-d[t]}n.enabled&&n.enableKeys&&(o&&!n.enablePan||r&&!n.enableZoom||(l*=60*e*a,t==Keys.A||t==Keys.LEFT_ARROW?E.x+=l:t==Keys.D||t==Keys.RIGHT_ARROW?E.x-=l:t==Keys.W||t==Keys.UP_ARROW?y+=l:t!=Keys.S&&t!=Keys.DOWN_ARROW||(y-=l)))}}()),this._handleCollisions();let e=!1;this._lastPosition.distanceToSquared(n.object.position)>i&&(this._lastPosition.copy(n.object.position),e=!0),c.dot(n.object.quaternion)<1-i&&(c.copy(n.object.quaternion),e=!0),e&&n.dispatchEvent(w)},this.forceMouseUp=function(){D({preventDefault:function(){}})},this.dispose=function(){X(),n.allowMouseOverIframes&&n.unlockIframeEvents()},this.releaseFromCollision=function(){this._onCollisionMesh=!1},this.tween=function(e,t,o,r,i){n.object.parent&&(e=_vec3Tmp$4.copy(e),n.object.parent.worldToLocal(e));const a=n.object.getWorldPosition(_vec3Tmp2$3),s=_vec3Tmp3$1.subVectors(t,a).length(),l=n.object.getWorldDirection(_vec3Tmp3$1).multiplyScalar(s).add(a),c=1e-5;e.manhattanDistanceTo(n.object.position)0){const t=e[0];this.object.position.y=t.point.y+this.gazeLevel,this._onCollisionMesh=!0}else if(this._onCollisionMesh){let e=1/0;for(const t of this.collisionMeshes){if(!t.geometry.boundsTree){console.warn("v3d.FirstPersonControls: no bounding tree found on "+t.name);continue}this._toMeshSpaceMatrix.copy(t.matrixWorld).invert(),this._lastIntersection.copy(this.object.position),this._lastIntersection.y-=this.gazeLevel,this._lastIntersection.applyMatrix4(this._toMeshSpaceMatrix);const n=this._ppTarget;t.geometry.boundsTree.closestPointToPoint(this._lastIntersection,n),n.distanceG.active||z.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,_=o,A=new Vector3,v={};v[Keys.W]=v[Keys.S]=v[Keys.A]=v[Keys.D]=v[Keys.UP_ARROW]=v[Keys.DOWN_ARROW]=v[Keys.LEFT_ARROW]=v[Keys.RIGHT_ARROW]=0;var x=new KeyListener(window);x.onKeyDown=function(e){n.enableKeys?e.keyCode in v&&(v[e.keyCode]=1):x.isKeyDown[e.keyCode]=!1};var y=new Spherical,b=new Spherical,C=new Vector2,S=1,E=1,M=new Vector2,T=new Vector2,I=0,w=0,R=1,L=1,B=0,P=0,N=new Vector2,D=new Vector2,O=1,F=1,V=new Vector2,U=new Vector2,G=new TweenCameraController;const z=new TweenCameraZoomToController;var k={type:"change"},W={type:"start"},Q={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,$=(H=new Vector2,function(e,t){return H.set((e-n.screen.left)/n.screen.width,(t-n.screen.top)/n.screen.height),H}),K=function(){var e=new Vector2;return function(t,o){return e.set((t-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-o))/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(K(e.pageX,e.pageY).negate()),M.copy(T),_=r;break;case n.mouseButtons.ZOOM:case n.mouseButtons.PAN:if(!1===n.enablePan)return;V.copy($(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.allowMouseOverIframes&&n.lockIframeEvents(),n.dispatchEvent(W)}}function Z(e){if(!1!==n.enabled)if(e.preventDefault(),_===r){if(!1===n.enableRotate)return;T.copy(K(e.pageX,e.pageY).negate()),C.add(T).sub(M),M.copy(T),S=n.rotateSpeed,E=n.rotateInertia}else if(_===a||_===i){if(!1===n.enablePan)return;U.copy($(e.pageX,e.pageY)),D.add(U).sub(V),V.copy(U),O=n.panSpeed,F=n.panInertia}}function J(e){!1!==n.enabled&&(e.preventDefault(),_=o,document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",J),document.removeEventListener("mouseleave",J),n.allowMouseOverIframes&&n.unlockIframeEvents(),n.dispatchEvent(Q))}function ee(e){if(!1!==n.enabled&&!1!==n.enableZoom&&(!n.enableCtrlZoom||e.ctrlKey)){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:w-=.025*e.deltaY,R=n.zoomSpeed,L=n.zoomInertia;break;case 1:w-=.01*e.deltaY,R=n.zoomSpeed,L=n.zoomInertia;break;default:w-=25e-5*e.deltaY,R=n.zoomSpeed,L=n.zoomInertia}n.dispatchEvent(W),n.dispatchEvent(Q)}}function te(e){if(!1!==n.enabled){var t=e.touches[0],o=e.touches[1];if(1===e.touches.length){if(!1===n.enableRotate)return;_=s,T.copy(K(t.pageX,t.pageY).negate()),M.copy(T)}else{if(!1===n.enableZoom&&!1===n.enablePan)return;if(_=l,n.enableZoom){var r=$(t.pageX-o.pageX,t.pageY-o.pageY);B=P=r.length()}if(n.enablePan){var i=$((t.pageX+o.pageX)/2,(t.pageY+o.pageY)/2);V.copy(i),U.copy(V)}}n.dispatchEvent(W)}}function ne(e){if(!1!==n.enabled){e.preventDefault();var t=e.touches[0],o=e.touches[1];if(1===e.touches.length){if(!1===n.enableRotate)return;T.copy(K(t.pageX,t.pageY).negate()),C.add(T).sub(M),M.copy(T),S=n.rotateSpeedTouch,E=n.rotateInertiaTouch}else{if(!1===n.enableZoom&&!1===n.enablePan)return;var r=$(t.pageX-o.pageX,t.pageY-o.pageY),i=(P=r.length())-B;B=P;var a=$((t.pageX+o.pageX)/2,(t.pageY+o.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)&&(w+=i,R=n.zoomSpeedTouch,L=n.zoomInertiaTouch),n.enablePan&&Math.abs(i)<=Math.abs(l)&&(D.add(s),O=n.panSpeedTouch,F=n.panInertiaTouch)}}}function oe(e){if(!1!==n.enabled){switch(e.touches.length){case 0:_=o;break;case 1:if(!1===n.enableRotate)return;_=s,T.copy(K(e.touches[0].pageX,e.touches[0].pageY).negate()),M.copy(T)}n.dispatchEvent(Q)}}function re(e){!1!==n.enabled&&e.preventDefault()}this.update=(new Vector3,function(){G.active?G.update(function(e,t,o){if(n.object.position.copy(t),n.object.lookAt(o),e>=1){for(var r in b.set(0,0,0),C.set(0,0),I=0,w=0,N.set(0,0),D.set(0,0),v)v[r]=0;c.getDelta()}}):z.active?z.update(function(e,t,o){if(n.object.lookAt(t),n.object.zoom=o,n.object.updateProjectionMatrix(),e>=1){b.set(0,0,0),C.set(0,0),I=0,w=0,N.set(0,0),D.set(0,0);for(let e in v)v[e]=0;c.getDelta()}}):(n.object.getLocalDirection(A),y.setFromVector3(A),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(),A.setFromSpherical(y),d.copy(A).add(n.object.position),n.object.lookAtLocal(d),n.object.isPerspectiveCamera?n.object.position.addScaledVector(A,I):n.object.isOrthographicCamera&&(n.object.zoom*=1+.15*I,n.object.updateProjectionMatrix()),h.copy(A).cross(n.object.up).setLength(-N.x),h.add(p.copy(n.object.up).setLength(N.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,E,.001):0,C.y=n.enableDamping?expAverageClamp(C.y,0,e,E,.001):0,b.set(b.radius,b.phi-C.y,b.theta-C.x),N.copy(D),D.x=n.enableDamping?expAverageClamp(D.x,0,e,F,.001):0,D.y=n.enableDamping?expAverageClamp(D.y,0,e,F,.001):0,N.sub(D),N.multiplyScalar(O),I=w,w=n.enableDamping?expAverageClamp(w,0,e,L,.001):0,I-=w,I*=R,v){var o=t==Keys.A||t==Keys.LEFT_ARROW||t==Keys.D||t==Keys.RIGHT_ARROW,r=t==Keys.W||t==Keys.UP_ARROW||t==Keys.S||t==Keys.DOWN_ARROW,i=o?n.panInertia:n.zoomInertia,a=o?n.panSpeedKey:n.zoomSpeedKey;if(x.isKeyDown[t])var s=v[t]=1;else{var l=v[t];v[t]=expAverageClamp(v[t],0,e,i,.001),s=l-v[t]}n.enabled&&n.enableKeys&&(o&&!n.enablePan||r&&!n.enableZoom||(s*=60*e*a,t==Keys.A||t==Keys.LEFT_ARROW?N.x+=s:t==Keys.D||t==Keys.RIGHT_ARROW?N.x-=s:t==Keys.W||t==Keys.UP_ARROW?I+=s:t!=Keys.S&&t!=Keys.DOWN_ARROW||(I-=s)))}}());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(k)}),this.forceMouseUp=function(){J({preventDefault:function(){}})},this.dispose=function(){this.domElement.removeEventListener("contextmenu",re),this.domElement.removeEventListener("mousedown",q),this.domElement.removeEventListener("wheel",ee),this.domElement.removeEventListener("touchstart",te),this.domElement.removeEventListener("touchend",oe),this.domElement.removeEventListener("touchmove",ne),document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",J),document.removeEventListener("mouseleave",J),x.dispose(),this.allowMouseOverIframes&&this.unlockIframeEvents()},this.tween=(X=new Vector3,Y=new Vector3,j=new Vector3,function(e,t,o,r,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)e.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{e.originData.texture===t&&(e.originData.texture=n)});for(const o in e.nodeTextures)e.nodeTextures[o]===t&&(e.nodeTextures[o]=n);break;case"MeshStandardMaterial":STD_TEX_PROPERTY_NAMES.forEach(o=>{e[o]===t&&(e[o]=n)});break;default:return void console.error("replaceTexture: Unsupported material type "+e.type)}n.encoding=t.encoding,n.wrapS=t.wrapS,n.wrapT=t.wrapT}function disposeTextures(e){if(STD_TEX_PROPERTY_NAMES.forEach(function(t){e[t]&&e[t].isTexture&&e[t].dispose()}),"MeshNodeMaterial"==e.type)for(const t in e.nodeTextures)e.nodeTextures[t]&&e.nodeTextures[t].dispose()}function createEnvironmentMaterial(e,t,n){const o=new DiGraph,r={};if(o.addNode(createNode("LIGHT_PATH_BL","Light Path")),o.addNode(createNode("TEX_ENVIRONMENT_BL","Lighting Texture",{texture:t})),r[nodeTexUniName("TEX_ENVIRONMENT_BL",0)]=t,n instanceof Color){const e=n.toArray([0,0,0,1]);o.addNode(createNode("RGB_BL","Background Color",{outputs:[e]}))}else o.addNode(createNode("TEX_ENVIRONMENT_BL","Background Texture",{texture:n})),r[nodeTexUniName("TEX_ENVIRONMENT_BL",1)]=n;return o.addNode(createNode("MIX_BL","Mix")),connectNodes(o,0,N_OUT.LIGHT_PATH_BL.isCameraRay,3,N_IN.MIX_BL.fac),connectNodes(o,1,N_OUT.TEX_ENVIRONMENT_BL.color,3,N_IN.MIX_BL.col1),connectNodes(o,2,N_OUT[getNodeType(o.node(2))].color,3,N_IN.MIX_BL.col2),o.addNode(createNode("BACKGROUND_BL","Background")),connectNodes(o,3,N_OUT.MIX_BL.col,4,N_IN.BACKGROUND_BL.color),o.addNode(createNode("OUTPUT_WORLD_BL","Output")),connectNodes(o,4,N_OUT.BACKGROUND_BL.color,5,N_IN.OUTPUT_WORLD_BL.surface),new MeshNodeMaterial({name:e,nodeGraph:o,nodeTextures:r})}function createDiffuseMaterial(e,t,n,o="blender"){let r=new DiGraph;switch(o){case"blender":if(n<1){r.addNode(createNode("BSDF_TRANSPARENT_BL","Transparent"));const e=createNode("DIFFUSE_BSDF_BL","Diffuse");t.toArray(e.originData.inputs[N_IN.DIFFUSE_BSDF_BL.color]),r.addNode(e);const o=createNode("MIX_SHADER_BL","Mix");o.originData.inputs[N_IN.MIX_SHADER_BL.fac]=n,r.addNode(o),connectNodes(r,0,N_OUT.BSDF_TRANSPARENT_BL.color,2,N_IN.MIX_SHADER_BL.color1),connectNodes(r,1,N_OUT.DIFFUSE_BSDF_BL.color,2,N_IN.MIX_SHADER_BL.color2)}else{const e=createNode("DIFFUSE_BSDF_BL","Diffuse");t.toArray(e.originData.inputs[N_IN.DIFFUSE_BSDF_BL.color]),r.addNode(e)}r.addNode(createNode("OUTPUT_MATERIAL_BL","Output")),connectNodes(r,r.len()-2,N_OUT[getNodeType(r.node(r.len()-2))].color,r.len()-1,N_IN.OUTPUT_MATERIAL_BL.surface);break;case"max":const e=createNode("LAMBERT_AR","Diffuse");e.originData.inputs[N_IN.LAMBERT_AR.base]=1,t.toArray(e.originData.inputs[N_IN.LAMBERT_AR.baseColor]),e.originData.inputs[N_IN.LAMBERT_AR.opacity][0]=n,e.originData.inputs[N_IN.LAMBERT_AR.opacity][1]=n,e.originData.inputs[N_IN.LAMBERT_AR.opacity][2]=n,r.addNode(e),r.addNode(createNode("OUTPUT_MX","Output")),connectNodes(r,0,N_OUT.LAMBERT_AR.color,1,N_IN.OUTPUT_MX.color);break;case"maya":const i=createNode("LAMBERT_MY","Diffuse");t.toArray(i.originData.inputs[N_IN.LAMBERT_MY.color]),i.originData.inputs[N_IN.LAMBERT_MY.diffuse]=1,i.originData.inputs[N_IN.LAMBERT_MY.transparency][0]=1-n,i.originData.inputs[N_IN.LAMBERT_MY.transparency][1]=1-n,i.originData.inputs[N_IN.LAMBERT_MY.transparency][2]=1-n,r.addNode(i),r.addNode(createNode("SHADING_ENGINE_MY","Output")),connectNodes(r,0,N_OUT.LAMBERT_MY.color,1,N_IN.SHADING_ENGINE_MY.surface);break;default:console.error("createDiffuseMaterial: Incorrect material profile - "+o),r=null}return new MeshNodeMaterial({name:e,nodeGraph:r,profile:o})}function createStandardPBRMaterial(e="blender",t={}){let n=new DiGraph,o=t.color??"white",r=t.emissive??"black";const i=t.opacity??1,a=t.metalness??0,s=t.roughness??1,l=t.emissiveIntensity??1;let c,u;switch(o instanceof Color||(o=new Color(o)),r instanceof Color||(r=new Color(r)),e){case"blender":c=createNode("RGB_BL","color"),o.toArray(c.originData.outputs[N_OUT.RGB_BL.color]),n.addNode(c),u=createNode("RGB_BL","emissive"),r.toArray(u.originData.outputs[N_OUT.RGB_BL.color]),n.addNode(u),n.addNode(createNode("VALUE_BL","opacity",{outputs:[i]})),n.addNode(createNode("VALUE_BL","metalness",{outputs:[a]})),n.addNode(createNode("VALUE_BL","roughness",{outputs:[s]})),n.addNode(createNode("VALUE_BL","emissiveIntensity",{outputs:[l]})),n.addNode(createNode("BSDF_PRINCIPLED_BL","Shader")),connectNodes(n,0,N_OUT.RGB_BL.color,6,N_IN.BSDF_PRINCIPLED_BL.baseColor),connectNodes(n,1,N_OUT.RGB_BL.color,6,N_IN.BSDF_PRINCIPLED_BL.emission),connectNodes(n,2,N_OUT.VALUE_BL.value,6,N_IN.BSDF_PRINCIPLED_BL.alpha),connectNodes(n,3,N_OUT.VALUE_BL.value,6,N_IN.BSDF_PRINCIPLED_BL.metallic),connectNodes(n,4,N_OUT.VALUE_BL.value,6,N_IN.BSDF_PRINCIPLED_BL.roughness),connectNodes(n,5,N_OUT.VALUE_BL.value,6,N_IN.BSDF_PRINCIPLED_BL.emissionStrength),n.addNode(createNode("OUTPUT_MATERIAL_BL","Output")),connectNodes(n,6,N_OUT.BSDF_PRINCIPLED_BL.color,7,N_IN.OUTPUT_MATERIAL_BL.surface);break;case"max":c=createNode("RGB_MX","color"),o.toArray(c.originData.outputs[N_OUT.RGB_MX.color]),n.addNode(c),u=createNode("RGB_MX","emissive"),r.toArray(u.originData.outputs[N_OUT.RGB_BL.color]),n.addNode(u),n.addNode(createNode("VALUE_MX","opacity",{outputs:[i]})),n.addNode(createNode("VALUE_MX","metalness",{outputs:[a]})),n.addNode(createNode("VALUE_MX","roughness",{outputs:[s]})),n.addNode(createNode("VALUE_MX","emissiveIntensity",{outputs:[l]})),n.addNode(createNode("PHYSICAL_MX","Shader")),connectNodes(n,0,N_OUT.RGB_MX.color,6,N_IN.PHYSICAL_MX.baseColor),connectNodes(n,1,N_OUT.RGB_MX.color,6,N_IN.PHYSICAL_MX.emitColor),connectNodes(n,2,N_OUT.VALUE_BL.value,6,N_IN.PHYSICAL_MX.opacity),connectNodes(n,3,N_OUT.VALUE_MX.value,6,N_IN.PHYSICAL_MX.metalness),connectNodes(n,4,N_OUT.VALUE_MX.value,6,N_IN.PHYSICAL_MX.roughness),connectNodes(n,5,N_OUT.VALUE_MX.value,6,N_IN.PHYSICAL_MX.emission),n.addNode(createNode("OUTPUT_MX","Output")),connectNodes(n,6,N_OUT.PHYSICAL_MX.color,7,N_IN.OUTPUT_MX.color);break;case"maya":c=createNode("COLOR_CONSTANT_MY","color"),o.toArray(c.originData.inputs[N_IN.COLOR_CONSTANT_MY.color]),o.toArray(c.originData.outputs[N_IN.COLOR_CONSTANT_MY.color]),n.addNode(c),u=createNode("COLOR_CONSTANT_MY","emissive"),r.toArray(u.originData.inputs[N_IN.COLOR_CONSTANT_MY.color]),r.toArray(u.originData.outputs[N_IN.COLOR_CONSTANT_MY.color]),n.addNode(u),n.addNode(createNode("FLOAT_CONSTANT_MY","opacity",{outputs:[i]})),n.addNode(createNode("FLOAT_CONSTANT_MY","metalness",{outputs:[a]})),n.addNode(createNode("FLOAT_CONSTANT_MY","roughness",{outputs:[s]})),n.addNode(createNode("FLOAT_CONSTANT_MY","emissiveIntensity",{outputs:[l]})),n.addNode(createNode("STANDARD_SURFACE_AR","Shader")),connectNodes(n,0,N_OUT.COLOR_CONSTANT_MY.color,6,N_IN.STANDARD_SURFACE_AR.baseColor),connectNodes(n,1,N_OUT.COLOR_CONSTANT_MY.color,6,N_IN.STANDARD_SURFACE_AR.emissionColor),connectNodes(n,2,N_OUT.FLOAT_CONSTANT_MY.value,6,N_IN.STANDARD_SURFACE_AR.opacity),connectNodes(n,3,N_OUT.FLOAT_CONSTANT_MY.value,6,N_IN.STANDARD_SURFACE_AR.metalness),connectNodes(n,4,N_OUT.FLOAT_CONSTANT_MY.value,6,N_IN.STANDARD_SURFACE_AR.specularRoughness),connectNodes(n,5,N_OUT.FLOAT_CONSTANT_MY.value,6,N_IN.STANDARD_SURFACE_AR.emission),n.addNode(createNode("SHADING_ENGINE_MY","Output")),connectNodes(n,6,N_OUT.STANDARD_SURFACE_AR.color,7,N_IN.SHADING_ENGINE_MY.surface);break;default:console.error("createStandardPBRMaterial: Incorrect material profile - "+e),n=null}return new MeshNodeMaterial({name:name??"",nodeGraph:n,profile:e})}var MaterialUtils=Object.freeze({__proto__:null,createDiffuseMaterial:createDiffuseMaterial,createEnvironmentMaterial:createEnvironmentMaterial,createStandardPBRMaterial:createStandardPBRMaterial,disposeTextures:disposeTextures,replaceTexture:replaceTexture});const _color=new Color,_matrix$1=new Matrix4;function createMeshesFromInstancedMesh(e){const t=new Group,n=e.count,o=e.geometry,r=e.material;for(let i=0;i=1&&p.setX(t,r.getX(n)),a>=2&&p.setY(t,r.getY(n)),a>=3&&p.setZ(t,r.getZ(n)),a>=4&&p.setW(t,r.getW(n))}u.setAttribute(t,p)}const h=new Mesh(u,d);h.isMaterialGeneratedMesh=!0,h.name=t.name+"MatMesh"+a,t.add(h)}return t}function createMultiMaterialMesh(e){const t=[],n=[];let o=null;for(let r=0;r=0;e--){const t=i.children[e];t.isMesh&&t.isMaterialGeneratedMesh&&i.remove(t)}return o.morphTargetInfluences&&(i.morphTargetInfluences=o.morphTargetInfluences.slice()),o.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},o.morphTargetDictionary)),o.isSkinnedMesh&&(i.bindMode=o.bindMode,i.bindMatrix.copy(o.bindMatrix),i.bindMatrixInverse.copy(o.bindMatrixInverse),i.skeleton=o.skeleton),i}function createMultiMaterialObject(e,t){const n=new Group;for(let o=0,r=t.length;o{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&&o.setY(t,e.getY(a)),o.itemSize>2&&o.setZ(t,e.getZ(a)),o.itemSize>3&&o.setW(t,e.getW(a))}}}}function getMaterialByName(e,t){if(checkUUID(t))return getMaterialByUUID(e,t);const n=this.getMaterialsByName(e,t);return n.length?n[0]:null}function getMaterialsByName(e,t){if(checkUUID(t)){const n=getMaterialByUUID(e,t);return n?[n]:[]}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 o=e.scene.worldMaterial;null!==o&&o.name===t&&-1===n.indexOf(o)&&n.push(o)}return n}function getMaterialByUUID(e,t){let n=null;if(null!==e.scene){e.scene.traverse(e=>{e.material&&e.material.uuid===t&&(n=e.material)});const o=e.scene.worldMaterial;null!==o&&o.uuid===t&&(n=o)}return n}function getAllMaterials(e){const t=[];if(null!==e.scene){e.scene.traverse(e=>{e.material&&!t.includes(e.material)&&t.push(e.material)});const n=e.scene.worldMaterial;null===n||t.includes(n)||t.push(n)}return t}function getAnimationActionByName(e,t){const n=checkUUID(t);for(let o=0;o{if(!t.material)return;const n=Array.isArray(t.material)?t.material:[t.material];for(let t=0;t=0;t--)o.clippingPlanes[t]===e.plane&&o.clippingPlanes.splice(t,1)}})}var SceneUtils=Object.freeze({__proto__:null,assignDefaultControls:assignDefaultControls,calcSceneBox:calcSceneBox,checkActionIsUsed:checkActionIsUsed,createDefaultCamera:createDefaultCamera,createEnvironmentMaterial:createEnvironmentMaterial,createMeshesFromInstancedMesh:createMeshesFromInstancedMesh,createMeshesFromMultiMaterialMesh:createMeshesFromMultiMaterialMesh,createMultiMaterialMesh:createMultiMaterialMesh,createMultiMaterialObject:createMultiMaterialObject,getAllMaterials:getAllMaterials,getAnimationActionByName:getAnimationActionByName,getAnimationActionByObjectUUID:getAnimationActionByObjectUUID,getAnimationActionsByName:getAnimationActionsByName,getMaterialByName:getMaterialByName,getMaterialByUUID:getMaterialByUUID,getMaterialsByName:getMaterialsByName,reduceVertices:reduceVertices,removeClipPlanesFromMats:removeClipPlanesFromMats,sortInstancedMesh:sortInstancedMesh});const WM_TEXT="MADE WITH VERGE3D TRIAL",PP_PASSES={Afterimage:AfterimagePass,Bloom:BloomPass,Bokeh:BokehPass,"Brightness/Contrast":BrightnessContrastPass,FXAA:FXAAPass,Grayscale:GrayscalePass,Mask:MaskPass,Outline:OutlinePass,Render:RenderPass,SSAA:SSAARenderPass,SSR:SSRPass,ToneMapping:ToneMapPass,"Copy/Other":ShaderPass},TEX_FORMAT_STRINGS={[RGFormat]:"RG",[RGBAFormat]:"RGBA",[DepthFormat]:"DEPTH",[RGBA_BPTC_Format]:"RGBA_BPTC",[RGBA_ASTC_4x4_Format]:"RGBA_ASTC_4x4",[RGB_S3TC_DXT1_Format]:"RGB_S3TC_DXT1",[RGBA_S3TC_DXT5_Format]:"RGBA_S3TC_DXT5",[RGB_PVRTC_4BPPV1_Format]:"RGB_PVRTC_4BPPV1",[RGBA_PVRTC_4BPPV1_Format]:"RGBA_PVRTC_4BPPV1",[RGB_ETC1_Format]:"RGB_ETC1",[RGB_ETC2_Format]:"RGB_ETC2",[RGBA_ETC2_EAC_Format]:"RGB_ETC2_EAC"};class AppUtils{static getPageParams(e){let t=(e=e||window).location.href.toString();const n={};if(-1==t.indexOf("?"))return n;const o=t.split("#")[0].split("?")[1].split("&");for(let e=0;e${WM_TEXT}`,t.appendChild(o),setTimeout(function(){t.contains(o)&&890310108==hashString(o.textContent)||e.dispose()},1e3)}static isXML(e){return null!==e.match(/.*\.xml$/)}static isJS(e){return null!==e.match(/.*\.js$/)}static addToAppList(e){const t=getGlobalScope();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))}static removeFromAppList(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)}}static printPerformanceInfo(e,t){t=t||1;const n=e.renderer.info;n.reset();const o=e.frame;for(let e=0;e1e4);const s=-1!=e._loadSceneURL.indexOf(".xz",e._loadSceneURL.length-3);i("Asset Compression: "+(s?"yes":"no"),0==s);const l=Math.round(n.numShaderCompiles);i(`Shader Compilations: ${l}`,l>100);const c=r/t;i("FPS: "+c,c<30);const u=Math.round(n.render.calls/r);i("Render Calls: "+u,u>1e3);const d=Math.round(n.render.triangles/r);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 1:p="Light Probe",p+=` ${e._pmremMaxTileSize} px`}i(`Image-Based Lighting: ${p}`);let f=0,m=0,g=0,_=0,A=0,v=0;e.scene.traverse(function(e){e.isLight&&(f++,e.castShadow&&e.shadow&&(_++,A=e.shadow.mapSize.width,v=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 0:y="Basic";break;case 1:y="Bilinear";break;case 2:y="PCF";break;case 3:y="ESM";break;default:y="Unknown"}y+=` ${A}x${v}x${_}`}i("Shadow Map: "+y,_>4||A>2048||v>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;e=.1?String(Math.round(10*o)/10)+"ms":o>0&&o<.1?String(Math.round(1e3*o)/1e3)+"ms":"N/R",i(" "+(0==n.size?"System Material":Array.from(n).join(","))+" - "+t.name+" - "+a,o>16),C+=o,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)}if(n.render.customCounter){const e=n.render.customCounter/r;i(`Custom Counter: ${Math.round(10*e)/10} iter/frame`)}},1e3*t)}static printMaterialsStats(e){const t=getAllMaterials(e).filter(e=>"MeshNodeMaterial"==e.type),n=new Map;t.forEach(e=>{e.traverseNodes(e=>{const t=e.originData.type;n.has(t)||n.set(t,0),n.set(t,n.get(t)+1)})});const o=Array.from(n);o.sort((e,t)=>t[1]-e[1]),console.log("Total Node Materials:",t.length);const r=e.renderer.info.programs.filter(e=>"MeshNodeMaterial"==e.name);console.log("Total Node Shaders:",r.length),console.log("Node Stats:"),o.forEach(e=>{console.log(` ${e[0]} - ${e[1]}`)})}static registerServiceKeys(e){AppUtils.unregisterServiceKeys(e),e._serviceKeyListeners=e._serviceKeyListeners||[];const t=e._serviceKeyListeners;t.push(new RepeatedKeyListener(window,"KeyP",function(){AppUtils.printPerformanceInfo(e,1)},3,1)),t.push(new RepeatedKeyListener(window,"KeyF",function(){e.stats?e.hideFPS():e.showFPS()},3,1)),t.push(new RepeatedKeyListener(window,"KeyH",function(){e.enableRender?e.disableRendering():e.enableRendering()},3,1)),t.push(new RepeatedKeyListener(window,["Backquote","IntlBackslash"],()=>{let t;AppUtils.showServiceKeysHelp(e),e.controls&&(t=e.controls.enableKeys,e.controls.enableKeys=!1);const n=o=>{switch(o.code){case"KeyW":e.hasDebugMode("wireframes")?e.disableDebugMode("wireframes"):e.enableDebugMode("wireframes");break;case"KeyL":e.hasDebugMode("lights")?e.disableDebugMode("lights"):e.enableDebugMode("lights");break;case"KeyS":e.hasDebugMode("skeletons")?e.disableDebugMode("skeletons"):e.enableDebugMode("skeletons");break;case"KeyP":AppUtils.printPerformanceInfo(e,1);break;case"KeyF":e.stats?e.hideFPS():e.showFPS();break;case"KeyH":e.enableRender?e.disableRendering():e.enableRendering();break;case"KeyN":e.hasDebugMode("normals")?e.disableDebugMode("normals"):e.enableDebugMode("normals")}window.removeEventListener("keydown",n),AppUtils.hideServiceKeysHelp(e),e.controls&&(e.controls.enableKeys=t)};window.addEventListener("keydown",n)},3,1))}static unregisterServiceKeys(e){Array.isArray(e._serviceKeyListeners)&&(e._serviceKeyListeners.forEach(e=>e.dispose()),e._serviceKeyListeners.length=0)}static showServiceKeysHelp(e){const t=e.container,n=["color: #fff;","font-size: 14px;","font-family: monospace;","text-decoration: none;","position: absolute;",`top: ${e.stats?60:10}px;`,"left: 10px;","user-select: none;","z-index: 9999;","text-shadow: 1px 1px #000;"].join("\n"),o=document.createElement("div");o.id="v3d-debug-info-help",o.style=n,o.innerHTML="Service Tools:
[F] FPS counter
[P] performance profile
[H] halt/resume render
[W] wireframes
[L] lights
[S] skeletons
[N] normals",t.appendChild(o)}static hideServiceKeysHelp(e){e.container.querySelector("#v3d-debug-info-help").remove()}}const Compat={prepareRenderer:function(e){Detector.getGPUVendor(e),Detector.getGPUModel(e);const t=Detector.checkAndroid();e.compatSettings.gtaoDisableBkgFix=t}},_position=new Vector3,_quaternion=new Quaternion,_scale$8=new Vector3;class CSS3DObject extends Object3D{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.style.pointerEvents="auto",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(e){e.element instanceof e.element.ownerDocument.defaultView.Element&&null!==e.element.parentNode&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}const _matrix=new Matrix4,_matrix2=new Matrix4;class CSS3DRenderer{constructor(e){const t=this;let n,o,r,i;const a={camera:{style:""},objects:new WeakMap};this.domElement=e;const s=document.createElement("div");s.id="v3d-css-render-view",s.style.transformOrigin="0 0",s.style.pointerEvents="none",s.style.position="absolute",s.style.zIndex="-2",e.appendChild(s),this.viewElement=s;const l=document.createElement("div");function c(e){return Math.abs(e)<1e-10?0:e}function u(e){const t=e.elements;return"matrix3d("+c(t[0])+","+c(-t[1])+","+c(t[2])+","+c(t[3])+","+c(t[4])+","+c(-t[5])+","+c(t[6])+","+c(t[7])+","+c(t[8])+","+c(-t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(-t[13])+","+c(t[14])+","+c(t[15])+")"}function d(e){const t=e.elements;return"translate(-50%,-50%)"+("matrix3d("+c(t[0])+","+c(t[1])+","+c(t[2])+","+c(t[3])+","+c(-t[4])+","+c(-t[5])+","+c(-t[6])+","+c(-t[7])+","+c(t[8])+","+c(t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(t[13])+","+c(t[14])+","+c(t[15])+")")}function h(e){e.isCSS3DObject&&(e.element.style.display="none");for(let t=0,n=e.children.length;t\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)}render(e,t,n=1){const o=e.toneMapping,r=e.toneMappingExposure,i=e.getRenderTarget();e.toneMapping=1,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=o,e.toneMappingExposure=r,e.setRenderTarget(i)}dispose(){this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}}function renderSceneToCubemap(e,t,n,{camPos:o=new Vector3,clipStart:r=.1,clipEnd:i=100}={}){Detector.checkHalfFloatTex(t,!0)||(console.warn("v3d.RenderUtils: disabling half float cubemaps"),n.texture.type=1009);const a=new CubeCamera(r,i,n);a.position.copy(o);let s=e.worldMaterial;if(null!==s&&s.isMeshNodeMaterial){const o=new Mesh(new BoxGeometry(1,1,1),s);o.material.side=1,o.material.defines.WORLD_NODES=1,new CubeCamera(.1,10,n).update(t,o),o.geometry.disposeBoundsTree&&o.geometry.disposeBoundsTree(),o.geometry.dispose();const r=e.background;e.background=null;const i=t.autoClearColor;t.autoClearColor=!1,a.update(t,e),t.autoClearColor=i,e.background=r}else a.update(t,e);return a.renderTarget}function renderWorldNodeMatToCubemap(e,t,n,o){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");const r=new Scene;r.worldMaterial=t;const i=new WebGLCubeRenderTarget(n,o);return i.texture.name="WorldNodesCubemap",renderSceneToCubemap(r,e,i)}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.isCubeReflectionProbe=!0,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:3001,format:1023,generateMipmaps:!0,minFilter:1008,type:1016}),this._renderTargetCube.texture.name="CubeReflectionProbe.ini",this._exposureRenderTargetCube=this._renderTargetCube.clone(),this._renderTargetCube.texture.name="CubeReflectionProbe.exp",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,o=n.boundsTree,r=_matrix4;switch(r.copy(e.matrixWorld).invert(),r.multiply(this.matrixWorld),this.influenceType){case 0:t=!0;break;case 1:_sphere.center.setScalar(0),_sphere.radius=this.influenceDistance,_sphere.applyMatrix4(r),o?t=o.intersectsSphere(_sphere):(null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsSphere(_sphere));break;case 2:const e=_vector3.setScalar(0),i=_vector3_2.setScalar(2*this.influenceDistance);_box.setFromCenterAndSize(e,i),o?t=o.intersectsBox(_box,r):(_box.applyMatrix4(r),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 o=e.worldMaterial,r=null!==o&&o.isMeshNodeMaterial&&o.needsLightPathDir();let i;r&&(i=o.defines.LIGHT_PATH_IS_CAM_RAY,o.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),r&&(o.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}}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;e{var e=import.meta.url;return function(t){t=void 0!==(t=t||{})?t:{};var n,o,r=Object.assign;t.ready=new Promise(function(e,t){n=e,o=t});var i,a,s,l,c,u,d=r({},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=j(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 o=j(e);o&&t(o),u(),e=c.normalize(e),l.readFile(e,function(e,o){e?n(e):t(o.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof ee))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=j(e);if(n)return function(e){for(var t=[],n=0;n255&&(o&=255),t.push(String.fromCharCode(o))}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=j(e);if(n)return n;throw t}}),a=(e,t,n)=>{var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=()=>{if(200==o.status||0==o.status&&o.response)t(o.response);else{var r=j(e);r?t(r.buffer):n()}},o.onerror=n,o.send(null)}),t.print||console.log.bind(console);var g,_,A=t.printErr||console.warn.bind(console);r(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&&O("no native wasm support detected");var v=!1;function x(e){return t["_"+e]}function y(e,t,n,o,r){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,o){if(!(o>0))return 0;for(var r=n,i=n+o-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=J(n),n)}return t},array:function(e){var t=J(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 o=t+n,r=t;e[r]&&!(r>=o);)++r;if(r-t>16&&e.subarray&&M)return M.decode(e.subarray(t,r));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,o):"":"boolean"===t?Boolean(e):e;var n,o}var s=x(e),l=[],c=0;if(o)for(var u=0;u0&&(e+=t-e%t),e}function I(e){b=e,t.HEAP8=C=new Int8Array(e),t.HEAP16=new Int16Array(e),t.HEAP32=new Int32Array(e),t.HEAPU8=S=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=new Uint32Array(e),t.HEAPF32=new Float32Array(e),t.HEAPF64=new Float64Array(e)}t.INITIAL_MEMORY;var w=[],R=[],L=[];function B(e){w.unshift(e)}function P(e){L.unshift(e)}var N=0,D=null;function O(e){t.onAbort&&t.onAbort(e),A(e="Aborted("+e+")"),v=!0,e+=". Build with -s ASSERTIONS=1 for more info.";var n=new WebAssembly.RuntimeError(e);throw o(n),n}t.preloadedImages={},t.preloadedAudios={};var F,V,U="data:application/octet-stream;base64,";function G(e){return e.startsWith(U)}function z(e){return e.startsWith("file://")}function k(e){try{if(e==F&&g)return new Uint8Array(g);var t=j(e);if(t)return t;if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){O(e)}}function W(e){for(;e.length>0;){var n=e.shift();if("function"!=typeof n){var o=n.func;"number"==typeof o?void 0===n.arg?H(o)():H(o)(n.arg):o(void 0===n.arg?null:n.arg)}else n(t)}}G(F="data:application/octet-stream;base64,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oCAoAgBGDQRBtKAgIABBAmoiBTYCACACIAZqLQAADQkgFCAFIARrrXxCA4NQBEAgBSEADAILQbCgICgCACEGQbigICgCACAFRgRAIAUhAgwFC0G0oCAgAEEDaiICNgIAIAUgBmotAAANCSAUIAIgBGutfEIDg1ANAEG4oCAoAgAgAkYEQEGwoCAoAgAhBgwFC0G0oCAgAEEEajYCAAwJCyACIQALIAFBsKAgKAIAIAAQDEEHIQMgDyABQZABakEYEA0NByABQQg2AgALAn9BtKAgKAIAIQBBuKAgKAIAIQUDQEEAIAAgBUYNARogASkDGCEUIAEoAgQhA0G0oCAgAEEBaiICNgIAQQdBsKAgKAIAIABqLQAAIBQgA62Ip0H/AXFHDQEaIAEgA0EIaiIDNgIEIAIhACADQSBJDQALIAFBADYCBCABQgA3AxhBAQsiA0EBRw0GIAFBCTYCACABQQw2AqwBC0EAIQMgASABKAKoASIAakGwAWpBtKAgKAIAIgJBsKAgKAIAakG4oCAoAgAgAmsiAiABKAKsASAAayIAIAAgAksbIgAQAkG0oCBBtKAgKAIAIABqNgIAIAFBACABKAKoASAAaiIAIAAgASgCrAFGIgAbNgKoASAARQ0FQQchAAJAIAEvALoBQdm0AUcNACABQbQBakEGQQAQAyABKACwAUcNACABNQC0ASABKQOAAUICiFINACABLQC4AQ0AQQFBByABKAIgIAEtALkBRhshAAsgACEDDAULIAEgBiACEAxBACEDDAQLIAEgFDcDMCAEQQBIBEAgASgCBCICRQRAIAFCADcDCAsgACAFIAAgBUsbIQQDQCAAIARGBEBBByEDDAYLIAAgCGotAAghAyABIABBAWoiADYCqAEgASABKQMIIANB/wBxrSACrYaEIhU3AwgCQCADQYABcUUEQCADDQEgAkUNAUEHIQMMBwtBByEDIAEgAkEHaiICNgIEIAJBP0cNAQwGCwsgAUEANgIECyABIBU3AzggBSAAa0ECSQRAQQchAwwECyABIABBAWoiAjYCqAEgACAIai0ACEEhRwRAQQYhAwwECyABIABBAmoiBDYCqAEgAiAIai0ACEEBRwRAQQYhAwwEC0EHIQMgBCAFRg0DIAEgAEEDajYCqAEgASgCsAkhAEEGIQICQCAEIAhqLQAIIgNBJ0sNACAA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")||(V=F,F=t.locateFile?t.locateFile(V,m):m+V);var Q=[];function H(e){var t=Q[e];return t||(e>=Q.length&&(Q.length=e+1),Q[e]=t=E.get(e)),t}function X(e){try{return _.grow(e-b.byteLength+65535>>>16),I(_.buffer),1}catch(e){}}var Y="function"==typeof atob?atob:function(e){var t,n,o,r,i,a,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=s.indexOf(e.charAt(c++))<<2|(r=s.indexOf(e.charAt(c++)))>>4,n=(15&r)<<4|(i=s.indexOf(e.charAt(c++)))>>2,o=(3&i)<<6|(a=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==i&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(o))}while(c>>=0)>n)return!1;for(var o=1;o<=4;o*=2){var r=t*(1+.2/o);if(r=Math.min(r,e+100663296),X(Math.min(n,T(Math.max(e,r),65536))))return!0}return!1}};!function(){var e={a:$};function n(e,n){var o,r=e.exports;t.asm=r,I((_=t.asm.c).buffer),E=t.asm.o,o=t.asm.d,R.unshift(o),function(){if(N--,t.monitorRunDependencies&&t.monitorRunDependencies(N),0==N&&D){var e=D;D=null,e()}}()}function r(e){n(e.instance)}function i(t){return function(){if(!g&&(h||p)){if("function"==typeof fetch&&!z(F))return fetch(F,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+F+"'";return e.arrayBuffer()}).catch(function(){return k(F)});if(a)return new Promise(function(e,t){a(F,function(t){e(new Uint8Array(t))},t)})}return Promise.resolve().then(function(){return k(F)})}().then(function(t){return WebAssembly.instantiate(t,e)}).then(function(e){return e}).then(t,function(e){A("failed to asynchronously prepare wasm: "+e),O(e)})}if(N++,t.monitorRunDependencies&&t.monitorRunDependencies(N),t.instantiateWasm)try{return t.instantiateWasm(e,n)}catch(e){return A("Module.instantiateWasm callback failed with error: "+e),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||G(F)||z(F)||"function"!=typeof fetch?i(r):fetch(F,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(r,function(e){return A("wasm streaming compile failed: "+e),A("falling back to ArrayBuffer instantiation"),i(r)})})).catch(o)}(),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 K,q=t.stackSave=function(){return(q=t.stackSave=t.asm.p).apply(null,arguments)},Z=t.stackRestore=function(){return(Z=t.stackRestore=t.asm.q).apply(null,arguments)},J=t.stackAlloc=function(){return(J=t.stackAlloc=t.asm.r).apply(null,arguments)};function ee(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function te(e){function o(){K||(K=!0,t.calledRun=!0,v||(W(R),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)P(t.postRun.shift());W(L)}()))}N>0||(!function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)B(t.preRun.shift());W(w)}(),N>0||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),o()},1)):o()))}if(t.cwrap=function(e,t,n,o){var r=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&r&&!o?x(e):function(){return y(e,t,n,arguments)}},D=function e(){K||te(),K||(D=e)},t.run=te,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return te(),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,o){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);const r=this,i=Cache.get(e);if(void 0!==i)return r.manager.itemStart(e),setTimeout(function(){t&&t(i),r.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(()=>{r.decompressArrayBuffer(s,function(n){setTimeout(function(){t&&t(n),r.manager.itemEnd(e),Cache.add(e,n)},1)},function(e){if(n){n((2+1*e)/3)}},function(t){o&&o(t),r.manager.itemEnd(e),r.manager.itemError(e)})})):(o&&o(i),r.manager.itemEnd(e),r.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){o&&o(t),r.manager.itemEnd(e),r.manager.itemError(e)},!1),s.responseType="arraybuffer",s.send(null),r.manager.itemStart(e),s}setCrossOrigin(e){return this.crossOrigin=e,this}setPath(e){return this.path=e,this}decompressArrayBuffer(e,t,n,o){const r=this;function i(e){const t=r._emGetInBufferPtr();r.xz.HEAPU8.set(e,t),r._emInBufferSetPos(0),r._emInBufferSetSize(e.length),a()}function a(){r._emOutBufferSetPos(0)}const s=r._emInitDecompressor();if(0!=s)return console.error("XZLoader._emInitDecompressor: error code "+s+" ("+ERR_CODES[s]+")"),void(o&&o(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=r._emDecompress();if(s)console.error("XZLoader._emDecompress: error code "+s+" ("+ERR_CODES[s]+")"),o&&o(s);else{const o=r._emGetCurrOutputLength();if(u.push(function(e){const t=r._emGetOutBufferPtr();return new Uint8Array(r.xz.HEAPU8.subarray(t,t+e))}(o)),a(),r._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,o){return e+t.length},0),n=new Uint8Array(e);let o=0;u.forEach(function(e){n.set(e,o),o+=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,o){const r=this,i=new FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.load(e,function(e){t(r.parse(e))},n,o)}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 o=[];return n.forEach(function(e){var t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};o.push(t);for(var n=e.length-1;n>0;n--){var r=e[n];t={type:r.type};void 0!==r.x2&&void 0!==r.y2?(t.x1=r.x2,t.y1=r.y2,t.x2=r.x1,t.y2=r.y1):void 0!==r.x1&&void 0!==r.y1&&(t.x1=r.x1,t.y1=r.y1),t.x=e[n-1].x,t.y=e[n-1].y,o.push(t)}}),o}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 o=Math.round,r={},i=1e3/(e.unitsPerEm||2048),a=e.encoding.cmap.glyphIndexMap,s=Object.keys(a),l=0;l(r=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(o))&&(s.gamma=parseFloat(c[1])),(c=l.match(r))&&(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,o){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const i=new Uint8Array(4*n*o);if(!i.length)return t(4,"unable to allocate buffer space");let a=0,s=0;const l=4*r,c=new Uint8Array(4),u=new Uint8Array(l);let d=o;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])!=r)return t(3,"bad rgbe scanline format");let n,o=0;for(;o128;if(r&&(n-=128),0===n||o+n>l)return t(3,"bad scanline data");if(r){const t=e[s++];for(let e=0;e0)return;this._traverseDisableOther(e),s.reflect(a).negate(),s.add(o),i.extractRotation(t.matrixWorld);const l=this.lookAtPosition;l.set(0,0,-1),l.applyMatrix4(i),l.add(r);const c=this.target;c.subVectors(o,l),c.reflect(a).negate(),c.add(o);const u=this.virtualCamera;u.position.copy(s),u.up.set(0,1,0),u.up.applyMatrix4(i),u.up.reflect(a),u.lookAt(c),u.far=t.far,u.updateMatrixWorld();const d=u.projectionMatrix;d.copy(t.projectionMatrix);const h=this.textureMatrix;h.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),h.multiply(d),h.multiply(u.matrixWorldInverse);const p=this.reflectorPlane;p.setFromNormalAndCoplanarPoint(a,o),p.applyMatrix4(u.matrixWorldInverse);const f=this.clipPlane;f.set(p.normal.x,p.normal.y,p.normal.z,p.constant),_vec4Tmp.x=(Math.sign(f.x)+d.elements[8])/d.elements[0],_vec4Tmp.y=(Math.sign(f.y)+d.elements[9])/d.elements[5],_vec4Tmp.z=-1,_vec4Tmp.w=(1+d.elements[10])/d.elements[14],f.multiplyScalar(2/f.dot(_vec4Tmp)),d.elements[2]=f.x,d.elements[6]=f.y,d.elements[10]=f.z+1-this.probeClipStart,d.elements[14]=f.w;const m=n.getRenderTarget(),g=n.xr.enabled,_=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,u),n.xr.enabled=g,n.shadowMap.autoUpdate=_,n.useOIT=A,n.setRenderTarget(m);const v=t.viewport;void 0!==v&&n.state.viewport(v),_objLayersMasks.forEach((e,t)=>{t.layers.mask=e}),_objLayersMasks.clear()}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}}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),o=new Float32Array(t);UniformsLib.LTC_FLOAT_1=new DataTexture(n,64,64,1023,1015,300,1001,1001,1006,1003,1),UniformsLib.LTC_FLOAT_2=new DataTexture(o,64,64,1023,1015,300,1001,1001,1006,1003,1),UniformsLib.LTC_FLOAT_1.name="RectArea.ltc1",UniformsLib.LTC_FLOAT_2.name="RectArea.ltc2",UniformsLib.LTC_FLOAT_1.needsUpdate=!0,UniformsLib.LTC_FLOAT_2.needsUpdate=!0;const r=new Uint16Array(e.length);e.forEach(function(e,t){r[t]=toHalfFloat(e)});const i=new Uint16Array(t.length);t.forEach(function(e,t){i[t]=toHalfFloat(e)}),UniformsLib.LTC_HALF_1=new DataTexture(r,64,64,1023,1016,300,1001,1001,1006,1003,1),UniformsLib.LTC_HALF_2=new DataTexture(i,64,64,1023,1016,300,1001,1001,1006,1003,1),UniformsLib.LTC_HALF_1.needsUpdate=!0,UniformsLib.LTC_HALF_2.needsUpdate=!0}}class Font{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="left",o="topBaseline",r=-1,i=!1){const a=[],s=createPaths(e,t,this.data,n,o,r,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,o=e.material,r=e.geometry;if(o.clippingPlanes=o.clippingPlanes||[],-1==o.clippingPlanes.indexOf(n)&&o.clippingPlanes.push(n),o.clipShadows=this.clipShadows,o.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=1,c.clippingPlanes=[n],c.stencilFail=34055,c.stencilZFail=34055,c.stencilZPass=34055,a?(u=new SkinnedMesh(r,c),u.skeleton=e.skeleton):u=new Mesh(r,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=0,d.clippingPlanes=[n],d.stencilFail=34056,d.stencilZFail=34056,d.stencilZPass=34056,a?(h=new SkinnedMesh(r,d),h.skeleton=e.skeleton):h=new Mesh(r,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),o.isMeshNodeMaterial&&(this._crossMatProfile=o.profile)}}createCrossSectionPlane(e,t){this.cleanupAuxMeshes();const n=new createDiffuseMaterial("ClipCrossSectionColor",this.crossSectionColor,this.crossSectionOpacity,this._crossMatProfile);n.clippingPlanes=e.filter(e=>e!==this.plane),n.clipShadows=this.clipShadows,n.clipIntersection=this.clipIntersection,n.stencilWrite=!0,n.stencilRef=0,n.stencilFunc=517,n.stencilFail=7681,n.stencilZFail=7681,n.stencilZPass=7681,n.side=this.crossSectionRenderSide,this.crossSectionOpacity<1&&(n.transparent=!0,n.premultipliedAlpha=!0,n.blending=5,n.blendEquation=100,n.blendSrc=201,n.blendDst=205);const o=new PlaneGeometry(this.crossSectionSize,this.crossSectionSize);this.negated?o.rotateX(-Math.PI/2):o.rotateX(Math.PI/2);const r=new Mesh(o,n);r.name="ClipCrossSectionColor",r.isAuxClippingMesh=!0,r.renderOrder=t,r.onAfterRender=function(e){e.clearStencil()},this.add(r)}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}}class Constraint{constuctor(){this.isConstraint=!0,this.name="",this.type="Constraint",this.mute=!1}_updateObjMatrixWorld(e){e.matrixAutoUpdate&&e.matrix.compose(e.position,e.quaternion,e.scale),null==e.parent?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix)}update(e){this.mute}copy(e){return this.name=e.name,this.mute=e.mute,this}clone(){return(new this.constructor).copy(this)}}class TargetConstraint extends Constraint{constructor(e){super(),this.isTargetConstraint=!0,this.type="TargetConstraint",this.target=e}copy(e){return super.copy(e),this.target=e.target,this}clone(){return new this.constructor(this.target).copy(this)}}const _mat=new Matrix4,QUAT_90_MX$7=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2);class ChildOfConstraint extends TargetConstraint{constructor(e){super(e),this.isChildOfConstraint=!0,this.type="ChildOfConstraint",this.offsetMatrix=new Matrix4,this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.offsetMatrix.copy(e.offsetMatrix),this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){super.update(e),this.mute||(_mat.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),_mat.decompose(e.position,e.quaternion,e.scale),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX$7))}}const _pos$8=new Vector3,_quat$7=new Quaternion,_scale$7=new Vector3;class CopyLocationConstraint extends TargetConstraint{constructor(e){super(e),this.isCopyLocationConstraint=!0,this.type="CopyLocationConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.invertX=!1,this.invertY=!1,this.invertZ=!1,this.useOffset=!1,this.influence=1,this._firstIteration=!0,this._objPosInit=new Vector3,this._offset=new Vector3}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.invertX=e.invertX,this.invertY=e.invertY,this.invertZ=e.invertZ,this.useOffset=e.useOffset,this.influence=e.influence,this._firstIteration=!1,this}update(e){super.update(e),this.mute||(this.target.matrixWorld.decompose(_pos$8,_quat$7,_scale$7),this._firstIteration&&(this._updateObjMatrixWorld(e),e.getWorldPositionNU(this._objPosInit),this._offset.subVectors(_pos$8,this._objPosInit),this._firstIteration=!1),this.useX?(this.invertX&&(_pos$8.x=-_pos$8.x),this.useOffset&&(_pos$8.x-=this._offset.x)):_pos$8.x=this._objPosInit.x,this.useY?(this.invertY&&(_pos$8.y=-_pos$8.y),this.useOffset&&(_pos$8.y-=this._offset.y)):_pos$8.y=this._objPosInit.y,this.useZ?(this.invertZ&&(_pos$8.z=-_pos$8.z),this.useOffset&&(_pos$8.z-=this._offset.z)):_pos$8.z=this._objPosInit.z,e.position.lerpVectors(this._objPosInit,_pos$8,this.influence),e.parent&&e.parent.worldToLocal(e.position))}}const QUAT_90_MX$6=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),_pos$7=new Vector3,_quat$6=new Quaternion,_scale$6=new Vector3;class CopyRotationConstraint extends TargetConstraint{constructor(e){super(e),this.isCopyRotationConstraint=!0,this.type="CopyRotationConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.invertX=!1,this.invertY=!1,this.invertZ=!1,this.mixMode="REPLACE",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objQuatInit=new Quaternion}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.invertX=e.invertX,this.invertY=e.invertY,this.invertZ=e.invertZ,this.mixMode=e.mixMode,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!1,this}update(e){super.update(e),this.mute||(this.target.matrixWorld.decompose(_pos$7,_quat$6,_scale$6),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(_pos$7,this._objQuatInit,_scale$6),this._firstIteration=!1),e.quaternion.copy(this._objQuatInit),(this.useX||this.useY||this.useZ)&&("REPLACE"==this.mixMode||"ADD"==this.mixMode||("BEFORE"==this.mixMode?_quat$6.multiply(e.quaternion):"AFTER"==this.mixMode?_quat$6.premultiply(e.quaternion):this.mixMode),e.quaternion.slerp(_quat$6,this.influence)),e.parent&&(e.parent.matrixWorld.decompose(_pos$7,_quat$6,_scale$6),e.quaternion.premultiply(_quat$6.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX$6))}}const _pos$6=new Vector3,_quat$5=new Quaternion,_scale$5=new Vector3;class CopyScaleConstraint extends TargetConstraint{constructor(e){super(e),this.isCopyScaleConstraint=!0,this.type="CopyScaleConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.power=1,this.useMakeUniform=!1,this.useOffset=!1,this.useAdd=!1,this.influence=1,this._objInitScale=new Vector3,this._volumeScaleFactor=new Vector3,this._firstIteration=!0}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.power=e.power,this.useMakeUniform=e.useMakeUniform,this.useOffset=e.useOffset,this.useAdd=e.useAdd,this.influence=e.influence,this._firstIteration=!1,this}update(e){if(super.update(e),!this.mute){if(this.target.matrixWorld.decompose(_pos$6,_quat$5,_scale$5),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(_pos$6,_quat$5,this._objInitScale),this._volumeScaleFactor.set(Math.pow(_scale$5.x-this._objInitScale.x,3),Math.pow(_scale$5.y-this._objInitScale.y,3),Math.pow(_scale$5.z-this._objInitScale.z,3)),this._firstIteration=!1),this.useMakeUniform){let e=1;this.useX&&(e*=_scale$5.x),this.useY&&(e*=_scale$5.y),this.useZ&&(e*=_scale$5.z),e=Math.pow(Math.cbrt(e),this.power),_scale$5.set(e,e,e),this.useOffset&&(this.useAdd?(_scale$5.add(this._objInitScale),_scale$5.addScalar(-1)):_scale$5.multiply(this._objInitScale))}else _scale$5.set(this.useX?Math.pow(_scale$5.x,this.power):this._objInitScale.x,this.useY?Math.pow(_scale$5.y,this.power):this._objInitScale.y,this.useZ?Math.pow(_scale$5.z,this.power):this._objInitScale.z),this.useOffset&&(this.useAdd?_scale$5.set(this.useX?_scale$5.x+this._objInitScale.x-1:_scale$5.x,this.useY?_scale$5.y+this._objInitScale.y-1:_scale$5.y,this.useZ?_scale$5.z+this._objInitScale.z-1:_scale$5.z):_scale$5.set(this.useX?_scale$5.x*this._objInitScale.x:_scale$5.x,this.useY?_scale$5.y*this._objInitScale.y:_scale$5.y,this.useZ?_scale$5.z*this._objInitScale.z:_scale$5.z));e.scale.copy(this._objInitScale),e.scale.lerp(_scale$5,this.influence)}}}const QUAT_90_MX$5=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),_matrixWorld=new Matrix4,_pos$5=new Vector3,_quat$4=new Quaternion,_scale$4=new Vector3;class CopyTransformsConstraint extends TargetConstraint{constructor(e){super(e),this.isCopyTransformsConstraint=!0,this.type="CopyTransformsConstraint",this.mixMode="REPLACE",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objMatrixWorldInit=new Matrix4}copy(e){return super.copy(e),this.mixMode=e.mixMode,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!0,this}update(e){super.update(e),this.mute||(this._firstIteration&&(this._updateObjMatrixWorld(e),this._objMatrixWorldInit.copy(e.matrixWorld),this._firstIteration=!1),_matrixWorld.copy(this.target.matrixWorld),"REPLACE"==this.mixMode||("BEFORE"==this.mixMode?_matrixWorld.multiply(this._objMatrixWorldInit):"AFTER"==this.mixMode&&_matrixWorld.premultiply(this._objMatrixWorldInit)),_matrixWorld.decompose(_pos$5,_quat$4,_scale$4),this._objMatrixWorldInit.decompose(e.position,e.quaternion,e.scale),e.position.lerp(_pos$5,this.influence),e.quaternion.slerp(_quat$4,this.influence),e.scale.lerp(_scale$4,this.influence),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX$5))}}const QUAT_90_MX$4=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),_pos$4=new Vector3,_quat$3=new Quaternion,_scale$3=new Vector3,_objWorldPos$1=new Vector3,_targetVec=new Vector3,_objVec=new Vector3,_rotAxis=new Vector3,TRACK_DIR_NUMS={X:0,Y:1,Z:2,"-X":3,"-Y":4,"-Z":5},TRACK_DIR_VECS$1={0:new Vector3(1,0,0),1:new Vector3(0,1,0),2:new Vector3(0,0,1),3:new Vector3(-1,0,0),4:new Vector3(0,-1,0),5:new Vector3(0,0,-1)};class DampedTrackConstraint extends TargetConstraint{constructor(e){super(e),this.isDampedTrackConstraint=!0,this.type="DampedTrackConstraint",this.trackAxis="X",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!1,this}update(e){if(super.update(e),!this.mute&&(this.target.matrixWorld.decompose(_pos$4,_quat$3,_scale$3),this._firstIteration&&(this._updateObjMatrixWorld(e),this._firstIteration=!1),e.matrixWorld.decompose(_objWorldPos$1,_quat$3,_scale$3),_targetVec.subVectors(_pos$4,_objWorldPos$1),0!=_targetVec.length())){let t;if(_targetVec.normalize(),_objVec.copy(TRACK_DIR_VECS$1[TRACK_DIR_NUMS[this.trackAxis]]),_objVec.applyQuaternion(_quat$3),0==_objVec.length()&&_objVec.copy(TRACK_DIR_VECS$1[TRACK_DIR_NUMS[this.trackAxis]]),_objVec.normalize(),_rotAxis.crossVectors(_objVec,_targetVec),t=_objVec.angleTo(_targetVec),_rotAxis.length()t.x?t.copy(_closestPlanePoint):t.x=Math.max(t.x,_tpos.x);break;case"Y":_tpos.y+=o*n.y,_pos$3.subVectors(t,_tpos),e=_normalVec.dot(_pos$3),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$3,_normalVec).add(_tpos),_closestPlanePoint.y>t.y?t.copy(_closestPlanePoint):t.y=Math.max(t.y,_tpos.y);break;case"Z":_tpos.z+=o*n.z,_pos$3.subVectors(t,_tpos),e=_normalVec.dot(_pos$3),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$3,_normalVec).add(_tpos),_closestPlanePoint.z>t.z?t.copy(_closestPlanePoint):t.z=Math.max(t.z,_tpos.z);break;case"-X":_tpos.x+=o*n.x,_pos$3.subVectors(t,_tpos),e=_normalVec.dot(_pos$3),_normalVec.multiplyScalar(e),_closestPlanePoint.subVectors(_pos$3,_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$2,(1-this._sfac)*this.influence),e.parent&&e.parent.worldToLocal(e.position)))}}const objPosWorld=new Vector3,objPosTarget=new Vector3,objPosLocal=new Vector3,mat4Tmp=new Matrix4;class LimitLocationConstraint extends TargetConstraint{constructor(e=null){super(e),this.isLimitLocationConstraint=!0,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)}}}const _euler=new Euler;class LimitRotationConstraint extends Constraint{constructor(){super(),this.isLimitRotationConstraint=!0,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}}class LimitScaleConstraint extends Constraint{constructor(){super(),this.isLimitScaleConstraint=!0,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)}}const QUAT_90_MX$3=(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.isLockedTrackConstraint=!0,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$3)}}const UP_WORLD$1=new Vector3(0,1,0),QUAT_90_MX$2=(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.isTrackToConstraint=!0,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],o="-"==this.trackAxis[0],r="-"==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),o&&targetDir.negate(),r&&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$2)}}class FixOrthoZoomConstraint extends TargetConstraint{constructor(e){super(e),this.isFixOrthoZoomConstraint=!0,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}}const _vec3Tmp$2=new Vector3,_vec3Tmp2$1=new Vector3,_quatTmp$1=new Quaternion,_bbox=new Box3,_bsphere=new Sphere;class CanvasFitConstraint extends TargetConstraint{constructor(e){super(e),this.isCanvasFitConstraint=!0,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,o,r;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&&(o=degToRad(t.fov/2),n=Math.atan(t.aspect*Math.tan(o)),"LEFT"==this.edgeH&&(n*=i),"BOTTOM"==this.edgeV&&(o*=a),r=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$2).sub(e.position),n=_bbox.getSize(_vec3Tmp2$1).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 r=_vec3Tmp$2.copy(_bsphere.center).sub(e.position);s=-(_bsphere.radius*i+r.x),l=-(_bsphere.radius*a+r.y),t.isPerspectiveCamera&&(s/=Math.cos(n),l/=Math.cos(o)),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*r*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=r*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*r*Math.tan(o)/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=r*Math.tan(o)+l:e.position.y=(a<0?t.bottom:t.top)/t.zoom+l)}}class CanvasBreakpointsConstraint extends Constraint{constructor(){super(),this.isCanvasBreakpointsConstraint=!0,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 o;switch(this.orientation){case"ALL":o=!0;break;case"LANDSCAPE":o=t/n>=1;break;case"PORTRAIT":o=t/n<1}if(this.appInstance.getCamera()!==e||t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&o)t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&o?e.traverse(e=>{e.internVisible=!0}):e.traverse(e=>{e.internVisible=!1});else{let o=this.findAlternativeCamera(e,this.appInstance.scene,t,n);o&&this.appInstance.setCamera(o)}}findAlternativeCamera(e,t,n,o){let r,i,a=!1;return e&&t.traverse(function(t){if(!a&&t.isCamera&&t!=e)for(let e=0;e=1;break;case"PORTRAIT":r=n/o<1}n>=s.minWidth&&n<=s.maxWidth&&o>=s.minHeight&&o<=s.maxHeight&&r&&(i?(console.error("CanvasBreakpointsConstraint: two or more alternative cameras"),a=!0):i=t)}}}),i}}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,o,r,i){var a,s=[],l=!1;for(a=0;a=0;o--){if(r[o]!==(Array.isArray(e[o])?e[o][1]:e[o])-1){r[o]++;break}r[o]=Array.isArray(e[o])?e[o][0]:0}},accessorPreamble=function(e,t,n,o){var r,i=[];switch(inferType(o)){case inferType.NDARRAY:for(i.push(" const "+t+" = "+n+".data;"),i.push(" const "+t+"Offset = "+n+".offset;"),r=0;r1)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(o)var C="function"==typeof o?o:console.log;if(b)return o&&C(codeCache[e]),b.bind(t);var S=[],E="evaluate"+e,M=n.point;i&&(M=function(e,t){for(var n=[],o=0;o "+N+"[i][1] || a === undefined || isNaN(a)) {"),V(" throw new Error('Invalid Spline parameter in dimension '+i+'. Valid domain is ['+"+N+"[i][0]+', '+"+N+"[i][1]+']. but got t'+i+' = '+arguments[i + 1]+'.');"),V(" }"),V("}")),d=0;d "+O(d)+" + 1) {"),V(" m = 0.5 * (h + "+O(d)+") | 0;"),V(" if ("+I([d,"m"])+" > "+P(d)+") h = m;"),V(" else "+O(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 "+w([d,s+m[d]-1])+" = "+k(O(d)+" < "+-s,I([d,0])+" + "+I([d,[D(d),O(d),s]])+" - "+I([d,[D(d)]]),I([d,[O(d),s]]))+";":s>0?"let "+w([d,s+m[d]-1])+" = "+k(O(d)+" + "+s+" > "+D(d),I([d,D(d)])+" + "+I([d,s+" + "+O(d)+" - "+D(d)])+" - "+I([d,0]),I([d,[O(d),s]]))+";":"let "+w([d,s+m[d]-1])+" = "+I([d,[O(d),s]])+";"):V("let "+w([d,s+m[d]-1])+" = "+I([d,[O(d),s]])+";");else{for(U("\n // Directly compute knot interval for dimension "+d+"\n"),"closed"===x[d]?V(O(d)+" = ("+P(d)+" | 0) % "+D(d)+";"):(V(O(d)+" = ("+P(d)+" | 0);"),V("if ("+O(d)+" < "+m[d]+") "+O(d)+" = "+m[d]+";"),V("if ("+O(d)+" > "+D(d)+" - 1) "+O(d)+" = "+D(d)+" - 1;")),U("\n // Compute and clamp knots for dimension "+d+"\n"),s=1-m[d];s<=m[d];s++)V("let "+(h=w([d,s+m[d]-1]))+" = "+O(d)+" + "+s+";");if("clamped"===x[d])for(s=1-m[d];s<=m[d];s++)h=w([d,s+m[d]-1]),s<0&&V("if ("+h+" < "+m[d]+") "+h+" = "+m[d]+";"),s>0&&V("if ("+h+" > "+D(d)+") "+h+" = "+D(d)+";");"closed"===x[d]&&(U("\n // Wrap the B-Spline parameter for closed boundary"),V(P(d)+" %= "+D(d)+";"))}for(d=0,c=[];d=0;d--)for(c[d]=[m[d],m[d]+1],s=0;ss;l--){var Q=a&&m[d]-s-a[d]<=0;Q?(V("m = 1 / ("+w([d,l-s+m[d]-1])+" - "+w([d,l-1])+");"),_&&(V("a = ("+P(d)+" - "+w([d,l-1])+") * m;"),V("b = 1 - a;"))):(V("a = ("+P(d)+" - "+w([d,l-1])+") / ("+w([d,l-s+m[d]-1])+" - "+w([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,Q&&_&&V("h = "+L(t)+";"),V(L(t)+" = b * "+L(n)+" + a * "+L(t)+";")}),ndloop(c,function(e){var t,n,o,r=e.slice(),a=e.slice();if(r[d]=l,a[d]=l-1,Q){var c=s+1;if(i)t=_?"h * "+L(a)+" / "+L(r)+" * ":"",n=R(r)+(_?" / h":""),o=R(a)+(_?" / "+L(a):""),V(R(r)+" = "+c+" * "+t+"("+n+" - "+o+") * m;");else{var h=r.slice(),f=a.slice();for(u=0;u= 0; "+a+"--) {");for(r=0;r=0;r--)p.push("}");p.push("return this;"),p.push("}");const g=new Function([p.join("\n"),"; return ",f].join(""))();return o&&console.log(p.join("\n")),transformerCache[e]=g,g.bind(t)};var supportCache={};const createSupport=function(e,t,n,o,r){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"),_=o?"domain":"d",A=createVariable(o?"size":"s"),v=createVariable(o?"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 "+v(l)+" + 1) {"),y(" m = 0.5 * (h + "+v(l)+") | 0;"),y(" if ("+m([l,"m"])+" > "+g(l)+") h = m;"),y(" else "+v(l)+" = m;"),y("}")):"closed"===h[l]?y(v(l)+" = ("+g(l)+" | 0) % "+A(l)+";"):(y(v(l)+" = ("+g(l)+" | 0);"),y("if ("+v(l)+" < "+c[l]+") "+v(l)+" = "+c[l]+";"),y("if ("+v(l)+" > "+A(l)+" - 1) "+v(l)+" = "+A(l)+" - 1;"));for(l=0,s=[];l0&&!isArrayLike(this.knots[0])&&(this.knots=[this.knots]),a=0;a0?1:-1;_tmpQuat$1.setFromAxisAngle(t,r.angleTo(o)*n),e.multiply(_tmpQuat$1)}else i<0&&(_tmpQuat$1.setFromAxisAngle(t,Math.PI),e.multiply(_tmpQuat$1));return e}_calcBankAngle(e,t,n,o){const r=_tmpVecF.copy(t).add(n).normalize();return e*(_tmpVecF1.crossVectors(r,t).normalize().dot(o)>0?1:-1)}_calcCurvature(e,t){return _tmpVecF.crossVectors(e,t).length()/Math.pow(e.length(),3)}_calcSecondDerivative(e,t,n,o){this.secondDerivativeEvaluatorForNonUniformBSplines(_tmpArray3,t);const r=_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(r).sub(_tmpVecF1.copy(o).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),o=0,r=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],o=0,r=0,i=t.length-1;for(;ot[r]?o=r+1:i=r-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)}}const QUAT_90_MX=(new Quaternion).setFromAxisAngle(new Vector3(1,0,0),-Math.PI/2),_pos=new Vector3,_quat=new Quaternion,_scale=new Vector3,_rot=new Euler,_mat4Tmp=new Matrix4,_mat4Tmp2=new Matrix4,AXIS_INDEX={X:0,Y:1,Z:2,"-X":0,"-Y":1,"-Z":2},COMP_LIST=["x","y","z"],_vec3Tmp$1=new Vector3,_vec3Tmp2=new Vector3,_vec3Tmp3=new Vector3,_eulerTmp=new Euler;function transformCoordsSpace(e,t,n,o=!1){if(t===n)return e;const r=e.y,i=e.z;return"Z_UP_RIGHT"===t&&"Y_UP_RIGHT"===n?(e.y=i,e.z=o?r:-r):"Y_UP_RIGHT"===t&&"Z_UP_RIGHT"===n?(e.y=o?i:-i,e.z=r):console.error("transformCoordsSpace: Unsupported coordinate space"),e}const transformEulerV3dToBlenderShortest=function(){const e=new Euler,t=new Euler,n=new Vector3;return function(o,r){const i=e.copy(o).reorder("YZX"),a=t.copy(i).makeAlternative(),s=n.setFromEuler(i).lengthSq(),l=n.setFromEuler(a).lengthSq();return r.copy(s-1?c[t]=s[t]+(1-o[COMP_LIST[AXIS_INDEX[this.mapToAxisFromAxis[e]]]])*(l[t]-s[t]):c[t]=s[t]+o[COMP_LIST[AXIS_INDEX[this.mapToAxisFromAxis[e]]]]*(l[t]-s[t])}if("POSITION"==this.mapTo)"ADD"==this.mixMode?c.add(e.position):this.mixMode,e.position.lerp(c,this.influence);else if("ROTATION"==this.mapTo){const t=_quat;if("ADD"==this.mixMode){const n=_eulerTmp.set(0,0,0,"XYZ");"Z_UP_RIGHT"==this.coordSystem?(transformEulerV3dToBlenderShortest(e.rotation,n),transformCoordsSpace(n,this.coordSystem,"Y_UP_RIGHT"),n.x+=c.x,n.y+=c.y,n.z+=c.z,n.order="YZX"):n.set(e.rotation.x+c.x,e.rotation.y+c.y,e.rotation.z+c.z),t.setFromEuler(n)}else{const n=_eulerTmp.setFromVector3(c);"Z_UP_RIGHT"==this.coordSystem&&(n.order="YZX"),t.setFromEuler(n),"AFTER"==this.mixMode?t.premultiply(e.quaternion):"BEFORE"==this.mixMode?t.multiply(e.quaternion):this.mixMode}e.quaternion.slerp(t,this.influence)}else"SCALE"==this.mapTo&&("REPLACE"==this.mixMode||"MULTIPLY"==this.mixMode&&c.multiply(e.scale),e.scale.lerp(c,this.influence));if(0==this.ownerSpace&&e.parent)e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrix.multiplyMatrices(_mat4Tmp.copy(e.parent.matrixWorld).invert(),e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale);else if(1==this.ownerSpace){if(!this.ownerSpaceObj)return;e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorld.premultiply(_mat4Tmp.copy(this.ownerSpaceObj.matrixWorld)),e.matrix.copy(e.matrixWorld),e.parent&&e.matrix.premultiply(_mat4Tmp.copy(e.parent.matrixWorld).invert()),e.matrix.decompose(e.position,e.quaternion,e.scale)}"ROTATION"==this.mapTo&&this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(QUAT_90_MX)}}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","OSL_NODE"],JSON_PROGRESS_RATIO=.3,BIN_PROGRESS_RATIO=1;class GLTFLoader extends Loader{constructor(e){super(e),this.ktx2Loader=null,this.pluginCallbacks=[],this.register(function(e){return new GLTFTextureBasisUExtension(e)}),this.register(function(e){return new GLTFTextureWebPExtension(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,o){const r=this;let i;r.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(r.manager):(s=new FileLoader(r.manager),s.setResponseType("arraybuffer"));const l=function(e){r.onProgress&&r.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{r.parse(e,i,t,o,a)}catch(e){void 0!==o&&o(e.constructor===Error?e:new Error("v3d.GLTFLoader: Unable to parse model."))}},c,o)}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(){return console.error("v3d.GLTFLoader: Mesh optimization is not supported, please use LZMA compression."),this}setDRACOLoader(){return console.error("v3d.GLTFLoader: Draco compression is not supported, please use LZMA compression."),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,o,r){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(o&&o(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(o&&o(new Error("v3d.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=this,u=new GLTFParser(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,loadBinXZ:r,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)},o)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,t,o,r)})}}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_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",EXT_TEXTURE_WEBP:"EXT_texture_webp",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 GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&o.push(n.assignTexture(e,"map",r.baseColorTexture,3001))}return Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,o=n.textures[e];if(!o.extensions||!o.extensions[this.name])return null;const r=o.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("v3d.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.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,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],a=o.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(r){if(r)return n.loadTextureImage(e,i.source,s);if(o.extensionsRequired&&o.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}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("v3d.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("v3d.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,o=new DataView(e,12);let r=0;for(;r(e&&(a.target=e),o=Promise.resolve(a),t.cache.add(n,o),o))}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],r=(o.extensions&&o.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return n._getNodeRef(t.cache,r,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,o=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),o=Promise.resolve(a),t.cache.add(n,o),o})}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],r=(o.extensions&&o.extensions[this.name]||{}).curve;return void 0===r?null:this._loadCurve(r).then(function(e){return n._getNodeRef(t.cache,r,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,o=t.length;n-1){const t=this.getAssetSuite(e);e.match(/(\d+).(\d+).(\d+)/)||(e+=" v0.0.0"),engineVersionCmp(e,"4.11.0",2)<0&&console.warn("Loading glTF with outdated version of Verge3D runtime. Please update your application!"),engineVersionCmp(e,REVISION_EXPORT_MIN[t],3)>0&&console.warn("Loading glTF exported with older version of Verge3D. Please reexport your scene!")}}afterRoot(e){const t=this.parser,n=t.json,o=n.scenes[n.scene||0],r=e.scene,i=isDef(o.extensions)?o.extensions[EXTENSIONS.S8S_V3D_SCENE]:void 0,a=[],s=[],l=[];let c;return c=o&&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{s.ownerSpaceObj=e}),isDef(i.targetSpaceObj)&&n.getDependency("node",i.targetSpaceObj).then(e=>{s.targetSpaceObj=e}),s.useMotionExtrapolate=i.useMotionExtrapolate,s.mixMode=i.mixMode,s.influence=i.influence,s.fixCameraLightRotation=!!isDef(i.fixCameraLightRotation)&&i.fixCameraLightRotation}s&&(s.name=i.name,s.mute=i.mute,e.constraints.push(s))}return e})}}class V3DCameraExtension{constructor(e){this.name=EXTENSIONS.S8S_V3D_CAMERA,this.parser=e}extendCameraParams(e,t){const n=this.parser,o=t.extensions&&t.extensions[this.name];if(!o)return Promise.resolve(e);if(e.controlSettings=new ControlSettings(o.controls,o.enablePan,o.rotateSpeed,o.moveSpeed),e.viewportFit.type=3,isDef(o.viewportFitType))switch(o.viewportFitType){case"VERTICAL":e.viewportFit.type=1;break;case"HORIZONTAL":e.viewportFit.type=2;break;case"AUTO":e.viewportFit.type=3;break;case"FILL":e.viewportFit.type=4;break;case"OVERSCAN":e.viewportFit.type=5}isDef(o.viewportFitInitialAspect)&&(e.viewportFit.initialAspect=o.viewportFitInitialAspect),isDef(o.orbitMinDistance)&&(e.controlSettings.orbitMinDistance=o.orbitMinDistance),isDef(o.orbitMaxDistance)&&(e.controlSettings.orbitMaxDistance=o.orbitMaxDistance),isDef(o.orbitMinZoom)&&(e.controlSettings.orbitMinZoom=o.orbitMinZoom),isDef(o.orbitMaxZoom)&&(e.controlSettings.orbitMaxZoom=o.orbitMaxZoom),isDef(o.orbitMinPolarAngle)&&(e.controlSettings.orbitMinPolarAngle=o.orbitMinPolarAngle),isDef(o.orbitMaxPolarAngle)&&(e.controlSettings.orbitMaxPolarAngle=o.orbitMaxPolarAngle),isDef(o.orbitMinAzimuthAngle)&&(e.controlSettings.orbitMinAzimuthAngle=o.orbitMinAzimuthAngle),isDef(o.orbitMaxAzimuthAngle)&&(e.controlSettings.orbitMaxAzimuthAngle=o.orbitMaxAzimuthAngle);const r=[];if(isDef(o.orbitTarget))if(o.orbitTarget instanceof Array){const e=new Object3D;e.position.fromArray(o.orbitTarget),r.push(Promise.resolve(e))}else r.push(n.getDependency("node",o.orbitTarget));else r.push(Promise.resolve());return isDef(o.fpsCollisionMaterial)?r.push(n.getDependency("material",o.fpsCollisionMaterial)):r.push(Promise.resolve()),isDef(o.fpsGazeLevel)&&(e.controlSettings.gazeLevel=o.fpsGazeLevel),isDef(o.fpsStoryHeight)&&(e.controlSettings.storyHeight=o.fpsStoryHeight),isDef(o.enablePointerLock)&&(e.controlSettings.enablePointerLock=o.enablePointerLock),Promise.all(r).then(t=>(t[0]&&(e.controlSettings.orbitTarget=t[0]),t[1]&&(e.controlSettings.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,o=n.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name],i=[];if(isDef(r.nodeGraph)){const e=MeshNodeMaterial.nodeGraphFromExtGraph(r.nodeGraph);t.nodeGraph=e,MeshNodeMaterial.nodeGraphTraverse(e,e=>{const t=e.originData;TEXTURE_NODES.indexOf(t.type)>-1&&isDef(t.texture)?i.push(this.assignTextureNode(t)):"RAMP_MY"==t.type&&(t.wrapS=WEBGL_WRAPPINGS[t.wrapS]||1e3,t.wrapT=WEBGL_WRAPPINGS[t.wrapT]||1e3)});const o=n.extensions&&n.extensions[this.name]||{};if(o&&o.nodeGraphs){t.additionalNodeGraphs={};for(let e in o.nodeGraphs){const n=MeshNodeMaterial.nodeGraphFromExtGraph(o.nodeGraphs[e]);t.additionalNodeGraphs[e]=n,MeshNodeMaterial.nodeGraphTraverse(n,e=>{const t=e.originData;TEXTURE_NODES.indexOf(t.type)>-1&&i.push(this.assignTextureNode(t))})}}}return isDef(r.profile)&&(t.profile=r.profile),isDef(r.renderSide)&&(t.side=RENDER_SIDES[r.renderSide]),isDef(r.useShadows)&&(t.receiveShadow=r.useShadows),isDef(r.useCastShadows)&&(t.castShadow=r.useCastShadows),isDef(r.depthWrite)&&(t.depthWrite=r.depthWrite),isDef(r.depthPrepass)&&(t.depthPrepass=r.depthPrepass),isDef(r.depthTest)&&(t.depthTest=r.depthTest),isDef(r.dithering)&&(t.dithering=r.dithering),isDef(r.materialIndex)&&(t.materialIndex=r.materialIndex),!0===r.alphaToCoverage&&(t.alphaToCoverage=!0),isDef(r.gtaoVisible)&&(t.gtaoVisible=r.gtaoVisible),delete t.metalness,delete t.roughness,Promise.all(i)}assignTextureNode(e){return this.parser.getDependency("texture",e.texture).then(function(t){e.texture=t})}assignTransparency(e,t,n){const o=t.extensions[this.name]||{};if(e.premultipliedAlpha=n==ALPHA_MODES.BLEND,n==ALPHA_MODES.BLEND)if(isDef(o.blendMode)){const t=o.blendMode;e.blending=5,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=2: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,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t];if(!isDef(i.source))return null;const a=o.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 o=this.name;if(!t.extensions||!t.extensions[o])return null;const r=t.extensions[o],i=r.colorSpace.startsWith("linear")||"non-color"==r.colorSpace?3e3:3001;e.encoding=i,(n instanceof RGBELoader||n instanceof XZLoader)&&(e.minFilter=1006),isDef(r.anisotropy)&&(e.anisotropy=r.anisotropy)}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,n,o){super(e,t,n,o)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,o=this.valueSize,r=e*o*3+o;for(let e=0;e!==o;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,o){const r=this.resultBuffer,i=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=o-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,A=g-d+u;for(let e=0;e!==a;e++){const t=i[f+e+a],n=i[f+e+s]*c,o=i[p+e+a],l=i[p+e]*c;r[e]=_*t+A*n+m*o+g*l}return r}}const _q=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,o){const r=super.interpolate_(e,t,n,o);return _q.fromArray(r).normalize().toArray(r),r}}const WEBGL_CONSTANTS={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},WEBGL_WRAPPINGS={33071:1001,33648:1002,10497:1e3},WEBGL_BLEND_EQUATIONS={32774:100,32778:101,32779:102},WEBGL_BLEND_FUNCS={0:200,1:201,768:202,769:203,770:204,771:205,772:206,773:207,774:208,775:209,776:210},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={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:0,BACK:1,DOUBLE:2,TWO_PASS_DOUBLE:3};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:0,receiveShadow:!0,castShadow:!0})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,n){for(const o in n.extensions)void 0===e[o]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[o]=n.extensions[o])}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 o=!1,r=!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,o=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o=navigator.userAgent.indexOf("Firefox")>-1,r=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||o&&r<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,o=this.json,r=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][o.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:o.asset,parser:n,userData:{}};addUnknownExtensionsToUserData(r,i,o),assignExtrasToUserData(i,o),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,o=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,o]of e.children.entries())r(o,t.children[n])};return r(n,o),o.name+="_instance_"+e.uses[t]++,o}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&d.setY(t,u[e*r+1]),r>=3&&d.setZ(t,u[e*r+2]),r>=4&&d.setW(t,u[e*r+3]),r>=5)throw new Error("v3d.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return d})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,r=t.images[o];let i=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,o,i)}loadTextureImage(e,t,n){const o=this,r=this.json,i=r.textures[e],a=r.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=(r.samplers||{})[i.sampler]||{};return t.magFilter=WEBGL_FILTERS[s.magFilter]||1006,t.minFilter=WEBGL_FILTERS[s.minFilter]||1008,t.wrapS=WEBGL_WRAPPINGS[s.wrapS]||1e3,t.wrapT=WEBGL_WRAPPINGS[s.wrapT]||1e3,o._invokeAll(function(e){return e.extendTextureParams&&e.extendTextureParams(t,i,n)}),o.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this,o=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=o.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,o){let i=n;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Texture(e);t.needsUpdate=!0,n(t)}),t.load(LoaderUtils.resolveURL(e,r.path),i,void 0,o)})}).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,o){return this.getDependency("texture",n.index).then(function(r){return r?(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."),void 0!==o&&(r.encoding=o),e[t]=r,r):null})}assignFinalMaterial(e,t,n){const o=e.geometry;let r=e.material;const i=void 0===o.attributes.tangent,a=void 0!==o.attributes.color&&!r.isMeshNodeMaterial,s=void 0===o.attributes.normal,l=r.isMeshNodeMaterial&&(r.nodeValue.length||r.nodeRGB.length),c=r.isMeshNodeMaterial&&r.hasNode("TEX_COORD_BL"),u=r.isMeshNodeMaterial&&Object.getOwnPropertyNames(t).length>0&&r.hasNode("UVMAP_BL"),d=r.isMeshNodeMaterial&&Object.getOwnPropertyNames(n).length>0&&(r.hasNode("ATTRIBUTE_BL")||r.hasNode("VERTEX_COLOR_BL")||r.hasNode("USER_DATA_COLOR_AR"));if(e.isPoints){const e="PointsMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){const e="LineBasicMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),this.cache.add(e,t)),r=t}if(i||a||s||l||c||u||d){let e="ClonedMaterial:"+r.uuid+":";i&&(e+="derivative-tangents:"),a&&(e+="vertex-colors:"),s&&(e+="flat-shading:");const o=generateUUID();l&&(e=o),c&&(e=o),u&&(e=o),d&&(e=o);let h=this.cache.get(e);h||(h=r.clone(),a&&(h.vertexColors=!0),s&&(h.flatShading=!0),i&&h.normalScale&&(h.normalScale.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(r))),r=h}r.aoMap&&void 0===o.attributes.uv2&&void 0!==o.attributes.uv&&o.setAttribute("uv2",o.attributes.uv),e.material=r,this.assignedMaterials.includes(r)||this.assignedMaterials.push(r)}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,o=this.extensions,r=n.materials[e];let i;const a={},s=r.extensions||{},l=[];if(!0===r.doubleSided&&(a.side=2),s[EXTENSIONS.KHR_MATERIALS_UNLIT]){const e=o[EXTENSIONS.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),l.push(e.extendParams(a,r,t))}else{const n=r.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&&l.push(t.assignTexture(a,"map",n.baseColorTexture,3001)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}const c=r.alphaMode||ALPHA_MODES.OPAQUE;if(c===ALPHA_MODES.BLEND?(a.transparent=!0,i!==MeshNodeMaterial&&(a.depthWrite=!1)):(a.transparent=!1,c===ALPHA_MODES.MASK&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&i!==MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Vector2(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&i!==MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&i!==MeshBasicMaterial&&(a.emissive=(new Color).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&i!==MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,3001)),Promise.all(l).then(function(){const n=new i(a);r.name&&(n.name=r.name),n.map&&(n.map.encoding=3001),n.emissiveMap&&(n.emissiveMap.encoding=3001);const s=t.plugins[EXTENSIONS.S8S_V3D_MATERIALS];return n.isMeshNodeMaterial&&s.assignTransparency(n,r,c),n.isMeshStandardMaterial&&n.normalScale&&s&&isDef(s.profile)&&"max"==s.profile&&(n.normalScale.y=-n.normalScale.y),assignExtrasToUserData(n,r),t.associations.set(n,{materials:e}),r.extensions&&addUnknownExtensionsToUserData(o,n,r),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;this.extensions;const n=this.primitiveCache,o=[];for(let r=0,i=e.length;r0&&updateMorphTargets(h,r),h.name=t.createUniqueName(r.name||"mesh_"+e),assignExtrasToUserData(h,r),d.extensions&&addUnknownExtensionsToUserData(o,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,o=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[h.path]===PATH_PROPERTIES.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 o=h.path.match(/\["(.*)"\]/);n=n&&null!==o&&null!==t.material.findNodeByName(o[1])}else n=!0;n&&_.push(t.name?t.name:t.uuid)})}else _.push(m);let A=u.array;if(u.normalized){const e=getNormalizedComponentScale(A.constructor),t=new Float32Array(A.length);for(let n=0,o=A.length;n1?new Group:1===t.length?t[0]:new Object3D,a!==t[0])for(let e=0,n=t.length;e{o._invokeOne(function(n){if(t!==e)return n.extendNodeParams&&n.extendNodeParams(t,r)})}),o._invokeOne(function(t){return t.extendNodeParams&&t.extendNodeParams(e,r)})})}loadScene(e){const t=this.json,n=this.extensions,o=this.json.scenes[e],r=this,i=new Scene;o.name&&(i.name=r.createUniqueName(o.name)),assignExtrasToUserData(i,o),o.extensions&&addUnknownExtensionsToUserData(n,i,o);const a=o.nodes||[],s=[];for(let e=0,n=a.length;e{const t=new Map;for(const[e,n]of r.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,n);return e.traverse(e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i})}}function buildNodeHierarchy(e,t,n,o){const r=n.nodes[e];return o.getDependency("node",e).then(function(e){return void 0===r.skin?e:o.getDependency("skin",r.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(r.children){const t=r.children;for(let r=0,a=t.length;r-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=5,e.blendEquation=100,e.blendSrc=201,e.blendDst=205}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,o=512){super(),this.scene=e,this.camera=t,this.width=n,this.height=o,this.distance=.1,this.factor=1,this.precision=1,this.bentNormals=!1,this.noiseTexture=this.createNoiseTexture(),this.fsQuad=new FullScreenQuad(null);const r=new DepthTexture;r.type=1014,this.renderTargetNormalDepth=new WebGLRenderTarget(this.width,this.height,{format:1023,depthTexture:r,depthBuffer:!0}),this.renderTargetNormalDepth.texture.name="GTAO.normal",this.renderTargetNormalDepth.depthTexture.name="GTAO.depth",this.renderTargetGTAO=new WebGLRenderTarget(this.width,this.height),this.renderTargetGTAO.texture.name="GTAO.gtao",this.renderTargetBlurX=new WebGLRenderTarget(this.width,this.height),this.renderTargetBlurX.texture.name="GTAO.blur",this.renderTarget=new WebGLRenderTarget(this.width,this.height),this.renderTarget.texture.name="GTAO.rt",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},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.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,o,r,i){const a=e.getRenderTarget(),s=e.getClearColor(_clearColor),l=e.getClearAlpha(),c=e.autoClear,u=this.scene.background;e.setRenderTarget(n),null!=o&&(e.setClearColor(o),e.setClearAlpha(r??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,o,r){const i=e.getRenderTarget(),a=e.getClearColor(_clearColor),s=e.getClearAlpha(),l=e.autoClear;e.setRenderTarget(n),null!=o&&(e.setClearColor(o),e.setClearAlpha(r??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(2048);for(let o=0;o<1024;o++)n[2*o]=e[o],n[2*o+1]=t[o];const o=new DataTexture(n,32,32,1030,1009);return o.name="GTAO.noise",o.wrapS=1e3,o.wrapT=1e3,o.needsUpdate=!0,o}}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 o=this._getIdleWorker();-1!==o?(this._initWorker(o),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 o=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,o]).then(([e,t])=>{const n=KTX2Loader.BasisWorker.toString(),o=["/* 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([o])),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,o){if(null===this.workerConfig)throw new Error("v3d.KTX2Loader: Missing initialization with `.detectSupport(renderer)`.");const r=new FileLoader(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials);const i=new CompressedTexture;return r.load(e,e=>{if(_taskCache.has(e)){return _taskCache.get(e).promise.then(t).catch(o)}this._createTexture([e]).then(function(e){i.copy(e),i.needsUpdate=!0,t&&t(i)}).catch(o)},n,o),i}_createTextureFrom(e){const{mipmaps:t,width:n,height:o,format:r,type:i,error:a,dfdTransferFn:s,dfdFlags:l}=e;if("error"===i)return Promise.reject(a);const c=new CompressedTexture(t,n,o,r,1009);return c.minFilter=1===t.length?1006:1008,c.magFilter=1006,c.generateMipmaps=!1,c.needsUpdate=!0,c.encoding=2===s?3001:3e3,c.premultiplyAlpha=!!(1&l),c}_createTexture(e,t={}){const n=t,o=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:o}),o}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:1023,RGBA_ASTC_4x4_Format:37808,RGBA_BPTC_Format:36492,RGBA_ETC2_EAC_Format:37496,RGBA_PVRTC_4BPPV1_Format:35842,RGBA_S3TC_DXT5_Format:33779,RGB_ETC1_Format:36196,RGB_ETC2_Format:37492,RGB_PVRTC_4BPPV1_Format:35840,RGB_S3TC_DXT1_Format:33776},KTX2Loader.BasisWorker=function(){let e,t,n;const o=_EngineFormat,r=_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:A,engineFormat:v}=function(t,n,a,u){let d,h;const p=t===i.ETC1S?s:l;for(let o=0;o1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}var Stats=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function o(n){for(var o=0;o=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(){r=this.end()}}};Stats.Panel=function(e,t,n){var o=1/0,r=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,_){o=Math.min(o,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,h),g.fillStyle=t,g.fillText(i(l)+" "+e+" ("+i(o)+"-"+i(r)+")",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 _v1=new Vector3,_v2=new Vector3;class VertexNormalsHelper extends LineSegments{constructor(e,t=1,n=16711680){const o=new BufferGeometry,r=e.geometry?.attributes.normal;if(r){const t=e.geometry.attributes.normal.count,n=new Float32BufferAttribute(2*t*3,3);o.setAttribute("position",n)}super(o,new LineBasicMaterial({color:n,toneMapped:!1})),this.object=e,this.size=t,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){const e=this.geometry.attributes.position,t=this.object.geometry?.attributes.position,n=this.object.geometry?.attributes.normal;if(e&&t&&n){let o=0;for(let r=0,i=t.count;r65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}function ensureIndex(e,t){if(!e.index){const n=e.attributes.position.count,o=getIndexArray(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new BufferAttribute(o,1));for(let e=0;ee-t);for(let e=0;ee.offset-t.offset),r=o[o.length-1];r.count=Math.min(n-r.offset,r.count);let i=0;return o.forEach(({count:e})=>i+=e),n!==i}function getBounds(e,t,n,o,r){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0,d=1/0,h=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let o=6*t,r=6*(t+n);ol&&(l=_),tf&&(f=t);const A=e[o+2],v=e[o+3],x=A-v,y=A+v;xc&&(c=y),Am&&(m=A);const b=e[o+4],C=e[o+5],S=b-C,E=b+C;Su&&(u=E),bg&&(g=b)}o[0]=i,o[1]=a,o[2]=s,o[3]=l,o[4]=c,o[5]=u,r[0]=d,r[1]=h,r[2]=p,r[3]=f,r[4]=m,r[5]=g}function computeTriangleBounds(e,t=null,n=null,o=null){const r=e.attributes.position,i=e.index?e.index.array:null,a=getTriCount(e),s=r.normalized;let l;null===t?(l=new Float32Array(6*a),n=0,o=a):(l=t,n=n||0,o=o||a);const c=r.array,u=r.offset||0;const d=["getX","getY","getZ"];for(let e=n;ef&&(f=i),u>f&&(f=u);const m=(f-p)/2,g=2*e;l[n+g+0]=p+m,l[n+g+1]=m+(Math.abs(p)+m)*FLOAT32_EPSILON}}return l}function arrayToBox(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function getLongestEdgeIndex(e){let t=-1,n=-1/0;for(let o=0;o<3;o++){const r=e[o+3]-e[o];r>n&&(n=r,t=o)}return t}function copyBounds(e,t){t.set(e)}function unionBounds(e,t,n){let o,r;for(let i=0;i<3;i++){const a=i+3;o=e[i],r=t[i],n[i]=or?o:r}}function expandByTriangleBounds(e,t,n){for(let o=0;o<3;o++){const r=t[e+2*o],i=t[e+2*o+1],a=r-i,s=r+i;an[o+3]&&(n[o+3]=s)}}function computeSurfaceArea(e){const t=e[3]-e[0],n=e[4]-e[1],o=e[5]-e[2];return 2*(t*n+n*o+o*t)}const BIN_COUNT=32,binsSort=(e,t)=>e.candidate-t.candidate,sahBins=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),leftBounds=new Float32Array(6);function getOptimalSplit(e,t,n,o,r,i){let a=-1,s=0;if(0===i)a=getLongestEdgeIndex(t),-1!==a&&(s=(t[a]+t[a+3])/2);else if(1===i)a=getLongestEdgeIndex(e),-1!==a&&(s=getAverage(n,o,r,a));else if(2===i){const i=computeSurfaceArea(e);let l=1.25*r;const c=6*o,u=6*(o+r);for(let e=0;e<3;e++){const o=t[e],d=(t[e+3]-o)/32;if(r<8){const t=[...sahBins];t.length=r;let o=0;for(let r=c;r=i.candidate?expandByTriangleBounds(o,n,i.rightCacheBounds):(expandByTriangleBounds(o,n,i.leftCacheBounds),i.count++)}}for(let n=0;n=32&&(r=31);const i=sahBins[r];i.count++,expandByTriangleBounds(t,n,i.bounds)}const t=sahBins[31];copyBounds(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=sahBins[e],n=sahBins[e+1];unionBounds(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let h=0;for(let t=0;t<31;t++){const n=sahBins[t],o=n.count,c=n.bounds,u=sahBins[t+1].rightCacheBounds;0!==o&&(0===h?copyBounds(c,leftBounds):unionBounds(c,leftBounds,leftBounds)),h+=o;let d=0,p=0;0!==h&&(d=computeSurfaceArea(leftBounds)/i);const f=r-h;0!==f&&(p=computeSurfaceArea(u)/i);const m=1+1.25*(d*h+p*f);m=l;)s--;if(!(a=l;)s--;if(!(aMAX_POINTER)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return uint32Array[n+6]=a/4,a=_populateBuffer(a,r),uint32Array[n+7]=i,a}}function generateIndirectBuffer(e,t){const n=(e.index?e.index.count:e.attributes.position.count)/3,o=n>65536,r=o?4:2,i=t?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),a=o?new Uint32Array(i):new Uint16Array(i);for(let e=0,t=a.length;e=i&&(_=!0,a&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(h)));if(r<=s||u>=i)return v(o+r),n.offset=o,n.count=r,n;const m=getOptimalSplit(n.boundingData,c,t,o,r,l);if(-1===m.axis)return v(o+r),n.offset=o,n.count=r,n;const A=f(d,p,t,o,r,m);if(A===o||A===o+r)v(o+r),n.offset=o,n.count=r;else{n.splitAxis=m.axis;const i=new MeshBVHNode,a=o,s=A-o;n.left=i,getBounds(t,a,s,i.boundingData,g),e(i,a,s,g,u+1);const l=new MeshBVHNode,c=A,d=r-s;n.right=l,getBounds(t,c,d,l.boundingData,g),e(l,c,d,g,u+1)}return n}(A,n,o,g),A;function v(e){c&&c(e/m)}}function buildPackedTree(e,t){const n=e.geometry;t.indirect&&(e._indirectBuffer=generateIndirectBuffer(n,t.useSharedArrayBuffer),hasGroupGaps(n,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),e._indirectBuffer||ensureIndex(n,t);const o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=computeTriangleBounds(n),i=t.indirect?getFullGeometryRange(n,t.range):getRootIndexRanges(n,t.range);e._roots=i.map(n=>{const i=buildTree(e,r,n.offset,n.count,t),a=countNodes(i),s=new o(32*a);return populateBuffer(0,i,s),s})}class SeparatingAxisBounds{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,o=-1/0;for(let r=0,i=e.length;ro?i:o}this.min=n,this.max=o}setFromPoints(e,t){let n=1/0,o=-1/0;for(let r=0,i=t.length;ro?a:o}this.min=n,this.max=o}isSeparated(e){return this.min>e.max||e.min>this.max}}SeparatingAxisBounds.prototype.setFromBox=function(){const e=new Vector3;return function(t,n){const o=n.min,r=n.max;let i=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let s=0;s<=1;s++)for(let l=0;l<=1;l++){e.x=o.x*n+r.x*(1-n),e.y=o.y*s+r.y*(1-s),e.z=o.z*l+r.z*(1-l);const c=t.dot(e);i=Math.min(c,i),a=Math.max(c,a)}this.min=i,this.max=a}}();const closestPointLineToLine=function(){const e=new Vector3,t=new Vector3,n=new Vector3;return function(o,r,i){const a=o.start,s=e,l=r.start,c=t;n.subVectors(a,l),e.subVectors(o.end,o.start),t.subVectors(r.end,r.start);const u=n.dot(c),d=c.dot(s),h=c.dot(c),p=n.dot(s),f=s.dot(s)*h-d*d;let m,g;m=0!==f?(u*d-p*h)/f:0,g=(u+m*d)/h,i.x=m,i.y=g}}(),closestPointsSegmentToSegment=function(){const e=new Vector2,t=new Vector3,n=new Vector3;return function(o,r,i,a){closestPointLineToLine(o,r,e);let s=e.x,l=e.y;if(s>=0&&s<=1&&l>=0&&l<=1)return o.at(s,i),void r.at(l,a);if(s>=0&&s<=1)return l<0?r.at(0,a):r.at(1,a),void o.closestPointToPoint(a,!0,i);if(l>=0&&l<=1)return s<0?o.at(0,i):o.at(1,i),void r.closestPointToPoint(i,!0,a);{let e,c;e=s<0?o.start:o.end,c=l<0?r.start:r.end;const u=t,d=n;return o.closestPointToPoint(c,!0,t),r.closestPointToPoint(e,!0,n),u.distanceToSquared(c)<=d.distanceToSquared(e)?(i.copy(u),void a.copy(c)):(i.copy(e),void a.copy(d))}}}(),sphereIntersectTriangle=function(){const e=new Vector3,t=new Vector3,n=new Plane,o=new Line3;return function(r,i){const{radius:a,center:s}=r,{a:l,b:c,c:u}=i;o.start=l,o.end=c;if(o.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;o.start=l,o.end=u;if(o.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;o.start=c,o.end=u;if(o.closestPointToPoint(s,!0,e).distanceTo(s)<=a)return!0;const d=i.getPlane(n);if(Math.abs(d.distanceToPoint(s))<=a){const e=d.projectPoint(s,t);if(i.containsPoint(e))return!0}return!1}}(),ZERO_EPSILON=1e-15;function isNearZero(e){return Math.abs(e)<1e-15}class ExtendedTriangle extends Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new Vector3),this.satBounds=new Array(4).fill().map(()=>new SeparatingAxisBounds),this.points=[this.a,this.b,this.c],this.sphere=new Sphere,this.plane=new Plane,this.needsUpdate=!0}intersectsSphere(e){return sphereIntersectTriangle(e,this)}update(){const e=this.a,t=this.b,n=this.c,o=this.points,r=this.satAxes,i=this.satBounds,a=r[0],s=i[0];this.getNormal(a),s.setFromPoints(a,o);const l=r[1],c=i[1];l.subVectors(e,t),c.setFromPoints(l,o);const u=r[2],d=i[2];u.subVectors(t,n),d.setFromPoints(u,o);const h=r[3],p=i[3];h.subVectors(n,e),p.setFromPoints(h,o),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ExtendedTriangle.prototype.closestPointToSegment=function(){const e=new Vector3,t=new Vector3,n=new Line3;return function(o,r=null,i=null){const{start:a,end:s}=o,l=this.points;let c,u=1/0;for(let a=0;a<3;a++){const s=(a+1)%3;n.start.copy(l[a]),n.end.copy(l[s]),closestPointsSegmentToSegment(n,o,e,t),c=e.distanceToSquared(t),c=2){(1===i?n.start:n.end).copy(p),r=2;break}if(r++,2===r&&-1===i)break}}return r}return function(a,u=null,p=!1){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);const m=this.plane,g=a.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){const e=this.satBounds,s=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let t=0;t<4;t++){const r=e[t],i=s[t];if(o.setFromPoints(i,n),r.isSeparated(o))return!1}const l=a.satBounds,c=a.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let e=0;e<4;e++){const n=l[e],r=c[e];if(o.setFromPoints(r,t),n.isSeparated(o))return!1}for(let e=0;e<4;e++){const a=s[e];for(let e=0;e<4;e++){const s=c[e];if(i.crossVectors(a,s),o.setFromPoints(i,t),r.setFromPoints(i,n),o.isSeparated(r))return!1}}return u&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),u.start.set(0,0,0),u.end.set(0,0,0)),!0}{const e=f(this,g,d);if(1===e&&a.containsPoint(d.end))return u&&(u.start.copy(d.end),u.end.copy(d.end)),!0;if(2!==e)return!1;const t=f(a,m,h);if(1===t&&this.containsPoint(h.end))return u&&(u.start.copy(h.end),u.end.copy(h.end)),!0;if(2!==t)return!1;if(d.delta(s),h.delta(l),s.dot(l)<0){let e=h.start;h.start=h.end,h.end=e}const n=d.start.dot(s),o=d.end.dot(s),r=h.start.dot(s),i=h.end.dot(s);return(n===i||r===o||o0?u.start.copy(d.start):u.start.copy(h.start),c.subVectors(d.end,h.end),c.dot(s)<0?u.end.copy(d.end):u.end.copy(h.end)),!0)}}}(),ExtendedTriangle.prototype.distanceToPoint=function(){const e=new Vector3;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),ExtendedTriangle.prototype.distanceToTriangle=function(){const e=new Vector3,t=new Vector3,n=["a","b","c"],o=new Line3,r=new Line3;return function(i,a=null,s=null){const l=a||s?o:null;if(this.intersectsTriangle(i,l))return(a||s)&&(a&&l.getCenter(a),s&&l.getCenter(s)),0;let c=1/0;for(let t=0;t<3;t++){let o;const r=n[t],l=i[r];this.closestPointToPoint(l,e),o=l.distanceToSquared(e),onew Vector3),this.satAxes=new Array(3).fill().map(()=>new Vector3),this.satBounds=new Array(3).fill().map(()=>new SeparatingAxisBounds),this.alignedSatBounds=new Array(3).fill().map(()=>new SeparatingAxisBounds),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}OrientedBox.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,o=this.points;for(let r=0;r<=1;r++)for(let i=0;i<=1;i++)for(let a=0;a<=1;a++){const s=o[1*r|2*i|4*a];s.x=r?n.x:t.x,s.y=i?n.y:t.y,s.z=a?n.z:t.z,s.applyMatrix4(e)}const r=this.satBounds,i=this.satAxes,a=o[0];for(let e=0;e<3;e++){const t=i[e],n=r[e],s=o[1<new Line3),n=new Array(12).fill().map(()=>new Line3),o=new Vector3,r=new Vector3;return function(i,a=0,s=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(i))return(s||l)&&(i.getCenter(r),this.closestPointToPoint(r,o),i.closestPointToPoint(o,r),s&&s.copy(o),l&&l.copy(r)),0;const c=a*a,u=i.min,d=i.max,h=this.points;let p=1/0;for(let e=0;e<8;e++){const t=h[e];r.copy(t).clamp(u,d);const n=t.distanceToSquared(r);if(nnew ExtendedTriangle)}}const ExtendedTrianglePool=new ExtendedTrianglePoolBase;class _BufferStack{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}}const BufferStack=new _BufferStack;let _box1,_box2;const boxStack=[],boxPool=new PrimitivePool(()=>new Box3);function shapecast(e,t,n,o,r,i){_box1=boxPool.getPrimitive(),_box2=boxPool.getPrimitive(),boxStack.push(_box1,_box2),BufferStack.setBuffer(e._roots[t]);const a=shapecastTraverse(0,e.geometry,n,o,r,i);BufferStack.clearBuffer(),boxPool.releasePrimitive(_box1),boxPool.releasePrimitive(_box2),boxStack.pop(),boxStack.pop();const s=boxStack.length;return s>0&&(_box2=boxStack[s-1],_box1=boxStack[s-2]),a}function shapecastTraverse(e,t,n,o,r=null,i=0,a=0){const{float32Array:s,uint16Array:l,uint32Array:c}=BufferStack;let u=2*e;if(IS_LEAF(u,l)){const p=OFFSET(e,c),f=COUNT(u,l);return arrayToBox(BOUNDING_DATA_INDEX(e),s,_box1),o(p,f,!1,a,i+e,_box1)}{const m=LEFT_NODE(e),g=RIGHT_NODE(e,c);let _,A,v,x,y=m,b=g;if(r&&(v=_box1,x=_box2,arrayToBox(BOUNDING_DATA_INDEX(y),s,v),arrayToBox(BOUNDING_DATA_INDEX(b),s,x),_=r(v),A=r(x),A<_)){y=g,b=m;const T=_;_=A,A=T,v=x}v||(v=_box1,arrayToBox(BOUNDING_DATA_INDEX(y),s,v));const C=n(v,IS_LEAF(2*y,l),_,a+1,i+y);let S;if(2===C){const I=d(y);S=o(I,h(y)-I,!0,a+1,i+y,v)}else S=C&&shapecastTraverse(y,t,n,o,r,i,a+1);if(S)return!0;x=_box2,arrayToBox(BOUNDING_DATA_INDEX(b),s,x);const E=n(x,IS_LEAF(2*b,l),A,a+1,i+b);let M;if(2===E){const w=d(b);M=o(w,h(b)-w,!0,a+1,i+b,x)}else M=E&&shapecastTraverse(b,t,n,o,r,i,a+1);return!!M;function d(e){const{uint16Array:t,uint32Array:n}=BufferStack;let o=2*e;for(;!IS_LEAF(o,t);)o=2*(e=LEFT_NODE(e));return OFFSET(e,n)}function h(e){const{uint16Array:t,uint32Array:n}=BufferStack;let o=2*e;for(;!IS_LEAF(o,t);)o=2*(e=RIGHT_NODE(e,n));return OFFSET(e,n)+COUNT(o,t)}}}const temp=new Vector3,temp1$2=new Vector3;function closestPointToPoint(e,t,n={},o=0,r=1/0){const i=o*o,a=r*r;let s=1/0,l=null;if(e.shapecast({boundsTraverseOrder:e=>(temp.copy(t).clamp(e.min,e.max),temp.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n{e.closestPointToPoint(t,temp);const o=t.distanceToSquared(temp);return o=169,_vA=new Vector3,_vB=new Vector3,_vC=new Vector3,_uvA=new Vector2,_uvB=new Vector2,_uvC=new Vector2,_normalA=new Vector3,_normalB=new Vector3,_normalC=new Vector3,_intersectionPoint=new Vector3;function checkIntersection(e,t,n,o,r,i,a,s){let l;if(l=1===i?e.intersectTriangle(o,n,t,!0,r):e.intersectTriangle(t,n,o,2!==i,r),null===l)return null;const c=e.origin.distanceTo(r);return cs?null:{distance:c,point:r.clone()}}function checkBufferGeometryIntersection(e,t,n,o,r,i,a,s,l,c,u){_vA.fromBufferAttribute(t,i),_vB.fromBufferAttribute(t,a),_vC.fromBufferAttribute(t,s);const d=checkIntersection(e,_vA,_vB,_vC,_intersectionPoint,l,c,u);if(d){const t=new Vector3;Triangle.getBarycoord(_intersectionPoint,_vA,_vB,_vC,t),o&&(_uvA.fromBufferAttribute(o,i),_uvB.fromBufferAttribute(o,a),_uvC.fromBufferAttribute(o,s),d.uv=Triangle.getInterpolation(_intersectionPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2)),r&&(_uvA.fromBufferAttribute(r,i),_uvB.fromBufferAttribute(r,a),_uvC.fromBufferAttribute(r,s),d.uv1=Triangle.getInterpolation(_intersectionPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2)),n&&(_normalA.fromBufferAttribute(n,i),_normalB.fromBufferAttribute(n,a),_normalC.fromBufferAttribute(n,s),d.normal=Triangle.getInterpolation(_intersectionPoint,_vA,_vB,_vC,_normalA,_normalB,_normalC,new Vector3),d.normal.dot(e.direction)>0&&d.normal.multiplyScalar(-1));const l={a:i,b:a,c:s,normal:new Vector3,materialIndex:0};Triangle.getNormal(_vA,_vB,_vC,l.normal),d.face=l,d.faceIndex=i,IS_GT_REVISION_169&&(d.barycoord=t)}return d}function intersectTri(e,t,n,o,r,i,a){const s=3*o;let l=s+0,c=s+1,u=s+2;const d=e.index;e.index&&(l=d.getX(l),c=d.getX(c),u=d.getX(u));const{position:h,normal:p,uv:f,uv1:m}=e.attributes,g=checkBufferGeometryIntersection(n,h,p,f,m,l,c,u,t,i,a);return g?(g.faceIndex=o,r&&r.push(g),g):null}function setTriangle(e,t,n,o){const r=e.a,i=e.b,a=e.c;let s=t,l=t+1,c=t+2;n&&(s=n.getX(s),l=n.getX(l),c=n.getX(c)),r.x=o.getX(s),r.y=o.getY(s),r.z=o.getZ(s),i.x=o.getX(l),i.y=o.getY(l),i.z=o.getZ(l),a.x=o.getX(c),a.y=o.getY(c),a.z=o.getZ(c)}function intersectTris(e,t,n,o,r,i,a,s){const{geometry:l,_indirectBuffer:c}=e;for(let e=o,c=o+r;ed&&(d=a),sh&&(h=s),lp&&(p=l)}return(l[e+0]!==n||l[e+1]!==i||l[e+2]!==u||l[e+3]!==d||l[e+4]!==h||l[e+5]!==p)&&(l[e+0]=n,l[e+1]=i,l[e+2]=u,l[e+3]=d,l[e+4]=h,l[e+5]=p,!0)}{const o=e+8,r=a[e+6],s=o+n,c=r+n;let u=i,h=!1,p=!1;t?u||(h=t.has(s),p=t.has(c),u=!h&&!p):(h=!0,p=!0);const f=u||p;let m=!1;(u||h)&&(m=d(o,n,u));let g=!1;f&&(g=d(r,n,u));const _=m||g;if(_)for(let t=0;t<3;t++){const n=o+t,i=r+t,a=l[n],s=l[n+3],c=l[i],u=l[i+3];l[e+t]=au?s:u}return _}}}function intersectRay(e,t,n,o,r){let i,a,s,l,c,u;const d=1/n.direction.x,h=1/n.direction.y,p=1/n.direction.z,f=n.origin.x,m=n.origin.y,g=n.origin.z;let _=t[e],A=t[e+3],v=t[e+1],x=t[e+3+1],y=t[e+2],b=t[e+3+2];return d>=0?(i=(_-f)*d,a=(A-f)*d):(i=(A-f)*d,a=(_-f)*d),h>=0?(s=(v-m)*h,l=(x-m)*h):(s=(x-m)*h,l=(v-m)*h),!(i>l||s>a)&&((s>i||isNaN(i))&&(i=s),(l=0?(c=(y-g)*p,u=(b-g)*p):(c=(b-g)*p,u=(y-g)*p),!(i>u||c>a)&&((c>i||i!=i)&&(i=c),(u=o))}function intersectTris_indirect(e,t,n,o,r,i,a,s){const{geometry:l,_indirectBuffer:c}=e;for(let e=o,u=o+r;e=0;let d,h;u?(d=LEFT_NODE(e),h=RIGHT_NODE(e,l)):(d=RIGHT_NODE(e,l),h=LEFT_NODE(e));const p=intersectRay(d,a,o,r,i)?_raycastFirst$1(d,t,n,o,r,i):null;if(p){const e=p.point[c];if(u?e<=a[h+s]:e>=a[h+s+3])return p}const f=intersectRay(h,a,o,r,i)?_raycastFirst$1(h,t,n,o,r,i):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const boundingBox$1=new Box3,triangle$1=new ExtendedTriangle,triangle2$1=new ExtendedTriangle,invertedMat$1=new Matrix4,obb$4=new OrientedBox,obb2$3=new OrientedBox;function intersectsGeometry(e,t,n,o){BufferStack.setBuffer(e._roots[t]);const r=_intersectsGeometry$1(0,e,n,o);return BufferStack.clearBuffer(),r}function _intersectsGeometry$1(e,t,n,o,r=null){const{float32Array:i,uint16Array:a,uint32Array:s}=BufferStack;let l=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),obb$4.set(n.boundingBox.min,n.boundingBox.max,o),r=obb$4);if(!IS_LEAF(l,a)){const a=e+8,l=s[e+6];arrayToBox(BOUNDING_DATA_INDEX(a),i,boundingBox$1);if(r.intersectsBox(boundingBox$1)&&_intersectsGeometry$1(a,t,n,o,r))return!0;arrayToBox(BOUNDING_DATA_INDEX(l),i,boundingBox$1);return!!(r.intersectsBox(boundingBox$1)&&_intersectsGeometry$1(l,t,n,o,r))}{const r=t.geometry,c=r.index,u=r.attributes.position,d=n.index,h=n.attributes.position,p=OFFSET(e,s),f=COUNT(l,a);if(invertedMat$1.copy(o).invert(),n.boundsTree){arrayToBox(BOUNDING_DATA_INDEX(e),i,obb2$3),obb2$3.matrix.copy(invertedMat$1),obb2$3.needsUpdate=!0;const t=n.boundsTree.shapecast({intersectsBounds:e=>obb2$3.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(o),e.b.applyMatrix4(o),e.c.applyMatrix4(o),e.needsUpdate=!0;for(let t=3*p,n=3*(f+p);tobb$3.distanceToBox(e),intersectsBounds:(e,t,n)=>n{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>obb2$2.distanceToBox(e),intersectsBounds:(e,t,n)=>n{for(let a=t,s=t+r;ah&&(h=a),sp&&(p=s),lf&&(f=l)}}return(l[n+0]!==i||l[n+1]!==c||l[n+2]!==d||l[n+3]!==h||l[n+4]!==p||l[n+5]!==f)&&(l[n+0]=i,l[n+1]=c,l[n+2]=d,l[n+3]=h,l[n+4]=p,l[n+5]=f,!0)}{const e=n+8,o=a[n+6],r=e+i,s=o+i;let u=c,h=!1,p=!1;t?u||(h=t.has(r),p=t.has(s),u=!h&&!p):(h=!0,p=!0);const f=u||p;let m=!1;(u||h)&&(m=d(e,i,u));let g=!1;f&&(g=d(o,i,u));const _=m||g;if(_)for(let t=0;t<3;t++){const r=e+t,i=o+t,a=l[r],s=l[r+3],c=l[i],u=l[i+3];l[n+t]=au?s:u}return _}}}function raycast_indirect(e,t,n,o,r,i,a){BufferStack.setBuffer(e._roots[t]),_raycast(0,e,n,o,r,i,a),BufferStack.clearBuffer()}function _raycast(e,t,n,o,r,i,a){const{float32Array:s,uint16Array:l,uint32Array:c}=BufferStack,u=2*e;if(IS_LEAF(u,l)){intersectTris_indirect(t,n,o,OFFSET(e,c),COUNT(u,l),r,i,a)}else{const l=LEFT_NODE(e);intersectRay(l,s,o,i,a)&&_raycast(l,t,n,o,r,i,a);const u=RIGHT_NODE(e,c);intersectRay(u,s,o,i,a)&&_raycast(u,t,n,o,r,i,a)}}const _xyzFields=["x","y","z"];function raycastFirst_indirect(e,t,n,o,r,i){BufferStack.setBuffer(e._roots[t]);const a=_raycastFirst(0,e,n,o,r,i);return BufferStack.clearBuffer(),a}function _raycastFirst(e,t,n,o,r,i){const{float32Array:a,uint16Array:s,uint32Array:l}=BufferStack;let c=2*e;if(IS_LEAF(c,s)){return intersectClosestTri_indirect(t,n,o,OFFSET(e,l),COUNT(c,s),r,i)}{const s=SPLIT_AXIS(e,l),c=_xyzFields[s],u=o.direction[c]>=0;let d,h;u?(d=LEFT_NODE(e),h=RIGHT_NODE(e,l)):(d=RIGHT_NODE(e,l),h=LEFT_NODE(e));const p=intersectRay(d,a,o,r,i)?_raycastFirst(d,t,n,o,r,i):null;if(p){const e=p.point[c];if(u?e<=a[h+s]:e>=a[h+s+3])return p}const f=intersectRay(h,a,o,r,i)?_raycastFirst(h,t,n,o,r,i):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const boundingBox=new Box3,triangle=new ExtendedTriangle,triangle2=new ExtendedTriangle,invertedMat=new Matrix4,obb$2=new OrientedBox,obb2$1=new OrientedBox;function intersectsGeometry_indirect(e,t,n,o){BufferStack.setBuffer(e._roots[t]);const r=_intersectsGeometry(0,e,n,o);return BufferStack.clearBuffer(),r}function _intersectsGeometry(e,t,n,o,r=null){const{float32Array:i,uint16Array:a,uint32Array:s}=BufferStack;let l=2*e;null===r&&(n.boundingBox||n.computeBoundingBox(),obb$2.set(n.boundingBox.min,n.boundingBox.max,o),r=obb$2);if(!IS_LEAF(l,a)){const a=e+8,l=s[e+6];arrayToBox(BOUNDING_DATA_INDEX(a),i,boundingBox);if(r.intersectsBox(boundingBox)&&_intersectsGeometry(a,t,n,o,r))return!0;arrayToBox(BOUNDING_DATA_INDEX(l),i,boundingBox);return!!(r.intersectsBox(boundingBox)&&_intersectsGeometry(l,t,n,o,r))}{const r=t.geometry,c=r.index,u=r.attributes.position,d=n.index,h=n.attributes.position,p=OFFSET(e,s),f=COUNT(l,a);if(invertedMat.copy(o).invert(),n.boundsTree){arrayToBox(BOUNDING_DATA_INDEX(e),i,obb2$1),obb2$1.matrix.copy(invertedMat),obb2$1.needsUpdate=!0;const r=n.boundsTree.shapecast({intersectsBounds:e=>obb2$1.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(o),e.b.applyMatrix4(o),e.c.applyMatrix4(o),e.needsUpdate=!0;for(let n=p,o=f+p;nobb$1.distanceToBox(e),intersectsBounds:(e,t,n)=>n{if(t.boundsTree){const s=t.boundsTree;return s.shapecast({boundsTraverseOrder:e=>obb2.distanceToBox(e),intersectsBounds:(e,t,n)=>n{for(let y=t,b=t+a;ynew Box3),_leftBox1=new Box3,_rightBox1=new Box3,_leftBox2=new Box3,_rightBox2=new Box3;let _active=!1;function bvhcast(e,t,n,o){if(_active)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");_active=!0;const r=e._roots,i=t._roots;let a,s=0,l=0;const c=(new Matrix4).copy(n).invert();for(let e=0,t=r.length;ee.slice()),index:i?i.array.slice():null,indirectBuffer:r?r.slice():null}:{roots:o,index:i?i.array:null,indirectBuffer:r},a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:Boolean(e.indirectBuffer),...n};const{index:o,roots:r,indirectBuffer:i}=e,a=new MeshBVH(t,{...n,[SKIP_GENERATION]:!0});if(a._roots=r,a._indirectBuffer=i||null,n.setIndex){const n=t.getIndex();if(null===n){const n=new BufferAttribute(e.index,1,!1);t.setIndex(n)}else n.array!==o&&(n.array.set(o),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if((t=Object.assign({...DEFAULT_OPTIONS,[SKIP_GENERATION]:!1},t)).useSharedArrayBuffer&&!isSharedArrayBufferSupported())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[SKIP_GENERATION]||(buildPackedTree(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Box3))),this.resolveTriangleIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e}refit(e=null){return(this.indirect?refit_indirect:refit)(this,e)}traverse(e,t=0){const n=this._roots[t],o=new Uint32Array(n),r=new Uint16Array(n);!function t(i,a=0){const s=2*i,l=65535===r[s+15];if(l){const t=o[i+6],c=r[s+14];e(a,l,new Float32Array(n,4*i,6),t,c)}else{const r=i+8,s=o[i+6],c=o[i+7];e(a,l,new Float32Array(n,4*i,6),c)||(t(r,a+1),t(s,a+1))}}(0)}raycast(e,t=0,n=0,o=1/0){const r=this._roots,i=this.geometry,a=[],s=t.isMaterial,l=Array.isArray(t),c=i.groups,u=s?t.side:t,d=this.indirect?raycast_indirect:raycast;for(let i=0,s=r.length;i!!e(o,r,i,s,l)||n(o,r,this,a,i,s,t)}else i||(i=a?(e,o,r,i)=>n(e,o,this,a,r,i,t):(e,t,n)=>n);let s=!1,l=0;const c=this._roots;for(let e=0,t=c.length;e{const t=this.resolveTriangleIndex(e);setTriangle(i,3*t,a,s)}:e=>{setTriangle(i,3*e,a,s)},c=ExtendedTrianglePool.getPrimitive(),u=e.geometry.index,d=e.geometry.attributes.position,h=e.indirect?t=>{const n=e.resolveTriangleIndex(t);setTriangle(c,3*n,u,d)}:e=>{setTriangle(c,3*e,u,d)};if(r){const e=(e,n,o,a,s,u,d,p)=>{for(let f=o,m=o+a;fobb.intersectsBox(e),intersectsTriangle:e=>obb.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},o={},r=0,i=1/0){return(this.indirect?closestPointToGeometry_indirect:closestPointToGeometry)(this,e,t,n,o,r,i)}closestPointToPoint(e,t={},n=0,o=1/0){return closestPointToPoint(this,e,t,n,o)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach(t=>{arrayToBox(0,new Float32Array(t),tempBox),e.union(tempBox)}),e}}class BatchedMesh extends Mesh{}function convertRaycastIntersect(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}const ray=new Ray,direction=new Vector3,tmpInverseMatrix=new Matrix4,origMeshRaycastFunc=Mesh.prototype.raycast,origBatchedRaycastFunc=BatchedMesh.prototype.raycast,_worldScale=new Vector3,_mesh=new Mesh,_batchIntersects=[];function acceleratedRaycast(e,t){this.isBatchedMesh?acceleratedBatchedMeshRaycast.call(this,e,t):acceleratedMeshRaycast.call(this,e,t)}function acceleratedBatchedMeshRaycast(e,t){if(this.boundsTrees){const n=this.boundsTrees,o=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,i=this.matrixWorld;_mesh.material=this.material,_mesh.geometry=this.geometry;const a=_mesh.geometry.boundsTree,s=_mesh.geometry.drawRange;null===_mesh.geometry.boundingSphere&&(_mesh.geometry.boundingSphere=new Sphere);for(let a=0,s=o.length;aFind out how to fix this here.';return void Detector.showWebGLErrorMessage(this.container,e)}ColorManagement.legacyMode=!1;const o={};o.alpha=!!isDef(t.alpha)&&t.alpha,o.depth=!isDef(t.depth)||t.depth,o.stencil=!isDef(t.stencil)||t.stencil,o.antialias=!isDef(t.antialias)||t.antialias,o.premultipliedAlpha=!isDef(t.premultipliedAlpha)||t.premultipliedAlpha,o.preserveDrawingBuffer=!!isDef(t.preserveDrawingBuffer)&&t.preserveDrawingBuffer,Detector.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy context AA on Safari 15.4"),o.antialias=!1),this.renderer=new WebGLRenderer(o),Compat.prepareRenderer(this.renderer),this.clearBkgOnLoad=!1,this.registerServiceKeys=!0,this.frameRateDivider=1,this.enableRender=!0,this.disableRenderTrigger=0,this.ssaaOnPause=!1,this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.renderer.outputEncoding=3001,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 r=(new KTX2Loader).setTranscoderPath(findModulePath()).detectSupport(this.renderer);this.loader.setKTX2Loader(r),BufferGeometry.prototype.computeBoundsTree=computeBoundsTree,BufferGeometry.prototype.disposeBoundsTree=disposeBoundsTree,Mesh.prototype.raycast=acceleratedRaycast,this.actions=[],this._envIBLMode=0,this._envLightProbe=null,this._resizeCb=null,this._loadSceneURL="",this._loadingTime=0,this._webxrSave={background:null,postprocessing:null,useOIT:!1},this.cssRenderer=null,this.cssScene=null,this.stats=null,AppUtils.drawWatermark(this),AppUtils.addToAppList(this)}_updateRendererFromGLTF(e){const t=this,n=Detector.checkHalfFloatTex(this.renderer,!0),o=this.renderer.capabilities.isWebGL2;if(e.renderer.shadowMap&&(this.renderer.shadowMap.enabled=e.renderer.shadowMap.enabled,this.renderer.shadowMap.type=e.renderer.shadowMap.type,n||3!==this.renderer.shadowMap.type||(this.renderer.shadowMap.type=2,e.scene.traverse(function(e){e.isLight&&e.castShadow&&e.shadow&&(e.shadow.bias/=100)}))),this.aaMethod=e.renderer.aaMethod??"AUTO","AUTO"===this.aaMethod||o||(console.warn("v3d.App: setting anti-aliasing to Auto for WebGL 1.0 renderer"),this.aaMethod="AUTO"),this.useHDR=Boolean(e.renderer.useHDR&&n),this.useHDR&&!o&&(console.warn("v3d.App: disabling HDR for WebGL 1.0 renderer"),this.useHDR=!1),this.renderer.useOIT=e.renderer.useOIT??!1,this.renderer.useOIT&&!o&&(console.warn("v3d.App: disabling order-independent transparency for WebGL 1.0 renderer"),this.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))}),r=!0)}),r&&(o?(t.useHiDPIRenderPass=!0,t.renderer.setPixelRatio(window.devicePixelRatio)):console.warn("v3d.App: disabling HiDPI pass for WebGL 1.0 renderer")),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.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 1:case 2:e.onUpdate=()=>null}}_prepareReflProbesEncoding(e,t){e.traverse(e=>{(e.isCubeReflectionProbe||e.isPlaneReflectionProbe)&&e.setEncoding(t)})}_prepareEnvMapProbeWorld(){if(2==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 1:t.onUpdate=e=>{const t=e.clone();t.setSize(this._lightProbeCubemapRes,this._lightProbeCubemapRes),Detector.checkHalfFloatReadPixels(this.renderer)?t.texture.type=1016:Detector.checkFloatReadPixels(this.renderer)?t.texture.type=1015:(console.warn("v3d.App: Target platform does not support reading pixels in float format, expect quality loss."),t.texture.type=1009),t.texture.format=1023,t.texture.encoding=3e3;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)}_updateMaterialsFromGLTF(e){const t=this;e.scene&&e.scene.traverse(function(e){const n=e.material;n&&t.useHDR&&(n.toneMapped=!1,n.useFloatTex=Detector.checkFloatTex(t.renderer,!0),n.isMeshNodeMaterial&&n.updateNodeGraph(!0))})}_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 o=t.getObjectById(e.nodeId);if(o){let r;e.clip.objectUUID=o.uuid,r=o.id==t.id||""!==o.name&&"root"!==o.name&&"."!==o.name&&o.name!==t.name&&o.name!==t.uuid?n.mixer.clipAction(e.clip,t):n.mixer.clipAction(e.clip,o),r.setLoop(e.loop,e.repetitions,!0),r.startAt(e.startAt+n.mixer.time),r.clampWhenFinished=!0,e.auto?r.play():(r.stop(),r.paused=!0),r.objectUUID=o.uuid,n.actions.push(r)}})}_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,o){const r=this,i=r.compileCallbacks;for(let e=0;e=1&&r.renderer.setRenderTarget(a),o&&o(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=0):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=[],o=[],r=[],i=-1e3;e.traverse(function(t){t.isClippingPlaneObject&&(n.push(t),o.push(t.plane),e.traverse(function(e){t.needsClippingPlane(e)&&t.assignToObject(e,i++)}),r.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}).`)}),r._loadingTime=performance.now()-r._loadingTime,r.dispatchEvent({..._sceneLoadEvent}),sendDevTools("observe",{loadingTime:r._loadingTime}),r.removeEventListener("afterFirstRender",a)},s=r.postprocessing?r.postprocessing.composer.renderTarget1:null;r._precompileSceneAsync(r.scene,r.camera,s,function(o){const i=(60+.4*o)/1;n&&n(i),r.preloader&&r.preloader.onUpdate(i),i>=100&&(r._updateMeshesRaycastFromGLTF(e),r.addEventListener("afterFirstRender",a),t&&setTimeout(function(){r.scene.visible=!0,r.scene.disableChildRendering=!1,r.updateReflectionProbes(r.scene),t(r.scene)},16),e=null)}),r.clearBkgOnLoad&&(r.scene.background=null),r.registerServiceKeys&&AppUtils.registerServiceKeys(r)},function(e){const t=.6*e/1;n&&n(t),r.preloader&&r.preloader.onUpdate(t)},function(e){console.error(e),o&&o(e)}),window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=function(){r.onResize&&r.onResize()},window.addEventListener("resize",this._resizeCb,!1)):o&&o("WebGL not found")}appendScene(e,t,n,o,r,i){const a=this;a.renderer?(void 0===r&&(r=!0),void 0===i&&(i=!0),a.preloader&&a.preloader.onUpdate(0),this.loader.load(e,function(e){const o=e.scene||new Scene,s=[];o.traverse(function(e){(e.isCamera&&!r||e.isLight&&!i)&&s.push(e)}),s.forEach(function(e){a.unload(e)}),a.scene&&(a.scene.add(o),a._prepareReflProbesFromGLTF(e),a._updateMaterialsFromGLTF(e),a._updateAnimationsFromGLTF(e,o),a.scene.updateWorldMatrix(!1,!0));const l=a.postprocessing?a.postprocessing.composer.renderTarget1:null,c=a.scene||o;a.assignClippingPlanes(c),a.updateConstraints(c),o.visible=!1,o.disableChildRendering=!0,a._precompileSceneAsync(c,a.camera||new Camera,l,function(r){const i=(60+.4*r)/1;n&&n(i),a.preloader&&a.preloader.onUpdate(i),i>=100&&(a._updateMeshesRaycastFromGLTF(e),a._traverseSceneForTexUniforms(o,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(){o.visible=!0,o.disableChildRendering=!1,a.updateReflectionProbes(a.scene),t(o)},16),e=null)})},function(e){const t=.6*e/1;n&&n(t),a.preloader&&a.preloader.onUpdate(t)},function(e){console.error(e),o&&o(e)})):o&&o("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.controlSettings&&e.controlSettings.orbitTarget)n(e.controlSettings.orbitTarget);else if(e.isScene){const t=e.worldMaterial;null!==t&&(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;disposeTextures(t),t.dispose()}}if(e||(e=t.scene),e===t.scene){if(t.scene&&(t.scene.traverse(n),t.disposeEnvironment()),t.scene=null,t.disableControls(),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(),AppUtils.unregisterServiceKeys(t),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.disableCSSRenderer(),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.cssRenderer&&this.cssRenderer.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,o=this.camera;if(o.isPerspectiveCamera){const e=o.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,o=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=o}this.cssRenderer&&this.cssRenderer.render(this.cssScene,this.camera),this.renderer.gtaoMapEnabled=!1,this.dispatchEvent({..._afterRenderEvent})}enableControls(e){const t=this.camera;if(!t.controlSettings)return;const n=t.controlSettings.type;if(this.controls&&t===this.controls.object&&(this.controls instanceof OrbitControls&&"ORBIT"===n||this.controls instanceof FlyingControls&&"FLYING"===n||this.controls instanceof FirstPersonControls&&"FIRST_PERSON"===n));else switch(this.disableControls(),n){case"ORBIT":this.controls=new OrbitControls(t,e||this.renderer.domElement);break;case"FLYING":this.controls=new FlyingControls(t,e||this.renderer.domElement);break;case"FIRST_PERSON":this.controls=new FirstPersonControls(t,e||this.renderer.domElement);break;default:this.controls=null}this.controls&&(t.controlSettings.assignToControls(this.controls,this.scene),this.controls.update())}disableControls(){this.controls&&(this.controls.dispose(),this.controls=null)}setCamera(e){let t=[];if(this.camera)for(let e=this.camera.children.length-1;e>=0;e--){const n=this.camera.children[e];n instanceof AudioListener&&(t.push(n),n.removeFromParent())}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=r.distance,h.factor=r.factor,h.precision=r.precision,h.bentNormals=r.bentNormals;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=r.edgeStrength,p.edgeGlow=r.edgeGlow,p.edgeThickness=r.edgeThickness,p.pulsePeriod=r.pulsePeriod,p.visibleEdgeColor.fromArray(r.visibleEdgeColor),p.hiddenEdgeColor.fromArray(r.hiddenEdgeColor),p.hiddenEdgeColor.setW(Number(r.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}const f=isDef(r.useRefract)&&r.useRefract,m=isDef(r.simpleRefraction)&&r.simpleRefraction;let g;g=f&&!m?this.postprocessing.ssrPassRefract:f&&m?this.postprocessing.ssrPassSimpleRefract:this.postprocessing.ssrPassReflect,g||(g=new SSRPass(this.scene,this.camera),n.insertPassAfter(g,[this.postprocessing.renderPass,this.postprocessing.ssrPassRefract,this.postprocessing.ssrPassReflect,this.postprocessing.ssrPassSimpleRefract]),f&&!m?this.postprocessing.ssrPassRefract=g:f&&m?this.postprocessing.ssrPassSimpleRefract=g:this.postprocessing.ssrPassReflect=g),g.useRefract=f,g.simpleRefraction=m,isDef(r.objects)&&(g.objects=r.objects),isDef(r.intensity)&&(g.intensity=r.intensity),isDef(r.steps)&&(g.steps=r.steps),isDef(r.stride)&&(g.stride=r.stride),isDef(r.binarySearchSteps)&&(g.binarySearchSteps=r.binarySearchSteps),isDef(r.renderTargetScale)&&(g.renderTargetScale=r.renderTargetScale),isDef(r.maxDistance)&&(g.maxDistance=r.maxDistance),isDef(r.jitter)&&(g.jitter=r.jitter),isDef(r.renderAfter)&&(g.renderAfter=r.renderAfter),this.onResize&&this.onResize();break;default:console.error(`v3d.App: wrong postprocessing effect "${r.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 o=["afterimagePass","bloomPass","brightnessContrastPass","bokehPass","grayscalePass","ssrPassReflect","ssrPassRefract","ssrPassSimpleRefract"];e||o.push("outlinePass");const r=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 o=this.postprocessing.composer;if(e>0&&o.passes[0]instanceof RenderPass){let r;this.postprocessing.ssaaRenderPass?r=this.postprocessing.ssaaRenderPass:(r=new SSAARenderPass(this.scene,this.camera),this.postprocessing.ssaaRenderPass=r,t&&r.addEventListener("iteration",function(t){t.frame==e*e-1&&(o.enableAllPasses(),o.renderToScreen=!0,o.passes[o.passes.length-1].renderToScreen=!0,n.disableRenderTrigger=1)})),r.sampleLevel=e||4,o.passes[0]=r,this.postprocessing.fxaaPass&&o.passes.splice(o.passes.length-1,1),t&&(r.iterative=!0,r.iterativeFrame=0,o.disableAllPasses(),o.renderToScreen=!1,r.enabled=!0)}else e>0?(o.passes[0].sampleLevel=e||4,t&&(ssaaRenderPass.iterative=!0,ssaaRenderPass.iterativeFrame=0,o.disableAllPasses(),o.renderToScreen=!1,ssaaRenderPass.enabled=!0)):0==e&&o.passes[0]instanceof SSAARenderPass&&(o.passes[0]=this.postprocessing.renderPass,this.postprocessing.fxaaPass&&o.passes.push(this.postprocessing.fxaaPass),o.enableAllPasses(),o.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=0===this.renderer.toneMapping?e.worldMaterialColor():null;null!==t?this.scene.background=t:(this.scene.background=renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,{encoding:3001,format:1023,generateMipmaps:!0,minFilter:1008,type:1016}).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),n=t.fromCubemap(e.texture);return t.dispose(),n}initWebXR(e,t,n,o,r,i){n=n||function(){},o=o||function(){},r=r||function(){},i=i||{};const a=this;function s(e){a.xrSession.removeEventListener("end",s),r();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(o){a._webxrSave.postprocessing=a.postprocessing,a.postprocessing=null,a._webxrSave.useOIT=a.renderer.useOIT,a.renderer.useOIT=!1,a.renderer.xr.setReferenceSpaceType(t),a.xrSession=o,o.addEventListener("end",s);const r="immersive-vr"==e?2:1;for(let e=0;e{e.push(t)}),e.forEach(e=>{e.removeFromParent()}),this.cssScene=null}}enableDebugMode(e){this.hasDebugMode(e)&&this.disableDebugMode(e),this.scene.traverse(t=>{let n=null,o=!1;if(!this._debugHelpers.includes(t)&&!this._debugHelpers.includes(t.parent)){if("wireframes"==e&&t.isMesh)n=new WireframeHelper(t,"white");else if("lights"==e)t.isDirectionalLight?(n=new DirectionalLightHelper(t,.5,"yellow"),o=!0):t.isSpotLight?(n=new SpotLightHelper(t,"yellow"),o=!0):t.isPointLight?(n=new PointLightHelper(t,.1,"yellow"),o=!0):t.isRectAreaLight&&(n=new RectAreaLightHelper(t,"yellow"));else if("skeletons"==e&&t.isBone){let e=!1;t.traverseAncestors(t=>{t.isBone&&(e=!0)}),e||(n=new SkeletonHelper(t))}else"normals"==e&&t.isMesh&&(n=new VertexNormalsHelper(t,.1));null!==n&&(n.name=t.name+"Helper",n.visible=t.visible,t.add(n),o&&n.update(),this._debugHelpers.push(n),this._debugModes.add(e))}})}disableDebugMode(e){const t={wireframes:["WireframeHelper"],lights:["DirectionalLightHelper","SpotLightHelper","PointLightHelper","RectAreaLightHelper"],skeletons:["SkeletonHelper"],normals:["VertexNormalsHelper"]};for(let n=this._debugHelpers.length-1;n>=0;n--){const o=this._debugHelpers[n];t[e].includes(o.type)&&(o.removeFromParent(),this._debugHelpers.splice(n,1))}this._debugModes.delete(e)}hasDebugMode(e){return this._debugModes.has(e)}}function SSAOPass(){console.error("v3d.SSAOPass has been removed, use v3d.GTAOMapGenerator instead")}function BlenderTextGeometry(){console.error("v3d.BlenderTextGeometry has been removed, use v3d.TextGeometry instead.")}function BlenderTextBufferGeometry(){console.error("v3d.BlenderTextBufferGeometry has been removed, use v3d.TextGeometry instead.")}function AnimationLoader(){console.error("v3d.AnimationLoader has been removed, use glTF format for asset loading.")}function BufferGeometryLoader(){console.error("v3d.BufferGeometryLoader has been removed, use glTF format for asset loading.")}function MaterialLoader(){console.error("v3d.MaterialLoader has been removed, use glTF format for asset loading.")}function ObjectLoader(){console.error("v3d.ObjectLoader has been removed, use glTF format for asset loading.")}class MeshPhongMaterial extends MeshLambertMaterial{constructor(e){console.error("v3d.MeshPhongMaterial has been removed, use node-based or standard material instead."),super(e)}}class MeshToonMaterial extends MeshLambertMaterial{constructor(e){console.error("v3d.MeshToonMaterial has been removed, use node-based material instead."),super(e)}}class MeshMatcapMaterial extends MeshLambertMaterial{constructor(e){console.error("v3d.MeshMatcapMaterial has been removed, use node-based material instead."),super(e)}}BufferGeometry.prototype.toJSON=function(){return console.error("v3d.BufferGeometry.toJSON() has been removed, use glTF format for export."),{}},Object3D.prototype.toJSON=function(){return console.error("v3d.Object3D.toJSON() has been removed, use glTF format for export."),{}},Material.prototype.toJSON=function(){return console.error("v3d.Material.toJSON() has been removed, use glTF format for export."),{}},MeshNodeMaterial.nodeGraphDiffuse=function(e,t,n){console.error("v3d.MeshNodeMaterial.nodeGraphDiffuse has been deprecated. Use v3d.MaterialUtils.createDiffuseMaterial instead.");return createDiffuseMaterial("",e,t,n).nodeGraph};const PCFSoftShadowMap=2,PCFShadowMapPoissonDisk=2;function InterleavedBufferAttribute(){console.error("v3d.InterleavedBufferAttribute has been removed, use tightly packed buffers instead.")}function InstancedInterleavedBuffer(){console.error("v3d.InstancedInterleavedBuffer has been removed, use tightly packed buffers instead.")}function InterleavedBuffer(){console.error("v3d.InterleavedBuffer has been removed, use tightly packed buffers instead.")}function AmbientLightProbe(){console.error("v3d.AmbientLightProbe has been removed in Verge3D 4.11, use IBL instead.")}function HemisphereLight(){console.error("v3d.HemisphereLight has been removed in Verge3D 4.11, use IBL instead.")}function HemisphereLightProbe(){console.error("v3d.HemisphereLightProbe has been removed in Verge3D 4.11, use IBL instead.")}function HemisphereLightHelper(){console.error("v3d.HemisphereLightHelper has been removed in Verge3D 4.11.")}function StereoCamera(){console.error("v3d.StereoCamera has been removed in Verge3D 4.11.")}function DodecahedronGeometry(){console.error("v3d.DodecahedronGeometry has been removed in Verge3D 4.11.")}function OctahedronGeometry(){console.error("v3d.OctahedronGeometry has been removed in Verge3D 4.11.")}function TetrahedronGeometry(){console.error("v3d.TetrahedronGeometry has been removed in Verge3D 4.11.")}function TorusKnotGeometry(){console.error("v3d.TorusKnotGeometry has been removed in Verge3D 4.11.")}class MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){console.error("v3d.MeshPhysicalMaterial has been removed, use MeshStandardMaterial or node-based material instead."),super(e)}}var CameraUtils={calcCameraZoomToObjectsParams:function(){var e=new Box3,t=new Sphere;return function(n,o,r,i,a){var s=e.makeEmpty();o.forEach(function(e){s.expandByObject(e)});var l=s.getBoundingSphere(t);CameraUtils.calcCameraZoomToSphereParams(n,l,r,i,a)}}(),calcCameraZoomToSphereParams:function(){const e=new Vector3;return function(t,n,o,r,i){if(t.isOrthographicCamera){let e=Math.min(t.top,t.right);i[0]=e/n.radius,o.setFromMatrixPosition(t.matrixWorld),r.copy(n.center)}else{let i=degToRad(t.fov/2);t.aspect<1&&(i=Math.atan(t.aspect*Math.tan(i)));let a=n.radius/Math.sin(i);const s=t.getWorldDirection(e);o.copy(n.center).addScaledVector(s,-a),r.copy(n.center)}}}()},CSVParser={normalizeDialectOptions:function(e){var t={delimiter:",",doublequote:!0,lineterminator:"\n",quotechar:'"',skipinitialspace:!0,skipinitialrows:0};for(var n in e)t[n.toLowerCase()]=e[n];return t},parse:function(e,t){(!t||t&&!t.lineterminator)&&(e=CSVParser.normalizeLineTerminator(e,t));var n=CSVParser.normalizeDialectOptions(t);e=CSVParser.chomp(e,n.lineterminator);var o,r,i="",a=!1,s=!1,l="",c=[],u=[];for(r=function(e){var t=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")};return!0!==s&&(""===e?e=null:!0===n.skipinitialspace&&(e=t(e)),/^\d+$/.test(e)?e=parseInt(e,10):/^\d*\.\d+$|^\d+\.\d*$/.test(e)&&(e=parseFloat(e,10))),e},o=0;ox?(b=A>m?Math.min(p+this.offset,A):Math.max(h-this.offset,A),y=(b-A)/v+_):(y=_=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 o=t.default;o?(new o).then(t=>{window.Ammo=t,e()}):n(new Error("Failed to load physics module"))})}else e()})}async loadLogic(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)}}async loadEditorWithLogic(e,t,n,o){try{let o=null;await this._getEditorPromise(e+EDITOR_JS_FILE);try{o=await this._getLogicViaEditorPromise(e,t)}catch(e){if("LogicFileLoadError"!==e.name)throw e}return await this._getAmmoJSPromise(),n&&n(),o}catch(e){console.error(e),o&&o(e)}}}function CubeTextureHelper(e){Mesh.call(this),this.type="CubeTextureHelper",this.geometry=new BoxGeometry(2,2,2,1,1,1),this.geometry.computeBoundingSphere(),this.material=new MeshBasicMaterial,this.material.envMap=e}CubeTextureHelper.prototype=Object.create(Mesh.prototype),CubeTextureHelper.prototype.constructor=CubeTextureHelper;class AnnotationControl extends Object3D{constructor(e){super(),this.isAnnotationControl=!0,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,o=this.container.offsetHeight,r=(.5+t.x/2)*n,i=(.5-t.y/2)*o;t.x=r,t.y=i;var a=t.z<=1&&r>=0&&r<=n&&i>=0&&i<=o;this.visible=a,this.updatedCallback&&this.updatedCallback(t.x,t.y,a)}}}var _raycaster=new Raycaster,_camPos=new Vector3,_annoPos=new Vector3,_dir=new Vector3;class Annotation extends AnnotationControl{constructor(e,t,n){super(e),this.isAnnotation=!0,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 o=!1,r=this;function i(e){e.target==r.annotation?0==r.annotationDialog.innerHTML.length||r.obscured||(r.annotationDialogVisible=!r.annotationDialogVisible,r.annotationDialog.style.visibility=r.annotationDialogVisible?"visible":"hidden",r.annotationDialogVisible?r.annotation.style.zIndex="2":r.annotation.style.zIndex="1"):e.target.className.indexOf("v3d-annotation")>-1&&(r.annotationDialogVisible=!1,r.annotationDialog.style.visibility="hidden",r.annotation.style.zIndex=r.obscured?"auto":"1")}this._touchstartCb=function(e){i(e),o=!0},document.body.addEventListener("touchstart",this._touchstartCb,!1),this._mousedownCb=function(e){o||i(e),o=!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 o=_raycaster.intersectObject(this.findRoot(),!0);o.length>1||1==o.length&&o[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)}}const _vec3Tmp=new Vector3,_quatTmp=new Quaternion,_quatTmp2=new Quaternion;function translateVRCamera(e,t,n){const o=e.parent;o&&!o.isScene&&(_vec3Tmp.copy(t).applyQuaternion(e.quaternion).applyQuaternion(o.quaternion),o.position.add(_vec3Tmp.multiplyScalar(n)))}function rotateVRCamera(e,t,n){const o=e.parent;o&&!o.isScene&&(_quatTmp.setFromAxisAngle(t,n),_quatTmp.premultiply(e.quaternion),_quatTmp.premultiply(o.quaternion),o.quaternion.multiplyQuaternions(_quatTmp,_quatTmp2.copy(e.quaternion).invert()))}var WebXRUtils=Object.freeze({__proto__:null,rotateVRCamera:rotateVRCamera,translateVRCamera:translateVRCamera}),cssText='.v3d-container {overflow: hidden;z-index: 0;}.v3d-canvas {position: absolute;top: 0;bottom: 0;left: 0;right: 0;z-index: -1;}.v3d-simple-preloader-background {background-color: #fff;position: absolute;top: 0;bottom: 0;left: 0;right: 0;z-index: 1;height: 100%;width: 100%;}.v3d-simple-preloader-container {--v3d-preloader-img-width: 120px;--v3d-preloader-img-height: 120px;position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);width: calc(var(--v3d-preloader-img-width) + 60px);height: calc(var(--v3d-preloader-img-height) + 60px);}.v3d-simple-preloader-bar {background: linear-gradient(90deg, #1458ae, #4388e0);width: 0%;height: 3px;margin: 15px -1px;border: 1px solid;border-radius: 50px;border-color: #2b70c7;}.v3d-simple-preloader-logo {width: var(--v3d-preloader-img-width);height: var(--v3d-preloader-img-height);background-image: url(\'data:image/svg+xml,%3C%3Fxml version="1.0" encoding="UTF-8" standalone="no"%3F%3E%3Csvg width="120" height="120" viewBox="0 0 31.75 31.75" version="1.1" id="svg5409" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns%23" xmlns:cc="http://creativecommons.org/ns%23" xmlns:dc="http://purl.org/dc/elements/1.1/"%3E%3Cdefs id="defs5403"%3E%3ClinearGradient xlink:href="%23linearGradient3077" id="linearGradient4375" gradientUnits="userSpaceOnUse" x1="172.91336" y1="78.689407" x2="193.7847" y2="53.806618" gradientTransform="matrix(1.1562901,0,0,1.1583991,-194.29093,208.80811)" /%3E%3ClinearGradient id="linearGradient3077"%3E%3Cstop style="stop-color:%230048a5;stop-opacity:1" offset="0" id="stop3073" /%3E%3Cstop style="stop-color:%234b86d1;stop-opacity:1" offset="1" id="stop3075" /%3E%3C/linearGradient%3E%3C/defs%3E%3Cmetadata id="metadata5406"%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=""%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg id="layer1" transform="translate(0,-270.54167)"%3E%3Cpath style="display:inline;fill:url(%23linearGradient4375);fill-opacity:1;stroke:none;stroke-width:0.9171;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 15.945207,270.5417 c -1.669933,-0.007 -3.344811,1.1051 -7.2273169,3.32785 -7.76503612,4.4455 -7.2281318,3.52338 -7.2677439,12.48309 -0.03948,8.95973 -0.56829626,8.03286 7.1571159,12.5471 7.7254249,4.51422 6.6598479,4.50948 14.4248479,0.064 7.765036,-4.4455 7.228132,-3.52338 7.267744,-12.48309 0.03948,-8.95973 0.568296,-8.03287 -7.157116,-12.5471 -3.862718,-2.25711 -5.527635,-3.38445 -7.197531,-3.39185 z m -0.0132,2.85167 c 1.6836,0.007 3.363685,0.8128 6.115359,2.4207 5.503323,3.21577 6.107199,4.27438 6.078963,10.65695 -0.02832,6.3826 -0.641388,7.43578 -6.172923,10.60259 -5.531523,3.16682 -6.748576,3.16139 -12.2518993,-0.0544 -5.503299,-3.21578 -6.1071633,-4.27439 -6.0789633,-10.65697 0.02844,-6.38259 0.6413884,-7.43577 6.1729353,-10.6026 2.7657613,-1.5834 4.4529153,-2.37377 6.1365283,-2.3663 z m -0.154249,1.6177 c -2.694169,0.0343 -5.683359,3.07006 -7.236352,6.07548 -1.5776528,3.05311 -2.4803533,5.94456 -2.1086051,9.65753 0.1618801,1.61652 1.6983849,3.67982 3.5378539,4.71425 -0.3909602,-3.2062 -0.1707481,-6.34306 0.5400002,-8.94693 0.71076,-2.60387 2.83223,-6.82883 5.337159,-6.82316 2.504954,0.006 4.626375,4.22704 5.337123,6.83091 0.710725,2.60386 0.930961,5.74073 0.539989,8.94693 1.839481,-1.03442 3.375985,-3.09779 3.537853,-4.71432 0.371749,-3.71296 -0.53082,-6.60428 -2.108485,-9.6574 -1.547604,-2.99499 -4.52153,-6.01988 -7.24846,-6.08267 -0.0426,-9.5e-4 -0.08532,-10e-4 -0.128028,-6.2e-4 z m 0.131713,8.9184 a 2.4731483,2.4776591 0 0 0 -1.188637,0.29153 2.4731483,2.4776591 0 0 0 -1.017889,3.35228 2.4731483,2.4776591 0 0 0 3.34619,1.01974 2.4731483,2.4776591 0 0 0 1.017877,-3.35231 2.4731483,2.4776591 0 0 0 -2.157541,-1.31124 z" id="path4130" /%3E%3C/g%3E%3C/svg%3E\');background-size: 100% 100%;background-repeat: no-repeat;margin: 20px auto;}.v3d-annotation {position: absolute;top: -0.7em;left: -0.5em;width: auto;min-width: 1em;height: 1.4em;padding: 0.3em 0.5em;border: 1px solid #fff;border-radius: 2em;font-size: 16px;font-family: sans-serif;line-height: 1.4em;color: #fff;text-align: center;user-select: none;background: rgba(0, 0, 0, 0.8);}.v3d-annotation-transparent {opacity: 0.5;}.v3d-annotation-dialog {position: absolute;top: 85%;left: 85%;font-family: sans-serif;user-select: none;padding: 1em;min-width: 200px;color: #fff;background: rgba(0, 0, 0, 0.8);border-radius: 1em;font-size: 12px;line-height: 1.2;transition: opacity .5s;visibility: hidden;}.v3d-mobile-forward {position: absolute;width: 62px;height: 62px;bottom: 31px;left: 50%;margin-left: -31px;background-image: url(\'data:image/svg+xml,%3C%3Fxml version="1.0" encoding="UTF-8" standalone="no"%3F%3E%3Csvg width="62" height="62" viewBox="0 0 16.404167 16.404167" version="1.1" id="svg2719" sodipodi:docname="move_forward.svg" inkscape:version="1.1.2 (b8e25be833, 2022-02-05)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns%23" xmlns:cc="http://creativecommons.org/ns%23" xmlns:dc="http://purl.org/dc/elements/1.1/"%3E%3Csodipodi:namedview id="namedview7548" pagecolor="%23505050" bordercolor="%23eeeeee" borderopacity="1" inkscape:pageshadow="0" inkscape:pageopacity="0" inkscape:pagecheckerboard="0" showgrid="false" inkscape:snap-global="false" inkscape:zoom="7.1451613" inkscape:cx="42.266366" inkscape:cy="15.814898" inkscape:window-width="1920" inkscape:window-height="1137" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="svg2719" /%3E%3Cdefs id="defs2713"%3E%3ClinearGradient gradientTransform="translate(-524.2581,-935.78503)" xlink:href="%23linearGradient2768" id="linearGradient2673" x1="501.88306" y1="942.95502" x2="508.08038" y2="935.61182" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient id="linearGradient2768"%3E%3Cstop style="stop-color:%23414141;stop-opacity:1" offset="0" id="stop2764" /%3E%3Cstop style="stop-color:%23767676;stop-opacity:1" offset="1" id="stop2766" /%3E%3C/linearGradient%3E%3ClinearGradient gradientTransform="translate(-521.96226,-941.8579)" xlink:href="%23linearGradient2648" id="linearGradient2665" x1="495.62714" y1="948.00964" x2="508.85629" y2="934.78046" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient id="linearGradient2648"%3E%3Cstop style="stop-color:%23ebebeb;stop-opacity:1" offset="0" id="stop2644" /%3E%3Cstop style="stop-color:%23ffffff;stop-opacity:1" offset="1" id="stop2646" /%3E%3C/linearGradient%3E%3Cfilter style="color-interpolation-filters:sRGB" id="filter2688" x="-0.12" width="1.24" y="-0.12" height="1.24"%3E%3CfeGaussianBlur stdDeviation="0.66145835" id="feGaussianBlur2690" /%3E%3C/filter%3E%3ClinearGradient inkscape:collect="always" xlink:href="%23linearGradient2768" id="linearGradient7749" x1="6.0107598" y1="11.942085" x2="11.430239" y2="4.0917845" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient inkscape:collect="always" xlink:href="%23linearGradient2648" id="linearGradient8251" x1="4.2536402" y1="13.238126" x2="12.150527" y2="2.9068334" gradientUnits="userSpaceOnUse" /%3E%3Cfilter inkscape:collect="always" style="color-interpolation-filters:sRGB" id="filter8772" x="-0.10840111" y="-0.10840111" width="1.2168022" height="1.2168022"%3E%3CfeGaussianBlur inkscape:collect="always" stdDeviation="0.59752352" id="feGaussianBlur8774" /%3E%3C/filter%3E%3C/defs%3E%3Cmetadata id="metadata2716"%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=""%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Ccircle style="fill:%23000000;stroke-width:0.230841;stroke-linecap:round;stroke-linejoin:round;fill-opacity:0.5;filter:url(%23filter8772)" id="circle8626" cx="8.2020836" cy="8.2020836" r="6.6145835" /%3E%3Ccircle style="fill:url(%23linearGradient8251);stroke-width:0.230841;stroke-linecap:round;stroke-linejoin:round;fill-opacity:1" id="path7652" cx="8.2020836" cy="8.2020836" r="6.6145835" /%3E%3Cpath d="m 4.2333333,6.7138018 c 0,0.9875367 0.4960933,2.4804692 0.4960933,2.4804692 h 1.984375 c 0,-0.7441408 0.2480473,-1.1782225 0.496094,-1.612305 0.2480467,-0.4340817 0.4960942,-0.8681642 0.4960942,-1.6123037 0,-0.8743657 -0.2480475,-2.7285166 -1.4882817,-2.7285166 -1.240234,0 -1.9843749,1.9843749 -1.9843748,3.4726561 z m 1.4882816,4.4648442 c 0.5472533,0 0.9921867,-0.444934 0.9921867,-0.992188 V 9.6903643 h -1.984375 v 0.4960937 c 0,0.547254 0.4449341,0.992188 0.9921883,0.992188 z M 12.170834,8.6981768 c 0,-1.4882808 -0.744141,-3.4726553 -1.984376,-3.4726553 -1.240234,0 -1.4882807,1.8541503 -1.4882807,2.7285153 0,0.74414 0.2480467,1.1782226 0.4960933,1.6123041 0.2480467,0.4340821 0.4960934,0.8681641 0.4960934,1.6123051 h 1.984376 c 0,0 0.496094,-1.4929325 0.496094,-2.4804692 z m -1.488281,4.4648442 c 0.547253,0 0.992187,-0.444935 0.992187,-0.992188 V 11.674739 H 9.690364 v 0.496094 c 0,0.547253 0.444935,0.992188 0.992189,0.992188 z" id="path7734" style="stroke-width:0.0155029;fill-opacity:1;fill:url(%23linearGradient7749)" /%3E%3C/svg%3E\');touch-action: none;-webkit-user-select: none;user-select: none;}.v3d-webgl-error-container {position: absolute;top: 50%;left: 50%;margin-top: -80px;margin-left: -200px;width: 400px;height: 160px;text-align: center;z-index: 10;}.v3d-webgl-error-image {width: 160px;height: 160px;background-repeat: no-repeat;margin: 0px auto;background-image: url(\'data:image/svg+xml,%3C%3Fxml version="1.0" encoding="UTF-8" standalone="no"%3F%3E%3Csvg width="160" height="160" viewBox="0 0 42.333332 42.333333" version="1.1" id="svg1" inkscape:version="1.3 (0e150ed6c4, 2023-07-21)" sodipodi:docname="webgl-error.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"%3E%3Csodipodi:namedview id="namedview1" pagecolor="%23ffffff" bordercolor="%23eeeeee" borderopacity="1" inkscape:showpageshadow="false" inkscape:pageopacity="0" inkscape:pagecheckerboard="false" inkscape:deskcolor="%23d1d1d1" inkscape:document-units="px" labelstyle="default" shape-rendering="auto" inkscape:clip-to-page="false" inkscape:zoom="1.6017536" inkscape:cx="-5.3066837" inkscape:cy="78.97594" inkscape:window-width="1920" inkscape:window-height="1137" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="layer1" /%3E%3Cdefs id="defs1"%3E%3Cfilter inkscape:collect="always" style="color-interpolation-filters:sRGB" id="filter1" x="-0.18167429" y="-0.16562716" width="1.3633486" height="1.3312543"%3E%3CfeGaussianBlur inkscape:collect="always" stdDeviation="2.1910722" id="feGaussianBlur1" /%3E%3C/filter%3E%3ClinearGradient inkscape:collect="always" xlink:href="%23linearGradient3259" id="linearGradient10" x1="863.9444" y1="1424.3892" x2="892.88947" y2="1424.3892" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient inkscape:collect="always" id="linearGradient3259"%3E%3Cstop style="stop-color:%23c90000;stop-opacity:1" offset="0" id="stop3255" /%3E%3Cstop style="stop-color:%23ff0a0a;stop-opacity:1" offset="1" id="stop3257" /%3E%3C/linearGradient%3E%3C/defs%3E%3Cg inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"%3E%3Cg id="g2" style="display:inline" transform="translate(-857.25025,-1403.2226)"%3E%3Cpath id="path10" style="fill:%23e40505;fill-opacity:0.4;stroke-width:0.0581876;filter:url(%23filter1)" d="m 878.41691,1413.9426 c 1.49459,-0.033 2.34009,1.1428 2.29362,2.1957 l -0.39169,8.8754 c -0.0465,1.0529 -0.84799,1.9018 -1.90193,1.9018 -1.05394,0 -1.8516,-0.8491 -1.90193,-1.9018 l -0.42433,-8.8754 c -0.0503,-1.0527 0.83167,-2.163 2.32626,-2.1957 z m -0.18948,15.5145 c 1.4715,-0.1102 2.72596,1.0544 2.72522,2.53 0.0257,3.4066 -5.09721,3.4066 -5.07148,0 -6.7e-4,-1.3275 1.02252,-2.4308 2.34626,-2.53 z m 0.26002,-20.9425 c -1.67293,-0.01 -3.35083,1.1046 -7.24038,3.3274 -7.77912,4.4454 -7.24153,3.5234 -7.28121,12.483 -0.0397,8.9596 -0.56935,8.0329 7.17011,12.547 7.73941,4.5142 6.67221,4.5096 14.45131,0.064 7.77911,-4.4455 7.241,-3.5233 7.28069,-12.483 0.0397,-8.9596 0.56933,-8.0328 -7.1701,-12.547 -3.86972,-2.257 -5.53749,-3.384 -7.21042,-3.3915 z m -0.0134,2.8509 v 6e-4 c 1.68666,0.01 3.37009,0.8126 6.12676,2.4205 5.51329,3.2157 6.11834,4.2746 6.09006,10.6572 -0.0283,6.3825 -0.64255,7.4357 -6.18411,10.6025 -5.54155,3.1668 -6.76089,3.161 -12.27419,-0.055 -5.51329,-3.2158 -6.11831,-4.2742 -6.09007,-10.6567 0.0284,-6.3825 0.64255,-7.4357 6.18412,-10.6025 2.77079,-1.5834 4.46077,-2.3737 6.14743,-2.3663 z" sodipodi:nodetypes="zssssszsccssssssssssccsssssssc" /%3E%3Cpath id="path3" style="fill:url(%23linearGradient10);stroke-width:0.0581876" d="m 878.41691,1413.9426 c 1.49459,-0.033 2.34009,1.1428 2.29362,2.1957 l -0.39169,8.8754 c -0.0465,1.0529 -0.84799,1.9018 -1.90193,1.9018 -1.05394,0 -1.8516,-0.8491 -1.90193,-1.9018 l -0.42433,-8.8754 c -0.0503,-1.0527 0.83167,-2.163 2.32626,-2.1957 z m -0.18948,15.5145 c 1.4715,-0.1102 2.72596,1.0544 2.72522,2.53 0.0257,3.4066 -5.09721,3.4066 -5.07148,0 -6.7e-4,-1.3275 1.02252,-2.4308 2.34626,-2.53 z m 0.26002,-20.9425 c -1.67293,-0.01 -3.35083,1.1046 -7.24038,3.3274 -7.77912,4.4454 -7.24153,3.5234 -7.28121,12.483 -0.0397,8.9596 -0.56935,8.0329 7.17011,12.547 7.73941,4.5142 6.67221,4.5096 14.45131,0.064 7.77911,-4.4455 7.241,-3.5233 7.28069,-12.483 0.0397,-8.9596 0.56933,-8.0328 -7.1701,-12.547 -3.86972,-2.257 -5.53749,-3.384 -7.21042,-3.3915 z m -0.0134,2.8509 v 6e-4 c 1.68666,0.01 3.37009,0.8126 6.12676,2.4205 5.51329,3.2157 6.11834,4.2746 6.09006,10.6572 -0.0283,6.3825 -0.64255,7.4357 -6.18411,10.6025 -5.54155,3.1668 -6.76089,3.161 -12.27419,-0.055 -5.51329,-3.2158 -6.11831,-4.2742 -6.09007,-10.6567 0.0284,-6.3825 0.64255,-7.4357 6.18412,-10.6025 2.77079,-1.5834 4.46077,-2.3737 6.14743,-2.3663 z" sodipodi:nodetypes="zssssszsccssssssssssccsssssssc" /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\');background-size: 100% 100%;}.v3d-webgl-error {font-family: Arial;font-size: 16px;}.v3d-webgl-error-link {font-style: italic;font-weight: bolder;}.v3d-webgl-error-link {color: #015fb1;}';if("undefined"!=typeof window&&(window.__V3D__?console.warn("WARNING: Multiple instances of Verge3D being imported."):window.__V3D__="4.11.0"),"undefined"!=typeof document){const e=document.createElement("style");e.appendChild(document.createTextNode(cssText)),document.head.insertBefore(e,document.head.firstChild)}export{ACESFilmicToneMapping,AVERAGE,AddEquation,AddOperation,AdditiveAnimationBlendMode,AdditiveBlending,AgXBlenderToneMapping,AlphaFormat,AlwaysDepth,AlwaysStencilFunc,AmbientLight,AmbientLightProbe,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,Annotation,AnnotationControl,App,AppUtils,ArcCurve,ArrayCamera,ArrowHelper,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BackSide,BasicDepthPacking,BasicShadowMap,BilinearShadowMap,BlenderTextBufferGeometry,BlenderTextGeometry,BloomPass,BokehPass,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxGeometry,BoxHelper,BrightnessContrastPass,BufferAttribute,BufferGeometry,BufferGeometryLoader,BufferGeometryUtils,ByteType,CENTER,CSS3DObject,CSS3DRenderer,CSVParser,Cache,Camera,CameraHelper,CameraUtils,CanvasBreakpointsConstraint,CanvasFitConstraint,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,ChildOfConstraint,CineonToneMapping,CircleGeometry,ClampToEdgeWrapping,ClearMaskPass,Clock,Color,ColorKeyframeTrack,ColorManagement,Compat,CompressedArrayTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,Constraint,ConstraintSpaceCustom,ConstraintSpaceLocal,ConstraintSpaceWorld,ControlSettings,CopyLocationConstraint,CopyRotationConstraint,CopyScaleConstraint,CopyTransformsConstraint,CubeCamera,CubeCopy,CubeReflectionMapping,CubeReflectionProbe,CubeRefractionMapping,CubeTexture,CubeTextureHelper,CubeTextureLoader,CubeUVReflectionMapping,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceBack,CullFaceFront,CullFaceFrontBack,CullFaceNone,Curve,CurvePath,CustomBlending,CustomToneMapping,CylinderGeometry,Cylindrical,DampedTrackConstraint,Data3DTexture,DataArrayTexture,DataTexture,DataTextureLoader,DataUtils,DecrementStencilOp,DecrementWrapStencilOp,DefaultLoadingManager,DepthFormat,DepthStencilFormat,DepthTexture,Detector,DirectionalLight,DirectionalLightCSMHelper,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DoubleSide,DstAlphaFactor,DstColorFactor,DynamicCopyUsage,DynamicDrawUsage,DynamicReadUsage,ESMDistancePacking,ESMShadowMap,EdgesGeometry,EffectComposer,EllipseCurve,EqualDepth,EqualStencilFunc,EquirectangularReflectionMapping,EquirectangularRefractionMapping,Euler,EventDispatcher,ExtendedTriangle,ExtrudeGeometry,FXAAPass,FileLoader,FilmicBlenderToneMapping,FirstPersonControls,FixOrthoZoomConstraint,Float16BufferAttribute,Float32BufferAttribute,Float64BufferAttribute,FloatType,FloorConstraint,FlyingControls,Fog,FogExp2,Font,FramebufferTexture,FrontSide,Frustum,GLBufferAttribute,GLSL1,GLSL3,GLTFExporter,GLTFLoader,GTAOMapGenerator,GraphUtils,GrayscalePass,GreaterDepth,GreaterEqualDepth,GreaterEqualStencilFunc,GreaterStencilFunc,GridHelper,Group,HalfFloatType,HemisphereLight,HemisphereLightHelper,HemisphereLightProbe,IBLEnvironmentNone,IBLEnvironmentPMREM,IBLEnvironmentProbe,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,IncrementStencilOp,IncrementWrapStencilOp,InstancedBufferAttribute$1 as InstancedBufferAttribute,InstancedBufferGeometry,InstancedInterleavedBuffer,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,IntType,InterleavedBuffer,InterleavedBufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InvertStencilOp,KeepStencilOp,KeyframeTrack,Keys,LOD,LatheGeometry,Layers,LessDepth,LessEqualDepth,LessEqualStencilFunc,LessStencilFunc,Light,LightProbe,LightProbeGenerator,LimitDistanceConstraint,LimitLocationConstraint,LimitRotationConstraint,LimitScaleConstraint,Line,Line3,LineBasicMaterial,LineCurve,LineCurve3,LineDashedMaterial,LineHTML,LineLoop,LineSegments,LinearDepthPacking,LinearEncoding,LinearFilter,LinearInterpolant,LinearMipMapLinearFilter,LinearMipMapNearestFilter,LinearMipmapLinearFilter,LinearMipmapNearestFilter,LinearSRGBColorSpace,LinearToneMapping,Loader,LoaderUtils,LoadingManager,LockedTrackConstraint,LogarithmicMaxToneMapping,LoopOnce,LoopPingPong,LoopRepeat,LuminanceAlphaFormat,LuminanceFormat,MOD_SUITE,MOUSE,MaskPass,Material,MaterialLoader,MaterialUtils,MathUtils,Matrix3,Matrix4,MaxEquation,Mesh,MeshBVH,MeshBasicMaterial,MeshDepthMaterial,MeshDistanceMaterial,MeshLambertMaterial,MeshLine,MeshLineIndexed,MeshLineMaterial,MeshMaskMaterial,MeshMatcapMaterial,MeshNodeMaterial,MeshNormalMaterial,MeshPhongMaterial,MeshPhysicalMaterial,MeshStandardMaterial,MeshToonMaterial,MinEquation,MirroredRepeatWrapping,MixOperation,MotionPathConstraint,MultiplyBlending,MultiplyOperation,NearestFilter,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NearestMipmapLinearFilter,NearestMipmapNearestFilter,NeverDepth,NeverStencilFunc,NoBlending,NoColorSpace,NoOIT,NoToneMapping,NormalAnimationBlendMode,NormalBlending,NotEqualDepth,NotEqualStencilFunc,NumberKeyframeTrack,OITWeighted,Object3D,ObjectLoader,ObjectSpaceNormalMap,OctahedronGeometry,OneFactor,OneMinusDstAlphaFactor,OneMinusDstColorFactor,OneMinusSrcAlphaFactor,OneMinusSrcColorFactor,OrbitControls,OrthographicCamera,OutlinePass,PCFShadowMap,PCFShadowMapPoissonDisk,PCFSoftShadowMap,PMREMGenerator,Pass,Path,PbrNeutralToneMapping,PerspectiveCamera,PhysicalMaxToneMapping,Plane,PlaneGeometry,PlaneHelper,PointLight,PointLightHelper,Points,PointsMaterial,PolarGridHelper,PolyhedronGeometry,PositionalAudio,Preloader,PropertyBinding,PropertyMixer,PuzzlesLoader,QuadraticBezierCurve,QuadraticBezierCurve3,Quaternion,QuaternionKeyframeTrack,QuaternionLinearInterpolant,REVISION,REVISION_EXPORT_MIN,RGBADepthPacking,RGBADistancePacking,RGBAFormat,RGBAIntegerFormat,RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format,RGBA_BPTC_Format,RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format,RGBELoader,RGB_ETC1_Format,RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format,RGFormat,RGIntegerFormat,RawShaderMaterial,Ray,Raycaster,RectAreaLight,RectAreaLightUniformsLib,RedFormat,RedIntegerFormat,ReflectionProbeTypeBox,ReflectionProbeTypeInfinite,ReflectionProbeTypeSphere,ReinhardToneMapping,RenderPass,RenderUtils,RepeatWrapping,ReplaceStencilOp,ReverseSubtractEquation,RingGeometry,SAH,SRGBColorSpace,SSAARenderPass,SSAOPass,Scene,Color as SceneBackground,SceneUtils,ShaderChunk,ShaderLib,ShaderMaterial,ShaderPass,ShadowMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,ShortType,SimplePreloader,Skeleton,SkeletonHelper,SkinnedMesh,Source,Sphere,SphereGeometry,Spherical,SphericalHarmonics3,SplineCurve,SpotLight,SpotLightHelper,Sprite,SpriteMaterial,SrcAlphaFactor,SrcAlphaSaturateFactor,SrcColorFactor,StaticCopyUsage,StaticDrawUsage,StaticReadUsage,Stats,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,SubtractEquation,SubtractiveBlending,TOUCH,TTFLoader,TangentSpaceNormalMap,TargetConstraint,TeapotGeometry,TetrahedronGeometry,TextGeometry,Texture,TextureLoader,ToneMapPass,ToneMappingLookAgXPunchy,ToneMappingLookNone,TorusGeometry,TorusKnotGeometry,TrackToConstraint,TransformationConstraint,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,TweenCameraController,TweenLinear,TweenSpherical,TwoPassDoubleSide,USDZExporter,UVMapping,Uint16BufferAttribute,Uint32BufferAttribute,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,UniformsLib,UniformsUtils,UnsignedByteType,UnsignedInt248Type,UnsignedIntType,UnsignedShort4444Type,UnsignedShort5551Type,UnsignedShortType,V3DL,Vector2,Vector3,Vector4,VectorKeyframeTrack,VideoTexture,ViewportFitAuto,ViewportFitFill,ViewportFitHorizontal,ViewportFitNone,ViewportFitOverscan,ViewportFitVertical,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLCubeRenderTarget,WebGLMultipleRenderTargets,WebGLRenderTarget,WebGLRenderer,WebGLUtils,WebXRUtils,WireframeGeometry,WrapAroundEnding,Module as XZ,XZLoader,ZeroCurvatureEnding,ZeroFactor,ZeroSlopeEnding,ZeroStencilOp,_SRGBAFormat,acceleratedRaycast,arrayMax,arrayMin,clampArray,computeBoundsTree,disposeBoundsTree,engineVersionCmp,findModulePath,getGlobalScope,isDef,loadModule,sRGBEncoding,shaderFloatStr};