"use strict";
(function (g, f) {
  var hasExports = typeof exports === 'object';
  if (typeof define === "function" && define.amd) {
    define(['fs', 'path'], f);
  } else if (typeof module === "object" && module.exports) {
    module.exports = f(require('fs'), require('path'));
  } else {
    var m = hasExports ? f(require('fs'), require('path')) : f(g["fs"], g["path"]);
    var root = hasExports ? exports : g;
    for(var i in m) root[i] = m[i];
  }}(typeof self !== 'undefined' ? self : this, (__da, __db) => {
var exports = {};
var module = { exports };
"use strict";var iA=Object.create;var dl=Object.defineProperty,oA=Object.defineProperties,sA=Object.getOwnPropertyDescriptor,aA=Object.getOwnPropertyDescriptors,cA=Object.getOwnPropertyNames,Wy=Object.getOwnPropertySymbols,lA=Object.getPrototypeOf,jy=Object.prototype.hasOwnProperty,uA=Object.prototype.propertyIsEnumerable;var sm=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),qy=Math.pow,am=(t,e,n)=>e in t?dl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,li=(t,e)=>{for(var n in e||(e={}))jy.call(e,n)&&am(t,n,e[n]);if(Wy)for(var n of Wy(e))uA.call(e,n)&&am(t,n,e[n]);return t},_a=(t,e)=>oA(t,aA(e));var Xy=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xh=(t,e)=>{for(var n in e)dl(t,n,{get:e[n],enumerable:!0})},Yy=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of cA(e))!jy.call(t,o)&&o!==n&&dl(t,o,{get:()=>e[o],enumerable:!(r=sA(e,o))||r.enumerable});return t};var $y=(t,e,n)=>(n=t!=null?iA(lA(t)):{},Yy(e||!t||!t.__esModule?dl(n,"default",{value:t,enumerable:!0}):n,t)),hA=t=>Yy(dl({},"__esModule",{value:!0}),t);var te=(t,e,n)=>(am(t,typeof e!="symbol"?e+"":e,n),n),fA=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var ba=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)};var ui=(t,e,n)=>(fA(t,e,"access private method"),n);var xe=(t,e,n)=>new Promise((r,o)=>{var a=u=>{try{l(n.next(u))}catch(h){o(h)}},c=u=>{try{l(n.throw(u))}catch(h){o(h)}},l=u=>u.done?r(u.value):Promise.resolve(u.value).then(a,c);l((n=n.apply(t,e)).next())}),dA=function(t,e){this[0]=t,this[1]=e};var Zy=t=>{var e=t[sm("asyncIterator")],n=!1,r,o={};return e==null?(e=t[sm("iterator")](),r=a=>o[a]=c=>e[a](c)):(e=e.call(t),r=a=>o[a]=c=>{if(n){if(n=!1,a==="throw")throw c;return c}return n=!0,{done:!1,value:new dA(new Promise(l=>{var u=e[a](c);if(!(u instanceof Object))throw TypeError("Object expected");l(u)}),1)}}),o[sm("iterator")]=()=>o,r("next"),"throw"in e?r("throw"):o.throw=a=>{throw a},"return"in e&&r("return"),o};var HT=Xy((exports,module)=>{"use strict";var i=0,BeautySightCore=(()=>{var _scriptDir=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(_scriptDir=_scriptDir||__filename),function(moduleArg={}){var Module=moduleArg,readyPromiseResolve,readyPromiseReject;Module.ready=new Promise((t,e)=>{readyPromiseResolve=t,readyPromiseReject=e});var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(t,e)=>{throw e},ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof importScripts=="function",ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",scriptDirectory="";function locateFile(t){return Module.locateFile?Module.locateFile(t,scriptDirectory):scriptDirectory+t}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs"),nodePath=require("path");ENVIRONMENT_IS_WORKER?scriptDirectory=nodePath.dirname(scriptDirectory)+"/":scriptDirectory=__dirname+"/",read_=(t,e)=>(t=isFileURI(t)?new URL(t):nodePath.normalize(t),fs.readFileSync(t,e?void 0:"utf8")),readBinary=t=>{var e=read_(t,!0);return e.buffer||(e=new Uint8Array(e)),e},readAsync=(t,e,n,r=!0)=>{t=isFileURI(t)?new URL(t):nodePath.normalize(t),fs.readFile(t,r?void 0:"utf8",(o,a)=>{o?n(o):e(r?a.buffer:a)})},!Module.thisProgram&&process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),quit_=(t,e)=>{throw process.exitCode=t,e},Module.inspect=()=>"[Emscripten Module object]"}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:typeof document!="undefined"&&document.currentScript&&(scriptDirectory=document.currentScript.src),_scriptDir&&(scriptDirectory=_scriptDir),scriptDirectory.indexOf("blob:")!==0?scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1):scriptDirectory="",read_=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},ENVIRONMENT_IS_WORKER&&(readBinary=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),readAsync=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{if(r.status==200||r.status==0&&r.response){e(r.response);return}n()},r.onerror=n,r.send(null)});var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var wasmBinary;Module.wasmBinary&&(wasmBinary=Module.wasmBinary);var noExitRuntime=Module.noExitRuntime||!0;typeof WebAssembly!="object"&&abort("no native wasm support detected");var wasmMemory,ABORT=!1,EXITSTATUS;function assert(t,e){t||abort(e)}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var t=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(t),Module.HEAP16=HEAP16=new Int16Array(t),Module.HEAPU8=HEAPU8=new Uint8Array(t),Module.HEAPU16=HEAPU16=new Uint16Array(t),Module.HEAP32=HEAP32=new Int32Array(t),Module.HEAPU32=HEAPU32=new Uint32Array(t),Module.HEAPF32=HEAPF32=new Float32Array(t),Module.HEAPF64=HEAPF64=new Float64Array(t)}var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],runtimeInitialized=!1,runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,!Module.noFSInit&&!FS.init.initialized&&FS.init(),FS.ignorePermissions=!1,TTY.init(),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(t){__ATPRERUN__.unshift(t)}function addOnInit(t){__ATINIT__.unshift(t)}function addOnPostRun(t){__ATPOSTRUN__.unshift(t)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function getUniqueRunDependency(t){return t}function addRunDependency(t){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(t){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),runDependencies==0&&(runDependencyWatcher!==null&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var e=dependenciesFulfilled;dependenciesFulfilled=null,e()}}function abort(t){Module.onAbort&&Module.onAbort(t),t="Aborted("+t+")",err(t),ABORT=!0,EXITSTATUS=1,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw readyPromiseReject(e),e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(t){return t.startsWith(dataURIPrefix)}function isFileURI(t){return t.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="BeautySightCore.wasm",isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));function getBinarySync(t){if(t==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(t);throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(t){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(t))return fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(()=>getBinarySync(t));if(readAsync)return new Promise((e,n)=>{readAsync(t,r=>e(new Uint8Array(r)),n)})}return Promise.resolve().then(()=>getBinarySync(t))}function instantiateArrayBuffer(t,e,n){return getBinaryPromise(t).then(r=>WebAssembly.instantiate(r,e)).then(r=>r).then(n,r=>{err(`failed to asynchronously prepare wasm: ${r}`),abort(r)})}function instantiateAsync(t,e,n,r){return!t&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(e)&&!isFileURI(e)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(o=>{var a=WebAssembly.instantiateStreaming(o,n);return a.then(r,function(c){return err(`wasm streaming compile failed: ${c}`),err("falling back to ArrayBuffer instantiation"),instantiateArrayBuffer(e,n,r)})}):instantiateArrayBuffer(e,n,r)}function createWasm(){var t={a:wasmImports};function e(r,o){return wasmExports=r.exports,wasmMemory=wasmExports.ab,updateMemoryViews(),wasmTable=wasmExports.db,addOnInit(wasmExports.bb),removeRunDependency("wasm-instantiate"),wasmExports}addRunDependency("wasm-instantiate");function n(r){e(r.instance)}if(Module.instantiateWasm)try{return Module.instantiateWasm(t,e)}catch(r){err(`Module.instantiateWasm callback failed with error: ${r}`),readyPromiseReject(r)}return instantiateAsync(wasmBinary,wasmBinaryFile,t,n).catch(readyPromiseReject),{}}var tempDouble,tempI64,ASM_CONSTS={235e3:(t,e,n,r,o,a)=>{var c=Emval.toValue(t),l=new Uint8ClampedArray(Module.HEAPU8.buffer,n,r),u=new ImageData(l,o,a);c.callback(e,u)}};function _(){abort("missing function: ")}_.stub=!0;var _emscripten_set_main_loop_timing=(t,e)=>{if(Browser.mainLoop.timingMode=t,Browser.mainLoop.timingValue=e,!Browser.mainLoop.func)return 1;if(Browser.mainLoop.running||(Browser.mainLoop.running=!0),t==0)Browser.mainLoop.scheduler=function(){var c=Math.max(0,Browser.mainLoop.tickStartTime+e-_emscripten_get_now())|0;setTimeout(Browser.mainLoop.runner,c)},Browser.mainLoop.method="timeout";else if(t==1)Browser.mainLoop.scheduler=function(){Browser.requestAnimationFrame(Browser.mainLoop.runner)},Browser.mainLoop.method="rAF";else if(t==2){if(typeof setImmediate=="undefined"){var n=[],r="setimmediate",o=a=>{(a.data===r||a.data.target===r)&&(a.stopPropagation(),n.shift()())};addEventListener("message",o,!0),setImmediate=function(c){n.push(c),ENVIRONMENT_IS_WORKER?(Module.setImmediates===void 0&&(Module.setImmediates=[]),Module.setImmediates.push(c),postMessage({target:r})):postMessage(r,"*")}}Browser.mainLoop.scheduler=function(){setImmediate(Browser.mainLoop.runner)},Browser.mainLoop.method="immediate"}return 0},_emscripten_get_now;_emscripten_get_now=()=>performance.now();var webgl_enable_ANGLE_instanced_arrays=t=>{var e=t.getExtension("ANGLE_instanced_arrays");if(e)return t.vertexAttribDivisor=(n,r)=>e.vertexAttribDivisorANGLE(n,r),t.drawArraysInstanced=(n,r,o,a)=>e.drawArraysInstancedANGLE(n,r,o,a),t.drawElementsInstanced=(n,r,o,a,c)=>e.drawElementsInstancedANGLE(n,r,o,a,c),1},webgl_enable_OES_vertex_array_object=t=>{var e=t.getExtension("OES_vertex_array_object");if(e)return t.createVertexArray=()=>e.createVertexArrayOES(),t.deleteVertexArray=n=>e.deleteVertexArrayOES(n),t.bindVertexArray=n=>e.bindVertexArrayOES(n),t.isVertexArray=n=>e.isVertexArrayOES(n),1},webgl_enable_WEBGL_draw_buffers=t=>{var e=t.getExtension("WEBGL_draw_buffers");if(e)return t.drawBuffers=(n,r)=>e.drawBuffersWEBGL(n,r),1},webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance=t=>!!(t.dibvbi=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance")),webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance=t=>!!(t.mdibvbi=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance")),webgl_enable_WEBGL_multi_draw=t=>!!(t.multiDrawWebgl=t.getExtension("WEBGL_multi_draw")),UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,UTF8ArrayToString=(t,e,n)=>{for(var r=e+n,o=e;t[o]&&!(o>=r);)++o;if(o-e>16&&t.buffer&&UTF8Decoder)return UTF8Decoder.decode(t.subarray(e,o));for(var a="";e<o;){var c=t[e++];if(!(c&128)){a+=String.fromCharCode(c);continue}var l=t[e++]&63;if((c&224)==192){a+=String.fromCharCode((c&31)<<6|l);continue}var u=t[e++]&63;if((c&240)==224?c=(c&15)<<12|l<<6|u:c=(c&7)<<18|l<<12|u<<6|t[e++]&63,c<65536)a+=String.fromCharCode(c);else{var h=c-65536;a+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return a},UTF8ToString=(t,e)=>t?UTF8ArrayToString(HEAPU8,t,e):"",GL={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:[],offscreenCanvases:{},queries:[],samplers:[],transformFeedbacks:[],syncs:[],stringCache:{},stringiCache:{},unpackAlignment:4,recordError:function(e){GL.lastError||(GL.lastError=e)},getNewId:t=>{for(var e=GL.counter++,n=t.length;n<e;n++)t[n]=null;return e},getSource:(t,e,n,r)=>{for(var o="",a=0;a<e;++a){var c=r?HEAP32[r+a*4>>2]:-1;o+=UTF8ToString(HEAP32[n+a*4>>2],c<0?void 0:c)}return o},createContext:(t,e)=>{if(e.renderViaOffscreenBackBuffer&&(e.preserveDrawingBuffer=!0),!t.getContextSafariWebGL2Fixed){let a=function(c,l){var u=t.getContextSafariWebGL2Fixed(c,l);return c=="webgl"==u instanceof WebGLRenderingContext?u:null};var o=a;t.getContextSafariWebGL2Fixed=t.getContext,t.getContext=a}var n=e.majorVersion>1?t.getContext("webgl2",e):t.getContext("webgl",e);if(!n)return 0;var r=GL.registerContext(n,e);return r},enableOffscreenFramebufferAttributes:t=>{t.renderViaOffscreenBackBuffer=!0,t.preserveDrawingBuffer=!0},createOffscreenFramebuffer:t=>{var e=t.GLctx,n=e.createFramebuffer();e.bindFramebuffer(36160,n),t.defaultFbo=n,t.defaultFboForbidBlitFramebuffer=!1,e.getContextAttributes().antialias&&(t.defaultFboForbidBlitFramebuffer=!0),t.defaultColorTarget=e.createTexture(),t.defaultDepthTarget=e.createRenderbuffer(),GL.resizeOffscreenFramebuffer(t),e.bindTexture(3553,t.defaultColorTarget),e.texParameteri(3553,10241,9728),e.texParameteri(3553,10240,9728),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texImage2D(3553,0,6408,e.canvas.width,e.canvas.height,0,6408,5121,null),e.framebufferTexture2D(36160,36064,3553,t.defaultColorTarget,0),e.bindTexture(3553,null);var r=e.createRenderbuffer();e.bindRenderbuffer(36161,t.defaultDepthTarget),e.renderbufferStorage(36161,33189,e.canvas.width,e.canvas.height),e.framebufferRenderbuffer(36160,36096,36161,t.defaultDepthTarget),e.bindRenderbuffer(36161,null);var o=[-1,-1,-1,1,1,-1,1,1],a=e.createBuffer();e.bindBuffer(34962,a),e.bufferData(34962,new Float32Array(o),35044),e.bindBuffer(34962,null),t.blitVB=a;var c="attribute vec2 pos;varying lowp vec2 tex;void main() { tex = pos * 0.5 + vec2(0.5,0.5); gl_Position = vec4(pos, 0.0, 1.0); }",l=e.createShader(35633);e.shaderSource(l,c),e.compileShader(l);var u="varying lowp vec2 tex;uniform sampler2D sampler;void main() { gl_FragColor = texture2D(sampler, tex); }",h=e.createShader(35632);e.shaderSource(h,u),e.compileShader(h);var d=e.createProgram();e.attachShader(d,l),e.attachShader(d,h),e.linkProgram(d),t.blitProgram=d,t.blitPosLoc=e.getAttribLocation(d,"pos"),e.useProgram(d),e.uniform1i(e.getUniformLocation(d,"sampler"),0),e.useProgram(null),t.defaultVao=void 0,e.createVertexArray&&(t.defaultVao=e.createVertexArray(),e.bindVertexArray(t.defaultVao),e.enableVertexAttribArray(t.blitPosLoc),e.bindVertexArray(null))},resizeOffscreenFramebuffer:t=>{var e=t.GLctx;if(t.defaultColorTarget){var n=e.getParameter(32873);e.bindTexture(3553,t.defaultColorTarget),e.texImage2D(3553,0,6408,e.drawingBufferWidth,e.drawingBufferHeight,0,6408,5121,null),e.bindTexture(3553,n)}if(t.defaultDepthTarget){var r=e.getParameter(36007);e.bindRenderbuffer(36161,t.defaultDepthTarget),e.renderbufferStorage(36161,33189,e.drawingBufferWidth,e.drawingBufferHeight),e.bindRenderbuffer(36161,r)}},blitOffscreenFramebuffer:t=>{var e=t.GLctx,n=e.getParameter(3089);n&&e.disable(3089);var r=e.getParameter(36006);if(e.blitFramebuffer&&!t.defaultFboForbidBlitFramebuffer)e.bindFramebuffer(36008,t.defaultFbo),e.bindFramebuffer(36009,null),e.blitFramebuffer(0,0,e.canvas.width,e.canvas.height,0,0,e.canvas.width,e.canvas.height,16384,9728);else{let E=function(){e.vertexAttribPointer(t.blitPosLoc,2,5126,!1,0,0),e.drawArrays(5,0,4)};var C=E;e.bindFramebuffer(36160,null);var o=e.getParameter(35725);e.useProgram(t.blitProgram);var a=e.getParameter(34964);e.bindBuffer(34962,t.blitVB);var c=e.getParameter(34016);e.activeTexture(33984);var l=e.getParameter(32873);e.bindTexture(3553,t.defaultColorTarget);var u=e.getParameter(3042);u&&e.disable(3042);var h=e.getParameter(2884);h&&e.disable(2884);var d=e.getParameter(2929);d&&e.disable(2929);var f=e.getParameter(2960);if(f&&e.disable(2960),t.defaultVao){var p=e.getParameter(34229);e.bindVertexArray(t.defaultVao),E(),e.bindVertexArray(p)}else{for(var m={buffer:e.getVertexAttrib(t.blitPosLoc,34975),size:e.getVertexAttrib(t.blitPosLoc,34339),stride:e.getVertexAttrib(t.blitPosLoc,34340),type:e.getVertexAttrib(t.blitPosLoc,34341),normalized:e.getVertexAttrib(t.blitPosLoc,34922),pointer:e.getVertexAttribOffset(t.blitPosLoc,34373)},v=e.getParameter(34921),x=[],b=0;b<v;++b){var y=e.getVertexAttrib(b,34338),g=b==t.blitPosLoc;y&&!g&&e.disableVertexAttribArray(b),!y&&g&&e.enableVertexAttribArray(b),x[b]=y}E();for(var b=0;b<v;++b){var y=x[b],M=b==t.blitPosLoc;y&&!M&&e.enableVertexAttribArray(b),!y&&M&&e.disableVertexAttribArray(b)}e.bindBuffer(34962,m.buffer),e.vertexAttribPointer(t.blitPosLoc,m.size,m.type,m.normalized,m.stride,m.offset)}f&&e.enable(2960),d&&e.enable(2929),h&&e.enable(2884),u&&e.enable(3042),e.bindTexture(3553,l),e.activeTexture(c),e.bindBuffer(34962,a),e.useProgram(o)}e.bindFramebuffer(36160,r),n&&e.enable(3089)},registerContext:(t,e)=>{var n=GL.getNewId(GL.contexts),r={handle:n,attributes:e,version:e.majorVersion,GLctx:t};return t.canvas&&(t.canvas.GLctxObject=r),GL.contexts[n]=r,(typeof e.enableExtensionsByDefault=="undefined"||e.enableExtensionsByDefault)&&GL.initExtensions(r),e.renderViaOffscreenBackBuffer&&GL.createOffscreenFramebuffer(r),n},makeContextCurrent:t=>(GL.currentContext=GL.contexts[t],Module.ctx=GLctx=GL.currentContext&&GL.currentContext.GLctx,!(t&&!GLctx)),getContext:t=>GL.contexts[t],deleteContext:t=>{GL.currentContext===GL.contexts[t]&&(GL.currentContext=null),typeof JSEvents=="object"&&JSEvents.removeAllHandlersOnTarget(GL.contexts[t].GLctx.canvas),GL.contexts[t]&&GL.contexts[t].GLctx.canvas&&(GL.contexts[t].GLctx.canvas.GLctxObject=void 0),GL.contexts[t]=null},initExtensions:t=>{if(t||(t=GL.currentContext),!t.initExtensionsDone){t.initExtensionsDone=!0;var e=t.GLctx;webgl_enable_ANGLE_instanced_arrays(e),webgl_enable_OES_vertex_array_object(e),webgl_enable_WEBGL_draw_buffers(e),webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(e),webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(e),t.version>=2&&(e.disjointTimerQueryExt=e.getExtension("EXT_disjoint_timer_query_webgl2")),(t.version<2||!e.disjointTimerQueryExt)&&(e.disjointTimerQueryExt=e.getExtension("EXT_disjoint_timer_query")),webgl_enable_WEBGL_multi_draw(e);var n=e.getSupportedExtensions()||[];n.forEach(r=>{!r.includes("lose_context")&&!r.includes("debug")&&e.getExtension(r)})}}},setMainLoop=(t,e,n,r,o)=>{assert(!Browser.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Browser.mainLoop.func=t,Browser.mainLoop.arg=r;var a=Browser.mainLoop.currentlyRunningMainloop;function c(){return!(a<Browser.mainLoop.currentlyRunningMainloop)}if(Browser.mainLoop.running=!1,Browser.mainLoop.runner=function(){if(!ABORT){if(Browser.mainLoop.queue.length>0){var u=Date.now(),h=Browser.mainLoop.queue.shift();if(h.func(h.arg),Browser.mainLoop.remainingBlockers){var d=Browser.mainLoop.remainingBlockers,f=d%1==0?d-1:Math.floor(d);h.counted?Browser.mainLoop.remainingBlockers=f:(f=f+.5,Browser.mainLoop.remainingBlockers=(8*d+f)/9)}if(Browser.mainLoop.updateStatus(),!c())return;setTimeout(Browser.mainLoop.runner,0);return}if(c()){if(Browser.mainLoop.currentFrameNumber=Browser.mainLoop.currentFrameNumber+1|0,Browser.mainLoop.timingMode==1&&Browser.mainLoop.timingValue>1&&Browser.mainLoop.currentFrameNumber%Browser.mainLoop.timingValue!=0){Browser.mainLoop.scheduler();return}else Browser.mainLoop.timingMode==0&&(Browser.mainLoop.tickStartTime=_emscripten_get_now());Browser.mainLoop.runIter(t),c()&&(typeof SDL=="object"&&SDL.audio&&SDL.audio.queueNewAudioData&&SDL.audio.queueNewAudioData(),Browser.mainLoop.scheduler())}}},o||(e&&e>0?_emscripten_set_main_loop_timing(0,1e3/e):_emscripten_set_main_loop_timing(1,1),Browser.mainLoop.scheduler()),n)throw"unwind"},handleException=t=>{if(t instanceof ExitStatus||t=="unwind")return EXITSTATUS;quit_(1,t)};function ExitStatus(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var PATH={isAbs:t=>t.charAt(0)==="/",splitPath:t=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(t).slice(1)},normalizeArray:(t,e)=>{for(var n=0,r=t.length-1;r>=0;r--){var o=t[r];o==="."?t.splice(r,1):o===".."?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n;n--)t.unshift("..");return t},normalize:t=>{var e=PATH.isAbs(t),n=t.substr(-1)==="/";return t=PATH.normalizeArray(t.split("/").filter(r=>!!r),!e).join("/"),!t&&!e&&(t="."),t&&n&&(t+="/"),(e?"/":"")+t},dirname:t=>{var e=PATH.splitPath(t),n=e[0],r=e[1];return!n&&!r?".":(r&&(r=r.substr(0,r.length-1)),n+r)},basename:t=>{if(t==="/")return"/";t=PATH.normalize(t),t=t.replace(/\/$/,"");var e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)},join:function(){var t=Array.prototype.slice.call(arguments);return PATH.normalize(t.join("/"))},join2:(t,e)=>PATH.normalize(t+"/"+e)},initRandomFill=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return r=>crypto.getRandomValues(r);if(ENVIRONMENT_IS_NODE)try{var t=require("crypto"),e=t.randomFillSync;if(e)return r=>t.randomFillSync(r);var n=t.randomBytes;return r=>(r.set(n(r.byteLength)),r)}catch(r){}abort("initRandomDevice")},randomFill=t=>(randomFill=initRandomFill())(t),PATH_FS={resolve:function(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var r=n>=0?arguments[n]:FS.cwd();if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)return"";t=r+"/"+t,e=PATH.isAbs(r)}return t=PATH.normalizeArray(t.split("/").filter(o=>!!o),!e).join("/"),(e?"/":"")+t||"."},relative:(t,e)=>{t=PATH_FS.resolve(t).substr(1),e=PATH_FS.resolve(e).substr(1);function n(h){for(var d=0;d<h.length&&h[d]==="";d++);for(var f=h.length-1;f>=0&&h[f]==="";f--);return d>f?[]:h.slice(d,f-d+1)}for(var r=n(t.split("/")),o=n(e.split("/")),a=Math.min(r.length,o.length),c=a,l=0;l<a;l++)if(r[l]!==o[l]){c=l;break}for(var u=[],l=c;l<r.length;l++)u.push("..");return u=u.concat(o.slice(c)),u.join("/")}},FS_stdin_getChar_buffer=[],lengthBytesUTF8=t=>{for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++n):e+=3}return e},stringToUTF8Array=(t,e,n,r)=>{if(!(r>0))return 0;for(var o=n,a=n+r-1,c=0;c<t.length;++c){var l=t.charCodeAt(c);if(l>=55296&&l<=57343){var u=t.charCodeAt(++c);l=65536+((l&1023)<<10)|u&1023}if(l<=127){if(n>=a)break;e[n++]=l}else if(l<=2047){if(n+1>=a)break;e[n++]=192|l>>6,e[n++]=128|l&63}else if(l<=65535){if(n+2>=a)break;e[n++]=224|l>>12,e[n++]=128|l>>6&63,e[n++]=128|l&63}else{if(n+3>=a)break;e[n++]=240|l>>18,e[n++]=128|l>>12&63,e[n++]=128|l>>6&63,e[n++]=128|l&63}}return e[n]=0,n-o};function intArrayFromString(t,e,n){var r=n>0?n:lengthBytesUTF8(t)+1,o=new Array(r),a=stringToUTF8Array(t,o,0,o.length);return e&&(o.length=a),o}var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var t=null;if(ENVIRONMENT_IS_NODE){var e=256,n=Buffer.alloc(e),r=0,o=process.stdin.fd;try{r=fs.readSync(o,n)}catch(a){if(a.toString().includes("EOF"))r=0;else throw a}r>0?t=n.slice(0,r).toString("utf-8"):t=null}else typeof window!="undefined"&&typeof window.prompt=="function"?(t=window.prompt("Input: "),t!==null&&(t+=`
`)):typeof readline=="function"&&(t=readline(),t!==null&&(t+=`
`));if(!t)return null;FS_stdin_getChar_buffer=intArrayFromString(t,!0)}return FS_stdin_getChar_buffer.shift()},TTY={ttys:[],init(){},shutdown(){},register(t,e){TTY.ttys[t]={input:[],output:[],ops:e},FS.registerDevice(t,TTY.stream_ops)},stream_ops:{open(t){var e=TTY.ttys[t.node.rdev];if(!e)throw new FS.ErrnoError(43);t.tty=e,t.seekable=!1},close(t){t.tty.ops.fsync(t.tty)},fsync(t){t.tty.ops.fsync(t.tty)},read(t,e,n,r,o){if(!t.tty||!t.tty.ops.get_char)throw new FS.ErrnoError(60);for(var a=0,c=0;c<r;c++){var l;try{l=t.tty.ops.get_char(t.tty)}catch(u){throw new FS.ErrnoError(29)}if(l===void 0&&a===0)throw new FS.ErrnoError(6);if(l==null)break;a++,e[n+c]=l}return a&&(t.node.timestamp=Date.now()),a},write(t,e,n,r,o){if(!t.tty||!t.tty.ops.put_char)throw new FS.ErrnoError(60);try{for(var a=0;a<r;a++)t.tty.ops.put_char(t.tty,e[n+a])}catch(c){throw new FS.ErrnoError(29)}return r&&(t.node.timestamp=Date.now()),a}},default_tty_ops:{get_char(t){return FS_stdin_getChar()},put_char(t,e){e===null||e===10?(out(UTF8ArrayToString(t.output,0)),t.output=[]):e!=0&&t.output.push(e)},fsync(t){t.output&&t.output.length>0&&(out(UTF8ArrayToString(t.output,0)),t.output=[])},ioctl_tcgets(t){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(t,e,n){return 0},ioctl_tiocgwinsz(t){return[24,80]}},default_tty1_ops:{put_char(t,e){e===null||e===10?(err(UTF8ArrayToString(t.output,0)),t.output=[]):e!=0&&t.output.push(e)},fsync(t){t.output&&t.output.length>0&&(err(UTF8ArrayToString(t.output,0)),t.output=[])}}},zeroMemory=(t,e)=>(HEAPU8.fill(0,t,t+e),t),alignMemory=(t,e)=>Math.ceil(t/e)*e,mmapAlloc=t=>{t=alignMemory(t,65536);var e=_emscripten_builtin_memalign(65536,t);return e?zeroMemory(e,t):0},MEMFS={ops_table:null,mount(t){return MEMFS.createNode(null,"/",16895,0)},createNode(t,e,n,r){if(FS.isBlkdev(n)||FS.isFIFO(n))throw new FS.ErrnoError(63);MEMFS.ops_table||(MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}});var o=FS.createNode(t,e,n,r);return FS.isDir(o.mode)?(o.node_ops=MEMFS.ops_table.dir.node,o.stream_ops=MEMFS.ops_table.dir.stream,o.contents={}):FS.isFile(o.mode)?(o.node_ops=MEMFS.ops_table.file.node,o.stream_ops=MEMFS.ops_table.file.stream,o.usedBytes=0,o.contents=null):FS.isLink(o.mode)?(o.node_ops=MEMFS.ops_table.link.node,o.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(o.mode)&&(o.node_ops=MEMFS.ops_table.chrdev.node,o.stream_ops=MEMFS.ops_table.chrdev.stream),o.timestamp=Date.now(),t&&(t.contents[e]=o,t.timestamp=o.timestamp),o},getFileDataAsTypedArray(t){return t.contents?t.contents.subarray?t.contents.subarray(0,t.usedBytes):new Uint8Array(t.contents):new Uint8Array(0)},expandFileStorage(t,e){var n=t.contents?t.contents.length:0;if(!(n>=e)){var r=1024*1024;e=Math.max(e,n*(n<r?2:1.125)>>>0),n!=0&&(e=Math.max(e,256));var o=t.contents;t.contents=new Uint8Array(e),t.usedBytes>0&&t.contents.set(o.subarray(0,t.usedBytes),0)}},resizeFileStorage(t,e){if(t.usedBytes!=e)if(e==0)t.contents=null,t.usedBytes=0;else{var n=t.contents;t.contents=new Uint8Array(e),n&&t.contents.set(n.subarray(0,Math.min(e,t.usedBytes))),t.usedBytes=e}},node_ops:{getattr(t){var e={};return e.dev=FS.isChrdev(t.mode)?t.id:1,e.ino=t.id,e.mode=t.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=t.rdev,FS.isDir(t.mode)?e.size=4096:FS.isFile(t.mode)?e.size=t.usedBytes:FS.isLink(t.mode)?e.size=t.link.length:e.size=0,e.atime=new Date(t.timestamp),e.mtime=new Date(t.timestamp),e.ctime=new Date(t.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr(t,e){e.mode!==void 0&&(t.mode=e.mode),e.timestamp!==void 0&&(t.timestamp=e.timestamp),e.size!==void 0&&MEMFS.resizeFileStorage(t,e.size)},lookup(t,e){throw FS.genericErrors[44]},mknod(t,e,n,r){return MEMFS.createNode(t,e,n,r)},rename(t,e,n){if(FS.isDir(t.mode)){var r;try{r=FS.lookupNode(e,n)}catch(a){}if(r)for(var o in r.contents)throw new FS.ErrnoError(55)}delete t.parent.contents[t.name],t.parent.timestamp=Date.now(),t.name=n,e.contents[n]=t,e.timestamp=t.parent.timestamp,t.parent=e},unlink(t,e){delete t.contents[e],t.timestamp=Date.now()},rmdir(t,e){var n=FS.lookupNode(t,e);for(var r in n.contents)throw new FS.ErrnoError(55);delete t.contents[e],t.timestamp=Date.now()},readdir(t){var e=[".",".."];for(var n in t.contents)t.contents.hasOwnProperty(n)&&e.push(n);return e},symlink(t,e,n){var r=MEMFS.createNode(t,e,41471,0);return r.link=n,r},readlink(t){if(!FS.isLink(t.mode))throw new FS.ErrnoError(28);return t.link}},stream_ops:{read(t,e,n,r,o){var a=t.node.contents;if(o>=t.node.usedBytes)return 0;var c=Math.min(t.node.usedBytes-o,r);if(c>8&&a.subarray)e.set(a.subarray(o,o+c),n);else for(var l=0;l<c;l++)e[n+l]=a[o+l];return c},write(t,e,n,r,o,a){if(!r)return 0;var c=t.node;if(c.timestamp=Date.now(),e.subarray&&(!c.contents||c.contents.subarray)){if(a)return c.contents=e.subarray(n,n+r),c.usedBytes=r,r;if(c.usedBytes===0&&o===0)return c.contents=e.slice(n,n+r),c.usedBytes=r,r;if(o+r<=c.usedBytes)return c.contents.set(e.subarray(n,n+r),o),r}if(MEMFS.expandFileStorage(c,o+r),c.contents.subarray&&e.subarray)c.contents.set(e.subarray(n,n+r),o);else for(var l=0;l<r;l++)c.contents[o+l]=e[n+l];return c.usedBytes=Math.max(c.usedBytes,o+r),r},llseek(t,e,n){var r=e;if(n===1?r+=t.position:n===2&&FS.isFile(t.node.mode)&&(r+=t.node.usedBytes),r<0)throw new FS.ErrnoError(28);return r},allocate(t,e,n){MEMFS.expandFileStorage(t.node,e+n),t.node.usedBytes=Math.max(t.node.usedBytes,e+n)},mmap(t,e,n,r,o){if(!FS.isFile(t.node.mode))throw new FS.ErrnoError(43);var a,c,l=t.node.contents;if(!(o&2)&&l.buffer===HEAP8.buffer)c=!1,a=l.byteOffset;else{if((n>0||n+e<l.length)&&(l.subarray?l=l.subarray(n,n+e):l=Array.prototype.slice.call(l,n,n+e)),c=!0,a=mmapAlloc(e),!a)throw new FS.ErrnoError(48);HEAP8.set(l,a)}return{ptr:a,allocated:c}},msync(t,e,n,r,o){return MEMFS.stream_ops.write(t,e,0,r,n,!1),0}}},asyncLoad=(t,e,n,r)=>{var o=r?"":`al ${t}`;readAsync(t,a=>{assert(a,`Loading data file "${t}" failed (no arrayBuffer).`),e(new Uint8Array(a)),o&&removeRunDependency(o)},a=>{if(n)n();else throw`Loading data file "${t}" failed.`}),o&&addRunDependency(o)},FS_createDataFile=(t,e,n,r,o,a)=>FS.createDataFile(t,e,n,r,o,a),preloadPlugins=Module.preloadPlugins||[],FS_handledByPreloadPlugin=(t,e,n,r)=>{typeof Browser!="undefined"&&Browser.init();var o=!1;return preloadPlugins.forEach(a=>{o||a.canHandle(e)&&(a.handle(t,e,n,r),o=!0)}),o},FS_createPreloadedFile=(t,e,n,r,o,a,c,l,u,h)=>{var d=e?PATH_FS.resolve(PATH.join2(t,e)):t,f=`cp ${d}`;function p(m){function v(x){h&&h(),l||FS_createDataFile(t,e,x,r,o,u),a&&a(),removeRunDependency(f)}FS_handledByPreloadPlugin(m,d,v,()=>{c&&c(),removeRunDependency(f)})||v(m)}addRunDependency(f),typeof n=="string"?asyncLoad(n,m=>p(m),c):p(n)},FS_modeStringToFlags=t=>{var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},n=e[t];if(typeof n=="undefined")throw new Error(`Unknown file open mode: ${t}`);return n},FS_getMode=(t,e)=>{var n=0;return t&&(n|=365),e&&(n|=146),n},FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(t,e={}){if(t=PATH_FS.resolve(t),!t)return{path:"",node:null};var n={follow_mount:!0,recurse_count:0};if(e=Object.assign(n,e),e.recurse_count>8)throw new FS.ErrnoError(32);for(var r=t.split("/").filter(f=>!!f),o=FS.root,a="/",c=0;c<r.length;c++){var l=c===r.length-1;if(l&&e.parent)break;if(o=FS.lookupNode(o,r[c]),a=PATH.join2(a,r[c]),FS.isMountpoint(o)&&(!l||l&&e.follow_mount)&&(o=o.mounted.root),!l||e.follow)for(var u=0;FS.isLink(o.mode);){var h=FS.readlink(a);a=PATH_FS.resolve(PATH.dirname(a),h);var d=FS.lookupPath(a,{recurse_count:e.recurse_count+1});if(o=d.node,u++>40)throw new FS.ErrnoError(32)}}return{path:a,node:o}},getPath(t){for(var e;;){if(FS.isRoot(t)){var n=t.mount.mountpoint;return e?n[n.length-1]!=="/"?`${n}/${e}`:n+e:n}e=e?`${t.name}/${e}`:t.name,t=t.parent}},hashName(t,e){for(var n=0,r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r)|0;return(t+n>>>0)%FS.nameTable.length},hashAddNode(t){var e=FS.hashName(t.parent.id,t.name);t.name_next=FS.nameTable[e],FS.nameTable[e]=t},hashRemoveNode(t){var e=FS.hashName(t.parent.id,t.name);if(FS.nameTable[e]===t)FS.nameTable[e]=t.name_next;else for(var n=FS.nameTable[e];n;){if(n.name_next===t){n.name_next=t.name_next;break}n=n.name_next}},lookupNode(t,e){var n=FS.mayLookup(t);if(n)throw new FS.ErrnoError(n,t);for(var r=FS.hashName(t.id,e),o=FS.nameTable[r];o;o=o.name_next){var a=o.name;if(o.parent.id===t.id&&a===e)return o}return FS.lookup(t,e)},createNode(t,e,n,r){var o=new FS.FSNode(t,e,n,r);return FS.hashAddNode(o),o},destroyNode(t){FS.hashRemoveNode(t)},isRoot(t){return t===t.parent},isMountpoint(t){return!!t.mounted},isFile(t){return(t&61440)===32768},isDir(t){return(t&61440)===16384},isLink(t){return(t&61440)===40960},isChrdev(t){return(t&61440)===8192},isBlkdev(t){return(t&61440)===24576},isFIFO(t){return(t&61440)===4096},isSocket(t){return(t&49152)===49152},flagsToPermissionString(t){var e=["r","w","rw"][t&3];return t&512&&(e+="w"),e},nodePermissions(t,e){return FS.ignorePermissions?0:e.includes("r")&&!(t.mode&292)||e.includes("w")&&!(t.mode&146)||e.includes("x")&&!(t.mode&73)?2:0},mayLookup(t){var e=FS.nodePermissions(t,"x");return e||(t.node_ops.lookup?0:2)},mayCreate(t,e){try{var n=FS.lookupNode(t,e);return 20}catch(r){}return FS.nodePermissions(t,"wx")},mayDelete(t,e,n){var r;try{r=FS.lookupNode(t,e)}catch(a){return a.errno}var o=FS.nodePermissions(t,"wx");if(o)return o;if(n){if(!FS.isDir(r.mode))return 54;if(FS.isRoot(r)||FS.getPath(r)===FS.cwd())return 10}else if(FS.isDir(r.mode))return 31;return 0},mayOpen(t,e){return t?FS.isLink(t.mode)?32:FS.isDir(t.mode)&&(FS.flagsToPermissionString(e)!=="r"||e&512)?31:FS.nodePermissions(t,FS.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd(){for(var t=0;t<=FS.MAX_OPEN_FDS;t++)if(!FS.streams[t])return t;throw new FS.ErrnoError(33)},getStreamChecked(t){var e=FS.getStream(t);if(!e)throw new FS.ErrnoError(8);return e},getStream:t=>FS.streams[t],createStream(t,e=-1){return FS.FSStream||(FS.FSStream=function(){this.shared={}},FS.FSStream.prototype={},Object.defineProperties(FS.FSStream.prototype,{object:{get(){return this.node},set(n){this.node=n}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(n){this.shared.flags=n}},position:{get(){return this.shared.position},set(n){this.shared.position=n}}})),t=Object.assign(new FS.FSStream,t),e==-1&&(e=FS.nextfd()),t.fd=e,FS.streams[e]=t,t},closeStream(t){FS.streams[t]=null},chrdev_stream_ops:{open(t){var e=FS.getDevice(t.node.rdev);t.stream_ops=e.stream_ops,t.stream_ops.open&&t.stream_ops.open(t)},llseek(){throw new FS.ErrnoError(70)}},major:t=>t>>8,minor:t=>t&255,makedev:(t,e)=>t<<8|e,registerDevice(t,e){FS.devices[t]={stream_ops:e}},getDevice:t=>FS.devices[t],getMounts(t){for(var e=[],n=[t];n.length;){var r=n.pop();e.push(r),n.push.apply(n,r.mounts)}return e},syncfs(t,e){typeof t=="function"&&(e=t,t=!1),FS.syncFSRequests++,FS.syncFSRequests>1&&err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var n=FS.getMounts(FS.root.mount),r=0;function o(c){return FS.syncFSRequests--,e(c)}function a(c){if(c)return a.errored?void 0:(a.errored=!0,o(c));++r>=n.length&&o(null)}n.forEach(c=>{if(!c.type.syncfs)return a(null);c.type.syncfs(c,t,a)})},mount(t,e,n){var r=n==="/",o=!n,a;if(r&&FS.root)throw new FS.ErrnoError(10);if(!r&&!o){var c=FS.lookupPath(n,{follow_mount:!1});if(n=c.path,a=c.node,FS.isMountpoint(a))throw new FS.ErrnoError(10);if(!FS.isDir(a.mode))throw new FS.ErrnoError(54)}var l={type:t,opts:e,mountpoint:n,mounts:[]},u=t.mount(l);return u.mount=l,l.root=u,r?FS.root=u:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),u},unmount(t){var e=FS.lookupPath(t,{follow_mount:!1});if(!FS.isMountpoint(e.node))throw new FS.ErrnoError(28);var n=e.node,r=n.mounted,o=FS.getMounts(r);Object.keys(FS.nameTable).forEach(c=>{for(var l=FS.nameTable[c];l;){var u=l.name_next;o.includes(l.mount)&&FS.destroyNode(l),l=u}}),n.mounted=null;var a=n.mount.mounts.indexOf(r);n.mount.mounts.splice(a,1)},lookup(t,e){return t.node_ops.lookup(t,e)},mknod(t,e,n){var r=FS.lookupPath(t,{parent:!0}),o=r.node,a=PATH.basename(t);if(!a||a==="."||a==="..")throw new FS.ErrnoError(28);var c=FS.mayCreate(o,a);if(c)throw new FS.ErrnoError(c);if(!o.node_ops.mknod)throw new FS.ErrnoError(63);return o.node_ops.mknod(o,a,e,n)},create(t,e){return e=e!==void 0?e:438,e&=4095,e|=32768,FS.mknod(t,e,0)},mkdir(t,e){return e=e!==void 0?e:511,e&=1023,e|=16384,FS.mknod(t,e,0)},mkdirTree(t,e){for(var n=t.split("/"),r="",o=0;o<n.length;++o)if(n[o]){r+="/"+n[o];try{FS.mkdir(r,e)}catch(a){if(a.errno!=20)throw a}}},mkdev(t,e,n){return typeof n=="undefined"&&(n=e,e=438),e|=8192,FS.mknod(t,e,n)},symlink(t,e){if(!PATH_FS.resolve(t))throw new FS.ErrnoError(44);var n=FS.lookupPath(e,{parent:!0}),r=n.node;if(!r)throw new FS.ErrnoError(44);var o=PATH.basename(e),a=FS.mayCreate(r,o);if(a)throw new FS.ErrnoError(a);if(!r.node_ops.symlink)throw new FS.ErrnoError(63);return r.node_ops.symlink(r,o,t)},rename(t,e){var n=PATH.dirname(t),r=PATH.dirname(e),o=PATH.basename(t),a=PATH.basename(e),c,l,u;if(c=FS.lookupPath(t,{parent:!0}),l=c.node,c=FS.lookupPath(e,{parent:!0}),u=c.node,!l||!u)throw new FS.ErrnoError(44);if(l.mount!==u.mount)throw new FS.ErrnoError(75);var h=FS.lookupNode(l,o),d=PATH_FS.relative(t,r);if(d.charAt(0)!==".")throw new FS.ErrnoError(28);if(d=PATH_FS.relative(e,n),d.charAt(0)!==".")throw new FS.ErrnoError(55);var f;try{f=FS.lookupNode(u,a)}catch(v){}if(h!==f){var p=FS.isDir(h.mode),m=FS.mayDelete(l,o,p);if(m)throw new FS.ErrnoError(m);if(m=f?FS.mayDelete(u,a,p):FS.mayCreate(u,a),m)throw new FS.ErrnoError(m);if(!l.node_ops.rename)throw new FS.ErrnoError(63);if(FS.isMountpoint(h)||f&&FS.isMountpoint(f))throw new FS.ErrnoError(10);if(u!==l&&(m=FS.nodePermissions(l,"w"),m))throw new FS.ErrnoError(m);FS.hashRemoveNode(h);try{l.node_ops.rename(h,u,a)}catch(v){throw v}finally{FS.hashAddNode(h)}}},rmdir(t){var e=FS.lookupPath(t,{parent:!0}),n=e.node,r=PATH.basename(t),o=FS.lookupNode(n,r),a=FS.mayDelete(n,r,!0);if(a)throw new FS.ErrnoError(a);if(!n.node_ops.rmdir)throw new FS.ErrnoError(63);if(FS.isMountpoint(o))throw new FS.ErrnoError(10);n.node_ops.rmdir(n,r),FS.destroyNode(o)},readdir(t){var e=FS.lookupPath(t,{follow:!0}),n=e.node;if(!n.node_ops.readdir)throw new FS.ErrnoError(54);return n.node_ops.readdir(n)},unlink(t){var e=FS.lookupPath(t,{parent:!0}),n=e.node;if(!n)throw new FS.ErrnoError(44);var r=PATH.basename(t),o=FS.lookupNode(n,r),a=FS.mayDelete(n,r,!1);if(a)throw new FS.ErrnoError(a);if(!n.node_ops.unlink)throw new FS.ErrnoError(63);if(FS.isMountpoint(o))throw new FS.ErrnoError(10);n.node_ops.unlink(n,r),FS.destroyNode(o)},readlink(t){var e=FS.lookupPath(t),n=e.node;if(!n)throw new FS.ErrnoError(44);if(!n.node_ops.readlink)throw new FS.ErrnoError(28);return PATH_FS.resolve(FS.getPath(n.parent),n.node_ops.readlink(n))},stat(t,e){var n=FS.lookupPath(t,{follow:!e}),r=n.node;if(!r)throw new FS.ErrnoError(44);if(!r.node_ops.getattr)throw new FS.ErrnoError(63);return r.node_ops.getattr(r)},lstat(t){return FS.stat(t,!0)},chmod(t,e,n){var r;if(typeof t=="string"){var o=FS.lookupPath(t,{follow:!n});r=o.node}else r=t;if(!r.node_ops.setattr)throw new FS.ErrnoError(63);r.node_ops.setattr(r,{mode:e&4095|r.mode&-4096,timestamp:Date.now()})},lchmod(t,e){FS.chmod(t,e,!0)},fchmod(t,e){var n=FS.getStreamChecked(t);FS.chmod(n.node,e)},chown(t,e,n,r){var o;if(typeof t=="string"){var a=FS.lookupPath(t,{follow:!r});o=a.node}else o=t;if(!o.node_ops.setattr)throw new FS.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown(t,e,n){FS.chown(t,e,n,!0)},fchown(t,e,n){var r=FS.getStreamChecked(t);FS.chown(r.node,e,n)},truncate(t,e){if(e<0)throw new FS.ErrnoError(28);var n;if(typeof t=="string"){var r=FS.lookupPath(t,{follow:!0});n=r.node}else n=t;if(!n.node_ops.setattr)throw new FS.ErrnoError(63);if(FS.isDir(n.mode))throw new FS.ErrnoError(31);if(!FS.isFile(n.mode))throw new FS.ErrnoError(28);var o=FS.nodePermissions(n,"w");if(o)throw new FS.ErrnoError(o);n.node_ops.setattr(n,{size:e,timestamp:Date.now()})},ftruncate(t,e){var n=FS.getStreamChecked(t);if(!(n.flags&2097155))throw new FS.ErrnoError(28);FS.truncate(n.node,e)},utime(t,e,n){var r=FS.lookupPath(t,{follow:!0}),o=r.node;o.node_ops.setattr(o,{timestamp:Math.max(e,n)})},open(t,e,n){if(t==="")throw new FS.ErrnoError(44);e=typeof e=="string"?FS_modeStringToFlags(e):e,n=typeof n=="undefined"?438:n,e&64?n=n&4095|32768:n=0;var r;if(typeof t=="object")r=t;else{t=PATH.normalize(t);try{var o=FS.lookupPath(t,{follow:!(e&131072)});r=o.node}catch(u){}}var a=!1;if(e&64)if(r){if(e&128)throw new FS.ErrnoError(20)}else r=FS.mknod(t,n,0),a=!0;if(!r)throw new FS.ErrnoError(44);if(FS.isChrdev(r.mode)&&(e&=-513),e&65536&&!FS.isDir(r.mode))throw new FS.ErrnoError(54);if(!a){var c=FS.mayOpen(r,e);if(c)throw new FS.ErrnoError(c)}e&512&&!a&&FS.truncate(r,0),e&=-131713;var l=FS.createStream({node:r,path:FS.getPath(r),flags:e,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),Module.logReadFiles&&!(e&1)&&(FS.readFiles||(FS.readFiles={}),t in FS.readFiles||(FS.readFiles[t]=1)),l},close(t){if(FS.isClosed(t))throw new FS.ErrnoError(8);t.getdents&&(t.getdents=null);try{t.stream_ops.close&&t.stream_ops.close(t)}catch(e){throw e}finally{FS.closeStream(t.fd)}t.fd=null},isClosed(t){return t.fd===null},llseek(t,e,n){if(FS.isClosed(t))throw new FS.ErrnoError(8);if(!t.seekable||!t.stream_ops.llseek)throw new FS.ErrnoError(70);if(n!=0&&n!=1&&n!=2)throw new FS.ErrnoError(28);return t.position=t.stream_ops.llseek(t,e,n),t.ungotten=[],t.position},read(t,e,n,r,o){if(r<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(t))throw new FS.ErrnoError(8);if((t.flags&2097155)===1)throw new FS.ErrnoError(8);if(FS.isDir(t.node.mode))throw new FS.ErrnoError(31);if(!t.stream_ops.read)throw new FS.ErrnoError(28);var a=typeof o!="undefined";if(!a)o=t.position;else if(!t.seekable)throw new FS.ErrnoError(70);var c=t.stream_ops.read(t,e,n,r,o);return a||(t.position+=c),c},write(t,e,n,r,o,a){if(r<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(t))throw new FS.ErrnoError(8);if(!(t.flags&2097155))throw new FS.ErrnoError(8);if(FS.isDir(t.node.mode))throw new FS.ErrnoError(31);if(!t.stream_ops.write)throw new FS.ErrnoError(28);t.seekable&&t.flags&1024&&FS.llseek(t,0,2);var c=typeof o!="undefined";if(!c)o=t.position;else if(!t.seekable)throw new FS.ErrnoError(70);var l=t.stream_ops.write(t,e,n,r,o,a);return c||(t.position+=l),l},allocate(t,e,n){if(FS.isClosed(t))throw new FS.ErrnoError(8);if(e<0||n<=0)throw new FS.ErrnoError(28);if(!(t.flags&2097155))throw new FS.ErrnoError(8);if(!FS.isFile(t.node.mode)&&!FS.isDir(t.node.mode))throw new FS.ErrnoError(43);if(!t.stream_ops.allocate)throw new FS.ErrnoError(138);t.stream_ops.allocate(t,e,n)},mmap(t,e,n,r,o){if(r&2&&!(o&2)&&(t.flags&2097155)!==2)throw new FS.ErrnoError(2);if((t.flags&2097155)===1)throw new FS.ErrnoError(2);if(!t.stream_ops.mmap)throw new FS.ErrnoError(43);return t.stream_ops.mmap(t,e,n,r,o)},msync(t,e,n,r,o){return t.stream_ops.msync?t.stream_ops.msync(t,e,n,r,o):0},munmap:t=>0,ioctl(t,e,n){if(!t.stream_ops.ioctl)throw new FS.ErrnoError(59);return t.stream_ops.ioctl(t,e,n)},readFile(t,e={}){if(e.flags=e.flags||0,e.encoding=e.encoding||"binary",e.encoding!=="utf8"&&e.encoding!=="binary")throw new Error(`Invalid encoding type "${e.encoding}"`);var n,r=FS.open(t,e.flags),o=FS.stat(t),a=o.size,c=new Uint8Array(a);return FS.read(r,c,0,a,0),e.encoding==="utf8"?n=UTF8ArrayToString(c,0):e.encoding==="binary"&&(n=c),FS.close(r),n},writeFile(t,e,n={}){n.flags=n.flags||577;var r=FS.open(t,n.flags,n.mode);if(typeof e=="string"){var o=new Uint8Array(lengthBytesUTF8(e)+1),a=stringToUTF8Array(e,o,0,o.length);FS.write(r,o,0,a,void 0,n.canOwn)}else if(ArrayBuffer.isView(e))FS.write(r,e,0,e.byteLength,void 0,n.canOwn);else throw new Error("Unsupported data type");FS.close(r)},cwd:()=>FS.currentPath,chdir(t){var e=FS.lookupPath(t,{follow:!0});if(e.node===null)throw new FS.ErrnoError(44);if(!FS.isDir(e.node.mode))throw new FS.ErrnoError(54);var n=FS.nodePermissions(e.node,"x");if(n)throw new FS.ErrnoError(n);FS.currentPath=e.path},createDefaultDirectories(){FS.mkdir("/tmp"),FS.mkdir("/home"),FS.mkdir("/home/web_user")},createDefaultDevices(){FS.mkdir("/dev"),FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(r,o,a,c,l)=>c}),FS.mkdev("/dev/null",FS.makedev(1,3)),TTY.register(FS.makedev(5,0),TTY.default_tty_ops),TTY.register(FS.makedev(6,0),TTY.default_tty1_ops),FS.mkdev("/dev/tty",FS.makedev(5,0)),FS.mkdev("/dev/tty1",FS.makedev(6,0));var t=new Uint8Array(1024),e=0,n=()=>(e===0&&(e=randomFill(t).byteLength),t[--e]);FS.createDevice("/dev","random",n),FS.createDevice("/dev","urandom",n),FS.mkdir("/dev/shm"),FS.mkdir("/dev/shm/tmp")},createSpecialDirectories(){FS.mkdir("/proc");var t=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd"),FS.mount({mount(){var e=FS.createNode(t,"fd",16895,73);return e.node_ops={lookup(n,r){var o=+r,a=FS.getStreamChecked(o),c={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path}};return c.parent=c,c}},e}},{},"/proc/self/fd")},createStandardStreams(){Module.stdin?FS.createDevice("/dev","stdin",Module.stdin):FS.symlink("/dev/tty","/dev/stdin"),Module.stdout?FS.createDevice("/dev","stdout",null,Module.stdout):FS.symlink("/dev/tty","/dev/stdout"),Module.stderr?FS.createDevice("/dev","stderr",null,Module.stderr):FS.symlink("/dev/tty1","/dev/stderr");var t=FS.open("/dev/stdin",0),e=FS.open("/dev/stdout",1),n=FS.open("/dev/stderr",1)},ensureErrnoError(){FS.ErrnoError||(FS.ErrnoError=function(e,n){this.name="ErrnoError",this.node=n,this.setErrno=function(r){this.errno=r},this.setErrno(e),this.message="FS error"},FS.ErrnoError.prototype=new Error,FS.ErrnoError.prototype.constructor=FS.ErrnoError,[44].forEach(t=>{FS.genericErrors[t]=new FS.ErrnoError(t),FS.genericErrors[t].stack="<generic error, no stack>"}))},staticInit(){FS.ensureErrnoError(),FS.nameTable=new Array(4096),FS.mount(MEMFS,{},"/"),FS.createDefaultDirectories(),FS.createDefaultDevices(),FS.createSpecialDirectories(),FS.filesystems={MEMFS}},init(t,e,n){FS.init.initialized=!0,FS.ensureErrnoError(),Module.stdin=t||Module.stdin,Module.stdout=e||Module.stdout,Module.stderr=n||Module.stderr,FS.createStandardStreams()},quit(){FS.init.initialized=!1;for(var t=0;t<FS.streams.length;t++){var e=FS.streams[t];e&&FS.close(e)}},findObject(t,e){var n=FS.analyzePath(t,e);return n.exists?n.object:null},analyzePath(t,e){try{var n=FS.lookupPath(t,{follow:!e});t=n.path}catch(o){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=FS.lookupPath(t,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=PATH.basename(t),n=FS.lookupPath(t,{follow:!e}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot=n.path==="/"}catch(o){r.error=o.errno}return r},createPath(t,e,n,r){t=typeof t=="string"?t:FS.getPath(t);for(var o=e.split("/").reverse();o.length;){var a=o.pop();if(a){var c=PATH.join2(t,a);try{FS.mkdir(c)}catch(l){}t=c}}return c},createFile(t,e,n,r,o){var a=PATH.join2(typeof t=="string"?t:FS.getPath(t),e),c=FS_getMode(r,o);return FS.create(a,c)},createDataFile(t,e,n,r,o,a){var c=e;t&&(t=typeof t=="string"?t:FS.getPath(t),c=e?PATH.join2(t,e):t);var l=FS_getMode(r,o),u=FS.create(c,l);if(n){if(typeof n=="string"){for(var h=new Array(n.length),d=0,f=n.length;d<f;++d)h[d]=n.charCodeAt(d);n=h}FS.chmod(u,l|146);var p=FS.open(u,577);FS.write(p,n,0,n.length,0,a),FS.close(p),FS.chmod(u,l)}return u},createDevice(t,e,n,r){var o=PATH.join2(typeof t=="string"?t:FS.getPath(t),e),a=FS_getMode(!!n,!!r);FS.createDevice.major||(FS.createDevice.major=64);var c=FS.makedev(FS.createDevice.major++,0);return FS.registerDevice(c,{open(l){l.seekable=!1},close(l){r&&r.buffer&&r.buffer.length&&r(10)},read(l,u,h,d,f){for(var p=0,m=0;m<d;m++){var v;try{v=n()}catch(x){throw new FS.ErrnoError(29)}if(v===void 0&&p===0)throw new FS.ErrnoError(6);if(v==null)break;p++,u[h+m]=v}return p&&(l.node.timestamp=Date.now()),p},write(l,u,h,d,f){for(var p=0;p<d;p++)try{r(u[h+p])}catch(m){throw new FS.ErrnoError(29)}return d&&(l.node.timestamp=Date.now()),p}}),FS.mkdev(o,a,c)},forceLoadFile(t){if(t.isDevice||t.isFolder||t.link||t.contents)return!0;if(typeof XMLHttpRequest!="undefined")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(read_)try{t.contents=intArrayFromString(read_(t.url),!0),t.usedBytes=t.contents.length}catch(e){throw new FS.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(t,e,n,r,o){function a(){this.lengthKnown=!1,this.chunks=[]}if(a.prototype.get=function(m){if(!(m>this.length-1||m<0)){var v=m%this.chunkSize,x=m/this.chunkSize|0;return this.getter(x)[v]}},a.prototype.setDataGetter=function(m){this.getter=m},a.prototype.cacheLength=function(){var m=new XMLHttpRequest;if(m.open("HEAD",n,!1),m.send(null),!(m.status>=200&&m.status<300||m.status===304))throw new Error("Couldn't load "+n+". Status: "+m.status);var v=Number(m.getResponseHeader("Content-length")),x,b=(x=m.getResponseHeader("Accept-Ranges"))&&x==="bytes",y=(x=m.getResponseHeader("Content-Encoding"))&&x==="gzip",g=1024*1024;b||(g=v);var M=(E,w)=>{if(E>w)throw new Error("invalid range ("+E+", "+w+") or no bytes requested!");if(w>v-1)throw new Error("only "+v+" bytes available! programmer error!");var F=new XMLHttpRequest;if(F.open("GET",n,!1),v!==g&&F.setRequestHeader("Range","bytes="+E+"-"+w),F.responseType="arraybuffer",F.overrideMimeType&&F.overrideMimeType("text/plain; charset=x-user-defined"),F.send(null),!(F.status>=200&&F.status<300||F.status===304))throw new Error("Couldn't load "+n+". Status: "+F.status);return F.response!==void 0?new Uint8Array(F.response||[]):intArrayFromString(F.responseText||"",!0)},C=this;C.setDataGetter(E=>{var w=E*g,F=(E+1)*g-1;if(F=Math.min(F,v-1),typeof C.chunks[E]=="undefined"&&(C.chunks[E]=M(w,F)),typeof C.chunks[E]=="undefined")throw new Error("doXHR failed!");return C.chunks[E]}),(y||!v)&&(g=v=1,v=this.getter(0).length,g=v,out("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=v,this._chunkSize=g,this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var c=new a;Object.defineProperties(c,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var l={isDevice:!1,contents:c}}else var l={isDevice:!1,url:n};var u=FS.createFile(t,e,l,r,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var h={},d=Object.keys(u.stream_ops);d.forEach(p=>{var m=u.stream_ops[p];h[p]=function(){return FS.forceLoadFile(u),m.apply(null,arguments)}});function f(p,m,v,x,b){var y=p.node.contents;if(b>=y.length)return 0;var g=Math.min(y.length-b,x);if(y.slice)for(var M=0;M<g;M++)m[v+M]=y[b+M];else for(var M=0;M<g;M++)m[v+M]=y.get(b+M);return g}return h.read=(p,m,v,x,b)=>(FS.forceLoadFile(u),f(p,m,v,x,b)),h.mmap=(p,m,v,x,b)=>{FS.forceLoadFile(u);var y=mmapAlloc(m);if(!y)throw new FS.ErrnoError(48);return f(p,HEAP8,y,m,v),{ptr:y,allocated:!0}},u.stream_ops=h,u}},SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(t,e,n){if(PATH.isAbs(e))return e;var r;if(t===-100)r=FS.cwd();else{var o=SYSCALLS.getStreamFromFD(t);r=o.path}if(e.length==0){if(!n)throw new FS.ErrnoError(44);return r}return PATH.join2(r,e)},doStat(t,e,n){try{var r=t(e)}catch(l){if(l&&l.node&&PATH.normalize(e)!==PATH.normalize(FS.getPath(l.node)))return-54;throw l}HEAP32[n>>2]=r.dev,HEAP32[n+4>>2]=r.mode,HEAPU32[n+8>>2]=r.nlink,HEAP32[n+12>>2]=r.uid,HEAP32[n+16>>2]=r.gid,HEAP32[n+20>>2]=r.rdev,tempI64=[r.size>>>0,(tempDouble=r.size,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+24>>2]=tempI64[0],HEAP32[n+28>>2]=tempI64[1],HEAP32[n+32>>2]=4096,HEAP32[n+36>>2]=r.blocks;var o=r.atime.getTime(),a=r.mtime.getTime(),c=r.ctime.getTime();return tempI64=[Math.floor(o/1e3)>>>0,(tempDouble=Math.floor(o/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+40>>2]=tempI64[0],HEAP32[n+44>>2]=tempI64[1],HEAPU32[n+48>>2]=o%1e3*1e3,tempI64=[Math.floor(a/1e3)>>>0,(tempDouble=Math.floor(a/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+56>>2]=tempI64[0],HEAP32[n+60>>2]=tempI64[1],HEAPU32[n+64>>2]=a%1e3*1e3,tempI64=[Math.floor(c/1e3)>>>0,(tempDouble=Math.floor(c/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+72>>2]=tempI64[0],HEAP32[n+76>>2]=tempI64[1],HEAPU32[n+80>>2]=c%1e3*1e3,tempI64=[r.ino>>>0,(tempDouble=r.ino,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+88>>2]=tempI64[0],HEAP32[n+92>>2]=tempI64[1],0},doMsync(t,e,n,r,o){if(!FS.isFile(e.node.mode))throw new FS.ErrnoError(43);if(r&2)return 0;var a=HEAPU8.slice(t,t+n);FS.msync(e,a,o,n,r)},varargs:void 0,get(){var t=HEAP32[+SYSCALLS.varargs>>2];return SYSCALLS.varargs+=4,t},getp(){return SYSCALLS.get()},getStr(t){var e=UTF8ToString(t);return e},getStreamFromFD(t){var e=FS.getStreamChecked(t);return e}},_proc_exit=t=>{EXITSTATUS=t,keepRuntimeAlive()||(Module.onExit&&Module.onExit(t),ABORT=!0),quit_(t,new ExitStatus(t))},exitJS=(t,e)=>{EXITSTATUS=t,_proc_exit(t)},_exit=exitJS,maybeExit=()=>{if(!keepRuntimeAlive())try{_exit(EXITSTATUS)}catch(t){handleException(t)}},callUserCallback=t=>{if(!ABORT)try{t(),maybeExit()}catch(e){handleException(e)}},safeSetTimeout=(t,e)=>setTimeout(()=>{callUserCallback(t)},e),warnOnce=t=>{warnOnce.shown||(warnOnce.shown={}),warnOnce.shown[t]||(warnOnce.shown[t]=1,ENVIRONMENT_IS_NODE&&(t="warning: "+t),err(t))},Browser={mainLoop:{running:!1,scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause(){Browser.mainLoop.scheduler=null,Browser.mainLoop.currentlyRunningMainloop++},resume(){Browser.mainLoop.currentlyRunningMainloop++;var t=Browser.mainLoop.timingMode,e=Browser.mainLoop.timingValue,n=Browser.mainLoop.func;Browser.mainLoop.func=null,setMainLoop(n,0,!1,Browser.mainLoop.arg,!0),_emscripten_set_main_loop_timing(t,e),Browser.mainLoop.scheduler()},updateStatus(){if(Module.setStatus){var t=Module.statusMessage||"Please wait...",e=Browser.mainLoop.remainingBlockers,n=Browser.mainLoop.expectedBlockers;e?e<n?Module.setStatus(t+" ("+(n-e)+"/"+n+")"):Module.setStatus(t):Module.setStatus("")}},runIter(t){if(!ABORT){if(Module.preMainLoop){var e=Module.preMainLoop();if(e===!1)return}callUserCallback(t),Module.postMainLoop&&Module.postMainLoop()}}},isFullscreen:!1,pointerLock:!1,moduleContextCreatedCallbacks:[],workers:[],init(){if(Browser.initted)return;Browser.initted=!0;var t={};t.canHandle=function(a){return!Module.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(a)},t.handle=function(a,c,l,u){var h=new Blob([a],{type:Browser.getMimetype(c)});h.size!==a.length&&(h=new Blob([new Uint8Array(a).buffer],{type:Browser.getMimetype(c)}));var d=URL.createObjectURL(h),f=new Image;f.onload=()=>{assert(f.complete,`Image ${c} could not be decoded`);var p=document.createElement("canvas");p.width=f.width,p.height=f.height;var m=p.getContext("2d");m.drawImage(f,0,0),preloadedImages[c]=p,URL.revokeObjectURL(d),l&&l(a)},f.onerror=p=>{err(`Image ${d} could not be decoded`),u&&u()},f.src=d},preloadPlugins.push(t);var e={};e.canHandle=function(a){return!Module.noAudioDecoding&&a.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},e.handle=function(a,c,l,u){var h=!1;function d(v){h||(h=!0,preloadedAudios[c]=v,l&&l(a))}var f=new Blob([a],{type:Browser.getMimetype(c)}),p=URL.createObjectURL(f),m=new Audio;m.addEventListener("canplaythrough",()=>d(m),!1),m.onerror=function(x){if(h)return;err(`warning: browser could not fully decode audio ${c}, trying slower base64 approach`);function b(y){for(var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",M="=",C="",E=0,w=0,F=0;F<y.length;F++)for(E=E<<8|y[F],w+=8;w>=6;){var H=E>>w-6&63;w-=6,C+=g[H]}return w==2?(C+=g[(E&3)<<4],C+=M+M):w==4&&(C+=g[(E&15)<<2],C+=M),C}m.src="data:audio/x-"+c.substr(-3)+";base64,"+b(a),d(m)},m.src=p,safeSetTimeout(()=>{d(m)},1e4)},preloadPlugins.push(e);function n(){Browser.pointerLock=document.pointerLockElement===Module.canvas||document.mozPointerLockElement===Module.canvas||document.webkitPointerLockElement===Module.canvas||document.msPointerLockElement===Module.canvas}var r=Module.canvas;r&&(r.requestPointerLock=r.requestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock||r.msRequestPointerLock||(()=>{}),r.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||(()=>{}),r.exitPointerLock=r.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",n,!1),document.addEventListener("mozpointerlockchange",n,!1),document.addEventListener("webkitpointerlockchange",n,!1),document.addEventListener("mspointerlockchange",n,!1),Module.elementPointerLock&&r.addEventListener("click",o=>{!Browser.pointerLock&&Module.canvas.requestPointerLock&&(Module.canvas.requestPointerLock(),o.preventDefault())},!1))},createContext(t,e,n,r){if(e&&Module.ctx&&t==Module.canvas)return Module.ctx;var o,a;if(e){var c={antialias:!1,alpha:!1,majorVersion:typeof WebGL2RenderingContext!="undefined"?2:1};if(r)for(var l in r)c[l]=r[l];typeof GL!="undefined"&&(a=GL.createContext(t,c),a&&(o=GL.getContext(a).GLctx))}else o=t.getContext("2d");return o?(n&&(e||assert(typeof GLctx=="undefined","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),Module.ctx=o,e&&GL.makeContextCurrent(a),Module.useWebGL=e,Browser.moduleContextCreatedCallbacks.forEach(u=>u()),Browser.init()),o):null},destroyContext(t,e,n){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen(t,e){Browser.lockPointer=t,Browser.resizeCanvas=e,typeof Browser.lockPointer=="undefined"&&(Browser.lockPointer=!0),typeof Browser.resizeCanvas=="undefined"&&(Browser.resizeCanvas=!1);var n=Module.canvas;function r(){Browser.isFullscreen=!1;var a=n.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===a?(n.exitFullscreen=Browser.exitFullscreen,Browser.lockPointer&&n.requestPointerLock(),Browser.isFullscreen=!0,Browser.resizeCanvas?Browser.setFullscreenCanvasSize():Browser.updateCanvasDimensions(n)):(a.parentNode.insertBefore(n,a),a.parentNode.removeChild(a),Browser.resizeCanvas?Browser.setWindowedCanvasSize():Browser.updateCanvasDimensions(n)),Module.onFullScreen&&Module.onFullScreen(Browser.isFullscreen),Module.onFullscreen&&Module.onFullscreen(Browser.isFullscreen)}Browser.fullscreenHandlersInstalled||(Browser.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",r,!1),document.addEventListener("mozfullscreenchange",r,!1),document.addEventListener("webkitfullscreenchange",r,!1),document.addEventListener("MSFullscreenChange",r,!1));var o=document.createElement("div");n.parentNode.insertBefore(o,n),o.appendChild(n),o.requestFullscreen=o.requestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen||(o.webkitRequestFullscreen?()=>o.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):null)||(o.webkitRequestFullScreen?()=>o.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):null),o.requestFullscreen()},exitFullscreen(){if(!Browser.isFullscreen)return!1;var t=document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||(()=>{});return t.apply(document,[]),!0},nextRAF:0,fakeRequestAnimationFrame(t){var e=Date.now();if(Browser.nextRAF===0)Browser.nextRAF=e+1e3/60;else for(;e+2>=Browser.nextRAF;)Browser.nextRAF+=1e3/60;var n=Math.max(Browser.nextRAF-e,0);setTimeout(t,n)},requestAnimationFrame(t){if(typeof requestAnimationFrame=="function"){requestAnimationFrame(t);return}var e=Browser.fakeRequestAnimationFrame;e(t)},safeSetTimeout(t,e){return safeSetTimeout(t,e)},safeRequestAnimationFrame(t){return Browser.requestAnimationFrame(()=>{callUserCallback(t)})},getMimetype(t){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[t.substr(t.lastIndexOf(".")+1)]},getUserMedia(t){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(t)},getMovementX(t){return t.movementX||t.mozMovementX||t.webkitMovementX||0},getMovementY(t){return t.movementY||t.mozMovementY||t.webkitMovementY||0},getMouseWheelDelta(t){var e=0;switch(t.type){case"DOMMouseScroll":e=t.detail/3;break;case"mousewheel":e=t.wheelDelta/120;break;case"wheel":switch(e=t.deltaY,t.deltaMode){case 0:e/=100;break;case 1:e/=3;break;case 2:e*=80;break;default:throw"unrecognized mouse wheel delta mode: "+t.deltaMode}break;default:throw"unrecognized mouse wheel event: "+t.type}return e},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent(t){if(Browser.pointerLock)t.type!="mousemove"&&"mozMovementX"in t?Browser.mouseMovementX=Browser.mouseMovementY=0:(Browser.mouseMovementX=Browser.getMovementX(t),Browser.mouseMovementY=Browser.getMovementY(t)),typeof SDL!="undefined"?(Browser.mouseX=SDL.mouseX+Browser.mouseMovementX,Browser.mouseY=SDL.mouseY+Browser.mouseMovementY):(Browser.mouseX+=Browser.mouseMovementX,Browser.mouseY+=Browser.mouseMovementY);else{var e=Module.canvas.getBoundingClientRect(),n=Module.canvas.width,r=Module.canvas.height,o=typeof window.scrollX!="undefined"?window.scrollX:window.pageXOffset,a=typeof window.scrollY!="undefined"?window.scrollY:window.pageYOffset;if(t.type==="touchstart"||t.type==="touchend"||t.type==="touchmove"){var c=t.touch;if(c===void 0)return;var l=c.pageX-(o+e.left),u=c.pageY-(a+e.top);l=l*(n/e.width),u=u*(r/e.height);var h={x:l,y:u};if(t.type==="touchstart")Browser.lastTouches[c.identifier]=h,Browser.touches[c.identifier]=h;else if(t.type==="touchend"||t.type==="touchmove"){var d=Browser.touches[c.identifier];d||(d=h),Browser.lastTouches[c.identifier]=d,Browser.touches[c.identifier]=h}return}var f=t.pageX-(o+e.left),p=t.pageY-(a+e.top);f=f*(n/e.width),p=p*(r/e.height),Browser.mouseMovementX=f-Browser.mouseX,Browser.mouseMovementY=p-Browser.mouseY,Browser.mouseX=f,Browser.mouseY=p}},resizeListeners:[],updateResizeListeners(){var t=Module.canvas;Browser.resizeListeners.forEach(e=>e(t.width,t.height))},setCanvasSize(t,e,n){var r=Module.canvas;Browser.updateCanvasDimensions(r,t,e),n||Browser.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize(){if(typeof SDL!="undefined"){var t=HEAPU32[SDL.screen>>2];t=t|8388608,HEAP32[SDL.screen>>2]=t}Browser.updateCanvasDimensions(Module.canvas),Browser.updateResizeListeners()},setWindowedCanvasSize(){if(typeof SDL!="undefined"){var t=HEAPU32[SDL.screen>>2];t=t&-8388609,HEAP32[SDL.screen>>2]=t}Browser.updateCanvasDimensions(Module.canvas),Browser.updateResizeListeners()},updateCanvasDimensions(t,e,n){e&&n?(t.widthNative=e,t.heightNative=n):(e=t.widthNative,n=t.heightNative);var r=e,o=n;if(Module.forcedAspectRatio&&Module.forcedAspectRatio>0&&(r/o<Module.forcedAspectRatio?r=Math.round(o*Module.forcedAspectRatio):o=Math.round(r/Module.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===t.parentNode&&typeof screen!="undefined"){var a=Math.min(screen.width/r,screen.height/o);r=Math.round(r*a),o=Math.round(o*a)}Browser.resizeCanvas?(t.width!=r&&(t.width=r),t.height!=o&&(t.height=o),typeof t.style!="undefined"&&(t.style.removeProperty("width"),t.style.removeProperty("height"))):(t.width!=e&&(t.width=e),t.height!=n&&(t.height=n),typeof t.style!="undefined"&&(r!=e||o!=n?(t.style.setProperty("width",r+"px","important"),t.style.setProperty("height",o+"px","important")):(t.style.removeProperty("width"),t.style.removeProperty("height"))))}},callRuntimeCallbacks=t=>{for(;t.length>0;)t.shift()(Module)},___assert_fail=(t,e,n,r)=>{abort(`Assertion failed: ${UTF8ToString(t)}, at: `+[e?UTF8ToString(e):"unknown filename",n,r?UTF8ToString(r):"unknown function"])},exceptionCaught=[],uncaughtExceptionCount=0,___cxa_begin_catch=t=>{var e=new ExceptionInfo(t);return e.get_caught()||(e.set_caught(!0),uncaughtExceptionCount--),e.set_rethrown(!1),exceptionCaught.push(e),___cxa_increment_exception_refcount(e.excPtr),e.get_exception_ptr()},exceptionLast=0,___cxa_end_catch=()=>{_setThrew(0,0);var t=exceptionCaught.pop();___cxa_decrement_exception_refcount(t.excPtr),exceptionLast=0};function ExceptionInfo(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(e){HEAPU32[this.ptr+4>>2]=e},this.get_type=function(){return HEAPU32[this.ptr+4>>2]},this.set_destructor=function(e){HEAPU32[this.ptr+8>>2]=e},this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,HEAP8[this.ptr+12>>0]=e},this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0},this.set_rethrown=function(e){e=e?1:0,HEAP8[this.ptr+13>>0]=e},this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0},this.init=function(e,n){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(n)},this.set_adjusted_ptr=function(e){HEAPU32[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]},this.get_exception_ptr=function(){var e=___cxa_is_pointer_type(this.get_type());if(e)return HEAPU32[this.excPtr>>2];var n=this.get_adjusted_ptr();return n!==0?n:this.excPtr}}var ___resumeException=t=>{throw exceptionLast||(exceptionLast=t),exceptionLast},findMatchingCatch=t=>{var e=exceptionLast;if(!e)return setTempRet0(0),0;var n=new ExceptionInfo(e);n.set_adjusted_ptr(e);var r=n.get_type();if(!r)return setTempRet0(0),e;for(var o in t){var a=t[o];if(a===0||a===r)break;var c=n.ptr+16;if(___cxa_can_catch(a,r,c))return setTempRet0(a),e}return setTempRet0(r),e},___cxa_find_matching_catch_2=()=>findMatchingCatch([]),___cxa_find_matching_catch_3=t=>findMatchingCatch([t]),___cxa_rethrow=()=>{var t=exceptionCaught.pop();t||abort("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(exceptionCaught.push(t),t.set_rethrown(!0),t.set_caught(!1),uncaughtExceptionCount++),exceptionLast=e,exceptionLast},___cxa_throw=(t,e,n)=>{var r=new ExceptionInfo(t);throw r.init(e,n),exceptionLast=t,uncaughtExceptionCount++,exceptionLast},___cxa_uncaught_exceptions=()=>uncaughtExceptionCount,setErrNo=t=>(HEAP32[___errno_location()>>2]=t,t);function ___syscall_fcntl64(t,e,n){SYSCALLS.varargs=n;try{var r=SYSCALLS.getStreamFromFD(t);switch(e){case 0:{var o=SYSCALLS.get();if(o<0)return-28;for(;FS.streams[o];)o++;var a;return a=FS.createStream(r,o),a.fd}case 1:case 2:return 0;case 3:return r.flags;case 4:{var o=SYSCALLS.get();return r.flags|=o,0}case 5:{var o=SYSCALLS.getp(),c=0;return HEAP16[o+c>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return setErrNo(28),-1;default:return-28}}catch(l){if(typeof FS=="undefined"||l.name!=="ErrnoError")throw l;return-l.errno}}function ___syscall_fstat64(t,e){try{var n=SYSCALLS.getStreamFromFD(t);return SYSCALLS.doStat(FS.stat,n.path,e)}catch(r){if(typeof FS=="undefined"||r.name!=="ErrnoError")throw r;return-r.errno}}var stringToUTF8=(t,e,n)=>stringToUTF8Array(t,HEAPU8,e,n);function ___syscall_getcwd(t,e){try{if(e===0)return-28;var n=FS.cwd(),r=lengthBytesUTF8(n)+1;return e<r?-68:(stringToUTF8(n,t,e),r)}catch(o){if(typeof FS=="undefined"||o.name!=="ErrnoError")throw o;return-o.errno}}function ___syscall_getdents64(t,e,n){try{var r=SYSCALLS.getStreamFromFD(t);r.getdents||(r.getdents=FS.readdir(r.path));for(var o=280,a=0,c=FS.llseek(r,0,1),l=Math.floor(c/o);l<r.getdents.length&&a+o<=n;){var u,h,d=r.getdents[l];if(d===".")u=r.node.id,h=4;else if(d===".."){var f=FS.lookupPath(r.path,{parent:!0});u=f.node.id,h=4}else{var p=FS.lookupNode(r.node,d);u=p.id,h=FS.isChrdev(p.mode)?2:FS.isDir(p.mode)?4:FS.isLink(p.mode)?10:8}tempI64=[u>>>0,(tempDouble=u,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e+a>>2]=tempI64[0],HEAP32[e+a+4>>2]=tempI64[1],tempI64=[(l+1)*o>>>0,(tempDouble=(l+1)*o,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e+a+8>>2]=tempI64[0],HEAP32[e+a+12>>2]=tempI64[1],HEAP16[e+a+16>>1]=280,HEAP8[e+a+18>>0]=h,stringToUTF8(d,e+a+19,256),a+=o,l+=1}return FS.llseek(r,l*o,0),a}catch(m){if(typeof FS=="undefined"||m.name!=="ErrnoError")throw m;return-m.errno}}function ___syscall_ioctl(t,e,n){SYSCALLS.varargs=n;try{var r=SYSCALLS.getStreamFromFD(t);switch(e){case 21509:return r.tty?0:-59;case 21505:{if(!r.tty)return-59;if(r.tty.ops.ioctl_tcgets){var o=r.tty.ops.ioctl_tcgets(r),a=SYSCALLS.getp();HEAP32[a>>2]=o.c_iflag||0,HEAP32[a+4>>2]=o.c_oflag||0,HEAP32[a+8>>2]=o.c_cflag||0,HEAP32[a+12>>2]=o.c_lflag||0;for(var c=0;c<32;c++)HEAP8[a+c+17>>0]=o.c_cc[c]||0;return 0}return 0}case 21510:case 21511:case 21512:return r.tty?0:-59;case 21506:case 21507:case 21508:{if(!r.tty)return-59;if(r.tty.ops.ioctl_tcsets){for(var a=SYSCALLS.getp(),l=HEAP32[a>>2],u=HEAP32[a+4>>2],h=HEAP32[a+8>>2],d=HEAP32[a+12>>2],f=[],c=0;c<32;c++)f.push(HEAP8[a+c+17>>0]);return r.tty.ops.ioctl_tcsets(r.tty,e,{c_iflag:l,c_oflag:u,c_cflag:h,c_lflag:d,c_cc:f})}return 0}case 21519:{if(!r.tty)return-59;var a=SYSCALLS.getp();return HEAP32[a>>2]=0,0}case 21520:return r.tty?-28:-59;case 21531:{var a=SYSCALLS.getp();return FS.ioctl(r,e,a)}case 21523:{if(!r.tty)return-59;if(r.tty.ops.ioctl_tiocgwinsz){var p=r.tty.ops.ioctl_tiocgwinsz(r.tty),a=SYSCALLS.getp();HEAP16[a>>1]=p[0],HEAP16[a+2>>1]=p[1]}return 0}case 21524:return r.tty?0:-59;case 21515:return r.tty?0:-59;default:return-28}}catch(m){if(typeof FS=="undefined"||m.name!=="ErrnoError")throw m;return-m.errno}}function ___syscall_lstat64(t,e){try{return t=SYSCALLS.getStr(t),SYSCALLS.doStat(FS.lstat,t,e)}catch(n){if(typeof FS=="undefined"||n.name!=="ErrnoError")throw n;return-n.errno}}function ___syscall_newfstatat(t,e,n,r){try{e=SYSCALLS.getStr(e);var o=r&256,a=r&4096;return r=r&-6401,e=SYSCALLS.calculateAt(t,e,a),SYSCALLS.doStat(o?FS.lstat:FS.stat,e,n)}catch(c){if(typeof FS=="undefined"||c.name!=="ErrnoError")throw c;return-c.errno}}function ___syscall_openat(t,e,n,r){SYSCALLS.varargs=r;try{e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e);var o=r?SYSCALLS.get():0;return FS.open(e,n,o).fd}catch(a){if(typeof FS=="undefined"||a.name!=="ErrnoError")throw a;return-a.errno}}function ___syscall_stat64(t,e){try{return t=SYSCALLS.getStr(t),SYSCALLS.doStat(FS.stat,t,e)}catch(n){if(typeof FS=="undefined"||n.name!=="ErrnoError")throw n;return-n.errno}}var tupleRegistrations={},runDestructors=t=>{for(;t.length;){var e=t.pop(),n=t.pop();n(e)}};function simpleReadValueFromPointer(t){return this.fromWireType(HEAP32[t>>2])}var awaitingDependencies={},registeredTypes={},typeDependencies={},InternalError,throwInternalError=t=>{throw new InternalError(t)},whenDependentTypesAreResolved=(t,e,n)=>{t.forEach(function(l){typeDependencies[l]=e});function r(l){var u=n(l);u.length!==t.length&&throwInternalError("Mismatched type converter count");for(var h=0;h<t.length;++h)registerType(t[h],u[h])}var o=new Array(e.length),a=[],c=0;e.forEach((l,u)=>{registeredTypes.hasOwnProperty(l)?o[u]=registeredTypes[l]:(a.push(l),awaitingDependencies.hasOwnProperty(l)||(awaitingDependencies[l]=[]),awaitingDependencies[l].push(()=>{o[u]=registeredTypes[l],++c,c===a.length&&r(o)}))}),a.length===0&&r(o)},__embind_finalize_value_array=t=>{var e=tupleRegistrations[t];delete tupleRegistrations[t];var n=e.elements,r=n.length,o=n.map(l=>l.getterReturnType).concat(n.map(l=>l.setterArgumentType)),a=e.rawConstructor,c=e.rawDestructor;whenDependentTypesAreResolved([t],o,function(l){return n.forEach((u,h)=>{var d=l[h],f=u.getter,p=u.getterContext,m=l[h+r],v=u.setter,x=u.setterContext;u.read=b=>d.fromWireType(f(p,b)),u.write=(b,y)=>{var g=[];v(x,b,m.toWireType(g,y)),runDestructors(g)}}),[{name:e.name,fromWireType:u=>{for(var h=new Array(r),d=0;d<r;++d)h[d]=n[d].read(u);return c(u),h},toWireType:(u,h)=>{if(r!==h.length)throw new TypeError(`Incorrect number of tuple elements for ${e.name}: expected=${r}, actual=${h.length}`);for(var d=a(),f=0;f<r;++f)n[f].write(d,h[f]);return u!==null&&u.push(c,d),d},argPackAdvance:GenericWireTypeSize,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:c}]})},structRegistrations={},__embind_finalize_value_object=t=>{var e=structRegistrations[t];delete structRegistrations[t];var n=e.rawConstructor,r=e.rawDestructor,o=e.fields,a=o.map(c=>c.getterReturnType).concat(o.map(c=>c.setterArgumentType));whenDependentTypesAreResolved([t],a,c=>{var l={};return o.forEach((u,h)=>{var d=u.fieldName,f=c[h],p=u.getter,m=u.getterContext,v=c[h+o.length],x=u.setter,b=u.setterContext;l[d]={read:y=>f.fromWireType(p(m,y)),write:(y,g)=>{var M=[];x(b,y,v.toWireType(M,g)),runDestructors(M)}}}),[{name:e.name,fromWireType:u=>{var h={};for(var d in l)h[d]=l[d].read(u);return r(u),h},toWireType:(u,h)=>{for(var d in l)if(!(d in h))throw new TypeError(`Missing field: "${d}"`);var f=n();for(d in l)l[d].write(f,h[d]);return u!==null&&u.push(r,f),f},argPackAdvance:GenericWireTypeSize,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:r}]})},__embind_register_bigint=(t,e,n,r,o)=>{},embind_init_charCodes=()=>{for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);embind_charCodes=t},embind_charCodes,readLatin1String=t=>{for(var e="",n=t;HEAPU8[n];)e+=embind_charCodes[HEAPU8[n++]];return e},BindingError,throwBindingError=t=>{throw new BindingError(t)};function sharedRegisterType(t,e,n={}){var r=e.name;if(t||throwBindingError(`type "${r}" must have a positive integer typeid pointer`),registeredTypes.hasOwnProperty(t)){if(n.ignoreDuplicateRegistrations)return;throwBindingError(`Cannot register type '${r}' twice`)}if(registeredTypes[t]=e,delete typeDependencies[t],awaitingDependencies.hasOwnProperty(t)){var o=awaitingDependencies[t];delete awaitingDependencies[t],o.forEach(a=>a())}}function registerType(t,e,n={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return sharedRegisterType(t,e,n)}var GenericWireTypeSize=8,__embind_register_bool=(t,e,n,r)=>{e=readLatin1String(e),registerType(t,{name:e,fromWireType:function(o){return!!o},toWireType:function(o,a){return a?n:r},argPackAdvance:GenericWireTypeSize,readValueFromPointer:function(o){return this.fromWireType(HEAPU8[o])},destructorFunction:null})},shallowCopyInternalPointer=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),throwInstanceAlreadyDeleted=t=>{function e(n){return n.$$.ptrType.registeredClass.name}throwBindingError(e(t)+" instance already deleted")},finalizationRegistry=!1,detachFinalizer=t=>{},runDestructor=t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)},releaseClassHandle=t=>{t.count.value-=1;var e=t.count.value===0;e&&runDestructor(t)},downcastPointer=(t,e,n)=>{if(e===n)return t;if(n.baseClass===void 0)return null;var r=downcastPointer(t,e,n.baseClass);return r===null?null:n.downcast(r)},registeredPointers={},getInheritedInstanceCount=()=>Object.keys(registeredInstances).length,getLiveInheritedInstances=()=>{var t=[];for(var e in registeredInstances)registeredInstances.hasOwnProperty(e)&&t.push(registeredInstances[e]);return t},deletionQueue=[],flushPendingDeletes=()=>{for(;deletionQueue.length;){var t=deletionQueue.pop();t.$$.deleteScheduled=!1,t.delete()}},delayFunction,setDelayFunction=t=>{delayFunction=t,deletionQueue.length&&delayFunction&&delayFunction(flushPendingDeletes)},init_embind=()=>{Module.getInheritedInstanceCount=getInheritedInstanceCount,Module.getLiveInheritedInstances=getLiveInheritedInstances,Module.flushPendingDeletes=flushPendingDeletes,Module.setDelayFunction=setDelayFunction},registeredInstances={},getBasestPointer=(t,e)=>{for(e===void 0&&throwBindingError("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e},getInheritedInstance=(t,e)=>(e=getBasestPointer(t,e),registeredInstances[e]),makeClassHandle=(t,e)=>{(!e.ptrType||!e.ptr)&&throwInternalError("makeClassHandle requires ptr and ptrType");var n=!!e.smartPtrType,r=!!e.smartPtr;return n!==r&&throwInternalError("Both smartPtrType and smartPtr must be specified"),e.count={value:1},attachFinalizer(Object.create(t,{$$:{value:e}}))};function RegisteredPointer_fromWireType(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var n=getInheritedInstance(this.registeredClass,e);if(n!==void 0){if(n.$$.count.value===0)return n.$$.ptr=e,n.$$.smartPtr=t,n.clone();var r=n.clone();return this.destructor(t),r}function o(){return this.isSmartPointer?makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var a=this.registeredClass.getActualType(e),c=registeredPointers[a];if(!c)return o.call(this);var l;this.isConst?l=c.constPointerType:l=c.pointerType;var u=downcastPointer(e,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?makeClassHandle(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:t}):makeClassHandle(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var attachFinalizer=t=>typeof FinalizationRegistry=="undefined"?(attachFinalizer=e=>e,t):(finalizationRegistry=new FinalizationRegistry(e=>{releaseClassHandle(e.$$)}),attachFinalizer=e=>{var n=e.$$,r=!!n.smartPtr;if(r){var o={$$:n};finalizationRegistry.register(e,o,e)}return e},detachFinalizer=e=>finalizationRegistry.unregister(e),attachFinalizer(t)),init_ClassHandle=()=>{Object.assign(ClassHandle.prototype,{isAliasOf(t){if(!(this instanceof ClassHandle)||!(t instanceof ClassHandle))return!1;var e=this.$$.ptrType.registeredClass,n=this.$$.ptr;t.$$=t.$$;for(var r=t.$$.ptrType.registeredClass,o=t.$$.ptr;e.baseClass;)n=e.upcast(n),e=e.baseClass;for(;r.baseClass;)o=r.upcast(o),r=r.baseClass;return e===r&&n===o},clone(){if(this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&throwBindingError("Object already scheduled for deletion"),detachFinalizer(this),releaseClassHandle(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&throwBindingError("Object already scheduled for deletion"),deletionQueue.push(this),deletionQueue.length===1&&delayFunction&&delayFunction(flushPendingDeletes),this.$$.deleteScheduled=!0,this}})};function ClassHandle(){}var char_0=48,char_9=57,makeLegalFunctionName=t=>{if(t===void 0)return"_unknown";t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=char_0&&e<=char_9?`_${t}`:t};function createNamedFunction(t,e){return t=makeLegalFunctionName(t),{[t]:function(){return e.apply(this,arguments)}}[t]}var ensureOverloadTable=(t,e,n)=>{if(t[e].overloadTable===void 0){var r=t[e];t[e]=function(){return t[e].overloadTable.hasOwnProperty(arguments.length)||throwBindingError(`Function '${n}' called with an invalid number of arguments (${arguments.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[arguments.length].apply(this,arguments)},t[e].overloadTable=[],t[e].overloadTable[r.argCount]=r}},exposePublicSymbol=(t,e,n)=>{Module.hasOwnProperty(t)?((n===void 0||Module[t].overloadTable!==void 0&&Module[t].overloadTable[n]!==void 0)&&throwBindingError(`Cannot register public name '${t}' twice`),ensureOverloadTable(Module,t,t),Module.hasOwnProperty(n)&&throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${n})!`),Module[t].overloadTable[n]=e):(Module[t]=e,n!==void 0&&(Module[t].numArguments=n))};function RegisteredClass(t,e,n,r,o,a,c,l){this.name=t,this.constructor=e,this.instancePrototype=n,this.rawDestructor=r,this.baseClass=o,this.getActualType=a,this.upcast=c,this.downcast=l,this.pureVirtualFunctions=[]}var upcastPointer=(t,e,n)=>{for(;e!==n;)e.upcast||throwBindingError(`Expected null or instance of ${n.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t};function constNoSmartPtrRawPointerToWireType(t,e){if(e===null)return this.isReference&&throwBindingError(`null is not a valid ${this.name}`),0;e.$$||throwBindingError(`Cannot pass "${embindRepr(e)}" as a ${this.name}`),e.$$.ptr||throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);var n=e.$$.ptrType.registeredClass,r=upcastPointer(e.$$.ptr,n,this.registeredClass);return r}function genericPointerToWireType(t,e){var n;if(e===null)return this.isReference&&throwBindingError(`null is not a valid ${this.name}`),this.isSmartPointer?(n=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,n),n):0;e.$$||throwBindingError(`Cannot pass "${embindRepr(e)}" as a ${this.name}`),e.$$.ptr||throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&throwBindingError(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass;if(n=upcastPointer(e.$$.ptr,r,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&throwBindingError("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?n=e.$$.smartPtr:throwBindingError(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:n=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)n=e.$$.smartPtr;else{var o=e.clone();n=this.rawShare(n,Emval.toHandle(()=>o.delete())),t!==null&&t.push(this.rawDestructor,n)}break;default:throwBindingError("Unsupporting sharing policy")}return n}function nonConstNoSmartPtrRawPointerToWireType(t,e){if(e===null)return this.isReference&&throwBindingError(`null is not a valid ${this.name}`),0;e.$$||throwBindingError(`Cannot pass "${embindRepr(e)}" as a ${this.name}`),e.$$.ptr||throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&throwBindingError(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass,r=upcastPointer(e.$$.ptr,n,this.registeredClass);return r}function readPointer(t){return this.fromWireType(HEAPU32[t>>2])}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){this.rawDestructor&&this.rawDestructor(t)},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,deleteObject(t){t!==null&&t.delete()},fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(t,e,n,r,o,a,c,l,u,h,d){this.name=t,this.registeredClass=e,this.isReference=n,this.isConst=r,this.isSmartPointer=o,this.pointeeType=a,this.sharingPolicy=c,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=h,this.rawDestructor=d,!o&&e.baseClass===void 0?r?(this.toWireType=constNoSmartPtrRawPointerToWireType,this.destructorFunction=null):(this.toWireType=nonConstNoSmartPtrRawPointerToWireType,this.destructorFunction=null):this.toWireType=genericPointerToWireType}var replacePublicSymbol=(t,e,n)=>{Module.hasOwnProperty(t)||throwInternalError("Replacing nonexistant public symbol"),Module[t].overloadTable!==void 0&&n!==void 0?Module[t].overloadTable[n]=e:(Module[t]=e,Module[t].argCount=n)},dynCallLegacy=(t,e,n)=>{var r=Module["dynCall_"+t];return n&&n.length?r.apply(null,[e].concat(n)):r.call(null,e)},wasmTableMirror=[],wasmTable,getWasmTableEntry=t=>{var e=wasmTableMirror[t];return e||(t>=wasmTableMirror.length&&(wasmTableMirror.length=t+1),wasmTableMirror[t]=e=wasmTable.get(t)),e},dynCall=(t,e,n)=>{if(t.includes("j"))return dynCallLegacy(t,e,n);var r=getWasmTableEntry(e).apply(null,n);return r},getDynCaller=(t,e)=>{var n=[];return function(){return n.length=0,Object.assign(n,arguments),dynCall(t,e,n)}},embind__requireFunction=(t,e)=>{t=readLatin1String(t);function n(){return t.includes("j")?getDynCaller(t,e):getWasmTableEntry(e)}var r=n();return typeof r!="function"&&throwBindingError(`unknown function pointer with signature ${t}: ${e}`),r},extendError=(t,e)=>{var n=createNamedFunction(e,function(r){this.name=e,this.message=r;var o=new Error(r).stack;o!==void 0&&(this.stack=this.toString()+`
`+o.replace(/^Error(:[^\n]*)?\n/,""))});return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},n},UnboundTypeError,getTypeName=t=>{var e=___getTypeName(t),n=readLatin1String(e);return _free(e),n},throwUnboundTypeError=(t,e)=>{var n=[],r={};function o(a){if(!r[a]&&!registeredTypes[a]){if(typeDependencies[a]){typeDependencies[a].forEach(o);return}n.push(a),r[a]=!0}}throw e.forEach(o),new UnboundTypeError(`${t}: `+n.map(getTypeName).join([", "]))},__embind_register_class=(t,e,n,r,o,a,c,l,u,h,d,f,p)=>{d=readLatin1String(d),a=embind__requireFunction(o,a),l&&(l=embind__requireFunction(c,l)),h&&(h=embind__requireFunction(u,h)),p=embind__requireFunction(f,p);var m=makeLegalFunctionName(d);exposePublicSymbol(m,function(){throwUnboundTypeError(`Cannot construct ${d} due to unbound types`,[r])}),whenDependentTypesAreResolved([t,e,n],r?[r]:[],function(v){v=v[0];var x,b;r?(x=v.registeredClass,b=x.instancePrototype):b=ClassHandle.prototype;var y=createNamedFunction(m,function(){if(Object.getPrototypeOf(this)!==g)throw new BindingError("Use 'new' to construct "+d);if(M.constructor_body===void 0)throw new BindingError(d+" has no accessible constructor");var F=M.constructor_body[arguments.length];if(F===void 0)throw new BindingError(`Tried to invoke ctor of ${d} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(M.constructor_body).toString()}) parameters instead!`);return F.apply(this,arguments)}),g=Object.create(b,{constructor:{value:y}});y.prototype=g;var M=new RegisteredClass(d,y,g,p,x,a,l,h);M.baseClass&&(M.baseClass.__derivedClasses===void 0&&(M.baseClass.__derivedClasses=[]),M.baseClass.__derivedClasses.push(M));var C=new RegisteredPointer(d,M,!0,!1,!1),E=new RegisteredPointer(d+"*",M,!1,!1,!1),w=new RegisteredPointer(d+" const*",M,!1,!0,!1);return registeredPointers[t]={pointerType:E,constPointerType:w},replacePublicSymbol(m,y),[C,E,w]})};function newFunc(t,e){if(!(t instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof t} which is not a function`);var n=createNamedFunction(t.name||"unknownFunctionName",function(){});n.prototype=t.prototype;var r=new n,o=t.apply(r,e);return o instanceof Object?o:r}function craftInvokerFunction(t,e,n,r,o,a){var c=e.length;c<2&&throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var l=e[1]!==null&&n!==null,u=!1,h=1;h<e.length;++h)if(e[h]!==null&&e[h].destructorFunction===void 0){u=!0;break}for(var d=e[0].name!=="void",f="",p="",h=0;h<c-2;++h)f+=(h!==0?", ":"")+"arg"+h,p+=(h!==0?", ":"")+"arg"+h+"Wired";var m=`
        return function ${makeLegalFunctionName(t)}(${f}) {
        if (arguments.length !== ${c-2}) {
          throwBindingError('function ${t} called with ' + arguments.length + ' arguments, expected ${c-2}');
        }`;u&&(m+=`var destructors = [];
`);var v=u?"destructors":"null",x=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],b=[throwBindingError,r,o,runDestructors,e[0],e[1]];l&&(m+="var thisWired = classParam.toWireType("+v+`, this);
`);for(var h=0;h<c-2;++h)m+="var arg"+h+"Wired = argType"+h+".toWireType("+v+", arg"+h+"); // "+e[h+2].name+`
`,x.push("argType"+h),b.push(e[h+2]);if(l&&(p="thisWired"+(p.length>0?", ":"")+p),m+=(d||a?"var rv = ":"")+"invoker(fn"+(p.length>0?", ":"")+p+`);
`,u)m+=`runDestructors(destructors);
`;else for(var h=l?1:2;h<e.length;++h){var y=h===1?"thisWired":"arg"+(h-2)+"Wired";e[h].destructorFunction!==null&&(m+=y+"_dtor("+y+"); // "+e[h].name+`
`,x.push(y+"_dtor"),b.push(e[h].destructorFunction))}return d&&(m+=`var ret = retType.fromWireType(rv);
return ret;
`),m+=`}
`,x.push(m),newFunc(Function,x).apply(null,b)}var heap32VectorToArray=(t,e)=>{for(var n=[],r=0;r<t;r++)n.push(HEAPU32[e+r*4>>2]);return n},__embind_register_class_class_function=(t,e,n,r,o,a,c,l)=>{var u=heap32VectorToArray(n,r);e=readLatin1String(e),a=embind__requireFunction(o,a),whenDependentTypesAreResolved([],[t],function(h){h=h[0];var d=`${h.name}.${e}`;function f(){throwUnboundTypeError(`Cannot call ${d} due to unbound types`,u)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]);var p=h.registeredClass.constructor;return p[e]===void 0?(f.argCount=n-1,p[e]=f):(ensureOverloadTable(p,e,d),p[e].overloadTable[n-1]=f),whenDependentTypesAreResolved([],u,function(m){var v=[m[0],null].concat(m.slice(1)),x=craftInvokerFunction(d,v,null,a,c,l);if(p[e].overloadTable===void 0?(x.argCount=n-1,p[e]=x):p[e].overloadTable[n-1]=x,h.registeredClass.__derivedClasses)for(let b of h.registeredClass.__derivedClasses)b.constructor.hasOwnProperty(e)||(b.constructor[e]=x);return[]}),[]})},validateThis=(t,e,n)=>(t instanceof Object||throwBindingError(`${n} with invalid "this": ${t}`),t instanceof e.registeredClass.constructor||throwBindingError(`${n} incompatible with "this" of type ${t.constructor.name}`),t.$$.ptr||throwBindingError(`cannot call emscripten binding method ${n} on deleted object`),upcastPointer(t.$$.ptr,t.$$.ptrType.registeredClass,e.registeredClass)),__embind_register_class_class_property=(t,e,n,r,o,a,c,l)=>{e=readLatin1String(e),a=embind__requireFunction(o,a),whenDependentTypesAreResolved([],[t],function(u){u=u[0];var h=`${u.name}.${e}`,d={get(){throwUnboundTypeError(`Cannot access ${h} due to unbound types`,[n])},enumerable:!0,configurable:!0};return l?d.set=()=>{throwUnboundTypeError(`Cannot access ${h} due to unbound types`,[n])}:d.set=f=>{throwBindingError(`${h} is a read-only property`)},Object.defineProperty(u.registeredClass.constructor,e,d),whenDependentTypesAreResolved([],[n],function(f){f=f[0];var p={get(){return f.fromWireType(a(r))},enumerable:!0};return l&&(l=embind__requireFunction(c,l),p.set=m=>{var v=[];l(r,f.toWireType(v,m)),runDestructors(v)}),Object.defineProperty(u.registeredClass.constructor,e,p),[]}),[]})},__embind_register_class_constructor=(t,e,n,r,o,a)=>{var c=heap32VectorToArray(e,n);o=embind__requireFunction(r,o),whenDependentTypesAreResolved([],[t],function(l){l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[e-1]!==void 0)throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[e-1]=()=>{throwUnboundTypeError(`Cannot construct ${l.name} due to unbound types`,c)},whenDependentTypesAreResolved([],c,h=>(h.splice(1,0,null),l.registeredClass.constructor_body[e-1]=craftInvokerFunction(u,h,null,o,a),[])),[]})},__embind_register_class_function=(t,e,n,r,o,a,c,l,u)=>{var h=heap32VectorToArray(n,r);e=readLatin1String(e),a=embind__requireFunction(o,a),whenDependentTypesAreResolved([],[t],function(d){d=d[0];var f=`${d.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),l&&d.registeredClass.pureVirtualFunctions.push(e);function p(){throwUnboundTypeError(`Cannot call ${f} due to unbound types`,h)}var m=d.registeredClass.instancePrototype,v=m[e];return v===void 0||v.overloadTable===void 0&&v.className!==d.name&&v.argCount===n-2?(p.argCount=n-2,p.className=d.name,m[e]=p):(ensureOverloadTable(m,e,f),m[e].overloadTable[n-2]=p),whenDependentTypesAreResolved([],h,function(x){var b=craftInvokerFunction(f,x,d,a,c,u);return m[e].overloadTable===void 0?(b.argCount=n-2,m[e]=b):m[e].overloadTable[n-2]=b,[]}),[]})},__embind_register_class_property=(t,e,n,r,o,a,c,l,u,h)=>{e=readLatin1String(e),o=embind__requireFunction(r,o),whenDependentTypesAreResolved([],[t],function(d){d=d[0];var f=`${d.name}.${e}`,p={get(){throwUnboundTypeError(`Cannot access ${f} due to unbound types`,[n,c])},enumerable:!0,configurable:!0};return u?p.set=()=>throwUnboundTypeError(`Cannot access ${f} due to unbound types`,[n,c]):p.set=m=>throwBindingError(f+" is a read-only property"),Object.defineProperty(d.registeredClass.instancePrototype,e,p),whenDependentTypesAreResolved([],u?[n,c]:[n],function(m){var v=m[0],x={get(){var y=validateThis(this,d,f+" getter");return v.fromWireType(o(a,y))},enumerable:!0};if(u){u=embind__requireFunction(l,u);var b=m[1];x.set=function(y){var g=validateThis(this,d,f+" setter"),M=[];u(h,g,b.toWireType(M,y)),runDestructors(M)}}return Object.defineProperty(d.registeredClass.instancePrototype,e,x),[]}),[]})};function handleAllocatorInit(){Object.assign(HandleAllocator.prototype,{get(t){return this.allocated[t]},has(t){return this.allocated[t]!==void 0},allocate(t){var e=this.freelist.pop()||this.allocated.length;return this.allocated[e]=t,e},free(t){this.allocated[t]=void 0,this.freelist.push(t)}})}function HandleAllocator(){this.allocated=[void 0],this.freelist=[]}var emval_handles=new HandleAllocator,__emval_decref=t=>{t>=emval_handles.reserved&&--emval_handles.get(t).refcount===0&&emval_handles.free(t)},count_emval_handles=()=>{for(var t=0,e=emval_handles.reserved;e<emval_handles.allocated.length;++e)emval_handles.allocated[e]!==void 0&&++t;return t},init_emval=()=>{emval_handles.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),emval_handles.reserved=emval_handles.allocated.length,Module.count_emval_handles=count_emval_handles},Emval={toValue:t=>(t||throwBindingError("Cannot use deleted val. handle = "+t),emval_handles.get(t).value),toHandle:t=>{switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return emval_handles.allocate({refcount:1,value:t})}}},__embind_register_emval=(t,e)=>{e=readLatin1String(e),registerType(t,{name:e,fromWireType:n=>{var r=Emval.toValue(n);return __emval_decref(n),r},toWireType:(n,r)=>Emval.toHandle(r),argPackAdvance:GenericWireTypeSize,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:null})},enumReadValueFromPointer=(t,e,n)=>{switch(e){case 1:return n?function(r){return this.fromWireType(HEAP8[r>>0])}:function(r){return this.fromWireType(HEAPU8[r>>0])};case 2:return n?function(r){return this.fromWireType(HEAP16[r>>1])}:function(r){return this.fromWireType(HEAPU16[r>>1])};case 4:return n?function(r){return this.fromWireType(HEAP32[r>>2])}:function(r){return this.fromWireType(HEAPU32[r>>2])};default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},__embind_register_enum=(t,e,n,r)=>{e=readLatin1String(e);function o(){}o.values={},registerType(t,{name:e,constructor:o,fromWireType:function(a){return this.constructor.values[a]},toWireType:(a,c)=>c.value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:enumReadValueFromPointer(e,n,r),destructorFunction:null}),exposePublicSymbol(e,o)},requireRegisteredType=(t,e)=>{var n=registeredTypes[t];return n===void 0&&throwBindingError(e+" has unknown type "+getTypeName(t)),n},__embind_register_enum_value=(t,e,n)=>{var r=requireRegisteredType(t,"enum");e=readLatin1String(e);var o=r.constructor,a=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:createNamedFunction(`${r.name}_${e}`,function(){})}});o.values[n]=a,o[e]=a},embindRepr=t=>{if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t},floatReadValueFromPointer=(t,e)=>{switch(e){case 4:return function(n){return this.fromWireType(HEAPF32[n>>2])};case 8:return function(n){return this.fromWireType(HEAPF64[n>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},__embind_register_float=(t,e,n)=>{e=readLatin1String(e),registerType(t,{name:e,fromWireType:r=>r,toWireType:(r,o)=>o,argPackAdvance:GenericWireTypeSize,readValueFromPointer:floatReadValueFromPointer(e,n),destructorFunction:null})},integerReadValueFromPointer=(t,e,n)=>{switch(e){case 1:return n?r=>HEAP8[r>>0]:r=>HEAPU8[r>>0];case 2:return n?r=>HEAP16[r>>1]:r=>HEAPU16[r>>1];case 4:return n?r=>HEAP32[r>>2]:r=>HEAPU32[r>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},__embind_register_integer=(t,e,n,r,o)=>{e=readLatin1String(e),o===-1&&(o=4294967295);var a=d=>d;if(r===0){var c=32-8*n;a=d=>d<<c>>>c}var l=e.includes("unsigned"),u=(d,f)=>{},h;l?h=function(d,f){return u(f,this.name),f>>>0}:h=function(d,f){return u(f,this.name),f},registerType(t,{name:e,fromWireType:a,toWireType:h,argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(e,n,r!==0),destructorFunction:null})},__embind_register_memory_view=(t,e,n)=>{var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=r[e];function a(c){var l=HEAPU32[c>>2],u=HEAPU32[c+4>>2];return new o(HEAP8.buffer,u,l)}n=readLatin1String(n),registerType(t,{name:n,fromWireType:a,argPackAdvance:GenericWireTypeSize,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},__embind_register_std_string=(t,e)=>{e=readLatin1String(e);var n=e==="std::string";registerType(t,{name:e,fromWireType(r){var o=HEAPU32[r>>2],a=r+4,c;if(n)for(var l=a,u=0;u<=o;++u){var h=a+u;if(u==o||HEAPU8[h]==0){var d=h-l,f=UTF8ToString(l,d);c===void 0?c=f:(c+="\0",c+=f),l=h+1}}else{for(var p=new Array(o),u=0;u<o;++u)p[u]=String.fromCharCode(HEAPU8[a+u]);c=p.join("")}return _free(r),c},toWireType(r,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var a,c=typeof o=="string";c||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||throwBindingError("Cannot pass non-string to std::string"),n&&c?a=lengthBytesUTF8(o):a=o.length;var l=_malloc(4+a+1),u=l+4;if(HEAPU32[l>>2]=a,n&&c)stringToUTF8(o,u,a+1);else if(c)for(var h=0;h<a;++h){var d=o.charCodeAt(h);d>255&&(_free(u),throwBindingError("String has UTF-16 code units that do not fit in 8 bits")),HEAPU8[u+h]=d}else for(var h=0;h<a;++h)HEAPU8[u+h]=o[h];return r!==null&&r.push(_free,l),l},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(r){_free(r)}})},UTF16Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,UTF16ToString=(t,e)=>{for(var n=t,r=n>>1,o=r+e/2;!(r>=o)&&HEAPU16[r];)++r;if(n=r<<1,n-t>32&&UTF16Decoder)return UTF16Decoder.decode(HEAPU8.subarray(t,n));for(var a="",c=0;!(c>=e/2);++c){var l=HEAP16[t+c*2>>1];if(l==0)break;a+=String.fromCharCode(l)}return a},stringToUTF16=(t,e,n)=>{if(n===void 0&&(n=2147483647),n<2)return 0;n-=2;for(var r=e,o=n<t.length*2?n/2:t.length,a=0;a<o;++a){var c=t.charCodeAt(a);HEAP16[e>>1]=c,e+=2}return HEAP16[e>>1]=0,e-r},lengthBytesUTF16=t=>t.length*2,UTF32ToString=(t,e)=>{for(var n=0,r="";!(n>=e/4);){var o=HEAP32[t+n*4>>2];if(o==0)break;if(++n,o>=65536){var a=o-65536;r+=String.fromCharCode(55296|a>>10,56320|a&1023)}else r+=String.fromCharCode(o)}return r},stringToUTF32=(t,e,n)=>{if(n===void 0&&(n=2147483647),n<4)return 0;for(var r=e,o=r+n-4,a=0;a<t.length;++a){var c=t.charCodeAt(a);if(c>=55296&&c<=57343){var l=t.charCodeAt(++a);c=65536+((c&1023)<<10)|l&1023}if(HEAP32[e>>2]=c,e+=4,e+4>o)break}return HEAP32[e>>2]=0,e-r},lengthBytesUTF32=t=>{for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r>=55296&&r<=57343&&++n,e+=4}return e},__embind_register_std_wstring=(t,e,n)=>{n=readLatin1String(n);var r,o,a,c,l;e===2?(r=UTF16ToString,o=stringToUTF16,c=lengthBytesUTF16,a=()=>HEAPU16,l=1):e===4&&(r=UTF32ToString,o=stringToUTF32,c=lengthBytesUTF32,a=()=>HEAPU32,l=2),registerType(t,{name:n,fromWireType:u=>{for(var h=HEAPU32[u>>2],d=a(),f,p=u+4,m=0;m<=h;++m){var v=u+4+m*e;if(m==h||d[v>>l]==0){var x=v-p,b=r(p,x);f===void 0?f=b:(f+="\0",f+=b),p=v+e}}return _free(u),f},toWireType:(u,h)=>{typeof h!="string"&&throwBindingError(`Cannot pass non-string to C++ string type ${n}`);var d=c(h),f=_malloc(4+d+e);return HEAPU32[f>>2]=d>>l,o(h,f+4,d+e),u!==null&&u.push(_free,f),f},argPackAdvance:GenericWireTypeSize,readValueFromPointer:simpleReadValueFromPointer,destructorFunction(u){_free(u)}})},__embind_register_value_array=(t,e,n,r,o,a)=>{tupleRegistrations[t]={name:readLatin1String(e),rawConstructor:embind__requireFunction(n,r),rawDestructor:embind__requireFunction(o,a),elements:[]}},__embind_register_value_array_element=(t,e,n,r,o,a,c,l,u)=>{tupleRegistrations[t].elements.push({getterReturnType:e,getter:embind__requireFunction(n,r),getterContext:o,setterArgumentType:a,setter:embind__requireFunction(c,l),setterContext:u})},__embind_register_value_object=(t,e,n,r,o,a)=>{structRegistrations[t]={name:readLatin1String(e),rawConstructor:embind__requireFunction(n,r),rawDestructor:embind__requireFunction(o,a),fields:[]}},__embind_register_value_object_field=(t,e,n,r,o,a,c,l,u,h)=>{structRegistrations[t].fields.push({fieldName:readLatin1String(e),getterReturnType:n,getter:embind__requireFunction(r,o),getterContext:a,setterArgumentType:c,setter:embind__requireFunction(l,u),setterContext:h})},__embind_register_void=(t,e)=>{e=readLatin1String(e),registerType(t,{isVoid:!0,name:e,argPackAdvance:0,fromWireType:()=>{},toWireType:(n,r)=>{}})};function __emscripten_fetch_free(t){if(Fetch.xhrs.has(t)){var e=Fetch.xhrs.get(t);Fetch.xhrs.free(t),e.readyState>0&&e.readyState<4&&e.abort()}}var nowIsMonotonic=!0,__emscripten_get_now_is_monotonic=()=>nowIsMonotonic,__emval_as=(t,e,n)=>{t=Emval.toValue(t),e=requireRegisteredType(e,"emval::as");var r=[],o=Emval.toHandle(r);return HEAPU32[n>>2]=o,e.toWireType(r,t)},emval_lookupTypes=(t,e)=>{for(var n=new Array(t),r=0;r<t;++r)n[r]=requireRegisteredType(HEAPU32[e+r*4>>2],"parameter "+r);return n},__emval_call=(t,e,n,r)=>{t=Emval.toValue(t);for(var o=emval_lookupTypes(e,n),a=new Array(e),c=0;c<e;++c){var l=o[c];a[c]=l.readValueFromPointer(r),r+=l.argPackAdvance}var u=t.apply(void 0,a);return Emval.toHandle(u)},emval_allocateDestructors=t=>{var e=[];return HEAPU32[t>>2]=Emval.toHandle(e),e},emval_symbols={},getStringOrSymbol=t=>{var e=emval_symbols[t];return e===void 0?readLatin1String(t):e},emval_methodCallers=[],__emval_call_method=(t,e,n,r,o)=>(t=emval_methodCallers[t],e=Emval.toValue(e),n=getStringOrSymbol(n),t(e,n,emval_allocateDestructors(r),o)),__emval_call_void_method=(t,e,n,r)=>{t=emval_methodCallers[t],e=Emval.toValue(e),n=getStringOrSymbol(n),t(e,n,null,r)},emval_get_global=()=>typeof globalThis=="object"?globalThis:function(){return Function}()("return this")(),__emval_get_global=t=>t===0?Emval.toHandle(emval_get_global()):(t=getStringOrSymbol(t),Emval.toHandle(emval_get_global()[t])),emval_addMethodCaller=t=>{var e=emval_methodCallers.length;return emval_methodCallers.push(t),e},emval_registeredMethods={},__emval_get_method_caller=(t,e)=>{var n=emval_lookupTypes(t,e),r=n[0],o=r.name+"_$"+n.slice(1).map(function(v){return v.name}).join("_")+"$",a=emval_registeredMethods[o];if(a!==void 0)return a;for(var c=["retType"],l=[r],u="",h=0;h<t-1;++h)u+=(h!==0?", ":"")+"arg"+h,c.push("argType"+h),l.push(n[1+h]);for(var d=makeLegalFunctionName("methodCaller_"+o),f="return function "+d+`(handle, name, destructors, args) {
`,p=0,h=0;h<t-1;++h)f+="    var arg"+h+" = argType"+h+".readValueFromPointer(args"+(p?"+"+p:"")+`);
`,p+=n[h+1].argPackAdvance;f+="    var rv = handle[name]("+u+`);
`;for(var h=0;h<t-1;++h)n[h+1].deleteObject&&(f+="    argType"+h+".deleteObject(arg"+h+`);
`);r.isVoid||(f+=`    return retType.toWireType(destructors, rv);
`),f+=`};
`,c.push(f);var m=newFunc(Function,c).apply(null,l);return a=emval_addMethodCaller(m),emval_registeredMethods[o]=a,a},__emval_get_property=(t,e)=>(t=Emval.toValue(t),e=Emval.toValue(e),Emval.toHandle(t[e])),__emval_incref=t=>{t>4&&(emval_handles.get(t).refcount+=1)},craftEmvalAllocator=t=>{for(var e="",n=0;n<t;++n)e+=(n!==0?", ":"")+"arg"+n;for(var r=()=>HEAPU32,o="return function emval_allocator_"+t+`(constructor, argTypes, args) {
  var HEAPU32 = getMemory();
`,n=0;n<t;++n)o+="var argType"+n+" = requireRegisteredType(HEAPU32[((argTypes)>>2)], 'parameter "+n+`');
var arg`+n+" = argType"+n+`.readValueFromPointer(args);
args += argType`+n+`['argPackAdvance'];
argTypes += 4;
`;return o+="var obj = new constructor("+e+`);
return valueToHandle(obj);
}
`,new Function("requireRegisteredType","Module","valueToHandle","getMemory",o)(requireRegisteredType,Module,Emval.toHandle,r)},emval_newers={},__emval_new=(t,e,n,r)=>{t=Emval.toValue(t);var o=emval_newers[e];return o||(o=craftEmvalAllocator(e),emval_newers[e]=o),o(t,n,r)},__emval_new_array_from_memory_view=t=>{t=Emval.toValue(t);for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return Emval.toHandle(e)},__emval_new_cstring=t=>Emval.toHandle(getStringOrSymbol(t)),__emval_new_object=()=>Emval.toHandle({}),__emval_run_destructors=t=>{var e=Emval.toValue(t);runDestructors(e),__emval_decref(t)},__emval_set_property=(t,e,n)=>{t=Emval.toValue(t),e=Emval.toValue(e),n=Emval.toValue(n),t[e]=n},__emval_take_value=(t,e)=>{t=requireRegisteredType(t,"_emval_take_value");var n=t.readValueFromPointer(e);return Emval.toHandle(n)},isLeapYear=t=>t%4===0&&(t%100!==0||t%400===0),MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335],MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334],ydayFromDate=t=>{var e=isLeapYear(t.getFullYear()),n=e?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE,r=n[t.getMonth()]+t.getDate()-1;return r},convertI32PairToI53Checked=(t,e)=>e+2097152>>>0<4194305-!!t?(t>>>0)+e*4294967296:NaN;function __localtime_js(t,e,n){var r=convertI32PairToI53Checked(t,e),o=new Date(r*1e3);HEAP32[n>>2]=o.getSeconds(),HEAP32[n+4>>2]=o.getMinutes(),HEAP32[n+8>>2]=o.getHours(),HEAP32[n+12>>2]=o.getDate(),HEAP32[n+16>>2]=o.getMonth(),HEAP32[n+20>>2]=o.getFullYear()-1900,HEAP32[n+24>>2]=o.getDay();var a=ydayFromDate(o)|0;HEAP32[n+28>>2]=a,HEAP32[n+36>>2]=-(o.getTimezoneOffset()*60);var c=new Date(o.getFullYear(),0,1),l=new Date(o.getFullYear(),6,1).getTimezoneOffset(),u=c.getTimezoneOffset(),h=(l!=u&&o.getTimezoneOffset()==Math.min(u,l))|0;HEAP32[n+32>>2]=h}var __mktime_js=function(t){var e=(()=>{var n=new Date(HEAP32[t+20>>2]+1900,HEAP32[t+16>>2],HEAP32[t+12>>2],HEAP32[t+8>>2],HEAP32[t+4>>2],HEAP32[t>>2],0),r=HEAP32[t+32>>2],o=n.getTimezoneOffset(),a=new Date(n.getFullYear(),0,1),c=new Date(n.getFullYear(),6,1).getTimezoneOffset(),l=a.getTimezoneOffset(),u=Math.min(l,c);if(r<0)HEAP32[t+32>>2]=+(c!=l&&u==o);else if(r>0!=(u==o)){var h=Math.max(l,c),d=r>0?u:h;n.setTime(n.getTime()+(d-o)*6e4)}HEAP32[t+24>>2]=n.getDay();var f=ydayFromDate(n)|0;return HEAP32[t+28>>2]=f,HEAP32[t>>2]=n.getSeconds(),HEAP32[t+4>>2]=n.getMinutes(),HEAP32[t+8>>2]=n.getHours(),HEAP32[t+12>>2]=n.getDate(),HEAP32[t+16>>2]=n.getMonth(),HEAP32[t+20>>2]=n.getYear(),n.getTime()/1e3})();return setTempRet0((tempDouble=e,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)),e>>>0};function __munmap_js(t,e,n,r,o,a,c){var l=convertI32PairToI53Checked(a,c);try{if(isNaN(l))return 61;var u=SYSCALLS.getStreamFromFD(o);n&2&&SYSCALLS.doMsync(t,u,e,r,l),FS.munmap(u)}catch(h){if(typeof FS=="undefined"||h.name!=="ErrnoError")throw h;return-h.errno}}var stringToNewUTF8=t=>{var e=lengthBytesUTF8(t)+1,n=_malloc(e);return n&&stringToUTF8(t,n,e),n},__tzset_js=(t,e,n)=>{var r=new Date().getFullYear(),o=new Date(r,0,1),a=new Date(r,6,1),c=o.getTimezoneOffset(),l=a.getTimezoneOffset(),u=Math.max(c,l);HEAPU32[t>>2]=u*60,HEAP32[e>>2]=+(c!=l);function h(v){var x=v.toTimeString().match(/\(([A-Za-z ]+)\)$/);return x?x[1]:"GMT"}var d=h(o),f=h(a),p=stringToNewUTF8(d),m=stringToNewUTF8(f);l<c?(HEAPU32[n>>2]=p,HEAPU32[n+4>>2]=m):(HEAPU32[n>>2]=m,HEAPU32[n+4>>2]=p)},_abort=()=>{abort("")},readEmAsmArgsArray=[],readEmAsmArgs=(t,e)=>{readEmAsmArgsArray.length=0;for(var n;n=HEAPU8[t++];){var r=n!=105;r&=n!=112,e+=r&&e%8?4:0,readEmAsmArgsArray.push(n==112?HEAPU32[e>>2]:n==105?HEAP32[e>>2]:HEAPF64[e>>3]),e+=r?8:4}return readEmAsmArgsArray},runEmAsmFunction=(t,e,n)=>{var r=readEmAsmArgs(e,n);return ASM_CONSTS[t].apply(null,r)},_emscripten_asm_const_int=(t,e,n)=>runEmAsmFunction(t,e,n),_emscripten_async_wget_data=(t,e,n,r)=>{asyncLoad(UTF8ToString(t),function(o){callUserCallback(function(){var a=_malloc(o.length);HEAPU8.set(o,a),getWasmTableEntry(n)(e,a,o.length),_free(a)})},function(){r&&callUserCallback(function(){getWasmTableEntry(r)(e)})},!0)},_emscripten_clear_timeout=t=>clearTimeout(t),_emscripten_date_now=()=>Date.now(),_emscripten_is_main_browser_thread=()=>!ENVIRONMENT_IS_WORKER,_emscripten_memcpy_js=(t,e,n)=>HEAPU8.copyWithin(t,e,e+n),abortOnCannotGrowMemory=t=>{abort("OOM")},_emscripten_resize_heap=t=>{var e=HEAPU8.length;t>>>=0,abortOnCannotGrowMemory(t)},_emscripten_run_script=ptr=>{eval(UTF8ToString(ptr))},_emscripten_run_script_string=ptr=>{var s=eval(UTF8ToString(ptr));if(s==null)return 0;s+="";var me=_emscripten_run_script_string,len=lengthBytesUTF8(s);return(!me.bufferSize||me.bufferSize<len+1)&&(me.bufferSize&&_free(me.buffer),me.bufferSize=len+1,me.buffer=_malloc(me.bufferSize)),stringToUTF8(s,me.buffer,me.bufferSize),me.buffer},_emscripten_set_timeout=(t,e,n)=>safeSetTimeout(()=>getWasmTableEntry(t)(n),e),Fetch={openDatabase(t,e,n,r){try{var o=indexedDB.open(t,e)}catch(a){return r(a)}o.onupgradeneeded=a=>{var c=a.target.result;c.objectStoreNames.contains("FILES")&&c.deleteObjectStore("FILES"),c.createObjectStore("FILES")},o.onsuccess=a=>n(a.target.result),o.onerror=a=>r(a)},init(){Fetch.xhrs=new HandleAllocator;var t=n=>{Fetch.dbInstance=n,removeRunDependency("library_fetch_init")},e=()=>{Fetch.dbInstance=!1,removeRunDependency("library_fetch_init")};addRunDependency("library_fetch_init"),Fetch.openDatabase("emscripten_filesystem",1,t,e)}};function fetchXHR(t,e,n,r,o){var a=HEAPU32[t+8>>2];if(!a){n(t,0,"no url specified!");return}var c=UTF8ToString(a),l=t+112,u=UTF8ToString(l+0);u||(u="GET");var h=HEAPU32[l+56>>2],d=HEAPU32[l+68>>2],f=HEAPU32[l+72>>2],p=HEAPU32[l+76>>2],m=HEAPU32[l+80>>2],v=HEAPU32[l+84>>2],x=HEAPU32[l+88>>2],b=HEAPU32[l+52>>2],y=!!(b&1),g=!!(b&2),M=!!(b&64),C=d?UTF8ToString(d):void 0,E=f?UTF8ToString(f):void 0,w=new XMLHttpRequest;if(w.withCredentials=!!HEAPU8[l+60>>0],w.open(u,c,!M,C,E),M||(w.timeout=h),w.url_=c,w.responseType="arraybuffer",m){var F=UTF8ToString(m);w.overrideMimeType(F)}if(p)for(;;){var H=HEAPU32[p>>2];if(!H)break;var ne=HEAPU32[p+4>>2];if(!ne)break;p+=8;var Y=UTF8ToString(H),L=UTF8ToString(ne);w.setRequestHeader(Y,L)}var N=Fetch.xhrs.allocate(w);HEAPU32[t>>2]=N;var G=v&&x?HEAPU8.slice(v,v+x):null;function z(){var D=0,B=0;w.response&&y&&HEAPU32[t+12>>2]===0&&(B=w.response.byteLength),B>0&&(D=_malloc(B),HEAPU8.set(new Uint8Array(w.response),D)),HEAPU32[t+12>>2]=D,writeI53ToI64(t+16,B),writeI53ToI64(t+24,0);var q=w.response?w.response.byteLength:0;q&&writeI53ToI64(t+32,q),HEAPU16[t+40>>1]=w.readyState,HEAPU16[t+42>>1]=w.status,w.statusText&&stringToUTF8(w.statusText,t+44,64)}w.onload=D=>{Fetch.xhrs.has(N)&&(z(),w.status>=200&&w.status<300?e&&e(t,w,D):n&&n(t,w,D))},w.onerror=D=>{Fetch.xhrs.has(N)&&(z(),n&&n(t,w,D))},w.ontimeout=D=>{Fetch.xhrs.has(N)&&n&&n(t,w,D)},w.onprogress=D=>{if(Fetch.xhrs.has(N)){var B=y&&g&&w.response?w.response.byteLength:0,q=0;B>0&&y&&g&&(q=_malloc(B),HEAPU8.set(new Uint8Array(w.response),q)),HEAPU32[t+12>>2]=q,writeI53ToI64(t+16,B),writeI53ToI64(t+24,D.loaded-B),writeI53ToI64(t+32,D.total),HEAPU16[t+40>>1]=w.readyState,w.readyState>=3&&w.status===0&&D.loaded>0&&(w.status=200),HEAPU16[t+42>>1]=w.status,w.statusText&&stringToUTF8(w.statusText,t+44,64),r&&r(t,w,D),q&&_free(q)}},w.onreadystatechange=D=>{Fetch.xhrs.has(N)&&(HEAPU16[t+40>>1]=w.readyState,w.readyState>=2&&(HEAPU16[t+42>>1]=w.status),o&&o(t,w,D))};try{w.send(G)}catch(D){n&&n(t,w,D)}}var writeI53ToI64=(t,e)=>{HEAPU32[t>>2]=e;var n=HEAPU32[t>>2];HEAPU32[t+4>>2]=(e-n)/4294967296};function fetchCacheData(t,e,n,r,o){if(!t){o(e,0,"IndexedDB not available!");return}var a=e+112,c=HEAPU32[a+64>>2];c||(c=HEAPU32[e+8>>2]);var l=UTF8ToString(c);try{var u=t.transaction(["FILES"],"readwrite"),h=u.objectStore("FILES"),d=h.put(n,l);d.onsuccess=f=>{HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=200,stringToUTF8("OK",e+44,64),r(e,0,l)},d.onerror=f=>{HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=413,stringToUTF8("Payload Too Large",e+44,64),o(e,0,f)}}catch(f){o(e,0,f)}}function fetchLoadCachedData(t,e,n,r){if(!t){r(e,0,"IndexedDB not available!");return}var o=e+112,a=HEAPU32[o+64>>2];a||(a=HEAPU32[e+8>>2]);var c=UTF8ToString(a);try{var l=t.transaction(["FILES"],"readonly"),u=l.objectStore("FILES"),h=u.get(c);h.onsuccess=d=>{if(d.target.result){var f=d.target.result,p=f.byteLength||f.length,m=_malloc(p);HEAPU8.set(new Uint8Array(f),m),HEAPU32[e+12>>2]=m,writeI53ToI64(e+16,p),writeI53ToI64(e+24,0),writeI53ToI64(e+32,p),HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=200,stringToUTF8("OK",e+44,64),n(e,0,f)}else HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=404,stringToUTF8("Not Found",e+44,64),r(e,0,"no data")},h.onerror=d=>{HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=404,stringToUTF8("Not Found",e+44,64),r(e,0,d)}}catch(d){r(e,0,d)}}function fetchDeleteCachedData(t,e,n,r){if(!t){r(e,0,"IndexedDB not available!");return}var o=e+112,a=HEAPU32[o+64>>2];a||(a=HEAPU32[e+8>>2]);var c=UTF8ToString(a);try{var l=t.transaction(["FILES"],"readwrite"),u=l.objectStore("FILES"),h=u.delete(c);h.onsuccess=d=>{var f=d.target.result;HEAPU32[e+12>>2]=0,writeI53ToI64(e+16,0),writeI53ToI64(e+24,0),writeI53ToI64(e+32,0),HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=200,stringToUTF8("OK",e+44,64),n(e,0,f)},h.onerror=d=>{HEAPU16[e+40>>1]=4,HEAPU16[e+42>>1]=404,stringToUTF8("Not Found",e+44,64),r(e,0,d)}}catch(d){r(e,0,d)}}function _emscripten_start_fetch(t,e,n,r,o){var a=t+112,c=HEAPU32[a+36>>2],l=HEAPU32[a+40>>2],u=HEAPU32[a+44>>2],h=HEAPU32[a+48>>2],d=HEAPU32[a+52>>2],f=!!(d&64);function p(Y){f?Y():callUserCallback(Y)}var m=(Y,L,N)=>{p(()=>{c?getWasmTableEntry(c)(Y):e&&e(Y)})},v=(Y,L,N)=>{p(()=>{u?getWasmTableEntry(u)(Y):r&&r(Y)})},x=(Y,L,N)=>{p(()=>{l?getWasmTableEntry(l)(Y):n&&n(Y)})},b=(Y,L,N)=>{p(()=>{h?getWasmTableEntry(h)(Y):o&&o(Y)})},y=(Y,L,N)=>{fetchXHR(Y,m,x,v,b)},g=(Y,L,N)=>{var G=(D,B,q)=>{p(()=>{c?getWasmTableEntry(c)(D):e&&e(D)})},z=(D,B,q)=>{p(()=>{c?getWasmTableEntry(c)(D):e&&e(D)})};fetchCacheData(Fetch.dbInstance,Y,L.response,G,z)},M=(Y,L,N)=>{fetchXHR(Y,g,x,v,b)},C=UTF8ToString(a+0),E=!!(d&16),w=!!(d&4),F=!!(d&32);if(C==="EM_IDB_STORE"){var H=HEAPU32[a+84>>2],ne=HEAPU32[a+88>>2];fetchCacheData(Fetch.dbInstance,t,HEAPU8.slice(H,H+ne),m,x)}else if(C==="EM_IDB_DELETE")fetchDeleteCachedData(Fetch.dbInstance,t,m,x);else if(!E)fetchLoadCachedData(Fetch.dbInstance,t,m,F?x:w?M:y);else if(!F)fetchXHR(t,w?g:m,x,v,b);else return 0;return t}var ENV={},getExecutableName=()=>thisProgram||"./this.program",getEnvStrings=()=>{if(!getEnvStrings.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:getExecutableName()};for(var n in ENV)ENV[n]===void 0?delete e[n]:e[n]=ENV[n];var r=[];for(var n in e)r.push(`${n}=${e[n]}`);getEnvStrings.strings=r}return getEnvStrings.strings},stringToAscii=(t,e)=>{for(var n=0;n<t.length;++n)HEAP8[e++>>0]=t.charCodeAt(n);HEAP8[e>>0]=0},_environ_get=(t,e)=>{var n=0;return getEnvStrings().forEach((r,o)=>{var a=e+n;HEAPU32[t+o*4>>2]=a,stringToAscii(r,a),n+=r.length+1}),0},_environ_sizes_get=(t,e)=>{var n=getEnvStrings();HEAPU32[t>>2]=n.length;var r=0;return n.forEach(o=>r+=o.length+1),HEAPU32[e>>2]=r,0};function _fd_close(t){try{var e=SYSCALLS.getStreamFromFD(t);return FS.close(e),0}catch(n){if(typeof FS=="undefined"||n.name!=="ErrnoError")throw n;return n.errno}}var doReadv=(t,e,n,r)=>{for(var o=0,a=0;a<n;a++){var c=HEAPU32[e>>2],l=HEAPU32[e+4>>2];e+=8;var u=FS.read(t,HEAP8,c,l,r);if(u<0)return-1;if(o+=u,u<l)break;typeof r!="undefined"&&(r+=u)}return o};function _fd_read(t,e,n,r){try{var o=SYSCALLS.getStreamFromFD(t),a=doReadv(o,e,n);return HEAPU32[r>>2]=a,0}catch(c){if(typeof FS=="undefined"||c.name!=="ErrnoError")throw c;return c.errno}}function _fd_seek(t,e,n,r,o){var a=convertI32PairToI53Checked(e,n);try{if(isNaN(a))return 61;var c=SYSCALLS.getStreamFromFD(t);return FS.llseek(c,a,r),tempI64=[c.position>>>0,(tempDouble=c.position,+Math.abs(tempDouble)>=1?tempDouble>0?+Math.floor(tempDouble/4294967296)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[o>>2]=tempI64[0],HEAP32[o+4>>2]=tempI64[1],c.getdents&&a===0&&r===0&&(c.getdents=null),0}catch(l){if(typeof FS=="undefined"||l.name!=="ErrnoError")throw l;return l.errno}}var doWritev=(t,e,n,r)=>{for(var o=0,a=0;a<n;a++){var c=HEAPU32[e>>2],l=HEAPU32[e+4>>2];e+=8;var u=FS.write(t,HEAP8,c,l,r);if(u<0)return-1;o+=u,typeof r!="undefined"&&(r+=u)}return o};function _fd_write(t,e,n,r){try{var o=SYSCALLS.getStreamFromFD(t),a=doWritev(o,e,n);return HEAPU32[r>>2]=a,0}catch(c){if(typeof FS=="undefined"||c.name!=="ErrnoError")throw c;return c.errno}}var _getentropy=(t,e)=>(randomFill(HEAPU8.subarray(t,t+e)),0),arraySum=(t,e)=>{for(var n=0,r=0;r<=e;n+=t[r++]);return n},MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31],MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31],addDays=(t,e)=>{for(var n=new Date(t.getTime());e>0;){var r=isLeapYear(n.getFullYear()),o=n.getMonth(),a=(r?MONTH_DAYS_LEAP:MONTH_DAYS_REGULAR)[o];if(e>a-n.getDate())e-=a-n.getDate()+1,n.setDate(1),o<11?n.setMonth(o+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1));else return n.setDate(n.getDate()+e),n}return n},writeArrayToMemory=(t,e)=>{HEAP8.set(t,e)},_strftime=(t,e,n,r)=>{var o=HEAPU32[r+40>>2],a={tm_sec:HEAP32[r>>2],tm_min:HEAP32[r+4>>2],tm_hour:HEAP32[r+8>>2],tm_mday:HEAP32[r+12>>2],tm_mon:HEAP32[r+16>>2],tm_year:HEAP32[r+20>>2],tm_wday:HEAP32[r+24>>2],tm_yday:HEAP32[r+28>>2],tm_isdst:HEAP32[r+32>>2],tm_gmtoff:HEAP32[r+36>>2],tm_zone:o?UTF8ToString(o):""},c=UTF8ToString(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)c=c.replace(new RegExp(u,"g"),l[u]);var h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"];function f(g,M,C){for(var E=typeof g=="number"?g.toString():g||"";E.length<M;)E=C[0]+E;return E}function p(g,M){return f(g,M,"0")}function m(g,M){function C(w){return w<0?-1:w>0?1:0}var E;return(E=C(g.getFullYear()-M.getFullYear()))===0&&(E=C(g.getMonth()-M.getMonth()))===0&&(E=C(g.getDate()-M.getDate())),E}function v(g){switch(g.getDay()){case 0:return new Date(g.getFullYear()-1,11,29);case 1:return g;case 2:return new Date(g.getFullYear(),0,3);case 3:return new Date(g.getFullYear(),0,2);case 4:return new Date(g.getFullYear(),0,1);case 5:return new Date(g.getFullYear()-1,11,31);case 6:return new Date(g.getFullYear()-1,11,30)}}function x(g){var M=addDays(new Date(g.tm_year+1900,0,1),g.tm_yday),C=new Date(M.getFullYear(),0,4),E=new Date(M.getFullYear()+1,0,4),w=v(C),F=v(E);return m(w,M)<=0?m(F,M)<=0?M.getFullYear()+1:M.getFullYear():M.getFullYear()-1}var b={"%a":g=>h[g.tm_wday].substring(0,3),"%A":g=>h[g.tm_wday],"%b":g=>d[g.tm_mon].substring(0,3),"%B":g=>d[g.tm_mon],"%C":g=>{var M=g.tm_year+1900;return p(M/100|0,2)},"%d":g=>p(g.tm_mday,2),"%e":g=>f(g.tm_mday,2," "),"%g":g=>x(g).toString().substring(2),"%G":g=>x(g),"%H":g=>p(g.tm_hour,2),"%I":g=>{var M=g.tm_hour;return M==0?M=12:M>12&&(M-=12),p(M,2)},"%j":g=>p(g.tm_mday+arraySum(isLeapYear(g.tm_year+1900)?MONTH_DAYS_LEAP:MONTH_DAYS_REGULAR,g.tm_mon-1),3),"%m":g=>p(g.tm_mon+1,2),"%M":g=>p(g.tm_min,2),"%n":()=>`
`,"%p":g=>g.tm_hour>=0&&g.tm_hour<12?"AM":"PM","%S":g=>p(g.tm_sec,2),"%t":()=>"	","%u":g=>g.tm_wday||7,"%U":g=>{var M=g.tm_yday+7-g.tm_wday;return p(Math.floor(M/7),2)},"%V":g=>{var M=Math.floor((g.tm_yday+7-(g.tm_wday+6)%7)/7);if((g.tm_wday+371-g.tm_yday-2)%7<=2&&M++,M){if(M==53){var E=(g.tm_wday+371-g.tm_yday)%7;E!=4&&(E!=3||!isLeapYear(g.tm_year))&&(M=1)}}else{M=52;var C=(g.tm_wday+7-g.tm_yday-1)%7;(C==4||C==5&&isLeapYear(g.tm_year%400-1))&&M++}return p(M,2)},"%w":g=>g.tm_wday,"%W":g=>{var M=g.tm_yday+7-(g.tm_wday+6)%7;return p(Math.floor(M/7),2)},"%y":g=>(g.tm_year+1900).toString().substring(2),"%Y":g=>g.tm_year+1900,"%z":g=>{var M=g.tm_gmtoff,C=M>=0;return M=Math.abs(M)/60,M=M/60*100+M%60,(C?"+":"-")+("0000"+M).slice(-4)},"%Z":g=>g.tm_zone,"%%":()=>"%"};c=c.replace(/%%/g,"\0\0");for(var u in b)c.includes(u)&&(c=c.replace(new RegExp(u,"g"),b[u](a)));c=c.replace(/\0\0/g,"%");var y=intArrayFromString(c,!1);return y.length>e?0:(writeArrayToMemory(y,t),y.length-1)},_strftime_l=(t,e,n,r,o)=>_strftime(t,e,n,r);Module.requestFullscreen=(t,e)=>Browser.requestFullscreen(t,e),Module.requestAnimationFrame=t=>Browser.requestAnimationFrame(t),Module.setCanvasSize=(t,e,n)=>Browser.setCanvasSize(t,e,n),Module.pauseMainLoop=()=>Browser.mainLoop.pause(),Module.resumeMainLoop=()=>Browser.mainLoop.resume(),Module.getUserMedia=()=>Browser.getUserMedia(),Module.createContext=(t,e,n,r)=>Browser.createContext(t,e,n,r);var preloadedImages={},preloadedAudios={},GLctx,FSNode=function(t,e,n,r){t||(t=this),this.parent=t,this.mount=t.mount,this.mounted=null,this.id=FS.nextInode++,this.name=e,this.mode=n,this.node_ops={},this.stream_ops={},this.rdev=r},readMode=365,writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(t){t?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(t){t?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}}),FS.FSNode=FSNode,FS.createPreloadedFile=FS_createPreloadedFile,FS.staticInit(),Module.FS_createPath=FS.createPath,Module.FS_createDataFile=FS.createDataFile,Module.FS_createPreloadedFile=FS.createPreloadedFile,Module.FS_unlink=FS.unlink,Module.FS_createLazyFile=FS.createLazyFile,Module.FS_createDevice=FS.createDevice,InternalError=Module.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},embind_init_charCodes(),BindingError=Module.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},init_ClassHandle(),init_embind(),init_RegisteredPointer(),UnboundTypeError=Module.UnboundTypeError=extendError(Error,"UnboundTypeError"),handleAllocatorInit(),init_emval(),Fetch.init();var wasmImports={k:___assert_fail,x:___cxa_begin_catch,A:___cxa_end_catch,a:___cxa_find_matching_catch_2,g:___cxa_find_matching_catch_3,da:___cxa_rethrow,q:___cxa_throw,va:___cxa_uncaught_exceptions,d:___resumeException,ka:___syscall_fcntl64,Fa:___syscall_fstat64,Ba:___syscall_getcwd,ya:___syscall_getdents64,Ga:___syscall_ioctl,Ca:___syscall_lstat64,Da:___syscall_newfstatat,la:___syscall_openat,Ea:___syscall_stat64,oa:__embind_finalize_value_array,L:__embind_finalize_value_object,$a:__embind_register_bigint,Ka:__embind_register_bool,w:__embind_register_class,F:__embind_register_class_class_function,fa:__embind_register_class_class_property,ea:__embind_register_class_constructor,h:__embind_register_class_function,p:__embind_register_class_property,Ja:__embind_register_emval,Q:__embind_register_enum,u:__embind_register_enum_value,na:__embind_register_float,I:__embind_register_integer,z:__embind_register_memory_view,ma:__embind_register_std_string,_:__embind_register_std_wstring,qa:__embind_register_value_array,O:__embind_register_value_array_element,M:__embind_register_value_object,v:__embind_register_value_object_field,La:__embind_register_void,Ma:__emscripten_fetch_free,Ha:__emscripten_get_now_is_monotonic,E:__emval_as,J:__emval_call,D:__emval_call_method,sa:__emval_call_void_method,c:__emval_decref,K:__emval_get_global,B:__emval_get_method_caller,m:__emval_get_property,o:__emval_incref,X:__emval_new,pa:__emval_new_array_from_memory_view,r:__emval_new_cstring,Qa:__emval_new_object,n:__emval_run_destructors,W:__emval_set_property,t:__emval_take_value,Ya:__localtime_js,Za:__mktime_js,Xa:__munmap_js,xa:__tzset_js,P:_abort,Ta:_emscripten_asm_const_int,Pa:_emscripten_async_wget_data,Sa:_emscripten_clear_timeout,Z:_emscripten_date_now,ra:_emscripten_get_now,Oa:_emscripten_is_main_browser_thread,Ia:_emscripten_memcpy_js,wa:_emscripten_resize_heap,ca:_emscripten_run_script,V:_emscripten_run_script_string,Ra:_emscripten_set_timeout,Na:_emscripten_start_fetch,za:_environ_get,Aa:_environ_sizes_get,$:_exit,T:_fd_close,ia:_fd_read,_a:_fd_seek,ja:_fd_write,ta:_getentropy,Y:invoke_diii,ga:invoke_fiii,y:invoke_i,b:invoke_ii,f:invoke_iii,s:invoke_iiii,l:invoke_iiiii,U:invoke_iiiiii,H:invoke_iiiiiii,ha:invoke_iiiiiiii,ba:invoke_iiiiiiiiii,S:invoke_iiiiiiiiiiii,Wa:invoke_j,Ua:invoke_jiiii,i:invoke_v,C:invoke_vi,e:invoke_vii,j:invoke_viii,aa:invoke_viiii,G:invoke_viiiiiii,N:invoke_viiiiiiiiii,R:invoke_viiiiiiiiiiiiiii,Va:invoke_viijii,ua:_strftime_l},wasmExports=createWasm(),___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports.bb)(),_main=Module._main=(t,e)=>(_main=Module._main=wasmExports.cb)(t,e),_malloc=t=>(_malloc=wasmExports.eb)(t),_free=t=>(_free=wasmExports.fb)(t),___errno_location=()=>(___errno_location=wasmExports.gb)(),___getTypeName=t=>(___getTypeName=wasmExports.hb)(t),__embind_initialize_bindings=Module.__embind_initialize_bindings=()=>(__embind_initialize_bindings=Module.__embind_initialize_bindings=wasmExports.ib)(),_emscripten_builtin_memalign=(t,e)=>(_emscripten_builtin_memalign=wasmExports.jb)(t,e),_setThrew=(t,e)=>(_setThrew=wasmExports.kb)(t,e),setTempRet0=t=>(setTempRet0=wasmExports.lb)(t),stackSave=()=>(stackSave=wasmExports.mb)(),stackRestore=t=>(stackRestore=wasmExports.nb)(t),___cxa_decrement_exception_refcount=t=>(___cxa_decrement_exception_refcount=wasmExports.ob)(t),___cxa_increment_exception_refcount=t=>(___cxa_increment_exception_refcount=wasmExports.pb)(t),___cxa_can_catch=(t,e,n)=>(___cxa_can_catch=wasmExports.qb)(t,e,n),___cxa_is_pointer_type=t=>(___cxa_is_pointer_type=wasmExports.rb)(t),dynCall_jiji=Module.dynCall_jiji=(t,e,n,r,o)=>(dynCall_jiji=Module.dynCall_jiji=wasmExports.sb)(t,e,n,r,o),dynCall_j=Module.dynCall_j=t=>(dynCall_j=Module.dynCall_j=wasmExports.tb)(t),dynCall_viijii=Module.dynCall_viijii=(t,e,n,r,o,a,c)=>(dynCall_viijii=Module.dynCall_viijii=wasmExports.ub)(t,e,n,r,o,a,c),dynCall_jiiii=Module.dynCall_jiiii=(t,e,n,r,o)=>(dynCall_jiiii=Module.dynCall_jiiii=wasmExports.vb)(t,e,n,r,o),dynCall_iiiiij=Module.dynCall_iiiiij=(t,e,n,r,o,a,c)=>(dynCall_iiiiij=Module.dynCall_iiiiij=wasmExports.wb)(t,e,n,r,o,a,c),dynCall_iiiiijj=Module.dynCall_iiiiijj=(t,e,n,r,o,a,c,l,u)=>(dynCall_iiiiijj=Module.dynCall_iiiiijj=wasmExports.xb)(t,e,n,r,o,a,c,l,u),dynCall_iiiiiijj=Module.dynCall_iiiiiijj=(t,e,n,r,o,a,c,l,u,h)=>(dynCall_iiiiiijj=Module.dynCall_iiiiiijj=wasmExports.yb)(t,e,n,r,o,a,c,l,u,h);function invoke_iii(t,e,n){var r=stackSave();try{return getWasmTableEntry(t)(e,n)}catch(o){if(stackRestore(r),o!==o+0)throw o;_setThrew(1,0)}}function invoke_iiii(t,e,n,r){var o=stackSave();try{return getWasmTableEntry(t)(e,n,r)}catch(a){if(stackRestore(o),a!==a+0)throw a;_setThrew(1,0)}}function invoke_ii(t,e){var n=stackSave();try{return getWasmTableEntry(t)(e)}catch(r){if(stackRestore(n),r!==r+0)throw r;_setThrew(1,0)}}function invoke_viii(t,e,n,r){var o=stackSave();try{getWasmTableEntry(t)(e,n,r)}catch(a){if(stackRestore(o),a!==a+0)throw a;_setThrew(1,0)}}function invoke_vii(t,e,n){var r=stackSave();try{getWasmTableEntry(t)(e,n)}catch(o){if(stackRestore(r),o!==o+0)throw o;_setThrew(1,0)}}function invoke_iiiiiiiiii(t,e,n,r,o,a,c,l,u,h){var d=stackSave();try{return getWasmTableEntry(t)(e,n,r,o,a,c,l,u,h)}catch(f){if(stackRestore(d),f!==f+0)throw f;_setThrew(1,0)}}function invoke_iiiiii(t,e,n,r,o,a){var c=stackSave();try{return getWasmTableEntry(t)(e,n,r,o,a)}catch(l){if(stackRestore(c),l!==l+0)throw l;_setThrew(1,0)}}function invoke_vi(t,e){var n=stackSave();try{getWasmTableEntry(t)(e)}catch(r){if(stackRestore(n),r!==r+0)throw r;_setThrew(1,0)}}function invoke_viiii(t,e,n,r,o){var a=stackSave();try{getWasmTableEntry(t)(e,n,r,o)}catch(c){if(stackRestore(a),c!==c+0)throw c;_setThrew(1,0)}}function invoke_iiiii(t,e,n,r,o){var a=stackSave();try{return getWasmTableEntry(t)(e,n,r,o)}catch(c){if(stackRestore(a),c!==c+0)throw c;_setThrew(1,0)}}function invoke_v(t){var e=stackSave();try{getWasmTableEntry(t)()}catch(n){if(stackRestore(e),n!==n+0)throw n;_setThrew(1,0)}}function invoke_iiiiiii(t,e,n,r,o,a,c){var l=stackSave();try{return getWasmTableEntry(t)(e,n,r,o,a,c)}catch(u){if(stackRestore(l),u!==u+0)throw u;_setThrew(1,0)}}function invoke_iiiiiiii(t,e,n,r,o,a,c,l){var u=stackSave();try{return getWasmTableEntry(t)(e,n,r,o,a,c,l)}catch(h){if(stackRestore(u),h!==h+0)throw h;_setThrew(1,0)}}function invoke_fiii(t,e,n,r){var o=stackSave();try{return getWasmTableEntry(t)(e,n,r)}catch(a){if(stackRestore(o),a!==a+0)throw a;_setThrew(1,0)}}function invoke_diii(t,e,n,r){var o=stackSave();try{return getWasmTableEntry(t)(e,n,r)}catch(a){if(stackRestore(o),a!==a+0)throw a;_setThrew(1,0)}}function invoke_i(t){var e=stackSave();try{return getWasmTableEntry(t)()}catch(n){if(stackRestore(e),n!==n+0)throw n;_setThrew(1,0)}}function invoke_viiiiiii(t,e,n,r,o,a,c,l){var u=stackSave();try{getWasmTableEntry(t)(e,n,r,o,a,c,l)}catch(h){if(stackRestore(u),h!==h+0)throw h;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(t,e,n,r,o,a,c,l,u,h,d,f){var p=stackSave();try{return getWasmTableEntry(t)(e,n,r,o,a,c,l,u,h,d,f)}catch(m){if(stackRestore(p),m!==m+0)throw m;_setThrew(1,0)}}function invoke_viiiiiiiiii(t,e,n,r,o,a,c,l,u,h,d){var f=stackSave();try{getWasmTableEntry(t)(e,n,r,o,a,c,l,u,h,d)}catch(p){if(stackRestore(f),p!==p+0)throw p;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiii(t,e,n,r,o,a,c,l,u,h,d,f,p,m,v,x){var b=stackSave();try{getWasmTableEntry(t)(e,n,r,o,a,c,l,u,h,d,f,p,m,v,x)}catch(y){if(stackRestore(b),y!==y+0)throw y;_setThrew(1,0)}}function invoke_j(t){var e=stackSave();try{return dynCall_j(t)}catch(n){if(stackRestore(e),n!==n+0)throw n;_setThrew(1,0)}}function invoke_viijii(t,e,n,r,o,a,c){var l=stackSave();try{dynCall_viijii(t,e,n,r,o,a,c)}catch(u){if(stackRestore(l),u!==u+0)throw u;_setThrew(1,0)}}function invoke_jiiii(t,e,n,r,o){var a=stackSave();try{return dynCall_jiiii(t,e,n,r,o)}catch(c){if(stackRestore(a),c!==c+0)throw c;_setThrew(1,0)}}Module.addRunDependency=addRunDependency,Module.removeRunDependency=removeRunDependency,Module.FS_createPath=FS.createPath,Module.FS_createLazyFile=FS.createLazyFile,Module.FS_createDevice=FS.createDevice,Module.FS_createPreloadedFile=FS.createPreloadedFile,Module.FS=FS,Module.FS_createDataFile=FS.createDataFile,Module.FS_unlink=FS.unlink;var calledRun;dependenciesFulfilled=function t(){calledRun||run(),calledRun||(dependenciesFulfilled=t)};function callMain(){var t=_main,e=0,n=0;try{var r=t(e,n);return exitJS(r,!0),r}catch(o){return handleException(o)}}function run(){if(runDependencies>0||(preRun(),runDependencies>0))return;function t(){calledRun||(calledRun=!0,Module.calledRun=!0,!ABORT&&(initRuntime(),preMain(),readyPromiseResolve(Module),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(),postRun()))}Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),t()},1)):t()}if(Module.preInit)for(typeof Module.preInit=="function"&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;return Module.noInitialRun&&(shouldRunNow=!1),run(),moduleArg.ready}})();typeof exports=="object"&&typeof module=="object"?module.exports=BeautySightCore:typeof define=="function"&&define.amd&&define([],()=>BeautySightCore);var _emscripten_BSC=BeautySightCore;BeautySightCore=function(t,e=void 0){return xe(this,null,function*(){var g,M,C;let n=typeof importScripts=="function";function r(E){return new Promise(w=>{if(n)importScripts(E),w();else{let F=document.createElement("script");F.setAttribute("src",E),document.body.appendChild(F),F.onload=w}})}let o=E=>`/assets/${E}`,a=e?e.locateFile:null,c=a||o;function l(E){let w=E?E.lastIndexOf("/"):null;return{name:w>=0?E.substring(w+1):E,path:E}}let u=r(c("visageSDKData.js")),h=r(c("tf.min.js"));yield Promise.all([u,h]);function d(E){return t[E]==null||t[E].isRaw?null:l(t[E].license,!1)}let f=d("makeup"),p=d("skintone"),m=d("facetrack"),v=f?f.name:(g=t.makeup)==null?void 0:g.license,x=p?p.name:(M=t.skintone)==null?void 0:M.license,b=m?m.name:(C=t.facetrack)==null?void 0:C.license,y=[];return _emscripten_BSC({locateFile:c,preRun:[E=>{f&&(E.FS_createPreloadedFile("/",f.name,f.path,!0,!1,function(){},function(){alert(`Loading License "${f.name}":"${f.path}" Failed!`)}),y.push(f)),p&&!y.find(w=>w.name===p.name&&w.path===p.path)&&(E.FS_createPreloadedFile("/",p.name,p.path,!0,!1,function(){},function(){alert(`Loading License "${p.name}":"${p.path}" Failed!`)}),y.push(p)),m&&!y.find(w=>w.name===m.name&&w.path===m.path)&&E.FS_createPreloadedFile("/",m.name,m.path,!0,!1,function(){},function(){alert(`Loading License "${m.name}":"${m.path}" Failed!`)}),E.FS_createPreloadedFile("/","NeuralNet.cfg",c("NeuralNet.cfg"),!0,!1,function(){},function(){alert("Loading NeuralNet.cfg Failed!")}),E.FS_createPreloadedFile("/","backend-wasm.wasm",c("backend-wasm.wasm"),!0,!1,function(){},function(){alert("Loading backend-wasm.wasm Failed!")}),E.FS_createPreloadedFile("/","backend-wasm-simd.wasm",c("backend-wasm-simd.wasm"),!0,!1,function(){},function(){alert("Loading backend-wasm-simd.wasm Failed!")})}]}).then(E=>xe(this,null,function*(){if(e&&e.statusCallback){let Y=E.setStatus,L=N=>{let G=N.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),z=G?G[2]/G[4]:1,D=Math.min(1,z);e.statusCallback({progress:D,text:N})};E.setStatus=L}let w=(Y,L)=>fetch(L).then(N=>N.arrayBuffer()).then(N=>{let G=N instanceof ArrayBuffer?new Uint8Array(N):N,z=E.FS.open(Y,"w");E.FS.write(z,G,0,G.byteLength),E.FS.close(z)});E.MountFile=w,tfjsInit(E),yield visageSDKdata(E);let F;E.CreateBSCProvider=(Y,L=null)=>xe(this,null,function*(){let N=l(Y);yield w(N.name,N.path),F=E.BSCProvider.Create(N.name,L),console.log(`BSCProvider ${L===null?"without":"with"} collection created.`)});let H="";E.GetFaceTracker=()=>E.FaceTracker.GetInstance(F,b!=null?b:H),E.GetSkinToneAnalysis=(Y=void 0)=>E.SkinToneAnalysis.GetInstance(F,Y!=null?Y:E.SkinToneTargetQuality.MORE_SPEED,x!=null?x:H),E.GetMeshGenerator=()=>E.MeshGenerator.GetInstance(F,v!=null?v:H),E.GetFaceShapeAnalysis=()=>E.FaceShapeAnalysis.GetInstance(F,x!=null?x:H),E.GetEyeShapeAnalysis=()=>E.EyeShapeAnalysis.GetInstance(F,x!=null?x:H),E.GetLipShapeAnalysis=()=>E.LipShapeAnalysis.GetInstance(F,x!=null?x:H),E.GetHairToneAnalysis=()=>E.HairToneAnalysis.GetInstance(F,x!=null?x:H),E.GetEyeToneAnalysis=()=>E.EyeToneAnalysis.GetInstance(F,x!=null?x:H),E.GetLightConditionsAnalysis=(Y,L,N)=>E.LightConditionsAnalysis.GetInstance(F,x!=null?x:H,Y,L,N);for(var ne of Object.keys(E))ne.startsWith("_emscripten_enum_BeautySightCore_")&&(E[ne.substring(33)]=E[ne]());return E.GetFrameProvider=()=>F.GetFrameProvider(),E.FrameProvider.callbackHandleCounterForFrameProvider=0,E.FrameProvider.prototype.SetCallback=function(Y){if(!Y)return;this.frameProviderObservers||(this.frameProviderObservers=new Map);let L=E.FrameProvider.callbackHandleCounterForFrameProvider++,N=new E.FrameObserverBaseJS(this,Y);return this.frameProviderObservers.set(L,N),L},E.FrameProvider.prototype.ClearCallback=function(Y){this.frameProviderObservers.has(Y)&&(this.frameProviderObservers.get(Y).delete(),this.frameProviderObservers.delete(Y))},E.MeshGenerator.prototype.SetCallback=function(Y){this._SetCallback(L=>{Y(L),L.delete()})},E}))})};typeof exports=="object"&&typeof module=="object"?module.exports=BeautySightCore:typeof define=="function"&&define.amd?define([],function(){return BeautySightCore}):typeof exports=="object"&&(exports.BeautySightCore=BeautySightCore)});var WT=Xy((VT,my)=>{"use strict";var zT=(()=>{var t=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(t=t||__filename),function(e={}){var n=e,r,o;n.ready=new Promise((R,P)=>{r=R,o=P});var a=Object.assign({},n),c=[],l="./this.program",u=(R,P)=>{throw P},h=typeof window=="object",d=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",p="";function m(R){return n.locateFile?n.locateFile(R,p):p+R}var v,x,b;if(f){var y=require("fs"),g=require("path");d?p=g.dirname(p)+"/":p=__dirname+"/",v=(R,P)=>(R=A(R)?new URL(R):g.normalize(R),y.readFileSync(R,P?void 0:"utf8")),b=R=>{var P=v(R,!0);return P.buffer||(P=new Uint8Array(P)),P},x=(R,P,j,J=!0)=>{R=A(R)?new URL(R):g.normalize(R),y.readFile(R,J?void 0:"utf8",(ye,Se)=>{ye?j(ye):P(J?Se.buffer:Se)})},!n.thisProgram&&process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),c=process.argv.slice(2),u=(R,P)=>{throw process.exitCode=R,P},n.inspect=()=>"[Emscripten Module object]"}else(h||d)&&(d?p=self.location.href:typeof document!="undefined"&&document.currentScript&&(p=document.currentScript.src),t&&(p=t),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="",v=R=>{var P=new XMLHttpRequest;return P.open("GET",R,!1),P.send(null),P.responseText},d&&(b=R=>{var P=new XMLHttpRequest;return P.open("GET",R,!1),P.responseType="arraybuffer",P.send(null),new Uint8Array(P.response)}),x=(R,P,j)=>{var J=new XMLHttpRequest;J.open("GET",R,!0),J.responseType="arraybuffer",J.onload=()=>{if(J.status==200||J.status==0&&J.response){P(J.response);return}j()},J.onerror=j,J.send(null)});var M=n.print||console.log.bind(console),C=n.printErr||console.error.bind(console);Object.assign(n,a),a=null,n.arguments&&(c=n.arguments),n.thisProgram&&(l=n.thisProgram),n.quit&&(u=n.quit);var E;n.wasmBinary&&(E=n.wasmBinary);var w=n.noExitRuntime||!0;typeof WebAssembly!="object"&&ie("no native wasm support detected");var F,H=!1,ne,Y,L,N,G,z,D,B,q;function $(){var R=F.buffer;n.HEAP8=Y=new Int8Array(R),n.HEAP16=N=new Int16Array(R),n.HEAPU8=L=new Uint8Array(R),n.HEAPU16=G=new Uint16Array(R),n.HEAP32=z=new Int32Array(R),n.HEAPU32=D=new Uint32Array(R),n.HEAPF32=B=new Float32Array(R),n.HEAPF64=q=new Float64Array(R)}var ce=[],ge=[],he=[],Pe=!1;function Fe(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)_t(n.preRun.shift());ve(ce)}function st(){Pe=!0,ve(ge)}function V(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Ve(n.postRun.shift());ve(he)}function _t(R){ce.unshift(R)}function we(R){ge.unshift(R)}function Ve(R){he.unshift(R)}var Ce=0,$e=null,Ie=null;function Q(R){Ce++,n.monitorRunDependencies&&n.monitorRunDependencies(Ce)}function re(R){if(Ce--,n.monitorRunDependencies&&n.monitorRunDependencies(Ce),Ce==0&&($e!==null&&(clearInterval($e),$e=null),Ie)){var P=Ie;Ie=null,P()}}function ie(R){n.onAbort&&n.onAbort(R),R="Aborted("+R+")",C(R),H=!0,ne=1,R+=". Build with -sASSERTIONS for more info.";var P=new WebAssembly.RuntimeError(R);throw o(P),P}var _e="data:application/octet-stream;base64,";function le(R){return R.startsWith(_e)}function A(R){return R.startsWith("file://")}var S;S="MeshGenerators.wasm",le(S)||(S=m(S));function K(R){if(R==S&&E)return new Uint8Array(E);if(b)return b(R);throw"both async and sync fetching of the wasm failed"}function Z(R){if(!E&&(h||d)){if(typeof fetch=="function"&&!A(R))return fetch(R,{credentials:"same-origin"}).then(P=>{if(!P.ok)throw"failed to load wasm binary file at '"+R+"'";return P.arrayBuffer()}).catch(()=>K(R));if(x)return new Promise((P,j)=>{x(R,J=>P(new Uint8Array(J)),j)})}return Promise.resolve().then(()=>K(R))}function I(R,P,j){return Z(R).then(J=>WebAssembly.instantiate(J,P)).then(J=>J).then(j,J=>{C(`failed to asynchronously prepare wasm: ${J}`),ie(J)})}function ee(R,P,j,J){return!R&&typeof WebAssembly.instantiateStreaming=="function"&&!le(P)&&!A(P)&&!f&&typeof fetch=="function"?fetch(P,{credentials:"same-origin"}).then(ye=>{var Se=WebAssembly.instantiateStreaming(ye,j);return Se.then(J,function(Oe){return C(`wasm streaming compile failed: ${Oe}`),C("falling back to ArrayBuffer instantiation"),I(P,j,J)})}):I(P,j,J)}function ae(){var R={a:Y1};function P(J,ye){return nn=J.exports,F=nn.C,$(),Cy=nn.E,we(nn.D),re("wasm-instantiate"),nn}Q("wasm-instantiate");function j(J){P(J.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(R,P)}catch(J){C(`Module.instantiateWasm callback failed with error: ${J}`),o(J)}return ee(E,S,R,j).catch(o),{}}var ve=R=>{for(;R.length>0;)R.shift()(n)},oe=[],pe=0,be=R=>{var P=new de(R);return P.get_caught()||(P.set_caught(!0),pe--),P.set_rethrown(!1),oe.push(P),Uy(P.excPtr),P.get_exception_ptr()},Te=0;function de(R){this.excPtr=R,this.ptr=R-24,this.set_type=function(P){D[this.ptr+4>>2]=P},this.get_type=function(){return D[this.ptr+4>>2]},this.set_destructor=function(P){D[this.ptr+8>>2]=P},this.get_destructor=function(){return D[this.ptr+8>>2]},this.set_caught=function(P){P=P?1:0,Y[this.ptr+12>>0]=P},this.get_caught=function(){return Y[this.ptr+12>>0]!=0},this.set_rethrown=function(P){P=P?1:0,Y[this.ptr+13>>0]=P},this.get_rethrown=function(){return Y[this.ptr+13>>0]!=0},this.init=function(P,j){this.set_adjusted_ptr(0),this.set_type(P),this.set_destructor(j)},this.set_adjusted_ptr=function(P){D[this.ptr+16>>2]=P},this.get_adjusted_ptr=function(){return D[this.ptr+16>>2]},this.get_exception_ptr=function(){var P=Gy(this.get_type());if(P)return D[this.excPtr>>2];var j=this.get_adjusted_ptr();return j!==0?j:this.excPtr}}var Me=R=>{throw Te||(Te=R),Te},ot=R=>{var P=Te;if(!P)return ul(0),0;var j=new de(P);j.set_adjusted_ptr(P);var J=j.get_type();if(!J)return ul(0),P;for(var ye in R){var Se=R[ye];if(Se===0||Se===J)break;var Oe=j.ptr+16;if(Ny(Se,J,Oe))return ul(Se),P}return ul(J),P},Mt=()=>ot([]),ms=R=>ot([R]),sl=(R,P,j)=>{var J=new de(R);throw J.init(P,j),Te=R,pe++,Te},gs=(R,P,j,J,ye)=>{},al=()=>{for(var R=new Array(256),P=0;P<256;++P)R[P]=String.fromCharCode(P);si=R},si,bn=R=>{for(var P="",j=R;L[j];)P+=si[L[j++]];return P},fn={},nr={},ai={},br,it=R=>{throw new br(R)},Eo,So=R=>{throw new Eo(R)},ci=(R,P,j)=>{R.forEach(function(Ee){ai[Ee]=P});function J(Ee){var Ze=j(Ee);Ze.length!==R.length&&So("Mismatched type converter count");for(var ke=0;ke<R.length;++ke)k(R[ke],Ze[ke])}var ye=new Array(P.length),Se=[],Oe=0;P.forEach((Ee,Ze)=>{nr.hasOwnProperty(Ee)?ye[Ze]=nr[Ee]:(Se.push(Ee),fn.hasOwnProperty(Ee)||(fn[Ee]=[]),fn[Ee].push(()=>{ye[Ze]=nr[Ee],++Oe,Oe===Se.length&&J(ye)}))}),Se.length===0&&J(ye)};function T(R,P,j={}){var J=P.name;if(R||it(`type "${J}" must have a positive integer typeid pointer`),nr.hasOwnProperty(R)){if(j.ignoreDuplicateRegistrations)return;it(`Cannot register type '${J}' twice`)}if(nr[R]=P,delete ai[R],fn.hasOwnProperty(R)){var ye=fn[R];delete fn[R],ye.forEach(Se=>Se())}}function k(R,P,j={}){if(!("argPackAdvance"in P))throw new TypeError("registerType registeredInstance requires argPackAdvance");return T(R,P,j)}var U=8,X=(R,P,j,J)=>{P=bn(P),k(R,{name:P,fromWireType:function(ye){return!!ye},toWireType:function(ye,Se){return Se?j:J},argPackAdvance:U,readValueFromPointer:function(ye){return this.fromWireType(L[ye])},destructorFunction:null})},se=R=>({count:R.count,deleteScheduled:R.deleteScheduled,preservePointerOnDelete:R.preservePointerOnDelete,ptr:R.ptr,ptrType:R.ptrType,smartPtr:R.smartPtr,smartPtrType:R.smartPtrType}),Ge=R=>{function P(j){return j.$$.ptrType.registeredClass.name}it(P(R)+" instance already deleted")},De=!1,ze=R=>{},Be=R=>{R.smartPtr?R.smartPtrType.rawDestructor(R.smartPtr):R.ptrType.registeredClass.rawDestructor(R.ptr)},lt=R=>{R.count.value-=1;var P=R.count.value===0;P&&Be(R)},ct=(R,P,j)=>{if(P===j)return R;if(j.baseClass===void 0)return null;var J=ct(R,P,j.baseClass);return J===null?null:j.downcast(J)},Re={},nt=()=>Object.keys(wn).length,Qt=()=>{var R=[];for(var P in wn)wn.hasOwnProperty(P)&&R.push(wn[P]);return R},et=[],tn=()=>{for(;et.length;){var R=et.pop();R.$$.deleteScheduled=!1,R.delete()}},ht,Gi=R=>{ht=R,et.length&&ht&&ht(tn)},Et=()=>{n.getInheritedInstanceCount=nt,n.getLiveInheritedInstances=Qt,n.flushPendingDeletes=tn,n.setDelayFunction=Gi},wn={},Gn=(R,P)=>{for(P===void 0&&it("ptr should not be undefined");R.baseClass;)P=R.upcast(P),R=R.baseClass;return P},rr=(R,P)=>(P=Gn(R,P),wn[P]),fh=(R,P)=>{(!P.ptrType||!P.ptr)&&So("makeClassHandle requires ptr and ptrType");var j=!!P.smartPtrType,J=!!P.smartPtr;return j!==J&&So("Both smartPtrType and smartPtr must be specified"),P.count={value:1},cl(Object.create(R,{$$:{value:P}}))};function KT(R){var P=this.getPointee(R);if(!P)return this.destructor(R),null;var j=rr(this.registeredClass,P);if(j!==void 0){if(j.$$.count.value===0)return j.$$.ptr=P,j.$$.smartPtr=R,j.clone();var J=j.clone();return this.destructor(R),J}function ye(){return this.isSmartPointer?fh(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:P,smartPtrType:this,smartPtr:R}):fh(this.registeredClass.instancePrototype,{ptrType:this,ptr:R})}var Se=this.registeredClass.getActualType(P),Oe=Re[Se];if(!Oe)return ye.call(this);var Ee;this.isConst?Ee=Oe.constPointerType:Ee=Oe.pointerType;var Ze=ct(P,this.registeredClass,Ee.registeredClass);return Ze===null?ye.call(this):this.isSmartPointer?fh(Ee.registeredClass.instancePrototype,{ptrType:Ee,ptr:Ze,smartPtrType:this,smartPtr:R}):fh(Ee.registeredClass.instancePrototype,{ptrType:Ee,ptr:Ze})}var cl=R=>typeof FinalizationRegistry=="undefined"?(cl=P=>P,R):(De=new FinalizationRegistry(P=>{lt(P.$$)}),cl=P=>{var j=P.$$,J=!!j.smartPtr;if(J){var ye={$$:j};De.register(P,ye,P)}return P},ze=P=>De.unregister(P),cl(R)),e1=()=>{Object.assign(dh.prototype,{isAliasOf(R){if(!(this instanceof dh)||!(R instanceof dh))return!1;var P=this.$$.ptrType.registeredClass,j=this.$$.ptr;R.$$=R.$$;for(var J=R.$$.ptrType.registeredClass,ye=R.$$.ptr;P.baseClass;)j=P.upcast(j),P=P.baseClass;for(;J.baseClass;)ye=J.upcast(ye),J=J.baseClass;return P===J&&j===ye},clone(){if(this.$$.ptr||Ge(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var R=cl(Object.create(Object.getPrototypeOf(this),{$$:{value:se(this.$$)}}));return R.$$.count.value+=1,R.$$.deleteScheduled=!1,R},delete(){this.$$.ptr||Ge(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&it("Object already scheduled for deletion"),ze(this),lt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ge(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&it("Object already scheduled for deletion"),et.push(this),et.length===1&&ht&&ht(tn),this.$$.deleteScheduled=!0,this}})};function dh(){}var t1=48,n1=57,Qp=R=>{if(R===void 0)return"_unknown";R=R.replace(/[^a-zA-Z0-9_]/g,"$");var P=R.charCodeAt(0);return P>=t1&&P<=n1?`_${R}`:R};function Kp(R,P){return R=Qp(R),{[R]:function(){return P.apply(this,arguments)}}[R]}var Ey=(R,P,j)=>{if(R[P].overloadTable===void 0){var J=R[P];R[P]=function(){return R[P].overloadTable.hasOwnProperty(arguments.length)||it(`Function '${j}' called with an invalid number of arguments (${arguments.length}) - expects one of (${R[P].overloadTable})!`),R[P].overloadTable[arguments.length].apply(this,arguments)},R[P].overloadTable=[],R[P].overloadTable[J.argCount]=J}},Sy=(R,P,j)=>{n.hasOwnProperty(R)?((j===void 0||n[R].overloadTable!==void 0&&n[R].overloadTable[j]!==void 0)&&it(`Cannot register public name '${R}' twice`),Ey(n,R,R),n.hasOwnProperty(j)&&it(`Cannot register multiple overloads of a function with the same number of arguments (${j})!`),n[R].overloadTable[j]=P):(n[R]=P,j!==void 0&&(n[R].numArguments=j))};function r1(R,P,j,J,ye,Se,Oe,Ee){this.name=R,this.constructor=P,this.instancePrototype=j,this.rawDestructor=J,this.baseClass=ye,this.getActualType=Se,this.upcast=Oe,this.downcast=Ee,this.pureVirtualFunctions=[]}var em=(R,P,j)=>{for(;P!==j;)P.upcast||it(`Expected null or instance of ${j.name}, got an instance of ${P.name}`),R=P.upcast(R),P=P.baseClass;return R};function i1(R,P){if(P===null)return this.isReference&&it(`null is not a valid ${this.name}`),0;P.$$||it(`Cannot pass "${rm(P)}" as a ${this.name}`),P.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`);var j=P.$$.ptrType.registeredClass,J=em(P.$$.ptr,j,this.registeredClass);return J}function o1(R,P){var j;if(P===null)return this.isReference&&it(`null is not a valid ${this.name}`),this.isSmartPointer?(j=this.rawConstructor(),R!==null&&R.push(this.rawDestructor,j),j):0;P.$$||it(`Cannot pass "${rm(P)}" as a ${this.name}`),P.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&P.$$.ptrType.isConst&&it(`Cannot convert argument of type ${P.$$.smartPtrType?P.$$.smartPtrType.name:P.$$.ptrType.name} to parameter type ${this.name}`);var J=P.$$.ptrType.registeredClass;if(j=em(P.$$.ptr,J,this.registeredClass),this.isSmartPointer)switch(P.$$.smartPtr===void 0&&it("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:P.$$.smartPtrType===this?j=P.$$.smartPtr:it(`Cannot convert argument of type ${P.$$.smartPtrType?P.$$.smartPtrType.name:P.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:j=P.$$.smartPtr;break;case 2:if(P.$$.smartPtrType===this)j=P.$$.smartPtr;else{var ye=P.clone();j=this.rawShare(j,vh.toHandle(()=>ye.delete())),R!==null&&R.push(this.rawDestructor,j)}break;default:it("Unsupporting sharing policy")}return j}function s1(R,P){if(P===null)return this.isReference&&it(`null is not a valid ${this.name}`),0;P.$$||it(`Cannot pass "${rm(P)}" as a ${this.name}`),P.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`),P.$$.ptrType.isConst&&it(`Cannot convert argument of type ${P.$$.ptrType.name} to parameter type ${this.name}`);var j=P.$$.ptrType.registeredClass,J=em(P.$$.ptr,j,this.registeredClass);return J}function Ty(R){return this.fromWireType(D[R>>2])}var a1=()=>{Object.assign(ph.prototype,{getPointee(R){return this.rawGetPointee&&(R=this.rawGetPointee(R)),R},destructor(R){this.rawDestructor&&this.rawDestructor(R)},argPackAdvance:U,readValueFromPointer:Ty,deleteObject(R){R!==null&&R.delete()},fromWireType:KT})};function ph(R,P,j,J,ye,Se,Oe,Ee,Ze,ke,ft){this.name=R,this.registeredClass=P,this.isReference=j,this.isConst=J,this.isSmartPointer=ye,this.pointeeType=Se,this.sharingPolicy=Oe,this.rawGetPointee=Ee,this.rawConstructor=Ze,this.rawShare=ke,this.rawDestructor=ft,!ye&&P.baseClass===void 0?J?(this.toWireType=i1,this.destructorFunction=null):(this.toWireType=s1,this.destructorFunction=null):this.toWireType=o1}var Ay=(R,P,j)=>{n.hasOwnProperty(R)||So("Replacing nonexistant public symbol"),n[R].overloadTable!==void 0&&j!==void 0?n[R].overloadTable[j]=P:(n[R]=P,n[R].argCount=j)},c1=(R,P,j)=>{var J=n["dynCall_"+R];return j&&j.length?J.apply(null,[P].concat(j)):J.call(null,P)},mh=[],Cy,xa=R=>{var P=mh[R];return P||(R>=mh.length&&(mh.length=R+1),mh[R]=P=Cy.get(R)),P},l1=(R,P,j)=>{if(R.includes("j"))return c1(R,P,j);var J=xa(P).apply(null,j);return J},u1=(R,P)=>{var j=[];return function(){return j.length=0,Object.assign(j,arguments),l1(R,P,j)}},vs=(R,P)=>{R=bn(R);function j(){return R.includes("j")?u1(R,P):xa(P)}var J=j();return typeof J!="function"&&it(`unknown function pointer with signature ${R}: ${P}`),J},h1=(R,P)=>{var j=Kp(P,function(J){this.name=P,this.message=J;var ye=new Error(J).stack;ye!==void 0&&(this.stack=this.toString()+`
`+ye.replace(/^Error(:[^\n]*)?\n/,""))});return j.prototype=Object.create(R.prototype),j.prototype.constructor=j,j.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},j},Ry,Py=R=>{var P=Oy(R),j=bn(P);return ki(P),j},gh=(R,P)=>{var j=[],J={};function ye(Se){if(!J[Se]&&!nr[Se]){if(ai[Se]){ai[Se].forEach(ye);return}j.push(Se),J[Se]=!0}}throw P.forEach(ye),new Ry(`${R}: `+j.map(Py).join([", "]))},f1=(R,P,j,J,ye,Se,Oe,Ee,Ze,ke,ft,Ct,Zt)=>{ft=bn(ft),Se=vs(ye,Se),Ee&&(Ee=vs(Oe,Ee)),ke&&(ke=vs(Ze,ke)),Zt=vs(Ct,Zt);var Ot=Qp(ft);Sy(Ot,function(){gh(`Cannot construct ${ft} due to unbound types`,[J])}),ci([R,P,j],J?[J]:[],function(kn){kn=kn[0];var Mr,Zn;J?(Mr=kn.registeredClass,Zn=Mr.instancePrototype):Zn=dh.prototype;var To=Kp(Ot,function(){if(Object.getPrototypeOf(this)!==om)throw new br("Use 'new' to construct "+ft);if(Hr.constructor_body===void 0)throw new br(ft+" has no accessible constructor");var Vy=Hr.constructor_body[arguments.length];if(Vy===void 0)throw new br(`Tried to invoke ctor of ${ft} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Hr.constructor_body).toString()}) parameters instead!`);return Vy.apply(this,arguments)}),om=Object.create(Zn,{constructor:{value:To}});To.prototype=om;var Hr=new r1(ft,To,om,Zt,Mr,Se,Ee,ke);Hr.baseClass&&(Hr.baseClass.__derivedClasses===void 0&&(Hr.baseClass.__derivedClasses=[]),Hr.baseClass.__derivedClasses.push(Hr));var rA=new ph(ft,Hr,!0,!1,!1),Hy=new ph(ft+"*",Hr,!1,!1,!1),zy=new ph(ft+" const*",Hr,!1,!0,!1);return Re[R]={pointerType:Hy,constPointerType:zy},Ay(Ot,To),[rA,Hy,zy]})},tm=(R,P)=>{for(var j=[],J=0;J<R;J++)j.push(D[P+J*4>>2]);return j},d1=R=>{for(;R.length;){var P=R.pop(),j=R.pop();j(P)}};function p1(R,P){if(!(R instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof R} which is not a function`);var j=Kp(R.name||"unknownFunctionName",function(){});j.prototype=R.prototype;var J=new j,ye=R.apply(J,P);return ye instanceof Object?ye:J}function nm(R,P,j,J,ye,Se){var Oe=P.length;Oe<2&&it("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var Ee=P[1]!==null&&j!==null,Ze=!1,ke=1;ke<P.length;++ke)if(P[ke]!==null&&P[ke].destructorFunction===void 0){Ze=!0;break}for(var ft=P[0].name!=="void",Ct="",Zt="",ke=0;ke<Oe-2;++ke)Ct+=(ke!==0?", ":"")+"arg"+ke,Zt+=(ke!==0?", ":"")+"arg"+ke+"Wired";var Ot=`
        return function ${Qp(R)}(${Ct}) {
        if (arguments.length !== ${Oe-2}) {
          throwBindingError('function ${R} called with ' + arguments.length + ' arguments, expected ${Oe-2}');
        }`;Ze&&(Ot+=`var destructors = [];
`);var kn=Ze?"destructors":"null",Mr=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Zn=[it,J,ye,d1,P[0],P[1]];Ee&&(Ot+="var thisWired = classParam.toWireType("+kn+`, this);
`);for(var ke=0;ke<Oe-2;++ke)Ot+="var arg"+ke+"Wired = argType"+ke+".toWireType("+kn+", arg"+ke+"); // "+P[ke+2].name+`
`,Mr.push("argType"+ke),Zn.push(P[ke+2]);if(Ee&&(Zt="thisWired"+(Zt.length>0?", ":"")+Zt),Ot+=(ft||Se?"var rv = ":"")+"invoker(fn"+(Zt.length>0?", ":"")+Zt+`);
`,Ze)Ot+=`runDestructors(destructors);
`;else for(var ke=Ee?1:2;ke<P.length;++ke){var To=ke===1?"thisWired":"arg"+(ke-2)+"Wired";P[ke].destructorFunction!==null&&(Ot+=To+"_dtor("+To+"); // "+P[ke].name+`
`,Mr.push(To+"_dtor"),Zn.push(P[ke].destructorFunction))}return ft&&(Ot+=`var ret = retType.fromWireType(rv);
return ret;
`),Ot+=`}
`,Mr.push(Ot),p1(Function,Mr).apply(null,Zn)}var m1=(R,P,j,J,ye,Se)=>{var Oe=tm(P,j);ye=vs(J,ye),ci([],[R],function(Ee){Ee=Ee[0];var Ze=`constructor ${Ee.name}`;if(Ee.registeredClass.constructor_body===void 0&&(Ee.registeredClass.constructor_body=[]),Ee.registeredClass.constructor_body[P-1]!==void 0)throw new br(`Cannot register multiple constructors with identical number of parameters (${P-1}) for class '${Ee.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return Ee.registeredClass.constructor_body[P-1]=()=>{gh(`Cannot construct ${Ee.name} due to unbound types`,Oe)},ci([],Oe,ke=>(ke.splice(1,0,null),Ee.registeredClass.constructor_body[P-1]=nm(Ze,ke,null,ye,Se),[])),[]})},g1=(R,P,j,J,ye,Se,Oe,Ee,Ze)=>{var ke=tm(j,J);P=bn(P),Se=vs(ye,Se),ci([],[R],function(ft){ft=ft[0];var Ct=`${ft.name}.${P}`;P.startsWith("@@")&&(P=Symbol[P.substring(2)]),Ee&&ft.registeredClass.pureVirtualFunctions.push(P);function Zt(){gh(`Cannot call ${Ct} due to unbound types`,ke)}var Ot=ft.registeredClass.instancePrototype,kn=Ot[P];return kn===void 0||kn.overloadTable===void 0&&kn.className!==ft.name&&kn.argCount===j-2?(Zt.argCount=j-2,Zt.className=ft.name,Ot[P]=Zt):(Ey(Ot,P,Ct),Ot[P].overloadTable[j-2]=Zt),ci([],ke,function(Mr){var Zn=nm(Ct,Mr,ft,Se,Oe,Ze);return Ot[P].overloadTable===void 0?(Zn.argCount=j-2,Ot[P]=Zn):Ot[P].overloadTable[j-2]=Zn,[]}),[]})};function v1(){Object.assign(Ly.prototype,{get(R){return this.allocated[R]},has(R){return this.allocated[R]!==void 0},allocate(R){var P=this.freelist.pop()||this.allocated.length;return this.allocated[P]=R,P},free(R){this.allocated[R]=void 0,this.freelist.push(R)}})}function Ly(){this.allocated=[void 0],this.freelist=[]}var wr=new Ly,Fy=R=>{R>=wr.reserved&&--wr.get(R).refcount===0&&wr.free(R)},y1=()=>{for(var R=0,P=wr.reserved;P<wr.allocated.length;++P)wr.allocated[P]!==void 0&&++R;return R},x1=()=>{wr.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),wr.reserved=wr.allocated.length,n.count_emval_handles=y1},vh={toValue:R=>(R||it("Cannot use deleted val. handle = "+R),wr.get(R).value),toHandle:R=>{switch(R){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return wr.allocate({refcount:1,value:R})}}};function Iy(R){return this.fromWireType(z[R>>2])}var _1=(R,P)=>{P=bn(P),k(R,{name:P,fromWireType:j=>{var J=vh.toValue(j);return Fy(j),J},toWireType:(j,J)=>vh.toHandle(J),argPackAdvance:U,readValueFromPointer:Iy,destructorFunction:null})},rm=R=>{if(R===null)return"null";var P=typeof R;return P==="object"||P==="array"||P==="function"?R.toString():""+R},b1=(R,P)=>{switch(P){case 4:return function(j){return this.fromWireType(B[j>>2])};case 8:return function(j){return this.fromWireType(q[j>>3])};default:throw new TypeError(`invalid float width (${P}): ${R}`)}},w1=(R,P,j)=>{P=bn(P),k(R,{name:P,fromWireType:J=>J,toWireType:(J,ye)=>ye,argPackAdvance:U,readValueFromPointer:b1(P,j),destructorFunction:null})},M1=(R,P,j,J,ye,Se,Oe)=>{var Ee=tm(P,j);R=bn(R),ye=vs(J,ye),Sy(R,function(){gh(`Cannot call ${R} due to unbound types`,Ee)},P-1),ci([],Ee,function(Ze){var ke=[Ze[0],null].concat(Ze.slice(1));return Ay(R,nm(R,ke,null,ye,Se,Oe),P-1),[]})},E1=(R,P,j)=>{switch(P){case 1:return j?J=>Y[J>>0]:J=>L[J>>0];case 2:return j?J=>N[J>>1]:J=>G[J>>1];case 4:return j?J=>z[J>>2]:J=>D[J>>2];default:throw new TypeError(`invalid integer width (${P}): ${R}`)}},S1=(R,P,j,J,ye)=>{P=bn(P),ye===-1&&(ye=4294967295);var Se=ft=>ft;if(J===0){var Oe=32-8*j;Se=ft=>ft<<Oe>>>Oe}var Ee=P.includes("unsigned"),Ze=(ft,Ct)=>{},ke;Ee?ke=function(ft,Ct){return Ze(Ct,this.name),Ct>>>0}:ke=function(ft,Ct){return Ze(Ct,this.name),Ct},k(R,{name:P,fromWireType:Se,toWireType:ke,argPackAdvance:U,readValueFromPointer:E1(P,j,J!==0),destructorFunction:null})},T1=(R,P,j)=>{var J=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],ye=J[P];function Se(Oe){var Ee=D[Oe>>2],Ze=D[Oe+4>>2];return new ye(Y.buffer,Ze,Ee)}j=bn(j),k(R,{name:j,fromWireType:Se,argPackAdvance:U,readValueFromPointer:Se},{ignoreDuplicateRegistrations:!0})},A1=(R,P,j,J)=>{if(!(J>0))return 0;for(var ye=j,Se=j+J-1,Oe=0;Oe<R.length;++Oe){var Ee=R.charCodeAt(Oe);if(Ee>=55296&&Ee<=57343){var Ze=R.charCodeAt(++Oe);Ee=65536+((Ee&1023)<<10)|Ze&1023}if(Ee<=127){if(j>=Se)break;P[j++]=Ee}else if(Ee<=2047){if(j+1>=Se)break;P[j++]=192|Ee>>6,P[j++]=128|Ee&63}else if(Ee<=65535){if(j+2>=Se)break;P[j++]=224|Ee>>12,P[j++]=128|Ee>>6&63,P[j++]=128|Ee&63}else{if(j+3>=Se)break;P[j++]=240|Ee>>18,P[j++]=128|Ee>>12&63,P[j++]=128|Ee>>6&63,P[j++]=128|Ee&63}}return P[j]=0,j-ye},C1=(R,P,j)=>A1(R,L,P,j),R1=R=>{for(var P=0,j=0;j<R.length;++j){var J=R.charCodeAt(j);J<=127?P++:J<=2047?P+=2:J>=55296&&J<=57343?(P+=4,++j):P+=3}return P},Dy=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,P1=(R,P,j)=>{for(var J=P+j,ye=P;R[ye]&&!(ye>=J);)++ye;if(ye-P>16&&R.buffer&&Dy)return Dy.decode(R.subarray(P,ye));for(var Se="";P<ye;){var Oe=R[P++];if(!(Oe&128)){Se+=String.fromCharCode(Oe);continue}var Ee=R[P++]&63;if((Oe&224)==192){Se+=String.fromCharCode((Oe&31)<<6|Ee);continue}var Ze=R[P++]&63;if((Oe&240)==224?Oe=(Oe&15)<<12|Ee<<6|Ze:Oe=(Oe&7)<<18|Ee<<12|Ze<<6|R[P++]&63,Oe<65536)Se+=String.fromCharCode(Oe);else{var ke=Oe-65536;Se+=String.fromCharCode(55296|ke>>10,56320|ke&1023)}}return Se},L1=(R,P)=>R?P1(L,R,P):"",F1=(R,P)=>{P=bn(P);var j=P==="std::string";k(R,{name:P,fromWireType(J){var ye=D[J>>2],Se=J+4,Oe;if(j)for(var Ee=Se,Ze=0;Ze<=ye;++Ze){var ke=Se+Ze;if(Ze==ye||L[ke]==0){var ft=ke-Ee,Ct=L1(Ee,ft);Oe===void 0?Oe=Ct:(Oe+="\0",Oe+=Ct),Ee=ke+1}}else{for(var Zt=new Array(ye),Ze=0;Ze<ye;++Ze)Zt[Ze]=String.fromCharCode(L[Se+Ze]);Oe=Zt.join("")}return ki(J),Oe},toWireType(J,ye){ye instanceof ArrayBuffer&&(ye=new Uint8Array(ye));var Se,Oe=typeof ye=="string";Oe||ye instanceof Uint8Array||ye instanceof Uint8ClampedArray||ye instanceof Int8Array||it("Cannot pass non-string to std::string"),j&&Oe?Se=R1(ye):Se=ye.length;var Ee=im(4+Se+1),Ze=Ee+4;if(D[Ee>>2]=Se,j&&Oe)C1(ye,Ze,Se+1);else if(Oe)for(var ke=0;ke<Se;++ke){var ft=ye.charCodeAt(ke);ft>255&&(ki(Ze),it("String has UTF-16 code units that do not fit in 8 bits")),L[Ze+ke]=ft}else for(var ke=0;ke<Se;++ke)L[Ze+ke]=ye[ke];return J!==null&&J.push(ki,Ee),Ee},argPackAdvance:U,readValueFromPointer:Ty,destructorFunction(J){ki(J)}})},By=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,I1=(R,P)=>{for(var j=R,J=j>>1,ye=J+P/2;!(J>=ye)&&G[J];)++J;if(j=J<<1,j-R>32&&By)return By.decode(L.subarray(R,j));for(var Se="",Oe=0;!(Oe>=P/2);++Oe){var Ee=N[R+Oe*2>>1];if(Ee==0)break;Se+=String.fromCharCode(Ee)}return Se},D1=(R,P,j)=>{if(j===void 0&&(j=2147483647),j<2)return 0;j-=2;for(var J=P,ye=j<R.length*2?j/2:R.length,Se=0;Se<ye;++Se){var Oe=R.charCodeAt(Se);N[P>>1]=Oe,P+=2}return N[P>>1]=0,P-J},B1=R=>R.length*2,O1=(R,P)=>{for(var j=0,J="";!(j>=P/4);){var ye=z[R+j*4>>2];if(ye==0)break;if(++j,ye>=65536){var Se=ye-65536;J+=String.fromCharCode(55296|Se>>10,56320|Se&1023)}else J+=String.fromCharCode(ye)}return J},U1=(R,P,j)=>{if(j===void 0&&(j=2147483647),j<4)return 0;for(var J=P,ye=J+j-4,Se=0;Se<R.length;++Se){var Oe=R.charCodeAt(Se);if(Oe>=55296&&Oe<=57343){var Ee=R.charCodeAt(++Se);Oe=65536+((Oe&1023)<<10)|Ee&1023}if(z[P>>2]=Oe,P+=4,P+4>ye)break}return z[P>>2]=0,P-J},N1=R=>{for(var P=0,j=0;j<R.length;++j){var J=R.charCodeAt(j);J>=55296&&J<=57343&&++j,P+=4}return P},G1=(R,P,j)=>{j=bn(j);var J,ye,Se,Oe,Ee;P===2?(J=I1,ye=D1,Oe=B1,Se=()=>G,Ee=1):P===4&&(J=O1,ye=U1,Oe=N1,Se=()=>D,Ee=2),k(R,{name:j,fromWireType:Ze=>{for(var ke=D[Ze>>2],ft=Se(),Ct,Zt=Ze+4,Ot=0;Ot<=ke;++Ot){var kn=Ze+4+Ot*P;if(Ot==ke||ft[kn>>Ee]==0){var Mr=kn-Zt,Zn=J(Zt,Mr);Ct===void 0?Ct=Zn:(Ct+="\0",Ct+=Zn),Zt=kn+P}}return ki(Ze),Ct},toWireType:(Ze,ke)=>{typeof ke!="string"&&it(`Cannot pass non-string to C++ string type ${j}`);var ft=Oe(ke),Ct=im(4+ft+P);return D[Ct>>2]=ft>>Ee,ye(ke,Ct+4,ft+P),Ze!==null&&Ze.push(ki,Ct),Ct},argPackAdvance:U,readValueFromPointer:Iy,destructorFunction(Ze){ki(Ze)}})},k1=(R,P)=>{P=bn(P),k(R,{isVoid:!0,name:P,argPackAdvance:0,fromWireType:()=>{},toWireType:(j,J)=>{}})},H1=R=>{R>4&&(wr.get(R).refcount+=1)},z1=(R,P)=>{var j=nr[R];return j===void 0&&it(P+" has unknown type "+Py(R)),j},V1=(R,P)=>{R=z1(R,"_emval_take_value");var j=R.readValueFromPointer(P);return vh.toHandle(j)},W1=()=>{ie("")},j1=(R,P,j)=>L.copyWithin(R,P,P+j),q1=R=>{ie("OOM")},X1=R=>{var P=L.length;R>>>=0,q1(R)};al(),br=n.BindingError=class extends Error{constructor(P){super(P),this.name="BindingError"}},Eo=n.InternalError=class extends Error{constructor(P){super(P),this.name="InternalError"}},e1(),Et(),a1(),Ry=n.UnboundTypeError=h1(Error,"UnboundTypeError"),v1(),x1();var Y1={x:be,u:Mt,h:ms,g:sl,t:Me,s:gs,q:X,c:f1,d:m1,e:g1,B:_1,p:w1,j:M1,b:S1,a:T1,o:F1,i:G1,r:k1,k:Fy,l:H1,f:V1,n:W1,A:j1,z:X1,y:K1,v:tA,w:eA,m:nA},nn=ae(),$1=()=>($1=nn.D)(),Oy=R=>(Oy=nn.F)(R),Z1=n.__embind_initialize_bindings=()=>(Z1=n.__embind_initialize_bindings=nn.G)(),J1=()=>(J1=nn.__errno_location)(),im=R=>(im=nn.H)(R),ki=R=>(ki=nn.I)(R),ll=(R,P)=>(ll=nn.J)(R,P),ul=R=>(ul=nn.K)(R),hl=()=>(hl=nn.L)(),fl=R=>(fl=nn.M)(R),Uy=R=>(Uy=nn.N)(R),Q1=R=>(Q1=nn.__cxa_decrement_exception_refcount)(R),Ny=(R,P,j)=>(Ny=nn.O)(R,P,j),Gy=R=>(Gy=nn.P)(R);function K1(R,P){var j=hl();try{return xa(R)(P)}catch(J){if(fl(j),J!==J+0)throw J;ll(1,0)}}function eA(R){var P=hl();try{xa(R)()}catch(j){if(fl(P),j!==j+0)throw j;ll(1,0)}}function tA(R,P,j){var J=hl();try{return xa(R)(P,j)}catch(ye){if(fl(J),ye!==ye+0)throw ye;ll(1,0)}}function nA(R,P,j){var J=hl();try{xa(R)(P,j)}catch(ye){if(fl(J),ye!==ye+0)throw ye;ll(1,0)}}var yh;Ie=function R(){yh||ky(),yh||(Ie=R)};function ky(){if(Ce>0||(Fe(),Ce>0))return;function R(){yh||(yh=!0,n.calledRun=!0,!H&&(st(),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),V()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),R()},1)):R()}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return ky(),e.ready}})();typeof VT=="object"&&typeof my=="object"?my.exports=zT:typeof define=="function"&&define.amd&&define([],()=>zT)});var TB={};xh(TB,{MakeUpSDK:()=>SB,MakeupSDK:()=>QT});module.exports=hA(TB);var My={};xh(My,{GetProvider:()=>EB,SKINTONE_TARGET_QUALITY:()=>Bp,SetOnProgressCallback:()=>wB,TRACKING_QUALITY:()=>by});function pA(){let t={};return t.uuid=localStorage.client_agent_uuid,t}function mA(){let t={},e=navigator.userAgent.search("\\("),n=navigator.userAgent.search("\\)");return t.device=navigator.userAgent.substring(e+1,n),t.platform=navigator.userAgent.substring(n+2),t}function gA(){return"client_agent_uuid"in localStorage?pA():mA()}function vA(t){localStorage.client_agent_uuid=t}function _h(t,e,n){return xe(this,null,function*(){try{let r=`${e}/analytics?access_token=${n}`,o=yield fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0});if(o.status===404)throw new Error("Resource not found (404)");if(!o.ok)throw new Error(`An error occurred: ${o.status}`);return yield o.json()}catch(r){return null}})}var bh=class t{constructor(e,n,r){te(this,"cmsURL");te(this,"accessToken");te(this,"sessionUuid");this.cmsURL=e,this.accessToken=n,this.sessionUuid=r}static requestSessionId(e,n){return xe(this,null,function*(){var l,u;let r=gA(),o={type:"ENTER",timestamp:new Date().getTime(),payload:{country:Intl.DateTimeFormat().resolvedOptions().timeZone,client_agent:r,timezone_offset_mins:new Date().getTimezoneOffset()}},a=yield _h(o,e,n),c=(u=(l=a==null?void 0:a.data)==null?void 0:l[0])==null?void 0:u.session_uuid;return"client_agent_uuid"in localStorage||vA(a.data[0].client_agent_uuid),c})}static create(e,n){return xe(this,null,function*(){if(!e)throw new Error("CMS URL is required");if(!n)throw new Error("Access token is required");let r=yield this.requestSessionId(e,n);return new t(e,n,r)})}onUnload(){return xe(this,null,function*(){let e={type:"CLEAN_EXIT",timestamp:new Date().getTime(),payload:{session_uuid:this.sessionUuid}};yield _h(e,this.cmsURL,this.accessToken)})}sendEffect(e,n){return xe(this,null,function*(){_h({type:e,timestamp:new Date().getTime(),payload:_a(li({},n),{session_uuid:this.sessionUuid})},this.cmsURL,this.accessToken)})}sendProduct(e,n){return xe(this,null,function*(){var a,c;let r=yield _h({type:e,timestamp:new Date().getTime(),payload:{product:n,session_uuid:this.sessionUuid}},this.cmsURL,this.accessToken),o=(c=(a=r==null?void 0:r.data[0])==null?void 0:a.interaction_id)!=null?c:void 0;return o||console.warn("sessionProductInteractionId returned by post request is undefined"),o})}sendProductAndEffects(e,n){return xe(this,null,function*(){if(e){let o=yield this.sendProduct(e.type,e.productId);for(let a of n)a.payload.session_product_interaction=o}let r=n.map(o=>this.sendEffect(o.type,o.payload));yield Promise.all(r)})}};var wh=class{constructor(e){te(this,"frame");this.module=e.modules.visage.module,this.bscFrameProvider=this.module.GetFrameProvider()}SetCallback(e){return this.bscFrameProvider.SetCallback(e)}ClearCallback(e){this.bscFrameProvider.ClearCallback(e)}AddFrame(e){var o,a,c;let n=(o=window.makeupsdkLogger)==null?void 0:o.GetTimestamp(),r=this.bscFrameProvider.AddFrame(e);return(a=window.makeupsdkLogger)==null||a.Log({message:"add_frame",id:r,isStarting:!0,time:n}),(c=window.makeupsdkLogger)==null||c.Log({message:"track",id:r,isStarting:!0,time:n}),r}};var dn=class dn{static SetOnProgressCallback(e){dn.onProgressCallback=e}static Update(e,n){let r=dn.callers.get(e);if(!r)return;r.progress=n;let o=0;for(let a of dn.callers.values())o+=a.size/dn.totalSize*a.progress;dn.onProgressCallback&&dn.onProgressCallback(o),r.progress===1&&dn.intervalDict[e]&&clearInterval(dn.intervalDict[e])}static StartFakeProgress(e){if(dn.intervalDict[e])return;let n=setInterval(function(){let r=dn.callers.get(e);if(!r)return;let o=Math.min(r.progress+.1,1);dn.Update(e,o)},500);dn.intervalDict[e]=n}};te(dn,"onProgressCallback"),te(dn,"totalSize",0),te(dn,"intervalDict",{}),te(dn,"callers",new Map([["LoadFeatureTemplates",{size:1.5,progress:0}],["LoadFinishTemplates",{size:1.5,progress:0}],["Tracker",{size:5,progress:0}],["FirstTrack",{size:.5,progress:0}]]));var Jn=dn,Jy=0;for(let t of Jn.callers.values())Jy+=t.size;Jn.totalSize=Jy;var yA="122";var xA=0,Qy=1,_A=2;var I0=1,bA=2,Ml=3,Sf=0,rn=1,Tf=2,D0=1;var Sl=0,Tl=1,Ky=2,ex=3,tx=4,wA=5,Ga=100,MA=101,EA=102,nx=103,rx=104,SA=200,TA=201,AA=202,CA=203,B0=204,O0=205,RA=206,PA=207,LA=208,FA=209,IA=210,DA=0,BA=1,OA=2,Um=3,UA=4,NA=5,GA=6,kA=7,Af=0,HA=1,zA=2,Al=0,VA=1,WA=2,jA=3,qA=4,XA=5,U0=300,Cg=301,Rg=302,ix=303,ox=304,Pg=306,Lg=307,Nm=1e3,sr=1001,Gm=1002,Hn=1003,sx=1004;var ax=1005;var sn=1006,YA=1007;var Cf=1008;var Fg=1009,$A=1010,ZA=1011,af=1012,JA=1013,rf=1014,Bo=1015,cf=1016,QA=1017,KA=1018,e2=1019,Cl=1020,t2=1021,Ms=1022,ar=1023,n2=1024,r2=1025;var Xa=1026,Dl=1027,i2=1028,o2=1029,s2=1030,a2=1031,c2=1032,l2=1033,cx=33776,lx=33777,ux=33778,hx=33779,fx=35840,dx=35841,px=35842,mx=35843,u2=36196,gx=37492,vx=37496,h2=37808,f2=37809,d2=37810,p2=37811,m2=37812,g2=37813,v2=37814,y2=37815,x2=37816,_2=37817,b2=37818,w2=37819,M2=37820,E2=37821,S2=36492,T2=37840,A2=37841,C2=37842,R2=37843,P2=37844,L2=37845,F2=37846,I2=37847,D2=37848,B2=37849,O2=37850,U2=37851,N2=37852,G2=37853,k2=2200,H2=2201,z2=2202,lf=2300,of=2301,cm=2302,ka=2400,Ha=2401,uf=2402,Ig=2500,N0=2501,V2=0;var sc=3e3,Dg=3001,G0=3007,k0=3002,W2=3003,H0=3004,z0=3005,V0=3006,j2=3200,q2=3201,ac=0,X2=1;var lm=7680;var Y2=519,Rf=35044,Bl=35048;var yx="300 es";function Ji(){}Object.assign(Ji.prototype,{addEventListener:function(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)},hasEventListener:function(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1},removeEventListener:function(t,e){if(this._listeners===void 0)return;let r=this._listeners[t];if(r!==void 0){let o=r.indexOf(e);o!==-1&&r.splice(o,1)}},dispatchEvent:function(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,t)}}});var Mn=[];for(let t=0;t<256;t++)Mn[t]=(t<16?"0":"")+t.toString(16);var Mh=1234567,dt={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Mn[t&255]+Mn[t>>8&255]+Mn[t>>16&255]+Mn[t>>24&255]+"-"+Mn[e&255]+Mn[e>>8&255]+"-"+Mn[e>>16&15|64]+Mn[e>>24&255]+"-"+Mn[n&63|128]+Mn[n>>8&255]+"-"+Mn[n>>16&255]+Mn[n>>24&255]+Mn[r&255]+Mn[r>>8&255]+Mn[r>>16&255]+Mn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,o){return r+(t-e)*(o-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return t!==void 0&&(Mh=t%2147483647),Mh=Mh*16807%2147483647,(Mh-1)/2147483646},degToRad:function(t){return t*dt.DEG2RAD},radToDeg:function(t){return t*dt.RAD2DEG},isPowerOfTwo:function(t){return(t&t-1)===0&&t!==0},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,r,o){let a=Math.cos,c=Math.sin,l=a(n/2),u=c(n/2),h=a((e+r)/2),d=c((e+r)/2),f=a((e-r)/2),p=c((e-r)/2),m=a((r-e)/2),v=c((r-e)/2);switch(o){case"XYX":t.set(l*d,u*f,u*p,l*h);break;case"YZY":t.set(u*p,l*d,u*f,l*h);break;case"ZXZ":t.set(u*f,u*p,l*d,l*h);break;case"XZX":t.set(l*d,u*v,u*m,l*h);break;case"YXY":t.set(u*m,l*d,u*v,l*h);break;case"ZYZ":t.set(u*v,u*m,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+o)}}},fe=class{constructor(e=0,n=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let n=this.x,r=this.y,o=e.elements;return this.x=o[0]*n+o[3]*r+o[6],this.y=o[1]*n+o[4]*r+o[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){let r=Math.cos(n),o=Math.sin(n),a=this.x-e.x,c=this.y-e.y;return this.x=a*r-c*o+e.x,this.y=a*o+c*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}},Fn=class{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,n,r,o,a,c,l,u,h){let d=this.elements;return d[0]=e,d[1]=o,d[2]=l,d[3]=n,d[4]=a,d[5]=u,d[6]=r,d[7]=c,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(e){let n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let r=e.elements,o=n.elements,a=this.elements,c=r[0],l=r[3],u=r[6],h=r[1],d=r[4],f=r[7],p=r[2],m=r[5],v=r[8],x=o[0],b=o[3],y=o[6],g=o[1],M=o[4],C=o[7],E=o[2],w=o[5],F=o[8];return a[0]=c*x+l*g+u*E,a[3]=c*b+l*M+u*w,a[6]=c*y+l*C+u*F,a[1]=h*x+d*g+f*E,a[4]=h*b+d*M+f*w,a[7]=h*y+d*C+f*F,a[2]=p*x+m*g+v*E,a[5]=p*b+m*M+v*w,a[8]=p*y+m*C+v*F,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){let e=this.elements,n=e[0],r=e[1],o=e[2],a=e[3],c=e[4],l=e[5],u=e[6],h=e[7],d=e[8];return n*c*d-n*l*h-r*a*d+r*l*u+o*a*h-o*c*u}getInverse(e,n){n!==void 0&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");let r=e.elements,o=this.elements,a=r[0],c=r[1],l=r[2],u=r[3],h=r[4],d=r[5],f=r[6],p=r[7],m=r[8],v=m*h-d*p,x=d*f-m*u,b=p*u-h*f,y=a*v+c*x+l*b;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/y;return o[0]=v*g,o[1]=(l*p-m*c)*g,o[2]=(d*c-l*h)*g,o[3]=x*g,o[4]=(m*a-l*f)*g,o[5]=(l*u-d*a)*g,o[6]=b*g,o[7]=(c*f-p*a)*g,o[8]=(h*a-c*u)*g,this}transpose(){let e,n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).getInverse(this).transpose()}transposeIntoArray(e){let n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,o,a,c,l){let u=Math.cos(a),h=Math.sin(a);this.set(r*u,r*h,-r*(u*c+h*l)+c+e,-o*h,o*u,-o*(-h*c+u*l)+l+n,0,0,1)}scale(e,n){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=n,r[4]*=n,r[7]*=n,this}rotate(e){let n=Math.cos(e),r=Math.sin(e),o=this.elements,a=o[0],c=o[3],l=o[6],u=o[1],h=o[4],d=o[7];return o[0]=n*a+r*u,o[3]=n*c+r*h,o[6]=n*l+r*d,o[1]=-r*a+n*u,o[4]=-r*c+n*h,o[7]=-r*l+n*d,this}translate(e,n){let r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=n*r[2],r[4]+=n*r[5],r[7]+=n*r[8],this}equals(e){let n=this.elements,r=e.elements;for(let o=0;o<9;o++)if(n[o]!==r[o])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){let r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}},wa,Es={getDataURL:function(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{wa===void 0&&(wa=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),wa.width=t.width,wa.height=t.height;let n=wa.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=wa}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},$2=0;function At(t,e,n,r,o,a,c,l,u,h){Object.defineProperty(this,"id",{value:$2++}),this.uuid=dt.generateUUID(),this.name="",this.image=t!==void 0?t:At.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=e!==void 0?e:At.DEFAULT_MAPPING,this.wrapS=n!==void 0?n:sr,this.wrapT=r!==void 0?r:sr,this.magFilter=o!==void 0?o:sn,this.minFilter=a!==void 0?a:Cf,this.anisotropy=u!==void 0?u:1,this.format=c!==void 0?c:ar,this.internalFormat=null,this.type=l!==void 0?l:Fg,this.offset=new fe(0,0),this.repeat=new fe(1,1),this.center=new fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h!==void 0?h:sc,this.version=0,this.onUpdate=null}At.DEFAULT_IMAGE=void 0;At.DEFAULT_MAPPING=U0;At.prototype=Object.assign(Object.create(Ji.prototype),{constructor:At,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let r=this.image;if(r.uuid===void 0&&(r.uuid=dt.generateUUID()),!e&&t.images[r.uuid]===void 0){let o;if(Array.isArray(r)){o=[];for(let a=0,c=r.length;a<c;a++)o.push(Es.getDataURL(r[a]))}else o=Es.getDataURL(r);t.images[r.uuid]={uuid:r.uuid,url:o}}n.image=r.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping!==U0)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Nm:t.x=t.x-Math.floor(t.x);break;case sr:t.x=t.x<0?0:1;break;case Gm:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Nm:t.y=t.y-Math.floor(t.y);break;case sr:t.y=t.y<0?0:1;break;case Gm:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}});Object.defineProperty(At.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});var Rt=class{constructor(e=0,n=0,r=0,o=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=e,this.y=n,this.z=r,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,n,r,o){return this.x=e,this.y=n,this.z=r,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw 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=e.w!==void 0?e.w:1,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let n=this.x,r=this.y,o=this.z,a=this.w,c=e.elements;return this.x=c[0]*n+c[4]*r+c[8]*o+c[12]*a,this.y=c[1]*n+c[5]*r+c[9]*o+c[13]*a,this.z=c[2]*n+c[6]*r+c[10]*o+c[14]*a,this.w=c[3]*n+c[7]*r+c[11]*o+c[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,o,a,u=e.elements,h=u[0],d=u[4],f=u[8],p=u[1],m=u[5],v=u[9],x=u[2],b=u[6],y=u[10];if(Math.abs(d-p)<.01&&Math.abs(f-x)<.01&&Math.abs(v-b)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+x)<.1&&Math.abs(v+b)<.1&&Math.abs(h+m+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;let M=(h+1)/2,C=(m+1)/2,E=(y+1)/2,w=(d+p)/4,F=(f+x)/4,H=(v+b)/4;return M>C&&M>E?M<.01?(r=0,o=.707106781,a=.707106781):(r=Math.sqrt(M),o=w/r,a=F/r):C>E?C<.01?(r=.707106781,o=0,a=.707106781):(o=Math.sqrt(C),r=w/o,a=H/o):E<.01?(r=.707106781,o=.707106781,a=0):(a=Math.sqrt(E),r=F/a,o=H/a),this.set(r,o,a,n),this}let g=Math.sqrt((b-v)*(b-v)+(f-x)*(f-x)+(p-d)*(p-d));return Math.abs(g)<.001&&(g=1),this.x=(b-v)/g,this.y=(f-x)/g,this.z=(p-d)/g,this.w=Math.acos((h+m+y-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}};function an(t,e,n){this.width=t,this.height=e,this.scissor=new Rt(0,0,t,e),this.scissorTest=!1,this.viewport=new Rt(0,0,t,e),n=n||{},this.texture=new At(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:sn,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null}an.prototype=Object.assign(Object.create(Ji.prototype),{constructor:an,isWebGLRenderTarget:!0,setSize:function(t,e){(this.width!==t||this.height!==e)&&(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});function xx(t,e,n){an.call(this,t,e,n),this.samples=4}xx.prototype=Object.assign(Object.create(an.prototype),{constructor:xx,isWebGLMultisampleRenderTarget:!0,copy:function(t){return an.prototype.copy.call(this,t),this.samples=t.samples,this}});var zn=class{constructor(e=0,n=0,r=0,o=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=e,this._y=n,this._z=r,this._w=o}static slerp(e,n,r,o){return r.copy(e).slerp(n,o)}static slerpFlat(e,n,r,o,a,c,l){let u=r[o+0],h=r[o+1],d=r[o+2],f=r[o+3],p=a[c+0],m=a[c+1],v=a[c+2],x=a[c+3];if(f!==x||u!==p||h!==m||d!==v){let b=1-l,y=u*p+h*m+d*v+f*x,g=y>=0?1:-1,M=1-y*y;if(M>Number.EPSILON){let E=Math.sqrt(M),w=Math.atan2(E,y*g);b=Math.sin(b*w)/E,l=Math.sin(l*w)/E}let C=l*g;if(u=u*b+p*C,h=h*b+m*C,d=d*b+v*C,f=f*b+x*C,b===1-l){let E=1/Math.sqrt(u*u+h*h+d*d+f*f);u*=E,h*=E,d*=E,f*=E}}e[n]=u,e[n+1]=h,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,o,a,c){let l=r[o],u=r[o+1],h=r[o+2],d=r[o+3],f=a[c],p=a[c+1],m=a[c+2],v=a[c+3];return e[n]=l*v+d*f+u*m-h*p,e[n+1]=u*v+d*p+h*f-l*m,e[n+2]=h*v+d*m+l*p-u*f,e[n+3]=d*v-l*f-u*p-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,o){return this._x=e,this._y=n,this._z=r,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,n){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let r=e._x,o=e._y,a=e._z,c=e._order,l=Math.cos,u=Math.sin,h=l(r/2),d=l(o/2),f=l(a/2),p=u(r/2),m=u(o/2),v=u(a/2);switch(c){case"XYZ":this._x=p*d*f+h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f-p*m*v;break;case"YXZ":this._x=p*d*f+h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f+p*m*v;break;case"ZXY":this._x=p*d*f-h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f-p*m*v;break;case"ZYX":this._x=p*d*f-h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f+p*m*v;break;case"YZX":this._x=p*d*f+h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f-p*m*v;break;case"XZY":this._x=p*d*f-h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){let r=n/2,o=Math.sin(r);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){let n=e.elements,r=n[0],o=n[4],a=n[8],c=n[1],l=n[5],u=n[9],h=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){let m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-u)*m,this._y=(a-h)*m,this._z=(c-o)*m}else if(r>l&&r>f){let m=2*Math.sqrt(1+r-l-f);this._w=(d-u)/m,this._x=.25*m,this._y=(o+c)/m,this._z=(a+h)/m}else if(l>f){let m=2*Math.sqrt(1+l-r-f);this._w=(a-h)/m,this._x=(o+c)/m,this._y=.25*m,this._z=(u+d)/m}else{let m=2*Math.sqrt(1+f-r-l);this._w=(c-o)/m,this._x=(a+h)/m,this._y=(u+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let o=e.dot(n)+1;return o<1e-6?(o=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=o):(this._x=0,this._y=-e.z,this._z=e.y,this._w=o)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=o),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(dt.clamp(this.dot(e),-1,1)))}rotateTowards(e,n){let r=this.angleTo(e);if(r===0)return this;let o=Math.min(1,n/r);return this.slerp(e,o),this}identity(){return this.set(0,0,0,1)}inverse(){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 e===0?(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,n){return n!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,n)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){let r=e._x,o=e._y,a=e._z,c=e._w,l=n._x,u=n._y,h=n._z,d=n._w;return this._x=r*d+c*l+o*h-a*u,this._y=o*d+c*u+a*l-r*h,this._z=a*d+c*h+r*u-o*l,this._w=c*d-r*l-o*u-a*h,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);let r=this._x,o=this._y,a=this._z,c=this._w,l=c*e._w+r*e._x+o*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=c,this._x=r,this._y=o,this._z=a,this;let u=1-l*l;if(u<=Number.EPSILON){let m=1-n;return this._w=m*c+n*this._w,this._x=m*r+n*this._x,this._y=m*o+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}let h=Math.sqrt(u),d=Math.atan2(h,l),f=Math.sin((1-n)*d)/h,p=Math.sin(n*d)/h;return this._w=c*f+this._w*p,this._x=r*f+this._x*p,this._y=o*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}},W=class{constructor(e=0,n=0,r=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw 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,n){return n!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,n)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_x.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(_x.setFromAxisAngle(e,n))}applyMatrix3(e){let n=this.x,r=this.y,o=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*o,this.y=a[1]*n+a[4]*r+a[7]*o,this.z=a[2]*n+a[5]*r+a[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let n=this.x,r=this.y,o=this.z,a=e.elements,c=1/(a[3]*n+a[7]*r+a[11]*o+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*o+a[12])*c,this.y=(a[1]*n+a[5]*r+a[9]*o+a[13])*c,this.z=(a[2]*n+a[6]*r+a[10]*o+a[14])*c,this}applyQuaternion(e){let n=this.x,r=this.y,o=this.z,a=e.x,c=e.y,l=e.z,u=e.w,h=u*n+c*o-l*r,d=u*r+l*n-a*o,f=u*o+a*r-c*n,p=-a*n-c*r-l*o;return this.x=h*u+p*-a+d*-l-f*-c,this.y=d*u+p*-c+f*-a-h*-l,this.z=f*u+p*-l+h*-c-d*-a,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let n=this.x,r=this.y,o=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*o,this.y=a[1]*n+a[5]*r+a[9]*o,this.z=a[2]*n+a[6]*r+a[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,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e,n){return n!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,n)):this.crossVectors(this,e)}crossVectors(e,n){let r=e.x,o=e.y,a=e.z,c=n.x,l=n.y,u=n.z;return this.x=o*u-a*l,this.y=a*c-r*u,this.z=r*l-o*c,this}projectOnVector(e){let n=e.lengthSq();if(n===0)return this.set(0,0,0);let r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return um.copy(this).projectOnVector(e),this.sub(um)}reflect(e){return this.sub(um.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;let r=this.dot(e)/n;return Math.acos(dt.clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,r=this.y-e.y,o=this.z-e.z;return n*n+r*r+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,n,r){let o=Math.sin(n)*e;return this.x=o*Math.sin(r),this.y=Math.cos(n)*e,this.z=o*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){let n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){let n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=o,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}},um=new W,_x=new zn,vi=class{constructor(e,n){Object.defineProperty(this,"isBox3",{value:!0}),this.min=e!==void 0?e:new W(1/0,1/0,1/0),this.max=n!==void 0?n:new W(-1/0,-1/0,-1/0)}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let u=0,h=e.length;u<h;u+=3){let d=e[u],f=e[u+1],p=e[u+2];d<n&&(n=d),f<r&&(r=f),p<o&&(o=p),d>a&&(a=d),f>c&&(c=f),p>l&&(l=p)}return this.min.set(n,r,o),this.max.set(a,c,l),this}setFromBufferAttribute(e){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let u=0,h=e.count;u<h;u++){let d=e.getX(u),f=e.getY(u),p=e.getZ(u);d<n&&(n=d),f<r&&(r=f),p<o&&(o=p),d>a&&(a=d),f>c&&(c=f),p>l&&(l=p)}return this.min.set(n,r,o),this.max.set(a,c,l),this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){let r=pl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return e===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new W),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new W),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);let n=e.geometry;n!==void 0&&(n.boundingBox===null&&n.computeBoundingBox(),fm.copy(n.boundingBox),fm.applyMatrix4(e.matrixWorld),this.union(fm));let r=e.children;for(let o=0,a=r.length;o<a;o++)this.expandByObject(r[o]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new W),n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,pl),pl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ml),Eh.subVectors(this.max,ml),Ma.subVectors(e.a,ml),Ea.subVectors(e.b,ml),Sa.subVectors(e.c,ml),Ao.subVectors(Ea,Ma),Co.subVectors(Sa,Ea),ys.subVectors(Ma,Sa);let n=[0,-Ao.z,Ao.y,0,-Co.z,Co.y,0,-ys.z,ys.y,Ao.z,0,-Ao.x,Co.z,0,-Co.x,ys.z,0,-ys.x,-Ao.y,Ao.x,0,-Co.y,Co.x,0,-ys.y,ys.x,0];return!hm(n,Ma,Ea,Sa,Eh)||(n=[1,0,0,0,1,0,0,0,1],!hm(n,Ma,Ea,Sa,Eh))?!1:(Sh.crossVectors(Ao,Co),n=[Sh.x,Sh.y,Sh.z],hm(n,Ma,Ea,Sa,Eh))}clampPoint(e,n){return n===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new W),n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return pl.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return e===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=this.getSize(pl).length()*.5,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()?this:(Hi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hi),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)}};function hm(t,e,n,r,o){for(let a=0,c=t.length-3;a<=c;a+=3){xs.fromArray(t,a);let l=o.x*Math.abs(xs.x)+o.y*Math.abs(xs.y)+o.z*Math.abs(xs.z),u=e.dot(xs),h=n.dot(xs),d=r.dot(xs);if(Math.max(-Math.max(u,h,d),Math.min(u,h,d))>l)return!1}return!0}var Hi=[new W,new W,new W,new W,new W,new W,new W,new W],pl=new W,fm=new vi,Ma=new W,Ea=new W,Sa=new W,Ao=new W,Co=new W,ys=new W,ml=new W,Eh=new W,Sh=new W,xs=new W,Z2=new vi,yi=class{constructor(e,n){this.center=e!==void 0?e:new W,this.radius=n!==void 0?n:-1}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){let r=this.center;n!==void 0?r.copy(n):Z2.setFromPoints(e).getCenter(r);let o=0;for(let a=0,c=e.length;a<c;a++)o=Math.max(o,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(o),this}clone(){return new this.constructor().copy(this)}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){let r=this.center.distanceToSquared(e);return n===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),n=new W),n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new vi),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}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}},zi=new W,dm=new W,Th=new W,Ro=new W,pm=new W,Ah=new W,mm=new W,Ss=class{constructor(e,n){this.origin=e!==void 0?e:new W,this.direction=n!==void 0?n:new W(0,0,-1)}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n===void 0&&(console.warn("THREE.Ray: .at() target is now required"),n=new W),n.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,zi)),this}closestPointToPoint(e,n){n===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new W),n.subVectors(e,this.origin);let r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let n=zi.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(zi.copy(this.direction).multiplyScalar(n).add(this.origin),zi.distanceToSquared(e))}distanceSqToSegment(e,n,r,o){dm.copy(e).add(n).multiplyScalar(.5),Th.copy(n).sub(e).normalize(),Ro.copy(this.origin).sub(dm);let a=e.distanceTo(n)*.5,c=-this.direction.dot(Th),l=Ro.dot(this.direction),u=-Ro.dot(Th),h=Ro.lengthSq(),d=Math.abs(1-c*c),f,p,m,v;if(d>0)if(f=c*u-l,p=c*l-u,v=a*d,f>=0)if(p>=-v)if(p<=v){let x=1/d;f*=x,p*=x,m=f*(f+c*p+2*l)+p*(c*f+p+2*u)+h}else p=a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;else p=-a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;else p<=-v?(f=Math.max(0,-(-c*a+l)),p=f>0?-a:Math.min(Math.max(-a,-u),a),m=-f*f+p*(p+2*u)+h):p<=v?(f=0,p=Math.min(Math.max(-a,-u),a),m=p*(p+2*u)+h):(f=Math.max(0,-(c*a+l)),p=f>0?a:Math.min(Math.max(-a,-u),a),m=-f*f+p*(p+2*u)+h);else p=c>0?-a:a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;return r&&r.copy(this.direction).multiplyScalar(f).add(this.origin),o&&o.copy(Th).multiplyScalar(p).add(dm),m}intersectSphere(e,n){zi.subVectors(e.center,this.origin);let r=zi.dot(this.direction),o=zi.dot(zi)-r*r,a=e.radius*e.radius;if(o>a)return null;let c=Math.sqrt(a-o),l=r-c,u=r+c;return l<0&&u<0?null:l<0?this.at(u,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;let r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){let r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){let n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,o,a,c,l,u,h=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return h>=0?(r=(e.min.x-p.x)*h,o=(e.max.x-p.x)*h):(r=(e.max.x-p.x)*h,o=(e.min.x-p.x)*h),d>=0?(a=(e.min.y-p.y)*d,c=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,c=(e.min.y-p.y)*d),r>c||a>o||((a>r||r!==r)&&(r=a),(c<o||o!==o)&&(o=c),f>=0?(l=(e.min.z-p.z)*f,u=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,u=(e.min.z-p.z)*f),r>u||l>o)||((l>r||r!==r)&&(r=l),(u<o||o!==o)&&(o=u),o<0)?null:this.at(r>=0?r:o,n)}intersectsBox(e){return this.intersectBox(e,zi)!==null}intersectTriangle(e,n,r,o,a){pm.subVectors(n,e),Ah.subVectors(r,e),mm.crossVectors(pm,Ah);let c=this.direction.dot(mm),l;if(c>0){if(o)return null;l=1}else if(c<0)l=-1,c=-c;else return null;Ro.subVectors(this.origin,e);let u=l*this.direction.dot(Ah.crossVectors(Ro,Ah));if(u<0)return null;let h=l*this.direction.dot(pm.cross(Ro));if(h<0||u+h>c)return null;let d=-l*Ro.dot(mm);return d<0?null:this.at(d/c,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},vt=class t{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,n,r,o,a,c,l,u,h,d,f,p,m,v,x,b){let y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=o,y[1]=a,y[5]=c,y[9]=l,y[13]=u,y[2]=h,y[6]=d,y[10]=f,y[14]=p,y[3]=m,y[7]=v,y[11]=x,y[15]=b,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 t().fromArray(this.elements)}copy(e){let n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){let n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){let n=this.elements,r=e.elements,o=1/Ta.setFromMatrixColumn(e,0).length(),a=1/Ta.setFromMatrixColumn(e,1).length(),c=1/Ta.setFromMatrixColumn(e,2).length();return n[0]=r[0]*o,n[1]=r[1]*o,n[2]=r[2]*o,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*c,n[9]=r[9]*c,n[10]=r[10]*c,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let n=this.elements,r=e.x,o=e.y,a=e.z,c=Math.cos(r),l=Math.sin(r),u=Math.cos(o),h=Math.sin(o),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let p=c*d,m=c*f,v=l*d,x=l*f;n[0]=u*d,n[4]=-u*f,n[8]=h,n[1]=m+v*h,n[5]=p-x*h,n[9]=-l*u,n[2]=x-p*h,n[6]=v+m*h,n[10]=c*u}else if(e.order==="YXZ"){let p=u*d,m=u*f,v=h*d,x=h*f;n[0]=p+x*l,n[4]=v*l-m,n[8]=c*h,n[1]=c*f,n[5]=c*d,n[9]=-l,n[2]=m*l-v,n[6]=x+p*l,n[10]=c*u}else if(e.order==="ZXY"){let p=u*d,m=u*f,v=h*d,x=h*f;n[0]=p-x*l,n[4]=-c*f,n[8]=v+m*l,n[1]=m+v*l,n[5]=c*d,n[9]=x-p*l,n[2]=-c*h,n[6]=l,n[10]=c*u}else if(e.order==="ZYX"){let p=c*d,m=c*f,v=l*d,x=l*f;n[0]=u*d,n[4]=v*h-m,n[8]=p*h+x,n[1]=u*f,n[5]=x*h+p,n[9]=m*h-v,n[2]=-h,n[6]=l*u,n[10]=c*u}else if(e.order==="YZX"){let p=c*u,m=c*h,v=l*u,x=l*h;n[0]=u*d,n[4]=x-p*f,n[8]=v*f+m,n[1]=f,n[5]=c*d,n[9]=-l*d,n[2]=-h*d,n[6]=m*f+v,n[10]=p-x*f}else if(e.order==="XZY"){let p=c*u,m=c*h,v=l*u,x=l*h;n[0]=u*d,n[4]=-f,n[8]=h*d,n[1]=p*f+x,n[5]=c*d,n[9]=m*f-v,n[2]=v*f-m,n[6]=l*d,n[10]=x*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(J2,e,Q2)}lookAt(e,n,r){let o=this.elements;return ir.subVectors(e,n),ir.lengthSq()===0&&(ir.z=1),ir.normalize(),Po.crossVectors(r,ir),Po.lengthSq()===0&&(Math.abs(r.z)===1?ir.x+=1e-4:ir.z+=1e-4,ir.normalize(),Po.crossVectors(r,ir)),Po.normalize(),Ch.crossVectors(ir,Po),o[0]=Po.x,o[4]=Ch.x,o[8]=ir.x,o[1]=Po.y,o[5]=Ch.y,o[9]=ir.y,o[2]=Po.z,o[6]=Ch.z,o[10]=ir.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,n)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let r=e.elements,o=n.elements,a=this.elements,c=r[0],l=r[4],u=r[8],h=r[12],d=r[1],f=r[5],p=r[9],m=r[13],v=r[2],x=r[6],b=r[10],y=r[14],g=r[3],M=r[7],C=r[11],E=r[15],w=o[0],F=o[4],H=o[8],ne=o[12],Y=o[1],L=o[5],N=o[9],G=o[13],z=o[2],D=o[6],B=o[10],q=o[14],$=o[3],ce=o[7],ge=o[11],he=o[15];return a[0]=c*w+l*Y+u*z+h*$,a[4]=c*F+l*L+u*D+h*ce,a[8]=c*H+l*N+u*B+h*ge,a[12]=c*ne+l*G+u*q+h*he,a[1]=d*w+f*Y+p*z+m*$,a[5]=d*F+f*L+p*D+m*ce,a[9]=d*H+f*N+p*B+m*ge,a[13]=d*ne+f*G+p*q+m*he,a[2]=v*w+x*Y+b*z+y*$,a[6]=v*F+x*L+b*D+y*ce,a[10]=v*H+x*N+b*B+y*ge,a[14]=v*ne+x*G+b*q+y*he,a[3]=g*w+M*Y+C*z+E*$,a[7]=g*F+M*L+C*D+E*ce,a[11]=g*H+M*N+C*B+E*ge,a[15]=g*ne+M*G+C*q+E*he,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){let e=this.elements,n=e[0],r=e[4],o=e[8],a=e[12],c=e[1],l=e[5],u=e[9],h=e[13],d=e[2],f=e[6],p=e[10],m=e[14],v=e[3],x=e[7],b=e[11],y=e[15];return v*(+a*u*f-o*h*f-a*l*p+r*h*p+o*l*m-r*u*m)+x*(+n*u*m-n*h*p+a*c*p-o*c*m+o*h*d-a*u*d)+b*(+n*h*f-n*l*m-a*c*f+r*c*m+a*l*d-r*h*d)+y*(-o*l*d-n*u*f+n*l*p+o*c*f-r*c*p+r*u*d)}transpose(){let e=this.elements,n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){let o=this.elements;return e.isVector3?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=n,o[14]=r),this}getInverse(e,n){n!==void 0&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");let r=this.elements,o=e.elements,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],f=o[6],p=o[7],m=o[8],v=o[9],x=o[10],b=o[11],y=o[12],g=o[13],M=o[14],C=o[15],E=v*M*p-g*x*p+g*f*b-d*M*b-v*f*C+d*x*C,w=y*x*p-m*M*p-y*f*b+h*M*b+m*f*C-h*x*C,F=m*g*p-y*v*p+y*d*b-h*g*b-m*d*C+h*v*C,H=y*v*f-m*g*f-y*d*x+h*g*x+m*d*M-h*v*M,ne=a*E+c*w+l*F+u*H;if(ne===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Y=1/ne;return r[0]=E*Y,r[1]=(g*x*u-v*M*u-g*l*b+c*M*b+v*l*C-c*x*C)*Y,r[2]=(d*M*u-g*f*u+g*l*p-c*M*p-d*l*C+c*f*C)*Y,r[3]=(v*f*u-d*x*u-v*l*p+c*x*p+d*l*b-c*f*b)*Y,r[4]=w*Y,r[5]=(m*M*u-y*x*u+y*l*b-a*M*b-m*l*C+a*x*C)*Y,r[6]=(y*f*u-h*M*u-y*l*p+a*M*p+h*l*C-a*f*C)*Y,r[7]=(h*x*u-m*f*u+m*l*p-a*x*p-h*l*b+a*f*b)*Y,r[8]=F*Y,r[9]=(y*v*u-m*g*u-y*c*b+a*g*b+m*c*C-a*v*C)*Y,r[10]=(h*g*u-y*d*u+y*c*p-a*g*p-h*c*C+a*d*C)*Y,r[11]=(m*d*u-h*v*u-m*c*p+a*v*p+h*c*b-a*d*b)*Y,r[12]=H*Y,r[13]=(m*g*l-y*v*l+y*c*x-a*g*x-m*c*M+a*v*M)*Y,r[14]=(y*d*l-h*g*l-y*c*f+a*g*f+h*c*M-a*d*M)*Y,r[15]=(h*v*l-m*d*l+m*c*f-a*v*f-h*c*x+a*d*x)*Y,this}scale(e){let n=this.elements,r=e.x,o=e.y,a=e.z;return n[0]*=r,n[4]*=o,n[8]*=a,n[1]*=r,n[5]*=o,n[9]*=a,n[2]*=r,n[6]*=o,n[10]*=a,n[3]*=r,n[7]*=o,n[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=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(n,r,o))}makeTranslation(e,n,r){return this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){let n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){let n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){let n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){let r=Math.cos(n),o=Math.sin(n),a=1-r,c=e.x,l=e.y,u=e.z,h=a*c,d=a*l;return this.set(h*c+r,h*l-o*u,h*u+o*l,0,h*l+o*u,d*l+r,d*u-o*c,0,h*u-o*l,d*u+o*c,a*u*u+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r){return this.set(1,n,r,0,e,1,r,0,e,n,1,0,0,0,0,1),this}compose(e,n,r){let o=this.elements,a=n._x,c=n._y,l=n._z,u=n._w,h=a+a,d=c+c,f=l+l,p=a*h,m=a*d,v=a*f,x=c*d,b=c*f,y=l*f,g=u*h,M=u*d,C=u*f,E=r.x,w=r.y,F=r.z;return o[0]=(1-(x+y))*E,o[1]=(m+C)*E,o[2]=(v-M)*E,o[3]=0,o[4]=(m-C)*w,o[5]=(1-(p+y))*w,o[6]=(b+g)*w,o[7]=0,o[8]=(v+M)*F,o[9]=(b-g)*F,o[10]=(1-(p+x))*F,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,n,r){let o=this.elements,a=Ta.set(o[0],o[1],o[2]).length(),c=Ta.set(o[4],o[5],o[6]).length(),l=Ta.set(o[8],o[9],o[10]).length();this.determinant()<0&&(a=-a),e.x=o[12],e.y=o[13],e.z=o[14],zr.copy(this);let h=1/a,d=1/c,f=1/l;return zr.elements[0]*=h,zr.elements[1]*=h,zr.elements[2]*=h,zr.elements[4]*=d,zr.elements[5]*=d,zr.elements[6]*=d,zr.elements[8]*=f,zr.elements[9]*=f,zr.elements[10]*=f,n.setFromRotationMatrix(zr),r.x=a,r.y=c,r.z=l,this}makePerspective(e,n,r,o,a,c){c===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let l=this.elements,u=2*a/(n-e),h=2*a/(r-o),d=(n+e)/(n-e),f=(r+o)/(r-o),p=-(c+a)/(c-a),m=-2*c*a/(c-a);return l[0]=u,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,o,a,c){let l=this.elements,u=1/(n-e),h=1/(r-o),d=1/(c-a),f=(n+e)*u,p=(r+o)*h,m=(c+a)*d;return l[0]=2*u,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=-2*d,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let n=this.elements,r=e.elements;for(let o=0;o<16;o++)if(n[o]!==r[o])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){let r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}},Ta=new W,zr=new vt,J2=new W(0,0,0),Q2=new W(1,1,1),Po=new W,Ch=new W,ir=new W,Ol=class t{constructor(e=0,n=0,r=0,o=t.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=e,this._y=n,this._z=r,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,n,r,o){return this._x=e,this._y=n,this._z=r,this._order=o||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n,r){let o=dt.clamp,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],p=a[2],m=a[6],v=a[10];switch(n=n||this._order,n){case"XYZ":this._y=Math.asin(o(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-f,v),this._z=Math.atan2(-l,c)):(this._x=Math.atan2(m,d),this._z=0);break;case"YXZ":this._x=Math.asin(-o(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(u,v),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-p,c),this._z=0);break;case"ZXY":this._x=Math.asin(o(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,v),this._z=Math.atan2(-l,d)):(this._y=0,this._z=Math.atan2(h,c));break;case"ZYX":this._y=Math.asin(-o(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(h,c)):(this._x=0,this._z=Math.atan2(-l,d));break;case"YZX":this._z=Math.asin(o(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-f,d),this._y=Math.atan2(-p,c)):(this._x=0,this._y=Math.atan2(u,v));break;case"XZY":this._z=Math.asin(-o(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(m,d),this._y=Math.atan2(u,c)):(this._x=Math.atan2(-f,v),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r!==!1&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return bx.makeRotationFromQuaternion(e),this.setFromRotationMatrix(bx,n,r)}setFromVector3(e,n){return this.set(e.x,e.y,e.z,n||this._order)}reorder(e){return wx.setFromEuler(this),this.setFromQuaternion(wx,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],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new W(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};Ol.DefaultOrder="XYZ";Ol.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var bx=new vt,wx=new zn,hf=class{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}},K2=0,Mx=new W,Aa=new zn,Vi=new vt,Rh=new W,gl=new W,eC=new W,tC=new zn,Ex=new W(1,0,0),Sx=new W(0,1,0),Tx=new W(0,0,1),nC={type:"added"},Ax={type:"removed"};function Je(){Object.defineProperty(this,"id",{value:K2++}),this.uuid=dt.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Je.DefaultUp.clone();let t=new W,e=new Ol,n=new zn,r=new W(1,1,1);function o(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(o),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new vt},normalMatrix:{value:new Fn}}),this.matrix=new vt,this.matrixWorld=new vt,this.matrixAutoUpdate=Je.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new hf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}Je.DefaultUp=new W(0,1,0);Je.DefaultMatrixAutoUpdate=!0;Je.prototype=Object.assign(Object.create(Ji.prototype),{constructor:Je,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return Aa.setFromAxisAngle(t,e),this.quaternion.multiply(Aa),this},rotateOnWorldAxis:function(t,e){return Aa.setFromAxisAngle(t,e),this.quaternion.premultiply(Aa),this},rotateX:function(t){return this.rotateOnAxis(Ex,t)},rotateY:function(t){return this.rotateOnAxis(Sx,t)},rotateZ:function(t){return this.rotateOnAxis(Tx,t)},translateOnAxis:function(t,e){return Mx.copy(t).applyQuaternion(this.quaternion),this.position.add(Mx.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(Ex,t)},translateY:function(t){return this.translateOnAxis(Sx,t)},translateZ:function(t){return this.translateOnAxis(Tx,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(Vi.getInverse(this.matrixWorld))},lookAt:function(t,e,n){t.isVector3?Rh.copy(t):Rh.set(t,e,n);let r=this.parent;this.updateWorldMatrix(!0,!1),gl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vi.lookAt(gl,Rh,this.up):Vi.lookAt(Rh,gl,this.up),this.quaternion.setFromRotationMatrix(Vi),r&&(Vi.extractRotation(r.matrixWorld),Aa.setFromRotationMatrix(Vi),this.quaternion.premultiply(Aa.inverse()))},add:function(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(nC)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ax)),this},clear:function(){for(let t=0;t<this.children.length;t++){let e=this.children[t];e.parent=null,e.dispatchEvent(Ax)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),Vi.getInverse(this.matrixWorld),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Vi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Vi),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}},getWorldPosition:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new W),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new zn),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gl,t,eC),t},getWorldScale:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new W),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gl,tC,t),t},getWorldDirection:function(t){t===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new W),this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)},traverseVisible:function(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)},traverseAncestors:function(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0)}},toJSON:function(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON());function o(c,l){return c[l.uuid]===void 0&&(c[l.uuid]=l.toJSON(t)),l.uuid}if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(t.geometries,this.geometry);let c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){let l=c.shapes;if(Array.isArray(l))for(let u=0,h=l.length;u<h;u++){let d=l[u];o(t.shapes,d)}else o(t.shapes,l)}}if(this.material!==void 0)if(Array.isArray(this.material)){let c=[];for(let l=0,u=this.material.length;l<u;l++)c.push(o(t.materials,this.material[l]));r.material=c}else r.material=o(t.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(t).object)}if(e){let c=a(t.geometries),l=a(t.materials),u=a(t.textures),h=a(t.images),d=a(t.shapes);c.length>0&&(n.geometries=c),l.length>0&&(n.materials=l),u.length>0&&(n.textures=u),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d)}return n.object=r,n;function a(c){let l=[];for(let u in c){let h=c[u];delete h.metadata,l.push(h)}return l}},clone:function(t){return new this.constructor().copy(this,t)},copy:function(t,e){if(e===void 0&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let r=t.children[n];this.add(r.clone())}return this}});var gm=new W,rC=new W,iC=new Fn,qr=class{constructor(e,n){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=e!==void 0?e:new W(1,0,0),this.constant=n!==void 0?n:0}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,o){return this.normal.set(e,n,r),this.constant=o,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){let o=gm.subVectors(r,n).cross(rC.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(o,e),this}clone(){return new this.constructor().copy(this)}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new W),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,n){n===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new W);let r=e.delta(gm),o=this.normal.dot(r);if(o===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):void 0;let a=-(e.start.dot(this.normal)+this.constant)/o;if(!(a<0||a>1))return n.copy(r).multiplyScalar(a).add(e.start)}intersectsLine(e){let n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new W),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){let r=n||iC.getNormalMatrix(e),o=this.coplanarPoint(gm).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-o.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},Vr=new W,Wi=new W,vm=new W,ji=new W,Ca=new W,Ra=new W,Cx=new W,ym=new W,xm=new W,_m=new W,Sr=class t{constructor(e,n,r){this.a=e!==void 0?e:new W,this.b=n!==void 0?n:new W,this.c=r!==void 0?r:new W}static getNormal(e,n,r,o){o===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),o=new W),o.subVectors(r,n),Vr.subVectors(e,n),o.cross(Vr);let a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}static getBarycoord(e,n,r,o,a){Vr.subVectors(o,n),Wi.subVectors(r,n),vm.subVectors(e,n);let c=Vr.dot(Vr),l=Vr.dot(Wi),u=Vr.dot(vm),h=Wi.dot(Wi),d=Wi.dot(vm),f=c*h-l*l;if(a===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),a=new W),f===0)return a.set(-2,-1,-1);let p=1/f,m=(h*u-l*d)*p,v=(c*d-l*u)*p;return a.set(1-m-v,v,m)}static containsPoint(e,n,r,o){return this.getBarycoord(e,n,r,o,ji),ji.x>=0&&ji.y>=0&&ji.x+ji.y<=1}static getUV(e,n,r,o,a,c,l,u){return this.getBarycoord(e,n,r,o,ji),u.set(0,0),u.addScaledVector(a,ji.x),u.addScaledVector(c,ji.y),u.addScaledVector(l,ji.z),u}static isFrontFacing(e,n,r,o){return Vr.subVectors(r,n),Wi.subVectors(e,n),Vr.cross(Wi).dot(o)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,o){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(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 Vr.subVectors(this.c,this.b),Wi.subVectors(this.a,this.b),Vr.cross(Wi).length()*.5}getMidpoint(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new W),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return t.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new qr),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return t.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,o,a){return t.getUV(e,this.a,this.b,this.c,n,r,o,a)}containsPoint(e){return t.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return t.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){n===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new W);let r=this.a,o=this.b,a=this.c,c,l;Ca.subVectors(o,r),Ra.subVectors(a,r),ym.subVectors(e,r);let u=Ca.dot(ym),h=Ra.dot(ym);if(u<=0&&h<=0)return n.copy(r);xm.subVectors(e,o);let d=Ca.dot(xm),f=Ra.dot(xm);if(d>=0&&f<=d)return n.copy(o);let p=u*f-d*h;if(p<=0&&u>=0&&d<=0)return c=u/(u-d),n.copy(r).addScaledVector(Ca,c);_m.subVectors(e,a);let m=Ca.dot(_m),v=Ra.dot(_m);if(v>=0&&m<=v)return n.copy(a);let x=m*h-u*v;if(x<=0&&h>=0&&v<=0)return l=h/(h-v),n.copy(r).addScaledVector(Ra,l);let b=d*v-m*f;if(b<=0&&f-d>=0&&m-v>=0)return Cx.subVectors(a,o),l=(f-d)/(f-d+(m-v)),n.copy(o).addScaledVector(Cx,l);let y=1/(b+x+p);return c=x*y,l=p*y,n.copy(r).addScaledVector(Ca,c).addScaledVector(Ra,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},W0={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},Wr={h:0,s:0,l:0},Ph={h:0,s:0,l:0};function bm(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}function wm(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Mm(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}var We=class{constructor(e,n,r){return Object.defineProperty(this,"isColor",{value:!0}),n===void 0&&r===void 0?this.set(e):this.setRGB(e,n,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,n,r){return this.r=e,this.g=n,this.b=r,this}setHSL(e,n,r){if(e=dt.euclideanModulo(e,1),n=dt.clamp(n,0,1),r=dt.clamp(r,0,1),n===0)this.r=this.g=this.b=r;else{let o=r<=.5?r*(1+n):r+n-r*n,a=2*r-o;this.r=bm(a,o,e+1/3),this.g=bm(a,o,e),this.b=bm(a,o,e-1/3)}return this}setStyle(e){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){let o,a=r[1],c=r[2];switch(a){case"rgb":case"rgba":if(o=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c))return this.r=Math.min(255,parseInt(o[1],10))/255,this.g=Math.min(255,parseInt(o[2],10))/255,this.b=Math.min(255,parseInt(o[3],10))/255,n(o[5]),this;if(o=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c))return this.r=Math.min(100,parseInt(o[1],10))/100,this.g=Math.min(100,parseInt(o[2],10))/100,this.b=Math.min(100,parseInt(o[3],10))/100,n(o[5]),this;break;case"hsl":case"hsla":if(o=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c)){let l=parseFloat(o[1])/360,u=parseInt(o[2],10)/100,h=parseInt(o[3],10)/100;return n(o[5]),this.setHSL(l,u,h)}break}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){let o=r[1],a=o.length;if(a===3)return this.r=parseInt(o.charAt(0)+o.charAt(0),16)/255,this.g=parseInt(o.charAt(1)+o.charAt(1),16)/255,this.b=parseInt(o.charAt(2)+o.charAt(2),16)/255,this;if(a===6)return this.r=parseInt(o.charAt(0)+o.charAt(1),16)/255,this.g=parseInt(o.charAt(2)+o.charAt(3),16)/255,this.b=parseInt(o.charAt(4)+o.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let n=W0[e];return n!==void 0?this.setHex(n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,n){return n===void 0&&(n=2),this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}copyLinearToGamma(e,n){n===void 0&&(n=2);let r=n>0?1/n:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=wm(e.r),this.g=wm(e.g),this.b=wm(e.b),this}copyLinearToSRGB(e){return this.r=Mm(e.r),this.g=Mm(e.g),this.b=Mm(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){e===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});let n=this.r,r=this.g,o=this.b,a=Math.max(n,r,o),c=Math.min(n,r,o),l,u,h=(c+a)/2;if(c===a)l=0,u=0;else{let d=a-c;switch(u=h<=.5?d/(a+c):d/(2-a-c),a){case n:l=(r-o)/d+(r<o?6:0);break;case r:l=(o-n)/d+2;break;case o:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=u,e.l=h,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,n,r){return this.getHSL(Wr),Wr.h+=e,Wr.s+=n,Wr.l+=r,this.setHSL(Wr.h,Wr.s,Wr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpHSL(e,n){this.getHSL(Wr),e.getHSL(Ph);let r=dt.lerp(Wr.h,Ph.h,n),o=dt.lerp(Wr.s,Ph.s,n),a=dt.lerp(Wr.l,Ph.l,n);return this.setHSL(r,o,a),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}};We.NAMES=W0;We.prototype.r=1;We.prototype.g=1;We.prototype.b=1;var Ar=class{constructor(e,n,r,o,a,c){this.a=e,this.b=n,this.c=r,this.normal=o&&o.isVector3?o:new W,this.vertexNormals=Array.isArray(o)?o:[],this.color=a&&a.isColor?a:new We,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=c!==void 0?c:0}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let n=0,r=e.vertexNormals.length;n<r;n++)this.vertexNormals[n]=e.vertexNormals[n].clone();for(let n=0,r=e.vertexColors.length;n<r;n++)this.vertexColors[n]=e.vertexColors[n].clone();return this}},oC=0;function at(){Object.defineProperty(this,"id",{value:oC++}),this.uuid=dt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=Tl,this.side=Sf,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=B0,this.blendDst=O0,this.blendEquation=Ga,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Um,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Y2,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=lm,this.stencilZFail=lm,this.stencilZPass=lm,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}at.prototype=Object.assign(Object.create(Ji.prototype),{constructor:at,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if(e==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===D0;continue}let r=this[e];if(r===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}},toJSON:function(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,this.combine!==void 0&&(n.combine=this.combine),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Tl&&(n.blending=this.blending),this.flatShading===!0&&(n.flatShading=this.flatShading),this.side!==Sf&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(n.morphTargets=!0),this.morphNormals===!0&&(n.morphNormals=!0),this.skinning===!0&&(n.skinning=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function r(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}if(e){let o=r(t.textures),a=r(t.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n},clone:function(){return new this.constructor().copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let r=e.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=e[o].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(at.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});function Xr(t){at.call(this),this.type="MeshBasicMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Af,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}Xr.prototype=Object.create(at.prototype);Xr.prototype.constructor=Xr;Xr.prototype.isMeshBasicMaterial=!0;Xr.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};var Ut=new W,Lh=new fe;function ut(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n===!0,this.usage=Rf,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(ut.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(ut.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,o=this.itemSize;r<o;r++)this.array[t+r]=e.array[n+r];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new We),e[n++]=a.r,e[n++]=a.g,e[n++]=a.b}return this},copyVector2sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new fe),e[n++]=a.x,e[n++]=a.y}return this},copyVector3sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new W),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z}return this},copyVector4sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new Rt),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z,e[n++]=a.w}return this},applyMatrix3:function(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Lh.fromBufferAttribute(this,e),Lh.applyMatrix3(t),this.setXY(e,Lh.x,Lh.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ut.fromBufferAttribute(this,e),Ut.applyMatrix3(t),this.setXYZ(e,Ut.x,Ut.y,Ut.z);return this},applyMatrix4:function(t){for(let e=0,n=this.count;e<n;e++)Ut.x=this.getX(e),Ut.y=this.getY(e),Ut.z=this.getZ(e),Ut.applyMatrix4(t),this.setXYZ(e,Ut.x,Ut.y,Ut.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)Ut.x=this.getX(e),Ut.y=this.getY(e),Ut.z=this.getZ(e),Ut.applyNormalMatrix(t),this.setXYZ(e,Ut.x,Ut.y,Ut.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)Ut.x=this.getX(e),Ut.y=this.getY(e),Ut.z=this.getZ(e),Ut.transformDirection(t),this.setXYZ(e,Ut.x,Ut.y,Ut.z);return this},set:function(t,e){return e===void 0&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this},setXYZW:function(t,e,n,r,o){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=o,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function km(t,e,n){ut.call(this,new Int8Array(t),e,n)}km.prototype=Object.create(ut.prototype);km.prototype.constructor=km;function Hm(t,e,n){ut.call(this,new Uint8Array(t),e,n)}Hm.prototype=Object.create(ut.prototype);Hm.prototype.constructor=Hm;function zm(t,e,n){ut.call(this,new Uint8ClampedArray(t),e,n)}zm.prototype=Object.create(ut.prototype);zm.prototype.constructor=zm;function Vm(t,e,n){ut.call(this,new Int16Array(t),e,n)}Vm.prototype=Object.create(ut.prototype);Vm.prototype.constructor=Vm;function Ul(t,e,n){ut.call(this,new Uint16Array(t),e,n)}Ul.prototype=Object.create(ut.prototype);Ul.prototype.constructor=Ul;function Wm(t,e,n){ut.call(this,new Int32Array(t),e,n)}Wm.prototype=Object.create(ut.prototype);Wm.prototype.constructor=Wm;function Nl(t,e,n){ut.call(this,new Uint32Array(t),e,n)}Nl.prototype=Object.create(ut.prototype);Nl.prototype.constructor=Nl;function St(t,e,n){ut.call(this,new Float32Array(t),e,n)}St.prototype=Object.create(ut.prototype);St.prototype.constructor=St;function jm(t,e,n){ut.call(this,new Float64Array(t),e,n)}jm.prototype=Object.create(ut.prototype);jm.prototype.constructor=jm;var qm=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let n=[],r,o,a,c=e.faces;for(o=0;o<c.length;o++){let l=c[o];l.materialIndex!==a&&(a=l.materialIndex,r!==void 0&&(r.count=o*3-r.start,n.push(r)),r={start:o*3,materialIndex:a})}r!==void 0&&(r.count=o*3-r.start,n.push(r)),this.groups=n}fromGeometry(e){let n=e.faces,r=e.vertices,o=e.faceVertexUvs,a=o[0]&&o[0].length>0,c=o[1]&&o[1].length>0,l=e.morphTargets,u=l.length,h;if(u>0){h=[];for(let y=0;y<u;y++)h[y]={name:l[y].name,data:[]};this.morphTargets.position=h}let d=e.morphNormals,f=d.length,p;if(f>0){p=[];for(let y=0;y<f;y++)p[y]={name:d[y].name,data:[]};this.morphTargets.normal=p}let m=e.skinIndices,v=e.skinWeights,x=m.length===r.length,b=v.length===r.length;r.length>0&&n.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<n.length;y++){let g=n[y];this.vertices.push(r[g.a],r[g.b],r[g.c]);let M=g.vertexNormals;if(M.length===3)this.normals.push(M[0],M[1],M[2]);else{let E=g.normal;this.normals.push(E,E,E)}let C=g.vertexColors;if(C.length===3)this.colors.push(C[0],C[1],C[2]);else{let E=g.color;this.colors.push(E,E,E)}if(a===!0){let E=o[0][y];E!==void 0?this.uvs.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new fe,new fe,new fe))}if(c===!0){let E=o[1][y];E!==void 0?this.uvs2.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new fe,new fe,new fe))}for(let E=0;E<u;E++){let w=l[E].vertices;h[E].data.push(w[g.a],w[g.b],w[g.c])}for(let E=0;E<f;E++){let w=d[E].vertexNormals[y];p[E].data.push(w.a,w.b,w.c)}x&&this.skinIndices.push(m[g.a],m[g.b],m[g.c]),b&&this.skinWeights.push(v[g.a],v[g.b],v[g.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}};function j0(t){if(t.length===0)return-1/0;let e=t[0];for(let n=1,r=t.length;n<r;++n)t[n]>e&&(e=t[n]);return e}var sC=1,hi=new vt,Em=new Je,Pa=new W,or=new vi,vl=new vi,pn=new W;function Tt(){Object.defineProperty(this,"id",{value:sC+=2}),this.uuid=dt.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}Tt.prototype=Object.assign(Object.create(Ji.prototype),{constructor:Tt,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(j0(t)>65535?Nl:Ul)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:n!==void 0?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let o=new Fn().getNormalMatrix(t);n.applyNormalMatrix(o),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(t){return hi.makeRotationX(t),this.applyMatrix4(hi),this},rotateY:function(t){return hi.makeRotationY(t),this.applyMatrix4(hi),this},rotateZ:function(t){return hi.makeRotationZ(t),this.applyMatrix4(hi),this},translate:function(t,e,n){return hi.makeTranslation(t,e,n),this.applyMatrix4(hi),this},scale:function(t,e,n){return hi.makeScale(t,e,n),this.applyMatrix4(hi),this},lookAt:function(t){return Em.lookAt(t),Em.updateMatrix(),this.applyMatrix4(Em.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pa).negate(),this.translate(Pa.x,Pa.y,Pa.z),this},setFromObject:function(t){let e=t.geometry;if(t.isPoints||t.isLine){let n=new St(e.vertices.length*3,3),r=new St(e.colors.length*3,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){let o=new St(e.lineDistances.length,1);this.setAttribute("lineDistance",o.copyArray(e.lineDistances))}e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){let e=[];for(let n=0,r=t.length;n<r;n++){let o=t[n];e.push(o.x,o.y,o.z||0)}return this.setAttribute("position",new St(e,3)),this},updateFromObject:function(t){let e=t.geometry;if(t.isMesh){let n=e.__directGeometry;if(e.elementsNeedUpdate===!0&&(n=void 0,e.elementsNeedUpdate=!1),n===void 0)return this.fromGeometry(e);n.verticesNeedUpdate=e.verticesNeedUpdate,n.normalsNeedUpdate=e.normalsNeedUpdate,n.colorsNeedUpdate=e.colorsNeedUpdate,n.uvsNeedUpdate=e.uvsNeedUpdate,n.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=n}if(e.verticesNeedUpdate===!0){let n=this.attributes.position;n!==void 0&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1}if(e.normalsNeedUpdate===!0){let n=this.attributes.normal;n!==void 0&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1}if(e.colorsNeedUpdate===!0){let n=this.attributes.color;n!==void 0&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1}if(e.uvsNeedUpdate){let n=this.attributes.uv;n!==void 0&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1}if(e.lineDistancesNeedUpdate){let n=this.attributes.lineDistance;n!==void 0&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1}return e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=new qm().fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){let e=new Float32Array(t.vertices.length*3);if(this.setAttribute("position",new ut(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);this.setAttribute("normal",new ut(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);this.setAttribute("color",new ut(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);this.setAttribute("uv",new ut(n,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);this.setAttribute("uv2",new ut(n,2).copyVector2sArray(t.uvs2))}this.groups=t.groups;for(let n in t.morphTargets){let r=[],o=t.morphTargets[n];for(let a=0,c=o.length;a<c;a++){let l=o[a],u=new St(l.data.length*3,3);u.name=l.name,r.push(u.copyVector3sArray(l.data))}this.morphAttributes[n]=r}if(t.skinIndices.length>0){let n=new St(t.skinIndices.length*4,4);this.setAttribute("skinIndex",n.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let n=new St(t.skinWeights.length*4,4);this.setAttribute("skinWeight",n.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new vi);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new W(-1/0,-1/0,-1/0),new W(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){let o=e[n];or.setFromBufferAttribute(o),this.morphTargetsRelative?(pn.addVectors(this.boundingBox.min,or.min),this.boundingBox.expandByPoint(pn),pn.addVectors(this.boundingBox.max,or.max),this.boundingBox.expandByPoint(pn)):(this.boundingBox.expandByPoint(or.min),this.boundingBox.expandByPoint(or.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new yi);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new W,1/0);return}if(t){let n=this.boundingSphere.center;if(or.setFromBufferAttribute(t),e)for(let o=0,a=e.length;o<a;o++){let c=e[o];vl.setFromBufferAttribute(c),this.morphTargetsRelative?(pn.addVectors(or.min,vl.min),or.expandByPoint(pn),pn.addVectors(or.max,vl.max),or.expandByPoint(pn)):(or.expandByPoint(vl.min),or.expandByPoint(vl.max))}or.getCenter(n);let r=0;for(let o=0,a=t.count;o<a;o++)pn.fromBufferAttribute(t,o),r=Math.max(r,n.distanceToSquared(pn));if(e)for(let o=0,a=e.length;o<a;o++){let c=e[o],l=this.morphTargetsRelative;for(let u=0,h=c.count;u<h;u++)pn.fromBufferAttribute(c,u),l&&(Pa.fromBufferAttribute(t,u),pn.add(Pa)),r=Math.max(r,n.distanceToSquared(pn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ut(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let r=new W,o=new W,a=new W,c=new W,l=new W,u=new W,h=new W,d=new W;if(t)for(let f=0,p=t.count;f<p;f+=3){let m=t.getX(f+0),v=t.getX(f+1),x=t.getX(f+2);r.fromBufferAttribute(e,m),o.fromBufferAttribute(e,v),a.fromBufferAttribute(e,x),h.subVectors(a,o),d.subVectors(r,o),h.cross(d),c.fromBufferAttribute(n,m),l.fromBufferAttribute(n,v),u.fromBufferAttribute(n,x),c.add(h),l.add(h),u.add(h),n.setXYZ(m,c.x,c.y,c.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(x,u.x,u.y,u.z)}else for(let f=0,p=e.count;f<p;f+=3)r.fromBufferAttribute(e,f+0),o.fromBufferAttribute(e,f+1),a.fromBufferAttribute(e,f+2),h.subVectors(a,o),d.subVectors(r,o),h.cross(d),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(t,e){if(!(t&&t.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);return}e===void 0&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let r in n){if(t.attributes[r]===void 0)continue;let a=n[r].array,c=t.attributes[r],l=c.array,u=c.itemSize*e,h=Math.min(l.length,a.length-u);for(let d=0,f=u;d<h;d++,f++)a[f]=l[d]}return this},normalizeNormals:function(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)pn.fromBufferAttribute(t,e),pn.normalize(),t.setXYZ(e,pn.x,pn.y,pn.z)},toNonIndexed:function(){function t(c,l){let u=c.array,h=c.itemSize,d=c.normalized,f=new u.constructor(l.length*h),p=0,m=0;for(let v=0,x=l.length;v<x;v++){p=l[v]*h;for(let b=0;b<h;b++)f[m++]=u[p++]}return new ut(f,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;let e=new Tt,n=this.index.array,r=this.attributes;for(let c in r){let l=r[c],u=t(l,n);e.setAttribute(c,u)}let o=this.morphAttributes;for(let c in o){let l=[],u=o[c];for(let h=0,d=u.length;h<d;h++){let f=u[h],p=t(f,n);l.push(p)}e.morphAttributes[c]=l}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let c=0,l=a.length;c<l;c++){let u=a[c];e.addGroup(u.start,u.count,u.materialIndex)}return e},toJSON:function(){let t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(t[u]=l[u]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let u=n[l],h=u.toJSON(t.data);u.name!==""&&(h.name=u.name),t.data.attributes[l]=h}let r={},o=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],h=[];for(let d=0,f=u.length;d<f;d++){let p=u[d],m=p.toJSON(t.data);p.name!==""&&(m.name=p.name),h.push(m)}h.length>0&&(r[l]=h,o=!0)}o&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let c=this.boundingSphere;return c!==null&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return new Tt().copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let r=t.attributes;for(let u in r){let h=r[u];this.setAttribute(u,h.clone(e))}let o=t.morphAttributes;for(let u in o){let h=[],d=o[u];for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone(e));this.morphAttributes[u]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let u=0,h=a.length;u<h;u++){let d=a[u];this.addGroup(d.start,d.count,d.materialIndex)}let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Rx=new vt,_s=new Ss,Sm=new yi,Lo=new W,Fo=new W,Io=new W,Tm=new W,Am=new W,Cm=new W,Fh=new W,Ih=new W,Dh=new W,za=new fe,Va=new fe,Wa=new fe,Rl=new W,Bh=new W;function Wt(t,e){Je.call(this),this.type="Mesh",this.geometry=t!==void 0?t:new Tt,this.material=e!==void 0?e:new Xr,this.updateMorphTargets()}Wt.prototype=Object.assign(Object.create(Je.prototype),{constructor:Wt,isMesh:!0,copy:function(t){return Je.prototype.copy.call(this,t),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){let n=this.geometry,r=this.material,o=this.matrixWorld;if(r===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Sm.copy(n.boundingSphere),Sm.applyMatrix4(o),t.ray.intersectsSphere(Sm)===!1)||(Rx.getInverse(o),_s.copy(t.ray).applyMatrix4(Rx),n.boundingBox!==null&&_s.intersectsBox(n.boundingBox)===!1))return;let a;if(n.isBufferGeometry){let c=n.index,l=n.attributes.position,u=n.morphAttributes.position,h=n.morphTargetsRelative,d=n.attributes.uv,f=n.attributes.uv2,p=n.groups,m=n.drawRange;if(c!==null)if(Array.isArray(r))for(let v=0,x=p.length;v<x;v++){let b=p[v],y=r[b.materialIndex],g=Math.max(b.start,m.start),M=Math.min(b.start+b.count,m.start+m.count);for(let C=g,E=M;C<E;C+=3){let w=c.getX(C),F=c.getX(C+1),H=c.getX(C+2);a=Oh(this,y,t,_s,l,u,h,d,f,w,F,H),a&&(a.faceIndex=Math.floor(C/3),a.face.materialIndex=b.materialIndex,e.push(a))}}else{let v=Math.max(0,m.start),x=Math.min(c.count,m.start+m.count);for(let b=v,y=x;b<y;b+=3){let g=c.getX(b),M=c.getX(b+1),C=c.getX(b+2);a=Oh(this,r,t,_s,l,u,h,d,f,g,M,C),a&&(a.faceIndex=Math.floor(b/3),e.push(a))}}else if(l!==void 0)if(Array.isArray(r))for(let v=0,x=p.length;v<x;v++){let b=p[v],y=r[b.materialIndex],g=Math.max(b.start,m.start),M=Math.min(b.start+b.count,m.start+m.count);for(let C=g,E=M;C<E;C+=3){let w=C,F=C+1,H=C+2;a=Oh(this,y,t,_s,l,u,h,d,f,w,F,H),a&&(a.faceIndex=Math.floor(C/3),a.face.materialIndex=b.materialIndex,e.push(a))}}else{let v=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let b=v,y=x;b<y;b+=3){let g=b,M=b+1,C=b+2;a=Oh(this,r,t,_s,l,u,h,d,f,g,M,C),a&&(a.faceIndex=Math.floor(b/3),e.push(a))}}}else if(n.isGeometry){let c=Array.isArray(r),l=n.vertices,u=n.faces,h,d=n.faceVertexUvs[0];d.length>0&&(h=d);for(let f=0,p=u.length;f<p;f++){let m=u[f],v=c?r[m.materialIndex]:r;if(v===void 0)continue;let x=l[m.a],b=l[m.b],y=l[m.c];if(a=q0(this,v,t,_s,x,b,y,Rl),a){if(h&&h[f]){let g=h[f];za.copy(g[0]),Va.copy(g[1]),Wa.copy(g[2]),a.uv=Sr.getUV(Rl,x,b,y,za,Va,Wa,new fe)}a.face=m,a.faceIndex=f,e.push(a)}}}}});function q0(t,e,n,r,o,a,c,l){let u;if(e.side===rn?u=r.intersectTriangle(c,a,o,!0,l):u=r.intersectTriangle(o,a,c,e.side!==Tf,l),u===null)return null;Bh.copy(l),Bh.applyMatrix4(t.matrixWorld);let h=n.ray.origin.distanceTo(Bh);return h<n.near||h>n.far?null:{distance:h,point:Bh.clone(),object:t}}function Oh(t,e,n,r,o,a,c,l,u,h,d,f){Lo.fromBufferAttribute(o,h),Fo.fromBufferAttribute(o,d),Io.fromBufferAttribute(o,f);let p=t.morphTargetInfluences;if(e.morphTargets&&a&&p){Fh.set(0,0,0),Ih.set(0,0,0),Dh.set(0,0,0);for(let v=0,x=a.length;v<x;v++){let b=p[v],y=a[v];b!==0&&(Tm.fromBufferAttribute(y,h),Am.fromBufferAttribute(y,d),Cm.fromBufferAttribute(y,f),c?(Fh.addScaledVector(Tm,b),Ih.addScaledVector(Am,b),Dh.addScaledVector(Cm,b)):(Fh.addScaledVector(Tm.sub(Lo),b),Ih.addScaledVector(Am.sub(Fo),b),Dh.addScaledVector(Cm.sub(Io),b)))}Lo.add(Fh),Fo.add(Ih),Io.add(Dh)}t.isSkinnedMesh&&(t.boneTransform(h,Lo),t.boneTransform(d,Fo),t.boneTransform(f,Io));let m=q0(t,e,n,r,Lo,Fo,Io,Rl);if(m){l&&(za.fromBufferAttribute(l,h),Va.fromBufferAttribute(l,d),Wa.fromBufferAttribute(l,f),m.uv=Sr.getUV(Rl,Lo,Fo,Io,za,Va,Wa,new fe)),u&&(za.fromBufferAttribute(u,h),Va.fromBufferAttribute(u,d),Wa.fromBufferAttribute(u,f),m.uv2=Sr.getUV(Rl,Lo,Fo,Io,za,Va,Wa,new fe));let v=new Ar(h,d,f);Sr.getNormal(Lo,Fo,Io,v.normal),m.face=v}return m}var ff=class extends Tt{constructor(e=1,n=1,r=1,o=1,a=1,c=1){super(),this.type="BoxBufferGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:o,heightSegments:a,depthSegments:c};let l=this;o=Math.floor(o),a=Math.floor(a),c=Math.floor(c);let u=[],h=[],d=[],f=[],p=0,m=0;v("z","y","x",-1,-1,r,n,e,c,a,0),v("z","y","x",1,-1,r,n,-e,c,a,1),v("x","z","y",1,1,e,r,n,o,c,2),v("x","z","y",1,-1,e,r,-n,o,c,3),v("x","y","z",1,-1,e,n,r,o,a,4),v("x","y","z",-1,-1,e,n,-r,o,a,5),this.setIndex(u),this.setAttribute("position",new St(h,3)),this.setAttribute("normal",new St(d,3)),this.setAttribute("uv",new St(f,2));function v(x,b,y,g,M,C,E,w,F,H,ne){let Y=C/F,L=E/H,N=C/2,G=E/2,z=w/2,D=F+1,B=H+1,q=0,$=0,ce=new W;for(let ge=0;ge<B;ge++){let he=ge*L-G;for(let Pe=0;Pe<D;Pe++){let Fe=Pe*Y-N;ce[x]=Fe*g,ce[b]=he*M,ce[y]=z,h.push(ce.x,ce.y,ce.z),ce[x]=0,ce[b]=0,ce[y]=w>0?1:-1,d.push(ce.x,ce.y,ce.z),f.push(Pe/F),f.push(1-ge/H),q+=1}}for(let ge=0;ge<H;ge++)for(let he=0;he<F;he++){let Pe=p+he+D*ge,Fe=p+he+D*(ge+1),st=p+(he+1)+D*(ge+1),V=p+(he+1)+D*ge;u.push(Pe,Fe,V),u.push(Fe,st,V),$+=6}l.addGroup(m,$,ne),m+=$,p+=q}}};function $a(t){let e={};for(let n in t){e[n]={};for(let r in t[n]){let o=t[n][r];o&&(o.isColor||o.isMatrix3||o.isMatrix4||o.isVector2||o.isVector3||o.isVector4||o.isTexture)?e[n][r]=o.clone():Array.isArray(o)?e[n][r]=o.slice():e[n][r]=o}}return e}function Ln(t){let e={};for(let n=0;n<t.length;n++){let r=$a(t[n]);for(let o in r)e[o]=r[o]}return e}var aC={clone:$a,merge:Ln},cC=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,lC=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;function In(t){at.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=cC,this.fragmentShader=lC,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&(t.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}In.prototype=Object.create(at.prototype);In.prototype.constructor=In;In.prototype.isShaderMaterial=!0;In.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=$a(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this};In.prototype.toJSON=function(t){let e=at.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(let r in this.uniforms){let a=this.uniforms[r].value;a&&a.isTexture?e.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[r]={type:"m4",value:a.toArray()}:e.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e};function Go(){Je.call(this),this.type="Camera",this.matrixWorldInverse=new vt,this.projectionMatrix=new vt,this.projectionMatrixInverse=new vt}Go.prototype=Object.assign(Object.create(Je.prototype),{constructor:Go,isCamera:!0,copy:function(t,e){return Je.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){t===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new W),this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){Je.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(t,e){Je.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function on(t,e,n,r){Go.call(this),this.type="PerspectiveCamera",this.fov=t!==void 0?t:50,this.zoom=1,this.near=n!==void 0?n:.1,this.far=r!==void 0?r:2e3,this.focus=10,this.aspect=e!==void 0?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}on.prototype=Object.assign(Object.create(Go.prototype),{constructor:on,isPerspectiveCamera:!0,copy:function(t,e){return Go.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){let e=.5*this.getFilmHeight()/t;this.fov=dt.RAD2DEG*2*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){let t=Math.tan(dt.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/t},getEffectiveFOV:function(){return dt.RAD2DEG*2*Math.atan(Math.tan(dt.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,n,r,o,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let t=this.near,e=t*Math.tan(dt.DEG2RAD*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,o=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,u=a.fullHeight;o+=a.offsetX*r/l,e-=a.offsetY*n/u,r*=a.width/l,n*=a.height/u}let c=this.filmOffset;c!==0&&(o+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){let e=Je.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var La=90,Fa=1;function Za(t,e,n){if(Je.call(this),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;let r=new on(La,Fa,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new W(1,0,0)),this.add(r);let o=new on(La,Fa,t,e);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new W(-1,0,0)),this.add(o);let a=new on(La,Fa,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new W(0,1,0)),this.add(a);let c=new on(La,Fa,t,e);c.layers=this.layers,c.up.set(0,0,-1),c.lookAt(new W(0,-1,0)),this.add(c);let l=new on(La,Fa,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new W(0,0,1)),this.add(l);let u=new on(La,Fa,t,e);u.layers=this.layers,u.up.set(0,-1,0),u.lookAt(new W(0,0,-1)),this.add(u),this.update=function(h,d){this.parent===null&&this.updateMatrixWorld();let f=h.xr.enabled,p=h.getRenderTarget();h.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,h.setRenderTarget(n,0),h.render(d,r),h.setRenderTarget(n,1),h.render(d,o),h.setRenderTarget(n,2),h.render(d,a),h.setRenderTarget(n,3),h.render(d,c),h.setRenderTarget(n,4),h.render(d,l),n.texture.generateMipmaps=m,h.setRenderTarget(n,5),h.render(d,u),h.setRenderTarget(p),h.xr.enabled=f}}Za.prototype=Object.create(Je.prototype);Za.prototype.constructor=Za;function ko(t,e,n,r,o,a,c,l,u,h){t=t!==void 0?t:[],e=e!==void 0?e:Cg,c=c!==void 0?c:Ms,At.call(this,t,e,n,r,o,a,c,l,u,h),this.flipY=!1,this._needsFlipEnvMap=!0}ko.prototype=Object.create(At.prototype);ko.prototype.constructor=ko;ko.prototype.isCubeTexture=!0;Object.defineProperty(ko.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});function Ts(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),an.call(this,t,t,e),e=e||{},this.texture=new ko(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture._needsFlipEnvMap=!1}Ts.prototype=Object.create(an.prototype);Ts.prototype.constructor=Ts;Ts.prototype.isWebGLCubeRenderTarget=!0;Ts.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=ar,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`

			varying vec3 vWorldDirection;

			vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

				return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

			}

			void main() {

				vWorldDirection = transformDirection( position, modelMatrix );

				#include <begin_vertex>
				#include <project_vertex>

			}
		`,fragmentShader:`

			uniform sampler2D tEquirect;

			varying vec3 vWorldDirection;

			#include <common>

			void main() {

				vec3 direction = normalize( vWorldDirection );

				vec2 sampleUV = equirectUv( direction );

				gl_FragColor = texture2D( tEquirect, sampleUV );

			}
		`},r=new ff(5,5,5),o=new In({name:"CubemapFromEquirect",uniforms:$a(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:rn,blending:Sl});o.uniforms.tEquirect.value=e;let a=new Wt(r,o),c=e.minFilter;return e.minFilter===Cf&&(e.minFilter=sn),new Za(1,10,this).update(t,a),e.minFilter=c,a.geometry.dispose(),a.material.dispose(),this};Ts.prototype.clear=function(t,e,n,r){let o=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(o)};function xi(t,e,n,r,o,a,c,l,u,h,d,f){At.call(this,null,a,c,l,u,h,r,o,d,f),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=u!==void 0?u:Hn,this.minFilter=h!==void 0?h:Hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}xi.prototype=Object.create(At.prototype);xi.prototype.constructor=xi;xi.prototype.isDataTexture=!0;var Ia=new yi,Uh=new W,Ja=class{constructor(e,n,r,o,a,c){this.planes=[e!==void 0?e:new qr,n!==void 0?n:new qr,r!==void 0?r:new qr,o!==void 0?o:new qr,a!==void 0?a:new qr,c!==void 0?c:new qr]}set(e,n,r,o,a,c){let l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(o),l[4].copy(a),l[5].copy(c),this}clone(){return new this.constructor().copy(this)}copy(e){let n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e){let n=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],u=r[4],h=r[5],d=r[6],f=r[7],p=r[8],m=r[9],v=r[10],x=r[11],b=r[12],y=r[13],g=r[14],M=r[15];return n[0].setComponents(l-o,f-u,x-p,M-b).normalize(),n[1].setComponents(l+o,f+u,x+p,M+b).normalize(),n[2].setComponents(l+a,f+h,x+m,M+y).normalize(),n[3].setComponents(l-a,f-h,x-m,M-y).normalize(),n[4].setComponents(l-c,f-d,x-v,M-g).normalize(),n[5].setComponents(l+c,f+d,x+v,M+g).normalize(),this}intersectsObject(e){let n=e.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),Ia.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ia)}intersectsSprite(e){return Ia.center.set(0,0,0),Ia.radius=.7071067811865476,Ia.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ia)}intersectsSphere(e){let n=this.planes,r=e.center,o=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<o)return!1;return!0}intersectsBox(e){let n=this.planes;for(let r=0;r<6;r++){let o=n[r];if(Uh.x=o.normal.x>0?e.max.x:e.min.x,Uh.y=o.normal.y>0?e.max.y:e.min.y,Uh.z=o.normal.z>0?e.max.z:e.min.z,o.distanceToPoint(Uh)<0)return!1}return!0}containsPoint(e){let n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}};function X0(){let t=null,e=!1,n=null,r=null;function o(a,c){n(a,c),r=t.requestAnimationFrame(o)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(o),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function uC(t,e){let n=e.isWebGL2,r=new WeakMap;function o(h,d){let f=h.array,p=h.usage,m=t.createBuffer();t.bindBuffer(d,m),t.bufferData(d,f,p),h.onUploadCallback();let v=5126;return f instanceof Float32Array?v=5126:f instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):f instanceof Uint16Array?v=5123:f instanceof Int16Array?v=5122:f instanceof Uint32Array?v=5125:f instanceof Int32Array?v=5124:f instanceof Int8Array?v=5120:f instanceof Uint8Array&&(v=5121),{buffer:m,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:h.version}}function a(h,d,f){let p=d.array,m=d.updateRange;t.bindBuffer(f,h),m.count===-1?t.bufferSubData(f,0,p):(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1)}function c(h){return h.isInterleavedBufferAttribute&&(h=h.data),r.get(h)}function l(h){h.isInterleavedBufferAttribute&&(h=h.data);let d=r.get(h);d&&(t.deleteBuffer(d.buffer),r.delete(h))}function u(h,d){if(h.isGLBufferAttribute){var f=r.get(h);(!f||f.version<h.version)&&r.set(h,{buffer:h.buffer,type:h.type,bytesPerElement:h.elementSize,version:h.version});return}h.isInterleavedBufferAttribute&&(h=h.data);let p=r.get(h);p===void 0?r.set(h,o(h,d)):p.version<h.version&&(a(p.buffer,h,d),p.version=h.version)}return{get:c,remove:l,update:u}}var df=class extends Tt{constructor(e,n,r,o){super(),this.type="PlaneBufferGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:o},e=e||1,n=n||1;let a=e/2,c=n/2,l=Math.floor(r)||1,u=Math.floor(o)||1,h=l+1,d=u+1,f=e/l,p=n/u,m=[],v=[],x=[],b=[];for(let y=0;y<d;y++){let g=y*p-c;for(let M=0;M<h;M++){let C=M*f-a;v.push(C,-g,0),x.push(0,0,1),b.push(M/l),b.push(1-y/u)}}for(let y=0;y<u;y++)for(let g=0;g<l;g++){let M=g+h*y,C=g+h*(y+1),E=g+1+h*(y+1),w=g+1+h*y;m.push(M,C,w),m.push(C,E,w)}this.setIndex(m),this.setAttribute("position",new St(v,3)),this.setAttribute("normal",new St(x,3)),this.setAttribute("uv",new St(b,2))}},hC=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif`,fC=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,dC=`#ifdef ALPHATEST
	if ( diffuseColor.a < ALPHATEST ) discard;
#endif`,pC=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
	#endif
#endif`,mC=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,gC="vec3 transformed = vec3( position );",vC=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,yC=`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	return vec2( -1.04, 1.04 ) * a004 + r.zw;
}
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
#else
	if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
		return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
	}
	return 1.0;
#endif
}
vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
	float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
	return ( 1.0 - specularColor ) * fresnel + specularColor;
}
vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
	float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
	vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
	return Fr * fresnel + F0;
}
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	return 1.0 / ( gl * gv );
}
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( incidentLight.direction + viewDir );
	float dotNL = saturate( dot( normal, incidentLight.direction ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
	vec3 F = F_Schlick( specularColor, dotLH );
	float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
	float D = D_GGX( alpha, dotNH );
	return F * ( G * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
	return specularColor * brdf.x + brdf.y;
}
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
	float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
	vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
	vec3 FssEss = F * brdf.x + brdf.y;
	float Ess = brdf.x + brdf.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
	float dotNH = saturate( dot( geometry.normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
	vec3 F = F_Schlick( specularColor, dotLH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
}
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
	return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
}
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
	return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
}
#if defined( USE_SHEEN )
float D_Charlie(float roughness, float NoH) {
	float invAlpha = 1.0 / roughness;
	float cos2h = NoH * NoH;
	float sin2h = max(1.0 - cos2h, 0.0078125);	return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
}
float V_Neubelt(float NoV, float NoL) {
	return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
}
vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
	vec3 N = geometry.normal;
	vec3 V = geometry.viewDir;
	vec3 H = normalize( V + L );
	float dotNH = saturate( dot( N, H ) );
	return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
}
#endif`,xC=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vUv );
		vec2 dSTdy = dFdy( vUv );
		float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
		vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
		vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 );
		fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,_C=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#pragma unroll_loop_start
	for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
		plane = clippingPlanes[ i ];
		if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
	}
	#pragma unroll_loop_end
	#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
		bool clipped = true;
		#pragma unroll_loop_start
		for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
		}
		#pragma unroll_loop_end
		if ( clipped ) discard;
	#endif
#endif`,bC=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,wC=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,MC=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,EC=`#ifdef USE_COLOR
	diffuseColor.rgb *= vColor;
#endif`,SC=`#ifdef USE_COLOR
	varying vec3 vColor;
#endif`,TC=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	varying vec3 vColor;
#endif`,AC=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor.xyz *= color.xyz;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif`,CC=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate(a) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement(a) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract(sin(sn) * c);
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
struct GeometricContext {
	vec3 position;
	vec3 normal;
	vec3 viewDir;
#ifdef CLEARCOAT
	vec3 clearcoatNormal;
#endif
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
	float distance = dot( planeNormal, point - pointOnPlane );
	return - distance * planeNormal + point;
}
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
	return sign( dot( point - pointOnPlane, planeNormal ) );
}
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
	return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
float linearToRelativeLuminance( const in vec3 color ) {
	vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
	return dot( weights, color.rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}`,RC=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_maxMipLevel 8.0
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_maxTileSize 256.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
		vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );
		vec2 f = fract( uv );
		uv += 0.5 - f;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		if ( mipInt < cubeUV_maxMipLevel ) {
			uv.y += 2.0 * cubeUV_maxTileSize;
		}
		uv.y += filterInt * 2.0 * cubeUV_minTileSize;
		uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
		uv *= texelSize;
		vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.x += texelSize;
		vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.y += texelSize;
		vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.x -= texelSize;
		vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		vec3 tm = mix( tl, tr, f.x );
		vec3 bm = mix( bl, br, f.x );
		return mix( tm, bm, f.y );
	}
	#define r0 1.0
	#define v0 0.339
	#define m0 - 2.0
	#define r1 0.8
	#define v1 0.276
	#define m1 - 1.0
	#define r4 0.4
	#define v4 0.046
	#define m4 2.0
	#define r5 0.305
	#define v5 0.016
	#define m5 3.0
	#define r6 0.21
	#define v6 0.0038
	#define m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= r1 ) {
			mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
		} else if ( roughness >= r4 ) {
			mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
		} else if ( roughness >= r5 ) {
			mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
		} else if ( roughness >= r6 ) {
			mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,PC=`vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
	mat3 m = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
	transformedNormal = m * transformedNormal;
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,LC=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,FC=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif`,IC=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vUv );
	emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,DC=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,BC="gl_FragColor = linearToOutputTexel( gl_FragColor );",OC=`
vec4 LinearToLinear( in vec4 value ) {
	return value;
}
vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
}
vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
}
vec4 sRGBToLinear( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 LinearTosRGB( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
vec4 RGBEToLinear( in vec4 value ) {
	return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
}
vec4 LinearToRGBE( in vec4 value ) {
	float maxComponent = max( max( value.r, value.g ), value.b );
	float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
	return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
}
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * value.a * maxRange, 1.0 );
}
vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
	M = ceil( M * 255.0 ) / 255.0;
	return vec4( value.rgb / ( M * maxRange ), M );
}
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
}
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float D = max( maxRange / maxRGB, 1.0 );
	D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
	return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
}
const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
vec4 LinearToLogLuv( in vec4 value ) {
	vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
	Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
	vec4 vResult;
	vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
	float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
	vResult.w = fract( Le );
	vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
	return vResult;
}
const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
vec4 LogLuvToLinear( in vec4 value ) {
	float Le = value.z * 255.0 + value.w;
	vec3 Xp_Y_XYZp;
	Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
	Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
	Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
	vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
	return vec4( max( vRGB, 0.0 ), 1.0 );
}`,UC=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifndef ENVMAP_TYPE_CUBE_UV
		envColor = envMapTexelToLinear( envColor );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,NC=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform int maxMipLevel;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,GC=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,kC=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,HC=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,zC=`#ifdef USE_FOG
	fogDepth = - mvPosition.z;
#endif`,VC=`#ifdef USE_FOG
	varying float fogDepth;
#endif`,WC=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,jC=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float fogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,qC=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return texture2D( gradientMap, coord ).rgb;
	#else
		return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
	#endif
}`,XC=`#ifdef USE_LIGHTMAP
	vec4 lightMapTexel= texture2D( lightMap, vUv2 );
	reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
#endif`,YC=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,$C=`vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
	vLightBack = vec3( 0.0 );
	vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry );
#ifdef DOUBLE_SIDED
	vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
	vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );
#endif
#if NUM_POINT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_HEMI_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
		vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
		#ifdef DOUBLE_SIDED
			vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
		#endif
	}
	#pragma unroll_loop_end
#endif`,ZC=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
	vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	return irradiance;
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		directLight.color = directionalLight.color;
		directLight.direction = directionalLight.direction;
		directLight.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		vec3 lVector = pointLight.position - geometry.position;
		directLight.direction = normalize( lVector );
		float lightDistance = length( lVector );
		directLight.color = pointLight.color;
		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
		directLight.visible = ( directLight.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		vec3 lVector = spotLight.position - geometry.position;
		directLight.direction = normalize( lVector );
		float lightDistance = length( lVector );
		float angleCos = dot( directLight.direction, spotLight.direction );
		if ( angleCos > spotLight.coneCos ) {
			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
			directLight.color = spotLight.color;
			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
			directLight.visible = true;
		} else {
			directLight.color = vec3( 0.0 );
			directLight.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
		float dotNL = dot( geometry.normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			irradiance *= PI;
		#endif
		return irradiance;
	}
#endif`,JC=`#if defined( USE_ENVMAP )
	#ifdef ENVMAP_MODE_REFRACTION
		uniform float refractionRatio;
	#endif
	vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
		vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
		#ifdef ENVMAP_TYPE_CUBE
			vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
			#ifdef TEXTURE_LOD_EXT
				vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
			#else
				vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
			#endif
			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
		#elif defined( ENVMAP_TYPE_CUBE_UV )
			vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
		#else
			vec4 envMapColor = vec4( 0.0 );
		#endif
		return PI * envMapColor.rgb * envMapIntensity;
	}
	float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
		float maxMIPLevelScalar = float( maxMIPLevel );
		float sigma = PI * roughness * roughness / ( 1.0 + roughness );
		float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
		return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
	}
	vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( -viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
		#else
			vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
		#endif
		reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
		float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
		#ifdef ENVMAP_TYPE_CUBE
			vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
			#ifdef TEXTURE_LOD_EXT
				vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
			#else
				vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
			#endif
			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
		#elif defined( ENVMAP_TYPE_CUBE_UV )
			vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
		#endif
		return envMapColor.rgb * envMapIntensity;
	}
#endif`,QC=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,KC=`varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon
#define Material_LightProbeLOD( material )	(0)`,eR=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,tR=`varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong
#define Material_LightProbeLOD( material )	(0)`,nR=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
material.specularRoughness = min( material.specularRoughness, 1.0 );
#ifdef REFLECTIVITY
	material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
#endif
#ifdef CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheen;
#endif`,rR=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float specularRoughness;
	vec3 specularColor;
#ifdef CLEARCOAT
	float clearcoat;
	float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
	vec3 sheenColor;
#endif
};
#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
#define DEFAULT_SPECULAR_COEFFICIENT 0.04
float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
	return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometry.normal;
		vec3 viewDir = geometry.viewDir;
		vec3 position = geometry.position;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.specularRoughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	#ifdef CLEARCOAT
		float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = ccDotNL * directLight.color;
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			ccIrradiance *= PI;
		#endif
		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
		reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
	#else
		float clearcoatDHR = 0.0;
	#endif
	#ifdef USE_SHEEN
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
			material.specularRoughness,
			directLight.direction,
			geometry,
			material.sheenColor
		);
	#else
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
	#endif
	reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef CLEARCOAT
		float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
		reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
		float ccDotNL = ccDotNV;
		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
	#else
		float clearcoatDHR = 0.0;
	#endif
	float clearcoatInv = 1.0 - clearcoatDHR;
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
	reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,iR=`
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef CLEARCOAT
	geometry.clearcoatNormal = clearcoatNormal;
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointDirectLightIrradiance( pointLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotDirectLightIrradiance( spotLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	irradiance += getLightProbeIrradiance( lightProbe, geometry );
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,oR=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			lightMapIrradiance *= PI;
		#endif
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
	#ifdef CLEARCOAT
		clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
	#endif
#endif`,sR=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif`,aR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,cR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,lR=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		varying float vFragDepth;
		varying float vIsPerspective;
	#else
		uniform float logDepthBufFC;
	#endif
#endif`,uR=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		vFragDepth = 1.0 + gl_Position.w;
		vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
	#else
		if ( isPerspectiveMatrix( projectionMatrix ) ) {
			gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
			gl_Position.z *= gl_Position.w;
		}
	#endif
#endif`,hR=`#ifdef USE_MAP
	vec4 texelColor = texture2D( map, vUv );
	texelColor = mapTexelToLinear( texelColor );
	diffuseColor *= texelColor;
#endif`,fR=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,dR=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
	vec4 mapTexel = texture2D( map, uv );
	diffuseColor *= mapTexelToLinear( mapTexel );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,pR=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,mR=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vUv );
	metalnessFactor *= texelMetalness.b;
#endif`,gR=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,vR=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
	objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
	objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
	objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
#endif`,yR=`#ifdef USE_MORPHTARGETS
	uniform float morphTargetBaseInfluence;
	#ifndef USE_MORPHNORMALS
		uniform float morphTargetInfluences[ 8 ];
	#else
		uniform float morphTargetInfluences[ 4 ];
	#endif
#endif`,xR=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	transformed += morphTarget0 * morphTargetInfluences[ 0 ];
	transformed += morphTarget1 * morphTargetInfluences[ 1 ];
	transformed += morphTarget2 * morphTargetInfluences[ 2 ];
	transformed += morphTarget3 * morphTargetInfluences[ 3 ];
	#ifndef USE_MORPHNORMALS
		transformed += morphTarget4 * morphTargetInfluences[ 4 ];
		transformed += morphTarget5 * morphTargetInfluences[ 5 ];
		transformed += morphTarget6 * morphTargetInfluences[ 6 ];
		transformed += morphTarget7 * morphTargetInfluences[ 7 ];
	#endif
#endif`,_R=`#ifdef FLAT_SHADED
	vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
	vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
	#endif
	#ifdef USE_TANGENT
		vec3 tangent = normalize( vTangent );
		vec3 bitangent = normalize( vBitangent );
		#ifdef DOUBLE_SIDED
			tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
			bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		#endif
		#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
			mat3 vTBN = mat3( tangent, bitangent, normal );
		#endif
	#endif
#endif
vec3 geometryNormal = normal;`,bR=`#ifdef OBJECTSPACE_NORMALMAP
	normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( TANGENTSPACE_NORMALMAP )
	vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	#ifdef USE_TANGENT
		normal = normalize( vTBN * mapN );
	#else
		normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
	#endif
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
#endif`,wR=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef OBJECTSPACE_NORMALMAP
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
	vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
		vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
		vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
		vec2 st0 = dFdx( vUv.st );
		vec2 st1 = dFdy( vUv.st );
		float scale = sign( st1.t * st0.s - st0.t * st1.s );
		vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
		vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
		vec3 N = normalize( surf_norm );
		mat3 tsn = mat3( S, T, N );
		mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		return normalize( tsn * mapN );
	}
#endif`,MR=`#ifdef CLEARCOAT
	vec3 clearcoatNormal = geometryNormal;
#endif`,ER=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	#ifdef USE_TANGENT
		clearcoatNormal = normalize( vTBN * clearcoatMapN );
	#else
		clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
	#endif
#endif`,SR=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif`,TR=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}
vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
	return linearClipZ * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * invClipZ - far );
}`,AR=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,CR=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,RR=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,PR=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,LR=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vUv );
	roughnessFactor *= texelRoughness.g;
#endif`,FR=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,IR=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
		bool inFrustum = all( inFrustumVec );
		bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
		bool frustumTest = all( frustumTestVec );
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return shadow;
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
		vec3 lightToPosition = shadowCoord.xyz;
		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );		dp += shadowBias;
		vec3 bd3D = normalize( lightToPosition );
		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
			return (
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
			) * ( 1.0 / 9.0 );
		#else
			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
		#endif
	}
#endif`,DR=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,BR=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
		vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		vec4 shadowWorldPosition;
	#endif
	#if NUM_DIR_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
		vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
		vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
		vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
#endif`,OR=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,UR=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,NR=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	#ifdef BONE_TEXTURE
		uniform highp sampler2D boneTexture;
		uniform int boneTextureSize;
		mat4 getBoneMatrix( const in float i ) {
			float j = i * 4.0;
			float x = mod( j, float( boneTextureSize ) );
			float y = floor( j / float( boneTextureSize ) );
			float dx = 1.0 / float( boneTextureSize );
			float dy = 1.0 / float( boneTextureSize );
			y = dy * ( y + 0.5 );
			vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
			vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
			vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
			vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
			mat4 bone = mat4( v1, v2, v3, v4 );
			return bone;
		}
	#else
		uniform mat4 boneMatrices[ MAX_BONES ];
		mat4 getBoneMatrix( const in float i ) {
			mat4 bone = boneMatrices[ int(i) ];
			return bone;
		}
	#endif
#endif`,GR=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,kR=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,HR=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,zR=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,VR=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,WR=`#ifndef saturate
#define saturate(a) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return toneMappingExposure * color;
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,jR=`#ifdef USE_TRANSMISSIONMAP
	totalTransmission *= texture2D( transmissionMap, vUv ).r;
#endif`,qR=`#ifdef USE_TRANSMISSIONMAP
	uniform sampler2D transmissionMap;
#endif`,XR=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
	varying vec2 vUv;
#endif`,YR=`#ifdef USE_UV
	#ifdef UVS_VERTEX_ONLY
		vec2 vUv;
	#else
		varying vec2 vUv;
	#endif
	uniform mat3 uvTransform;
#endif`,$R=`#ifdef USE_UV
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif`,ZR=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	varying vec2 vUv2;
#endif`,JR=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	attribute vec2 uv2;
	varying vec2 vUv2;
	uniform mat3 uv2Transform;
#endif`,QR=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif`,KR=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,eP=`uniform sampler2D t2D;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	gl_FragColor = mapTexelToLinear( texColor );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,tP=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,nP=`#include <envmap_common_pars_fragment>
uniform float opacity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	vec3 vReflect = vWorldDirection;
	#include <envmap_fragment>
	gl_FragColor = envColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,rP=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,iP=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#endif
}`,oP=`#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,sP=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,aP=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,cP=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	vec4 texColor = texture2D( tEquirect, sampleUV );
	gl_FragColor = mapTexelToLinear( texColor );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,lP=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,uP=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,hP=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,fP=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
	
		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,dP=`#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <skinbase_vertex>
	#ifdef USE_ENVMAP
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,pP=`uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <emissivemap_fragment>
	#ifdef DOUBLE_SIDED
		reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
	#else
		reflectedLight.indirectDiffuse += vIndirectFront;
	#endif
	#include <lightmap_fragment>
	reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
	#ifdef DOUBLE_SIDED
		reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
	#else
		reflectedLight.directDiffuse = vLightFront;
	#endif
	reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,mP=`#define LAMBERT
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <lights_lambert_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,gP=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <fog_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
		matcapColor = matcapTexelToLinear( matcapColor );
	#else
		vec4 matcapColor = vec4( 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,vP=`#define MATCAP
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#ifndef FLAT_SHADED
		vNormal = normalize( transformedNormal );
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,yP=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,xP=`#define TOON
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,_P=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,bP=`#define PHONG
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,wP=`#define STANDARD
#ifdef PHYSICAL
	#define REFLECTIVITY
	#define CLEARCOAT
	#define TRANSMISSION
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef TRANSMISSION
	uniform float transmission;
#endif
#ifdef REFLECTIVITY
	uniform float reflectivity;
#endif
#ifdef CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheen;
#endif
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <transmissionmap_pars_fragment>
#include <bsdfs>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <lights_physical_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#ifdef TRANSMISSION
		float totalTransmission = transmission;
	#endif
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <transmissionmap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#ifdef TRANSMISSION
		diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );
	#endif
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,MP=`#define STANDARD
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,EP=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <packing>
#include <uv_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
}`,SP=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	vViewPosition = - mvPosition.xyz;
#endif
}`,TP=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,AP=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,CP=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,RP=`#include <common>
#include <fog_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <begin_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,PP=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,LP=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,xt={alphamap_fragment:hC,alphamap_pars_fragment:fC,alphatest_fragment:dC,aomap_fragment:pC,aomap_pars_fragment:mC,begin_vertex:gC,beginnormal_vertex:vC,bsdfs:yC,bumpmap_pars_fragment:xC,clipping_planes_fragment:_C,clipping_planes_pars_fragment:bC,clipping_planes_pars_vertex:wC,clipping_planes_vertex:MC,color_fragment:EC,color_pars_fragment:SC,color_pars_vertex:TC,color_vertex:AC,common:CC,cube_uv_reflection_fragment:RC,defaultnormal_vertex:PC,displacementmap_pars_vertex:LC,displacementmap_vertex:FC,emissivemap_fragment:IC,emissivemap_pars_fragment:DC,encodings_fragment:BC,encodings_pars_fragment:OC,envmap_fragment:UC,envmap_common_pars_fragment:NC,envmap_pars_fragment:GC,envmap_pars_vertex:kC,envmap_physical_pars_fragment:JC,envmap_vertex:HC,fog_vertex:zC,fog_pars_vertex:VC,fog_fragment:WC,fog_pars_fragment:jC,gradientmap_pars_fragment:qC,lightmap_fragment:XC,lightmap_pars_fragment:YC,lights_lambert_vertex:$C,lights_pars_begin:ZC,lights_toon_fragment:QC,lights_toon_pars_fragment:KC,lights_phong_fragment:eR,lights_phong_pars_fragment:tR,lights_physical_fragment:nR,lights_physical_pars_fragment:rR,lights_fragment_begin:iR,lights_fragment_maps:oR,lights_fragment_end:sR,logdepthbuf_fragment:aR,logdepthbuf_pars_fragment:cR,logdepthbuf_pars_vertex:lR,logdepthbuf_vertex:uR,map_fragment:hR,map_pars_fragment:fR,map_particle_fragment:dR,map_particle_pars_fragment:pR,metalnessmap_fragment:mR,metalnessmap_pars_fragment:gR,morphnormal_vertex:vR,morphtarget_pars_vertex:yR,morphtarget_vertex:xR,normal_fragment_begin:_R,normal_fragment_maps:bR,normalmap_pars_fragment:wR,clearcoat_normal_fragment_begin:MR,clearcoat_normal_fragment_maps:ER,clearcoat_pars_fragment:SR,packing:TR,premultiplied_alpha_fragment:AR,project_vertex:CR,dithering_fragment:RR,dithering_pars_fragment:PR,roughnessmap_fragment:LR,roughnessmap_pars_fragment:FR,shadowmap_pars_fragment:IR,shadowmap_pars_vertex:DR,shadowmap_vertex:BR,shadowmask_pars_fragment:OR,skinbase_vertex:UR,skinning_pars_vertex:NR,skinning_vertex:GR,skinnormal_vertex:kR,specularmap_fragment:HR,specularmap_pars_fragment:zR,tonemapping_fragment:VR,tonemapping_pars_fragment:WR,transmissionmap_fragment:jR,transmissionmap_pars_fragment:qR,uv_pars_fragment:XR,uv_pars_vertex:YR,uv_vertex:$R,uv2_pars_fragment:ZR,uv2_pars_vertex:JR,uv2_vertex:QR,worldpos_vertex:KR,background_frag:eP,background_vert:tP,cube_frag:nP,cube_vert:rP,depth_frag:iP,depth_vert:oP,distanceRGBA_frag:sP,distanceRGBA_vert:aP,equirect_frag:cP,equirect_vert:lP,linedashed_frag:uP,linedashed_vert:hP,meshbasic_frag:fP,meshbasic_vert:dP,meshlambert_frag:pP,meshlambert_vert:mP,meshmatcap_frag:gP,meshmatcap_vert:vP,meshtoon_frag:yP,meshtoon_vert:xP,meshphong_frag:_P,meshphong_vert:bP,meshphysical_frag:wP,meshphysical_vert:MP,normal_frag:EP,normal_vert:SP,points_frag:TP,points_vert:AP,shadow_frag:CP,shadow_vert:RP,sprite_frag:PP,sprite_vert:LP},He={common:{diffuse:{value:new We(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Fn},uv2Transform:{value:new Fn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new We(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Fn}},sprite:{diffuse:{value:new We(15658734)},opacity:{value:1},center:{value:new fe(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Fn}}},di={basic:{uniforms:Ln([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.fog]),vertexShader:xt.meshbasic_vert,fragmentShader:xt.meshbasic_frag},lambert:{uniforms:Ln([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.fog,He.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshlambert_vert,fragmentShader:xt.meshlambert_frag},phong:{uniforms:Ln([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.fog,He.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30}}]),vertexShader:xt.meshphong_vert,fragmentShader:xt.meshphong_frag},standard:{uniforms:Ln([He.common,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.roughnessmap,He.metalnessmap,He.fog,He.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag},toon:{uniforms:Ln([He.common,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.gradientmap,He.fog,He.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshtoon_vert,fragmentShader:xt.meshtoon_frag},matcap:{uniforms:Ln([He.common,He.bumpmap,He.normalmap,He.displacementmap,He.fog,{matcap:{value:null}}]),vertexShader:xt.meshmatcap_vert,fragmentShader:xt.meshmatcap_frag},points:{uniforms:Ln([He.points,He.fog]),vertexShader:xt.points_vert,fragmentShader:xt.points_frag},dashed:{uniforms:Ln([He.common,He.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xt.linedashed_vert,fragmentShader:xt.linedashed_frag},depth:{uniforms:Ln([He.common,He.displacementmap]),vertexShader:xt.depth_vert,fragmentShader:xt.depth_frag},normal:{uniforms:Ln([He.common,He.bumpmap,He.normalmap,He.displacementmap,{opacity:{value:1}}]),vertexShader:xt.normal_vert,fragmentShader:xt.normal_frag},sprite:{uniforms:Ln([He.sprite,He.fog]),vertexShader:xt.sprite_vert,fragmentShader:xt.sprite_frag},background:{uniforms:{uvTransform:{value:new Fn},t2D:{value:null}},vertexShader:xt.background_vert,fragmentShader:xt.background_frag},cube:{uniforms:Ln([He.envmap,{opacity:{value:1}}]),vertexShader:xt.cube_vert,fragmentShader:xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xt.equirect_vert,fragmentShader:xt.equirect_frag},distanceRGBA:{uniforms:Ln([He.common,He.displacementmap,{referencePosition:{value:new W},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xt.distanceRGBA_vert,fragmentShader:xt.distanceRGBA_frag},shadow:{uniforms:Ln([He.lights,He.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:xt.shadow_vert,fragmentShader:xt.shadow_frag}};di.physical={uniforms:Ln([di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new fe(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new We(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag};function FP(t,e,n,r,o){let a=new We(0),c=0,l,u,h=null,d=0,f=null;function p(v,x,b,y){let g=x.isScene===!0?x.background:null;g&&g.isTexture&&(g=e.get(g));let M=t.xr,C=M.getSession&&M.getSession();C&&C.environmentBlendMode==="additive"&&(g=null),g===null?m(a,c):g&&g.isColor&&(m(g,1),y=!0),(t.autoClear||y)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),g&&(g.isCubeTexture||g.isWebGLCubeRenderTarget||g.mapping===Pg)?(u===void 0&&(u=new Wt(new ff(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:$a(di.cube.uniforms),vertexShader:di.cube.vertexShader,fragmentShader:di.cube.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,w,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),g.isWebGLCubeRenderTarget&&(g=g.texture),u.material.uniforms.envMap.value=g,u.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g._needsFlipEnvMap?-1:1,(h!==g||d!==g.version||f!==t.toneMapping)&&(u.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),v.unshift(u,u.geometry,u.material,0,0,null)):g&&g.isTexture&&(l===void 0&&(l=new Wt(new df(2,2),new In({name:"BackgroundMaterial",uniforms:$a(di.background.uniforms),vertexShader:di.background.vertexShader,fragmentShader:di.background.fragmentShader,side:Sf,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=g,g.matrixAutoUpdate===!0&&g.updateMatrix(),l.material.uniforms.uvTransform.value.copy(g.matrix),(h!==g||d!==g.version||f!==t.toneMapping)&&(l.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),v.unshift(l,l.geometry,l.material,0,0,null))}function m(v,x){n.buffers.color.setClear(v.r,v.g,v.b,x,o)}return{getClearColor:function(){return a},setClearColor:function(v,x){a.set(v),c=x!==void 0?x:1,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,m(a,c)},render:p}}function IP(t,e,n,r){let o=t.getParameter(34921),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),c=r.isWebGL2||a!==null,l={},u=x(null),h=u;function d(G,z,D,B,q){let $=!1;if(c){let ce=v(B,D,z);h!==ce&&(h=ce,p(h.object)),$=b(B,q),$&&y(B,q)}else{let ce=z.wireframe===!0;(h.geometry!==B.id||h.program!==D.id||h.wireframe!==ce)&&(h.geometry=B.id,h.program=D.id,h.wireframe=ce,$=!0)}G.isInstancedMesh===!0&&($=!0),q!==null&&n.update(q,34963),$&&(F(G,z,D,B),q!==null&&t.bindBuffer(34963,n.get(q).buffer))}function f(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(G){return r.isWebGL2?t.bindVertexArray(G):a.bindVertexArrayOES(G)}function m(G){return r.isWebGL2?t.deleteVertexArray(G):a.deleteVertexArrayOES(G)}function v(G,z,D){let B=D.wireframe===!0,q=l[G.id];q===void 0&&(q={},l[G.id]=q);let $=q[z.id];$===void 0&&($={},q[z.id]=$);let ce=$[B];return ce===void 0&&(ce=x(f()),$[B]=ce),ce}function x(G){let z=[],D=[],B=[];for(let q=0;q<o;q++)z[q]=0,D[q]=0,B[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:D,attributeDivisors:B,object:G,attributes:{},index:null}}function b(G,z){let D=h.attributes,B=G.attributes;if(Object.keys(D).length!==Object.keys(B).length)return!0;for(let q in B){let $=D[q],ce=B[q];if($===void 0||$.attribute!==ce||$.data!==ce.data)return!0}return h.index!==z}function y(G,z){let D={},B=G.attributes;for(let q in B){let $=B[q],ce={};ce.attribute=$,$.data&&(ce.data=$.data),D[q]=ce}h.attributes=D,h.index=z}function g(){let G=h.newAttributes;for(let z=0,D=G.length;z<D;z++)G[z]=0}function M(G){C(G,0)}function C(G,z){let D=h.newAttributes,B=h.enabledAttributes,q=h.attributeDivisors;D[G]=1,B[G]===0&&(t.enableVertexAttribArray(G),B[G]=1),q[G]!==z&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](G,z),q[G]=z)}function E(){let G=h.newAttributes,z=h.enabledAttributes;for(let D=0,B=z.length;D<B;D++)z[D]!==G[D]&&(t.disableVertexAttribArray(D),z[D]=0)}function w(G,z,D,B,q,$){r.isWebGL2===!0&&(D===5124||D===5125)?t.vertexAttribIPointer(G,z,D,q,$):t.vertexAttribPointer(G,z,D,B,q,$)}function F(G,z,D,B){if(r.isWebGL2===!1&&(G.isInstancedMesh||B.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;g();let q=B.attributes,$=D.getAttributes(),ce=z.defaultAttributeValues;for(let ge in $){let he=$[ge];if(he>=0){let Pe=q[ge];if(Pe!==void 0){let Fe=Pe.normalized,st=Pe.itemSize,V=n.get(Pe);if(V===void 0)continue;let _t=V.buffer,we=V.type,Ve=V.bytesPerElement;if(Pe.isInterleavedBufferAttribute){let Ce=Pe.data,$e=Ce.stride,Ie=Pe.offset;Ce&&Ce.isInstancedInterleavedBuffer?(C(he,Ce.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=Ce.meshPerAttribute*Ce.count)):M(he),t.bindBuffer(34962,_t),w(he,st,we,Fe,$e*Ve,Ie*Ve)}else Pe.isInstancedBufferAttribute?(C(he,Pe.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=Pe.meshPerAttribute*Pe.count)):M(he),t.bindBuffer(34962,_t),w(he,st,we,Fe,0,0)}else if(ge==="instanceMatrix"){let Fe=n.get(G.instanceMatrix);if(Fe===void 0)continue;let st=Fe.buffer,V=Fe.type;C(he+0,1),C(he+1,1),C(he+2,1),C(he+3,1),t.bindBuffer(34962,st),t.vertexAttribPointer(he+0,4,V,!1,64,0),t.vertexAttribPointer(he+1,4,V,!1,64,16),t.vertexAttribPointer(he+2,4,V,!1,64,32),t.vertexAttribPointer(he+3,4,V,!1,64,48)}else if(ge==="instanceColor"){let Fe=n.get(G.instanceColor);if(Fe===void 0)continue;let st=Fe.buffer,V=Fe.type;C(he,1),t.bindBuffer(34962,st),t.vertexAttribPointer(he,3,V,!1,12,0)}else if(ce!==void 0){let Fe=ce[ge];if(Fe!==void 0)switch(Fe.length){case 2:t.vertexAttrib2fv(he,Fe);break;case 3:t.vertexAttrib3fv(he,Fe);break;case 4:t.vertexAttrib4fv(he,Fe);break;default:t.vertexAttrib1fv(he,Fe)}}}}E()}function H(){L();for(let G in l){let z=l[G];for(let D in z){let B=z[D];for(let q in B)m(B[q].object),delete B[q];delete z[D]}delete l[G]}}function ne(G){if(l[G.id]===void 0)return;let z=l[G.id];for(let D in z){let B=z[D];for(let q in B)m(B[q].object),delete B[q];delete z[D]}delete l[G.id]}function Y(G){for(let z in l){let D=l[z];if(D[G.id]===void 0)continue;let B=D[G.id];for(let q in B)m(B[q].object),delete B[q];delete D[G.id]}}function L(){N(),h!==u&&(h=u,p(h.object))}function N(){u.geometry=null,u.program=null,u.wireframe=!1}return{setup:d,reset:L,resetDefaultState:N,dispose:H,releaseStatesOfGeometry:ne,releaseStatesOfProgram:Y,initAttributes:g,enableAttribute:M,disableUnusedAttributes:E}}function DP(t,e,n,r){let o=r.isWebGL2,a;function c(h){a=h}function l(h,d){t.drawArrays(a,h,d),n.update(d,a,1)}function u(h,d,f){if(f===0)return;let p,m;if(o)p=t,m="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[m](a,h,d,f),n.update(d,a,f)}this.setMode=c,this.render=l,this.renderInstances=u}function BP(t,e,n){let r;function o(){if(r!==void 0)return r;let w=e.get("EXT_texture_filter_anisotropic");return w!==null?r=t.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT):r=0,r}function a(w){if(w==="highp"){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";w="mediump"}return w==="mediump"&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let c=typeof WebGL2RenderingContext!="undefined"&&t instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&t instanceof WebGL2ComputeRenderingContext,l=n.precision!==void 0?n.precision:"highp",u=a(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=n.logarithmicDepthBuffer===!0,d=t.getParameter(34930),f=t.getParameter(35660),p=t.getParameter(3379),m=t.getParameter(34076),v=t.getParameter(34921),x=t.getParameter(36347),b=t.getParameter(36348),y=t.getParameter(36349),g=f>0,M=c||!!e.get("OES_texture_float"),C=g&&M,E=c?t.getParameter(36183):0;return{isWebGL2:c,getMaxAnisotropy:o,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:v,maxVertexUniforms:x,maxVaryings:b,maxFragmentUniforms:y,vertexTextures:g,floatFragmentTextures:M,floatVertexTextures:C,maxSamples:E}}function OP(t){let e=this,n=null,r=0,o=!1,a=!1,c=new qr,l=new Fn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p,m){let v=f.length!==0||p||r!==0||o;return o=p,n=d(f,m,0),r=f.length,v},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1,h()},this.setState=function(f,p,m){let v=f.clippingPlanes,x=f.clipIntersection,b=f.clipShadows,y=t.get(f);if(!o||v===null||v.length===0||a&&!b)a?d(null):h();else{let g=a?0:r,M=g*4,C=y.clippingState||null;u.value=C,C=d(v,p,M,m);for(let E=0;E!==M;++E)C[E]=n[E];y.clippingState=C,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=g}};function h(){u.value!==n&&(u.value=n,u.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,m,v){let x=f!==null?f.length:0,b=null;if(x!==0){if(b=u.value,v!==!0||b===null){let y=m+x*4,g=p.matrixWorldInverse;l.getNormalMatrix(g),(b===null||b.length<y)&&(b=new Float32Array(y));for(let M=0,C=m;M!==x;++M,C+=4)c.copy(f[M]).applyMatrix4(g,l),c.normal.toArray(b,C),b[C+3]=c.constant}u.value=b,u.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,b}}function UP(t){let e=new WeakMap;function n(c,l){return l===ix?c.mapping=Cg:l===ox&&(c.mapping=Rg),c}function r(c){if(c&&c.isTexture){let l=c.mapping;if(l===ix||l===ox)if(e.has(c)){let u=e.get(c).texture;return n(u,c.mapping)}else{let u=c.image;if(u&&u.height>0){let h=t.getRenderList(),d=t.getRenderTarget(),f=t.getRenderState(),p=new Ts(u.height/2);return p.fromEquirectangularTexture(t,c),e.set(c,p),t.setRenderTarget(d),t.setRenderList(h),t.setRenderState(f),c.addEventListener("dispose",o),n(p.texture,c.mapping)}else return null}}return c}function o(c){let l=c.target;l.removeEventListener("dispose",o);let u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}function NP(t){let e={};return{has:function(n){if(e[n]!==void 0)return e[n]!==null;let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r!==null},get:function(n){return this.has(n)||console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),e[n]}}}function GP(t,e,n,r){let o=new WeakMap,a=new WeakMap;function c(f){let p=f.target,m=o.get(p);m.index!==null&&e.remove(m.index);for(let x in m.attributes)e.remove(m.attributes[x]);p.removeEventListener("dispose",c),o.delete(p);let v=a.get(m);v&&(e.remove(v),a.delete(m)),r.releaseStatesOfGeometry(m),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){let m=o.get(p);return m||(p.addEventListener("dispose",c),p.isBufferGeometry?m=p:p.isGeometry&&(p._bufferGeometry===void 0&&(p._bufferGeometry=new Tt().setFromObject(f)),m=p._bufferGeometry),o.set(p,m),n.memory.geometries++,m)}function u(f){let p=f.attributes;for(let v in p)e.update(p[v],34962);let m=f.morphAttributes;for(let v in m){let x=m[v];for(let b=0,y=x.length;b<y;b++)e.update(x[b],34962)}}function h(f){let p=[],m=f.index,v=f.attributes.position,x=0;if(m!==null){let g=m.array;x=m.version;for(let M=0,C=g.length;M<C;M+=3){let E=g[M+0],w=g[M+1],F=g[M+2];p.push(E,w,w,F,F,E)}}else{let g=v.array;x=v.version;for(let M=0,C=g.length/3-1;M<C;M+=3){let E=M+0,w=M+1,F=M+2;p.push(E,w,w,F,F,E)}}let b=new(j0(p)>65535?Nl:Ul)(p,1);b.version=x;let y=a.get(f);y&&e.remove(y),a.set(f,b)}function d(f){let p=a.get(f);if(p){let m=f.index;m!==null&&p.version<m.version&&h(f)}else h(f);return a.get(f)}return{get:l,update:u,getWireframeAttribute:d}}function kP(t,e,n,r){let o=r.isWebGL2,a;function c(p){a=p}let l,u;function h(p){l=p.type,u=p.bytesPerElement}function d(p,m){t.drawElements(a,m,l,p*u),n.update(m,a,1)}function f(p,m,v){if(v===0)return;let x,b;if(o)x=t,b="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[b](a,m,l,p*u,v),n.update(m,a,v)}this.setMode=c,this.setIndex=h,this.render=d,this.renderInstances=f}function HP(t){let e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,c,l){switch(n.calls++,c){case 4:n.triangles+=l*(a/3);break;case 1:n.lines+=l*(a/2);break;case 3:n.lines+=l*(a-1);break;case 2:n.lines+=l*a;break;case 0:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",c);break}}function o(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:o,update:r}}function zP(t,e){return t[0]-e[0]}function VP(t,e){return Math.abs(e[1])-Math.abs(t[1])}function WP(t){let e={},n=new Float32Array(8),r=[];for(let a=0;a<8;a++)r[a]=[a,0];function o(a,c,l,u){let h=a.morphTargetInfluences,d=h===void 0?0:h.length,f=e[c.id];if(f===void 0){f=[];for(let b=0;b<d;b++)f[b]=[b,0];e[c.id]=f}for(let b=0;b<d;b++){let y=f[b];y[0]=b,y[1]=h[b]}f.sort(VP);for(let b=0;b<8;b++)b<d&&f[b][1]?(r[b][0]=f[b][0],r[b][1]=f[b][1]):(r[b][0]=Number.MAX_SAFE_INTEGER,r[b][1]=0);r.sort(zP);let p=l.morphTargets&&c.morphAttributes.position,m=l.morphNormals&&c.morphAttributes.normal,v=0;for(let b=0;b<8;b++){let y=r[b],g=y[0],M=y[1];g!==Number.MAX_SAFE_INTEGER&&M?(p&&c.getAttribute("morphTarget"+b)!==p[g]&&c.setAttribute("morphTarget"+b,p[g]),m&&c.getAttribute("morphNormal"+b)!==m[g]&&c.setAttribute("morphNormal"+b,m[g]),n[b]=M,v+=M):(p&&c.getAttribute("morphTarget"+b)!==void 0&&c.deleteAttribute("morphTarget"+b),m&&c.getAttribute("morphNormal"+b)!==void 0&&c.deleteAttribute("morphNormal"+b),n[b]=0)}let x=c.morphTargetsRelative?1:1-v;u.getUniforms().setValue(t,"morphTargetBaseInfluence",x),u.getUniforms().setValue(t,"morphTargetInfluences",n)}return{update:o}}function jP(t,e,n,r){let o=new WeakMap;function a(l){let u=r.render.frame,h=l.geometry,d=e.get(l,h);return o.get(d)!==u&&(h.isGeometry&&d.updateFromObject(l),e.update(d),o.set(d,u)),l.isInstancedMesh&&(n.update(l.instanceMatrix,34962),l.instanceColor!==null&&n.update(l.instanceColor,34962)),d}function c(){o=new WeakMap}return{update:a,dispose:c}}function Gl(t,e,n,r){At.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=Hn,this.minFilter=Hn,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Gl.prototype=Object.create(At.prototype);Gl.prototype.constructor=Gl;Gl.prototype.isDataTexture2DArray=!0;function kl(t,e,n,r){At.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=Hn,this.minFilter=Hn,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}kl.prototype=Object.create(At.prototype);kl.prototype.constructor=kl;kl.prototype.isDataTexture3D=!0;var Y0=new At,qP=new Gl,XP=new kl,$0=new ko,Px=[],Lx=[],Fx=new Float32Array(16),Ix=new Float32Array(9),Dx=new Float32Array(4);function cc(t,e,n){let r=t[0];if(r<=0||r>0)return t;let o=e*n,a=Px[o];if(a===void 0&&(a=new Float32Array(o),Px[o]=a),e!==0){r.toArray(a,0);for(let c=1,l=0;c!==e;++c)l+=n,t[c].toArray(a,l)}return a}function Cr(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function cr(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Z0(t,e){let n=Lx[e];n===void 0&&(n=new Int32Array(e),Lx[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function YP(t,e){let n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $P(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Cr(n,e))return;t.uniform2fv(this.addr,e),cr(n,e)}}function ZP(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Cr(n,e))return;t.uniform3fv(this.addr,e),cr(n,e)}}function JP(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Cr(n,e))return;t.uniform4fv(this.addr,e),cr(n,e)}}function QP(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Cr(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),cr(n,e)}else{if(Cr(n,r))return;Dx.set(r),t.uniformMatrix2fv(this.addr,!1,Dx),cr(n,r)}}function KP(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Cr(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),cr(n,e)}else{if(Cr(n,r))return;Ix.set(r),t.uniformMatrix3fv(this.addr,!1,Ix),cr(n,r)}}function eL(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Cr(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),cr(n,e)}else{if(Cr(n,r))return;Fx.set(r),t.uniformMatrix4fv(this.addr,!1,Fx),cr(n,r)}}function tL(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.safeSetTexture2D(e||Y0,o)}function nL(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.setTexture2DArray(e||qP,o)}function rL(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.setTexture3D(e||XP,o)}function iL(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.safeSetTextureCube(e||$0,o)}function oL(t,e){let n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function sL(t,e){let n=this.cache;Cr(n,e)||(t.uniform2iv(this.addr,e),cr(n,e))}function aL(t,e){let n=this.cache;Cr(n,e)||(t.uniform3iv(this.addr,e),cr(n,e))}function cL(t,e){let n=this.cache;Cr(n,e)||(t.uniform4iv(this.addr,e),cr(n,e))}function lL(t,e){let n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function uL(t){switch(t){case 5126:return YP;case 35664:return $P;case 35665:return ZP;case 35666:return JP;case 35674:return QP;case 35675:return KP;case 35676:return eL;case 5124:case 35670:return oL;case 35667:case 35671:return sL;case 35668:case 35672:return aL;case 35669:case 35673:return cL;case 5125:return lL;case 35678:case 36198:case 36298:case 36306:case 35682:return tL;case 35679:case 36299:case 36307:return rL;case 35680:case 36300:case 36308:case 36293:return iL;case 36289:case 36303:case 36311:case 36292:return nL}}function hL(t,e){t.uniform1fv(this.addr,e)}function fL(t,e){t.uniform1iv(this.addr,e)}function dL(t,e){t.uniform2iv(this.addr,e)}function pL(t,e){t.uniform3iv(this.addr,e)}function mL(t,e){t.uniform4iv(this.addr,e)}function gL(t,e){let n=cc(e,this.size,2);t.uniform2fv(this.addr,n)}function vL(t,e){let n=cc(e,this.size,3);t.uniform3fv(this.addr,n)}function yL(t,e){let n=cc(e,this.size,4);t.uniform4fv(this.addr,n)}function xL(t,e){let n=cc(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function _L(t,e){let n=cc(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function bL(t,e){let n=cc(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function wL(t,e,n){let r=e.length,o=Z0(n,r);t.uniform1iv(this.addr,o);for(let a=0;a!==r;++a)n.safeSetTexture2D(e[a]||Y0,o[a])}function ML(t,e,n){let r=e.length,o=Z0(n,r);t.uniform1iv(this.addr,o);for(let a=0;a!==r;++a)n.safeSetTextureCube(e[a]||$0,o[a])}function EL(t){switch(t){case 5126:return hL;case 35664:return gL;case 35665:return vL;case 35666:return yL;case 35674:return xL;case 35675:return _L;case 35676:return bL;case 5124:case 35670:return fL;case 35667:case 35671:return dL;case 35668:case 35672:return pL;case 35669:case 35673:return mL;case 35678:case 36198:case 36298:case 36306:case 35682:return wL;case 35680:case 36300:case 36308:case 36293:return ML}}function SL(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=uL(e.type)}function J0(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=EL(e.type)}J0.prototype.updateCache=function(t){let e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),cr(e,t)};function Q0(t){this.id=t,this.seq=[],this.map={}}Q0.prototype.setValue=function(t,e,n){let r=this.seq;for(let o=0,a=r.length;o!==a;++o){let c=r[o];c.setValue(t,e[c.id],n)}};var Rm=/([\w\d_]+)(\])?(\[|\.)?/g;function Bx(t,e){t.seq.push(e),t.map[e.id]=e}function TL(t,e,n){let r=t.name,o=r.length;for(Rm.lastIndex=0;;){let a=Rm.exec(r),c=Rm.lastIndex,l=a[1],u=a[2]==="]",h=a[3];if(u&&(l=l|0),h===void 0||h==="["&&c+2===o){Bx(n,h===void 0?new SL(l,t,e):new J0(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new Q0(l),Bx(n,f)),n=f}}}function Uo(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,35718);for(let r=0;r<n;++r){let o=t.getActiveUniform(e,r),a=t.getUniformLocation(e,o.name);TL(o,a,this)}}Uo.prototype.setValue=function(t,e,n,r){let o=this.map[e];o!==void 0&&o.setValue(t,n,r)};Uo.prototype.setOptional=function(t,e,n){let r=e[n];r!==void 0&&this.setValue(t,n,r)};Uo.upload=function(t,e,n,r){for(let o=0,a=e.length;o!==a;++o){let c=e[o],l=n[c.id];l.needsUpdate!==!1&&c.setValue(t,l.value,r)}};Uo.seqWithValue=function(t,e){let n=[];for(let r=0,o=t.length;r!==o;++r){let a=t[r];a.id in e&&n.push(a)}return n};function Ox(t,e,n){let r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}var AL=0;function CL(t){let e=t.split(`
`);for(let n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join(`
`)}function K0(t){switch(t){case sc:return["Linear","( value )"];case Dg:return["sRGB","( value )"];case k0:return["RGBE","( value )"];case H0:return["RGBM","( value, 7.0 )"];case z0:return["RGBM","( value, 16.0 )"];case V0:return["RGBD","( value, 256.0 )"];case G0:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case W2:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function Ux(t,e,n){let r=t.getShaderParameter(e,35713),o=t.getShaderInfoLog(e).trim();if(r&&o==="")return"";let a=t.getShaderSource(e);return"THREE.WebGLShader: gl.getShaderInfoLog() "+n+`
`+o+CL(a)}function yl(t,e){let n=K0(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function RL(t,e){let n=K0(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function PL(t,e){let n;switch(e){case VA:n="Linear";break;case WA:n="Reinhard";break;case jA:n="OptimizedCineon";break;case qA:n="ACESFilmic";break;case XA:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function LL(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(El).join(`
`)}function FL(t){let e=[];for(let n in t){let r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
`)}function IL(t,e){let n={},r=t.getProgramParameter(e,35721);for(let o=0;o<r;o++){let c=t.getActiveAttrib(e,o).name;n[c]=t.getAttribLocation(e,c)}return n}function El(t){return t!==""}function Nx(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Gx(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var DL=/^[ \t]*#include +<([\w\d./]+)>/gm;function Xm(t){return t.replace(DL,BL)}function BL(t,e){let n=xt[e];if(n===void 0)throw new Error("Can not resolve #include <"+e+">");return Xm(n)}var OL=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,UL=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function kx(t){return t.replace(UL,e_).replace(OL,NL)}function NL(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),e_(t,e,n,r)}function e_(t,e,n,r){let o="";for(let a=parseInt(e);a<parseInt(n);a++)o+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return o}function Hx(t){let e="precision "+t.precision+` float;
precision `+t.precision+" int;";return t.precision==="highp"?e+=`
#define HIGH_PRECISION`:t.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function kL(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===I0?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===bA?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Ml&&(e="SHADOWMAP_TYPE_VSM"),e}function HL(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Cg:case Rg:e="ENVMAP_TYPE_CUBE";break;case Pg:case Lg:e="ENVMAP_TYPE_CUBE_UV";break}return e}function zL(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Rg:case Lg:e="ENVMAP_MODE_REFRACTION";break}return e}function VL(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case Af:e="ENVMAP_BLENDING_MULTIPLY";break;case HA:e="ENVMAP_BLENDING_MIX";break;case zA:e="ENVMAP_BLENDING_ADD";break}return e}function WL(t,e,n,r){let o=t.getContext(),a=n.defines,c=n.vertexShader,l=n.fragmentShader,u=kL(n),h=HL(n),d=zL(n),f=VL(n),p=t.gammaFactor>0?t.gammaFactor:1,m=n.isWebGL2?"":LL(n),v=FL(a),x=o.createProgram(),b,y,g=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(b=[v].filter(El).join(`
`),b.length>0&&(b+=`
`),y=[m,v].filter(El).join(`
`),y.length>0&&(y+=`
`)):(b=[Hx(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+p,"#define MAX_BONES "+n.maxBones,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 "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+u:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#ifdef USE_COLOR","	attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","	attribute vec3 morphTarget0;","	attribute vec3 morphTarget1;","	attribute vec3 morphTarget2;","	attribute vec3 morphTarget3;","	#ifdef USE_MORPHNORMALS","		attribute vec3 morphNormal0;","		attribute vec3 morphNormal1;","		attribute vec3 morphNormal2;","		attribute vec3 morphNormal3;","	#else","		attribute vec3 morphTarget4;","		attribute vec3 morphTarget5;","		attribute vec3 morphTarget6;","		attribute vec3 morphTarget7;","	#endif","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(El).join(`
`),y=[m,Hx(n),"#define SHADER_NAME "+n.shaderName,v,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+u:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Al?"#define TONE_MAPPING":"",n.toneMapping!==Al?xt.tonemapping_pars_fragment:"",n.toneMapping!==Al?PL("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",xt.encodings_pars_fragment,n.map?yl("mapTexelToLinear",n.mapEncoding):"",n.matcap?yl("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?yl("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?yl("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?yl("lightMapTexelToLinear",n.lightMapEncoding):"",RL("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(El).join(`
`)),c=Xm(c),c=Nx(c,n),c=Gx(c,n),l=Xm(l),l=Nx(l,n),l=Gx(l,n),c=kx(c),l=kx(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(g=`#version 300 es
`,b=["#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+b,y=["#define varying in",n.glslVersion===yx?"":"out highp vec4 pc_fragColor;",n.glslVersion===yx?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+y);let M=g+b+c,C=g+y+l,E=Ox(o,35633,M),w=Ox(o,35632,C);if(o.attachShader(x,E),o.attachShader(x,w),n.index0AttributeName!==void 0?o.bindAttribLocation(x,0,n.index0AttributeName):n.morphTargets===!0&&o.bindAttribLocation(x,0,"position"),o.linkProgram(x),t.debug.checkShaderErrors){let ne=o.getProgramInfoLog(x).trim(),Y=o.getShaderInfoLog(E).trim(),L=o.getShaderInfoLog(w).trim(),N=!0,G=!0;if(o.getProgramParameter(x,35714)===!1){N=!1;let z=Ux(o,E,"vertex"),D=Ux(o,w,"fragment");console.error("THREE.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(x,35715),"gl.getProgramInfoLog",ne,z,D)}else ne!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ne):(Y===""||L==="")&&(G=!1);G&&(this.diagnostics={runnable:N,programLog:ne,vertexShader:{log:Y,prefix:b},fragmentShader:{log:L,prefix:y}})}o.deleteShader(E),o.deleteShader(w);let F;this.getUniforms=function(){return F===void 0&&(F=new Uo(o,x)),F};let H;return this.getAttributes=function(){return H===void 0&&(H=IL(o,x)),H},this.destroy=function(){r.releaseStatesOfProgram(this),o.deleteProgram(x),this.program=void 0},this.name=n.shaderName,this.id=AL++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=E,this.fragmentShader=w,this}function jL(t,e,n,r,o,a){let c=[],l=r.isWebGL2,u=r.logarithmicDepthBuffer,h=r.floatVertexTextures,d=r.maxVertexUniforms,f=r.vertexTextures,p=r.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},v=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function x(w){let H=w.skeleton.bones;if(h)return 1024;{let Y=Math.floor((d-20)/4),L=Math.min(Y,H.length);return L<H.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+H.length+" bones. This GPU supports "+L+"."),0):L}}function b(w){let F;return w?w.isTexture?F=w.encoding:w.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),F=w.texture.encoding):F=sc,F}function y(w,F,H,ne,Y){let L=ne.fog,N=w.isMeshStandardMaterial?ne.environment:null,G=e.get(w.envMap||N),z=m[w.type],D=Y.isSkinnedMesh?x(Y):0;w.precision!==null&&(p=r.getMaxPrecision(w.precision),p!==w.precision&&console.warn("THREE.WebGLProgram.getParameters:",w.precision,"not supported, using",p,"instead."));let B,q;if(z){let ge=di[z];B=ge.vertexShader,q=ge.fragmentShader}else B=w.vertexShader,q=w.fragmentShader;let $=t.getRenderTarget();return{isWebGL2:l,shaderID:z,shaderName:w.type,vertexShader:B,fragmentShader:q,defines:w.defines,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:p,instancing:Y.isInstancedMesh===!0,instancingColor:Y.isInstancedMesh===!0&&Y.instanceColor!==null,supportsVertexTextures:f,outputEncoding:$!==null?b($.texture):t.outputEncoding,map:!!w.map,mapEncoding:b(w.map),matcap:!!w.matcap,matcapEncoding:b(w.matcap),envMap:!!G,envMapMode:G&&G.mapping,envMapEncoding:b(G),envMapCubeUV:!!G&&(G.mapping===Pg||G.mapping===Lg),lightMap:!!w.lightMap,lightMapEncoding:b(w.lightMap),aoMap:!!w.aoMap,emissiveMap:!!w.emissiveMap,emissiveMapEncoding:b(w.emissiveMap),bumpMap:!!w.bumpMap,normalMap:!!w.normalMap,objectSpaceNormalMap:w.normalMapType===X2,tangentSpaceNormalMap:w.normalMapType===ac,clearcoatMap:!!w.clearcoatMap,clearcoatRoughnessMap:!!w.clearcoatRoughnessMap,clearcoatNormalMap:!!w.clearcoatNormalMap,displacementMap:!!w.displacementMap,roughnessMap:!!w.roughnessMap,metalnessMap:!!w.metalnessMap,specularMap:!!w.specularMap,alphaMap:!!w.alphaMap,gradientMap:!!w.gradientMap,sheen:!!w.sheen,transmissionMap:!!w.transmissionMap,combine:w.combine,vertexTangents:w.normalMap&&w.vertexTangents,vertexColors:w.vertexColors,vertexUvs:!!w.map||!!w.bumpMap||!!w.normalMap||!!w.specularMap||!!w.alphaMap||!!w.emissiveMap||!!w.roughnessMap||!!w.metalnessMap||!!w.clearcoatMap||!!w.clearcoatRoughnessMap||!!w.clearcoatNormalMap||!!w.displacementMap||!!w.transmissionMap,uvsVertexOnly:!(w.map||w.bumpMap||w.normalMap||w.specularMap||w.alphaMap||w.emissiveMap||w.roughnessMap||w.metalnessMap||w.clearcoatNormalMap||w.transmissionMap)&&!!w.displacementMap,fog:!!L,useFog:w.fog,fogExp2:L&&L.isFogExp2,flatShading:w.flatShading,sizeAttenuation:w.sizeAttenuation,logarithmicDepthBuffer:u,skinning:w.skinning&&D>0,maxBones:D,useVertexTexture:h,morphTargets:w.morphTargets,morphNormals:w.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:F.directional.length,numPointLights:F.point.length,numSpotLights:F.spot.length,numRectAreaLights:F.rectArea.length,numHemiLights:F.hemi.length,numDirLightShadows:F.directionalShadowMap.length,numPointLightShadows:F.pointShadowMap.length,numSpotLightShadows:F.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:t.shadowMap.enabled&&H.length>0,shadowMapType:t.shadowMap.type,toneMapping:w.toneMapped?t.toneMapping:Al,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:w.premultipliedAlpha,alphaTest:w.alphaTest,doubleSided:w.side===Tf,flipSided:w.side===rn,depthPacking:w.depthPacking!==void 0?w.depthPacking:!1,index0AttributeName:w.index0AttributeName,extensionDerivatives:w.extensions&&w.extensions.derivatives,extensionFragDepth:w.extensions&&w.extensions.fragDepth,extensionDrawBuffers:w.extensions&&w.extensions.drawBuffers,extensionShaderTextureLOD:w.extensions&&w.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:w.customProgramCacheKey()}}function g(w){let F=[];if(w.shaderID?F.push(w.shaderID):(F.push(w.fragmentShader),F.push(w.vertexShader)),w.defines!==void 0)for(let H in w.defines)F.push(H),F.push(w.defines[H]);if(w.isRawShaderMaterial===!1){for(let H=0;H<v.length;H++)F.push(w[v[H]]);F.push(t.outputEncoding),F.push(t.gammaFactor)}return F.push(w.customProgramCacheKey),F.join()}function M(w){let F=m[w.type],H;if(F){let ne=di[F];H=aC.clone(ne.uniforms)}else H=w.uniforms;return H}function C(w,F){let H;for(let ne=0,Y=c.length;ne<Y;ne++){let L=c[ne];if(L.cacheKey===F){H=L,++H.usedTimes;break}}return H===void 0&&(H=new WL(t,F,w,o),c.push(H)),H}function E(w){if(--w.usedTimes===0){let F=c.indexOf(w);c[F]=c[c.length-1],c.pop(),w.destroy()}}return{getParameters:y,getProgramCacheKey:g,getUniforms:M,acquireProgram:C,releaseProgram:E,programs:c}}function qL(){let t=new WeakMap;function e(a){let c=t.get(a);return c===void 0&&(c={},t.set(a,c)),c}function n(a){t.delete(a)}function r(a,c,l){t.get(a)[c]=l}function o(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:o}}function XL(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function YL(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function zx(t){let e=[],n=0,r=[],o=[],a={id:-1};function c(){n=0,r.length=0,o.length=0}function l(p,m,v,x,b,y){let g=e[n],M=t.get(v);return g===void 0?(g={id:p.id,object:p,geometry:m,material:v,program:M.program||a,groupOrder:x,renderOrder:p.renderOrder,z:b,group:y},e[n]=g):(g.id=p.id,g.object=p,g.geometry=m,g.material=v,g.program=M.program||a,g.groupOrder=x,g.renderOrder=p.renderOrder,g.z=b,g.group=y),n++,g}function u(p,m,v,x,b,y){let g=l(p,m,v,x,b,y);(v.transparent===!0?o:r).push(g)}function h(p,m,v,x,b,y){let g=l(p,m,v,x,b,y);(v.transparent===!0?o:r).unshift(g)}function d(p,m){r.length>1&&r.sort(p||XL),o.length>1&&o.sort(m||YL)}function f(){for(let p=n,m=e.length;p<m;p++){let v=e[p];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.program=null,v.group=null}}return{opaque:r,transparent:o,init:c,push:u,unshift:h,finish:f,sort:d}}function $L(t){let e=new WeakMap;function n(o,a){let c=e.get(o),l;return c===void 0?(l=new zx(t),e.set(o,new WeakMap),e.get(o).set(a,l)):(l=c.get(a),l===void 0&&(l=new zx(t),c.set(a,l))),l}function r(){e=new WeakMap}return{get:n,dispose:r}}function ZL(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new W,color:new We};break;case"SpotLight":n={position:new W,direction:new W,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new W,color:new We,distance:0,decay:0};break;case"HemisphereLight":n={direction:new W,skyColor:new We,groundColor:new We};break;case"RectAreaLight":n={color:new We,position:new W,halfWidth:new W,halfHeight:new W};break}return t[e.id]=n,n}}}function JL(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}var QL=0;function KL(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function e3(t,e){let n=new ZL,r=JL(),o={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)o.probe.push(new W);let a=new W,c=new vt,l=new vt;function u(h,d,f){let p=0,m=0,v=0;for(let ne=0;ne<9;ne++)o.probe[ne].set(0,0,0);let x=0,b=0,y=0,g=0,M=0,C=0,E=0,w=0,F=f.matrixWorldInverse;h.sort(KL);for(let ne=0,Y=h.length;ne<Y;ne++){let L=h[ne],N=L.color,G=L.intensity,z=L.distance,D=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)p+=N.r*G,m+=N.g*G,v+=N.b*G;else if(L.isLightProbe)for(let B=0;B<9;B++)o.probe[B].addScaledVector(L.sh.coefficients[B],G);else if(L.isDirectionalLight){let B=n.get(L);if(B.color.copy(L.color).multiplyScalar(L.intensity),B.direction.setFromMatrixPosition(L.matrixWorld),a.setFromMatrixPosition(L.target.matrixWorld),B.direction.sub(a),B.direction.transformDirection(F),L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,o.directionalShadow[x]=$,o.directionalShadowMap[x]=D,o.directionalShadowMatrix[x]=L.shadow.matrix,C++}o.directional[x]=B,x++}else if(L.isSpotLight){let B=n.get(L);if(B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),B.color.copy(N).multiplyScalar(G),B.distance=z,B.direction.setFromMatrixPosition(L.matrixWorld),a.setFromMatrixPosition(L.target.matrixWorld),B.direction.sub(a),B.direction.transformDirection(F),B.coneCos=Math.cos(L.angle),B.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),B.decay=L.decay,L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,o.spotShadow[y]=$,o.spotShadowMap[y]=D,o.spotShadowMatrix[y]=L.shadow.matrix,w++}o.spot[y]=B,y++}else if(L.isRectAreaLight){let B=n.get(L);B.color.copy(N).multiplyScalar(G),B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),l.identity(),c.copy(L.matrixWorld),c.premultiply(F),l.extractRotation(c),B.halfWidth.set(L.width*.5,0,0),B.halfHeight.set(0,L.height*.5,0),B.halfWidth.applyMatrix4(l),B.halfHeight.applyMatrix4(l),o.rectArea[g]=B,g++}else if(L.isPointLight){let B=n.get(L);if(B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),B.color.copy(L.color).multiplyScalar(L.intensity),B.distance=L.distance,B.decay=L.decay,L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,$.shadowCameraNear=q.camera.near,$.shadowCameraFar=q.camera.far,o.pointShadow[b]=$,o.pointShadowMap[b]=D,o.pointShadowMatrix[b]=L.shadow.matrix,E++}o.point[b]=B,b++}else if(L.isHemisphereLight){let B=n.get(L);B.direction.setFromMatrixPosition(L.matrixWorld),B.direction.transformDirection(F),B.direction.normalize(),B.skyColor.copy(L.color).multiplyScalar(G),B.groundColor.copy(L.groundColor).multiplyScalar(G),o.hemi[M]=B,M++}}g>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(o.rectAreaLTC1=He.LTC_FLOAT_1,o.rectAreaLTC2=He.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(o.rectAreaLTC1=He.LTC_HALF_1,o.rectAreaLTC2=He.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),o.ambient[0]=p,o.ambient[1]=m,o.ambient[2]=v;let H=o.hash;(H.directionalLength!==x||H.pointLength!==b||H.spotLength!==y||H.rectAreaLength!==g||H.hemiLength!==M||H.numDirectionalShadows!==C||H.numPointShadows!==E||H.numSpotShadows!==w)&&(o.directional.length=x,o.spot.length=y,o.rectArea.length=g,o.point.length=b,o.hemi.length=M,o.directionalShadow.length=C,o.directionalShadowMap.length=C,o.pointShadow.length=E,o.pointShadowMap.length=E,o.spotShadow.length=w,o.spotShadowMap.length=w,o.directionalShadowMatrix.length=C,o.pointShadowMatrix.length=E,o.spotShadowMatrix.length=w,H.directionalLength=x,H.pointLength=b,H.spotLength=y,H.rectAreaLength=g,H.hemiLength=M,H.numDirectionalShadows=C,H.numPointShadows=E,H.numSpotShadows=w,o.version=QL++)}return{setup:u,state:o}}function Vx(t,e){let n=new e3(t,e),r=[],o=[];function a(){r.length=0,o.length=0}function c(d){r.push(d)}function l(d){o.push(d)}function u(d){n.setup(r,o,d)}return{init:a,state:{lightsArray:r,shadowsArray:o,lights:n},setupLights:u,pushLight:c,pushShadow:l}}function t3(t,e){let n=new WeakMap;function r(a,c){let l;return n.has(a)===!1?(l=new Vx(t,e),n.set(a,new WeakMap),n.get(a).set(c,l)):n.get(a).has(c)===!1?(l=new Vx(t,e),n.get(a).set(c,l)):l=n.get(a).get(c),l}function o(){n=new WeakMap}return{get:r,dispose:o}}function As(t){at.call(this),this.type="MeshDepthMaterial",this.depthPacking=j2,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}As.prototype=Object.create(at.prototype);As.prototype.constructor=As;As.prototype.isMeshDepthMaterial=!0;As.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this};function Cs(t){at.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new W,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}Cs.prototype=Object.create(at.prototype);Cs.prototype.constructor=Cs;Cs.prototype.isMeshDistanceMaterial=!0;Cs.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};var n3=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	float mean = 0.0;
	float squared_mean = 0.0;
	float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
	for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
		#ifdef HORIZONAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean * HALF_SAMPLE_RATE;
	squared_mean = squared_mean * HALF_SAMPLE_RATE;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`,r3=`void main() {
	gl_Position = vec4( position, 1.0 );
}`;function t_(t,e,n){let r=new Ja,o=new fe,a=new fe,c=new Rt,l=[],u=[],h={},d={0:rn,1:Sf,2:Tf},f=new In({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new fe},radius:{value:4}},vertexShader:r3,fragmentShader:n3}),p=f.clone();p.defines.HORIZONAL_PASS=1;let m=new Tt;m.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Wt(m,f),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=I0,this.render=function(E,w,F){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||E.length===0)return;let H=t.getRenderTarget(),ne=t.getActiveCubeFace(),Y=t.getActiveMipmapLevel(),L=t.state;L.setBlending(Sl),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let N=0,G=E.length;N<G;N++){let z=E[N],D=z.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;o.copy(D.mapSize);let B=D.getFrameExtents();if(o.multiply(B),a.copy(D.mapSize),(o.x>n||o.y>n)&&(o.x>n&&(a.x=Math.floor(n/B.x),o.x=a.x*B.x,D.mapSize.x=a.x),o.y>n&&(a.y=Math.floor(n/B.y),o.y=a.y*B.y,D.mapSize.y=a.y)),D.map===null&&!D.isPointLightShadow&&this.type===Ml){let $={minFilter:sn,magFilter:sn,format:ar};D.map=new an(o.x,o.y,$),D.map.texture.name=z.name+".shadowMap",D.mapPass=new an(o.x,o.y,$),D.camera.updateProjectionMatrix()}if(D.map===null){let $={minFilter:Hn,magFilter:Hn,format:ar};D.map=new an(o.x,o.y,$),D.map.texture.name=z.name+".shadowMap",D.camera.updateProjectionMatrix()}t.setRenderTarget(D.map),t.clear();let q=D.getViewportCount();for(let $=0;$<q;$++){let ce=D.getViewport($);c.set(a.x*ce.x,a.y*ce.y,a.x*ce.z,a.y*ce.w),L.viewport(c),D.updateMatrices(z,$),r=D.getFrustum(),C(w,F,D.camera,z,this.type)}!D.isPointLightShadow&&this.type===Ml&&b(D,F),D.needsUpdate=!1}x.needsUpdate=!1,t.setRenderTarget(H,ne,Y)};function b(E,w){let F=e.update(v);f.uniforms.shadow_pass.value=E.map.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(w,null,F,f,v,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(w,null,F,p,v,null)}function y(E,w,F){let H=E<<0|w<<1|F<<2,ne=l[H];return ne===void 0&&(ne=new As({depthPacking:q2,morphTargets:E,skinning:w}),l[H]=ne),ne}function g(E,w,F){let H=E<<0|w<<1|F<<2,ne=u[H];return ne===void 0&&(ne=new Cs({morphTargets:E,skinning:w}),u[H]=ne),ne}function M(E,w,F,H,ne,Y,L){let N=null,G=y,z=E.customDepthMaterial;if(H.isPointLight===!0&&(G=g,z=E.customDistanceMaterial),z===void 0){let D=!1;F.morphTargets===!0&&(D=w.morphAttributes&&w.morphAttributes.position&&w.morphAttributes.position.length>0);let B=!1;E.isSkinnedMesh===!0&&(F.skinning===!0?B=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",E));let q=E.isInstancedMesh===!0;N=G(D,B,q)}else N=z;if(t.localClippingEnabled&&F.clipShadows===!0&&F.clippingPlanes.length!==0){let D=N.uuid,B=F.uuid,q=h[D];q===void 0&&(q={},h[D]=q);let $=q[B];$===void 0&&($=N.clone(),q[B]=$),N=$}return N.visible=F.visible,N.wireframe=F.wireframe,L===Ml?N.side=F.shadowSide!==null?F.shadowSide:F.side:N.side=F.shadowSide!==null?F.shadowSide:d[F.side],N.clipShadows=F.clipShadows,N.clippingPlanes=F.clippingPlanes,N.clipIntersection=F.clipIntersection,N.wireframeLinewidth=F.wireframeLinewidth,N.linewidth=F.linewidth,H.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(H.matrixWorld),N.nearDistance=ne,N.farDistance=Y),N}function C(E,w,F,H,ne){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&ne===Ml)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,E.matrixWorld);let N=e.update(E),G=E.material;if(Array.isArray(G)){let z=N.groups;for(let D=0,B=z.length;D<B;D++){let q=z[D],$=G[q.materialIndex];if($&&$.visible){let ce=M(E,N,$,H,F.near,F.far,ne);t.renderBufferDirect(F,null,N,ce,E,q)}}}else if(G.visible){let z=M(E,N,G,H,F.near,F.far,ne);t.renderBufferDirect(F,null,N,z,E,null)}}let L=E.children;for(let N=0,G=L.length;N<G;N++)C(L[N],w,F,H,ne)}}function i3(t,e,n){let r=n.isWebGL2;function o(){let I=!1,ee=new Rt,ae=null,ve=new Rt(0,0,0,0);return{setMask:function(oe){ae!==oe&&!I&&(t.colorMask(oe,oe,oe,oe),ae=oe)},setLocked:function(oe){I=oe},setClear:function(oe,pe,be,Te,de){de===!0&&(oe*=Te,pe*=Te,be*=Te),ee.set(oe,pe,be,Te),ve.equals(ee)===!1&&(t.clearColor(oe,pe,be,Te),ve.copy(ee))},reset:function(){I=!1,ae=null,ve.set(-1,0,0,0)}}}function a(){let I=!1,ee=null,ae=null,ve=null;return{setTest:function(oe){oe?ge(2929):he(2929)},setMask:function(oe){ee!==oe&&!I&&(t.depthMask(oe),ee=oe)},setFunc:function(oe){if(ae!==oe){if(oe)switch(oe){case DA:t.depthFunc(512);break;case BA:t.depthFunc(519);break;case OA:t.depthFunc(513);break;case Um:t.depthFunc(515);break;case UA:t.depthFunc(514);break;case NA:t.depthFunc(518);break;case GA:t.depthFunc(516);break;case kA:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);ae=oe}},setLocked:function(oe){I=oe},setClear:function(oe){ve!==oe&&(t.clearDepth(oe),ve=oe)},reset:function(){I=!1,ee=null,ae=null,ve=null}}}function c(){let I=!1,ee=null,ae=null,ve=null,oe=null,pe=null,be=null,Te=null,de=null;return{setTest:function(Me){I||(Me?ge(2960):he(2960))},setMask:function(Me){ee!==Me&&!I&&(t.stencilMask(Me),ee=Me)},setFunc:function(Me,ot,Mt){(ae!==Me||ve!==ot||oe!==Mt)&&(t.stencilFunc(Me,ot,Mt),ae=Me,ve=ot,oe=Mt)},setOp:function(Me,ot,Mt){(pe!==Me||be!==ot||Te!==Mt)&&(t.stencilOp(Me,ot,Mt),pe=Me,be=ot,Te=Mt)},setLocked:function(Me){I=Me},setClear:function(Me){de!==Me&&(t.clearStencil(Me),de=Me)},reset:function(){I=!1,ee=null,ae=null,ve=null,oe=null,pe=null,be=null,Te=null,de=null}}}let l=new o,u=new a,h=new c,d={},f=null,p=null,m=null,v=null,x=null,b=null,y=null,g=null,M=null,C=!1,E=null,w=null,F=null,H=null,ne=null,Y=t.getParameter(35661),L=!1,N=0,G=t.getParameter(7938);G.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL\ ([0-9])/.exec(G)[1]),L=N>=1):G.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(G)[1]),L=N>=2);let z=null,D={},B=new Rt,q=new Rt;function $(I,ee,ae){let ve=new Uint8Array(4),oe=t.createTexture();t.bindTexture(I,oe),t.texParameteri(I,10241,9728),t.texParameteri(I,10240,9728);for(let pe=0;pe<ae;pe++)t.texImage2D(ee+pe,0,6408,1,1,0,6408,5121,ve);return oe}let ce={};ce[3553]=$(3553,3553,1),ce[34067]=$(34067,34069,6),l.setClear(0,0,0,1),u.setClear(1),h.setClear(0),ge(2929),u.setFunc(Um),we(!1),Ve(Qy),ge(2884),V(Sl);function ge(I){d[I]!==!0&&(t.enable(I),d[I]=!0)}function he(I){d[I]!==!1&&(t.disable(I),d[I]=!1)}function Pe(I){return f!==I?(t.useProgram(I),f=I,!0):!1}let Fe={[Ga]:32774,[MA]:32778,[EA]:32779};if(r)Fe[nx]=32775,Fe[rx]=32776;else{let I=e.get("EXT_blend_minmax");I!==null&&(Fe[nx]=I.MIN_EXT,Fe[rx]=I.MAX_EXT)}let st={[SA]:0,[TA]:1,[AA]:768,[B0]:770,[IA]:776,[LA]:774,[RA]:772,[CA]:769,[O0]:771,[FA]:775,[PA]:773};function V(I,ee,ae,ve,oe,pe,be,Te){if(I===Sl){p&&(he(3042),p=!1);return}if(p||(ge(3042),p=!0),I!==wA){if(I!==m||Te!==C){if((v!==Ga||y!==Ga)&&(t.blendEquation(32774),v=Ga,y=Ga),Te)switch(I){case Tl:t.blendFuncSeparate(1,771,1,771);break;case Ky:t.blendFunc(1,1);break;case ex:t.blendFuncSeparate(0,0,769,771);break;case tx:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}else switch(I){case Tl:t.blendFuncSeparate(770,771,1,771);break;case Ky:t.blendFunc(770,1);break;case ex:t.blendFunc(0,769);break;case tx:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}x=null,b=null,g=null,M=null,m=I,C=Te}return}oe=oe||ee,pe=pe||ae,be=be||ve,(ee!==v||oe!==y)&&(t.blendEquationSeparate(Fe[ee],Fe[oe]),v=ee,y=oe),(ae!==x||ve!==b||pe!==g||be!==M)&&(t.blendFuncSeparate(st[ae],st[ve],st[pe],st[be]),x=ae,b=ve,g=pe,M=be),m=I,C=null}function _t(I,ee){I.side===Tf?he(2884):ge(2884);let ae=I.side===rn;ee&&(ae=!ae),we(ae),I.blending===Tl&&I.transparent===!1?V(Sl):V(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.premultipliedAlpha),u.setFunc(I.depthFunc),u.setTest(I.depthTest),u.setMask(I.depthWrite),l.setMask(I.colorWrite);let ve=I.stencilWrite;h.setTest(ve),ve&&(h.setMask(I.stencilWriteMask),h.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),h.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),$e(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits)}function we(I){E!==I&&(I?t.frontFace(2304):t.frontFace(2305),E=I)}function Ve(I){I!==xA?(ge(2884),I!==w&&(I===Qy?t.cullFace(1029):I===_A?t.cullFace(1028):t.cullFace(1032))):he(2884),w=I}function Ce(I){I!==F&&(L&&t.lineWidth(I),F=I)}function $e(I,ee,ae){I?(ge(32823),(H!==ee||ne!==ae)&&(t.polygonOffset(ee,ae),H=ee,ne=ae)):he(32823)}function Ie(I){I?ge(3089):he(3089)}function Q(I){I===void 0&&(I=33984+Y-1),z!==I&&(t.activeTexture(I),z=I)}function re(I,ee){z===null&&Q();let ae=D[z];ae===void 0&&(ae={type:void 0,texture:void 0},D[z]=ae),(ae.type!==I||ae.texture!==ee)&&(t.bindTexture(I,ee||ce[I]),ae.type=I,ae.texture=ee)}function ie(){let I=D[z];I!==void 0&&I.type!==void 0&&(t.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function _e(){try{t.compressedTexImage2D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function le(){try{t.texImage2D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function A(){try{t.texImage3D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function S(I){B.equals(I)===!1&&(t.scissor(I.x,I.y,I.z,I.w),B.copy(I))}function K(I){q.equals(I)===!1&&(t.viewport(I.x,I.y,I.z,I.w),q.copy(I))}function Z(){d={},z=null,D={},f=null,m=null,E=null,w=null,l.reset(),u.reset(),h.reset()}return{buffers:{color:l,depth:u,stencil:h},enable:ge,disable:he,useProgram:Pe,setBlending:V,setMaterial:_t,setFlipSided:we,setCullFace:Ve,setLineWidth:Ce,setPolygonOffset:$e,setScissorTest:Ie,activeTexture:Q,bindTexture:re,unbindTexture:ie,compressedTexImage2D:_e,texImage2D:le,texImage3D:A,scissor:S,viewport:K,reset:Z}}function o3(t,e,n,r,o,a,c){let l=o.isWebGL2,u=o.maxTextures,h=o.maxCubemapSize,d=o.maxTextureSize,f=o.maxSamples,p=new WeakMap,m,v=!1;try{v=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function x(A,S){return v?new OffscreenCanvas(A,S):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function b(A,S,K,Z){let I=1;if((A.width>Z||A.height>Z)&&(I=Z/Math.max(A.width,A.height)),I<1||S===!0)if(typeof HTMLImageElement!="undefined"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&A instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&A instanceof ImageBitmap){let ee=S?dt.floorPowerOfTwo:Math.floor,ae=ee(I*A.width),ve=ee(I*A.height);m===void 0&&(m=x(ae,ve));let oe=K?x(ae,ve):m;return oe.width=ae,oe.height=ve,oe.getContext("2d").drawImage(A,0,0,ae,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+A.width+"x"+A.height+") to ("+ae+"x"+ve+")."),oe}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+A.width+"x"+A.height+")."),A;return A}function y(A){return dt.isPowerOfTwo(A.width)&&dt.isPowerOfTwo(A.height)}function g(A){return l?!1:A.wrapS!==sr||A.wrapT!==sr||A.minFilter!==Hn&&A.minFilter!==sn}function M(A,S){return A.generateMipmaps&&S&&A.minFilter!==Hn&&A.minFilter!==sn}function C(A,S,K,Z){t.generateMipmap(A);let I=r.get(S);I.__maxMipLevel=Math.log(Math.max(K,Z))*Math.LOG2E}function E(A,S,K){if(l===!1)return S;if(A!==null){if(t[A]!==void 0)return t[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let Z=S;return S===6403&&(K===5126&&(Z=33326),K===5131&&(Z=33325),K===5121&&(Z=33321)),S===6407&&(K===5126&&(Z=34837),K===5131&&(Z=34843),K===5121&&(Z=32849)),S===6408&&(K===5126&&(Z=34836),K===5131&&(Z=34842),K===5121&&(Z=32856)),(Z===33325||Z===33326||Z===34842||Z===34836)&&e.get("EXT_color_buffer_float"),Z}function w(A){return A===Hn||A===sx||A===ax?9728:9729}function F(A){let S=A.target;S.removeEventListener("dispose",F),ne(S),S.isVideoTexture&&p.delete(S),c.memory.textures--}function H(A){let S=A.target;S.removeEventListener("dispose",H),Y(S),c.memory.textures--}function ne(A){let S=r.get(A);S.__webglInit!==void 0&&(t.deleteTexture(S.__webglTexture),r.remove(A))}function Y(A){let S=r.get(A),K=r.get(A.texture);if(A){if(K.__webglTexture!==void 0&&t.deleteTexture(K.__webglTexture),A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++)t.deleteFramebuffer(S.__webglFramebuffer[Z]),S.__webglDepthbuffer&&t.deleteRenderbuffer(S.__webglDepthbuffer[Z]);else t.deleteFramebuffer(S.__webglFramebuffer),S.__webglDepthbuffer&&t.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&t.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer&&t.deleteRenderbuffer(S.__webglColorRenderbuffer),S.__webglDepthRenderbuffer&&t.deleteRenderbuffer(S.__webglDepthRenderbuffer);r.remove(A.texture),r.remove(A)}}let L=0;function N(){L=0}function G(){let A=L;return A>=u&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+u),L+=1,A}function z(A,S){let K=r.get(A);if(A.isVideoTexture&&Q(A),A.version>0&&K.__version!==A.version){let Z=A.image;if(Z===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(K,A,S);return}}n.activeTexture(33984+S),n.bindTexture(3553,K.__webglTexture)}function D(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Pe(K,A,S);return}n.activeTexture(33984+S),n.bindTexture(35866,K.__webglTexture)}function B(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Pe(K,A,S);return}n.activeTexture(33984+S),n.bindTexture(32879,K.__webglTexture)}function q(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Fe(K,A,S);return}n.activeTexture(33984+S),n.bindTexture(34067,K.__webglTexture)}let $={[Nm]:10497,[sr]:33071,[Gm]:33648},ce={[Hn]:9728,[sx]:9984,[ax]:9986,[sn]:9729,[YA]:9985,[Cf]:9987};function ge(A,S,K){K?(t.texParameteri(A,10242,$[S.wrapS]),t.texParameteri(A,10243,$[S.wrapT]),(A===32879||A===35866)&&t.texParameteri(A,32882,$[S.wrapR]),t.texParameteri(A,10240,ce[S.magFilter]),t.texParameteri(A,10241,ce[S.minFilter])):(t.texParameteri(A,10242,33071),t.texParameteri(A,10243,33071),(A===32879||A===35866)&&t.texParameteri(A,32882,33071),(S.wrapS!==sr||S.wrapT!==sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(A,10240,w(S.magFilter)),t.texParameteri(A,10241,w(S.minFilter)),S.minFilter!==Hn&&S.minFilter!==sn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));let Z=e.get("EXT_texture_filter_anisotropic");if(Z){if(S.type===Bo&&e.get("OES_texture_float_linear")===null||S.type===cf&&(l||e.get("OES_texture_half_float_linear"))===null)return;(S.anisotropy>1||r.get(S).__currentAnisotropy)&&(t.texParameterf(A,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,o.getMaxAnisotropy())),r.get(S).__currentAnisotropy=S.anisotropy)}}function he(A,S){A.__webglInit===void 0&&(A.__webglInit=!0,S.addEventListener("dispose",F),A.__webglTexture=t.createTexture(),c.memory.textures++)}function Pe(A,S,K){let Z=3553;S.isDataTexture2DArray&&(Z=35866),S.isDataTexture3D&&(Z=32879),he(A,S),n.activeTexture(33984+K),n.bindTexture(Z,A.__webglTexture),t.pixelStorei(37440,S.flipY),t.pixelStorei(37441,S.premultiplyAlpha),t.pixelStorei(3317,S.unpackAlignment);let I=g(S)&&y(S.image)===!1,ee=b(S.image,I,!1,d),ae=y(ee)||l,ve=a.convert(S.format),oe=a.convert(S.type),pe=E(S.internalFormat,ve,oe);ge(Z,S,ae);let be,Te=S.mipmaps;if(S.isDepthTexture)pe=6402,l?S.type===Bo?pe=36012:S.type===rf?pe=33190:S.type===Cl?pe=35056:pe=33189:S.type===Bo&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===Xa&&pe===6402&&S.type!==af&&S.type!==rf&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=af,oe=a.convert(S.type)),S.format===Dl&&pe===6402&&(pe=34041,S.type!==Cl&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Cl,oe=a.convert(S.type))),n.texImage2D(3553,0,pe,ee.width,ee.height,0,ve,oe,null);else if(S.isDataTexture)if(Te.length>0&&ae){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],n.texImage2D(3553,de,pe,be.width,be.height,0,ve,oe,be.data);S.generateMipmaps=!1,A.__maxMipLevel=Te.length-1}else n.texImage2D(3553,0,pe,ee.width,ee.height,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(S.isCompressedTexture){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],S.format!==ar&&S.format!==Ms?ve!==null?n.compressedTexImage2D(3553,de,pe,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,de,pe,be.width,be.height,0,ve,oe,be.data);A.__maxMipLevel=Te.length-1}else if(S.isDataTexture2DArray)n.texImage3D(35866,0,pe,ee.width,ee.height,ee.depth,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(S.isDataTexture3D)n.texImage3D(32879,0,pe,ee.width,ee.height,ee.depth,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(Te.length>0&&ae){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],n.texImage2D(3553,de,pe,ve,oe,be);S.generateMipmaps=!1,A.__maxMipLevel=Te.length-1}else n.texImage2D(3553,0,pe,ve,oe,ee),A.__maxMipLevel=0;M(S,ae)&&C(Z,S,ee.width,ee.height),A.__version=S.version,S.onUpdate&&S.onUpdate(S)}function Fe(A,S,K){if(S.image.length!==6)return;he(A,S),n.activeTexture(33984+K),n.bindTexture(34067,A.__webglTexture),t.pixelStorei(37440,S.flipY);let Z=S&&(S.isCompressedTexture||S.image[0].isCompressedTexture),I=S.image[0]&&S.image[0].isDataTexture,ee=[];for(let de=0;de<6;de++)!Z&&!I?ee[de]=b(S.image[de],!1,!0,h):ee[de]=I?S.image[de].image:S.image[de];let ae=ee[0],ve=y(ae)||l,oe=a.convert(S.format),pe=a.convert(S.type),be=E(S.internalFormat,oe,pe);ge(34067,S,ve);let Te;if(Z){for(let de=0;de<6;de++){Te=ee[de].mipmaps;for(let Me=0;Me<Te.length;Me++){let ot=Te[Me];S.format!==ar&&S.format!==Ms?oe!==null?n.compressedTexImage2D(34069+de,Me,be,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+de,Me,be,ot.width,ot.height,0,oe,pe,ot.data)}}A.__maxMipLevel=Te.length-1}else{Te=S.mipmaps;for(let de=0;de<6;de++)if(I){n.texImage2D(34069+de,0,be,ee[de].width,ee[de].height,0,oe,pe,ee[de].data);for(let Me=0;Me<Te.length;Me++){let Mt=Te[Me].image[de].image;n.texImage2D(34069+de,Me+1,be,Mt.width,Mt.height,0,oe,pe,Mt.data)}}else{n.texImage2D(34069+de,0,be,oe,pe,ee[de]);for(let Me=0;Me<Te.length;Me++){let ot=Te[Me];n.texImage2D(34069+de,Me+1,be,oe,pe,ot.image[de])}}A.__maxMipLevel=Te.length}M(S,ve)&&C(34067,S,ae.width,ae.height),A.__version=S.version,S.onUpdate&&S.onUpdate(S)}function st(A,S,K,Z){let I=a.convert(S.texture.format),ee=a.convert(S.texture.type),ae=E(S.texture.internalFormat,I,ee);n.texImage2D(Z,0,ae,S.width,S.height,0,I,ee,null),t.bindFramebuffer(36160,A),t.framebufferTexture2D(36160,K,Z,r.get(S.texture).__webglTexture,0),t.bindFramebuffer(36160,null)}function V(A,S,K){if(t.bindRenderbuffer(36161,A),S.depthBuffer&&!S.stencilBuffer){let Z=33189;if(K){let I=S.depthTexture;I&&I.isDepthTexture&&(I.type===Bo?Z=36012:I.type===rf&&(Z=33190));let ee=Ie(S);t.renderbufferStorageMultisample(36161,ee,Z,S.width,S.height)}else t.renderbufferStorage(36161,Z,S.width,S.height);t.framebufferRenderbuffer(36160,36096,36161,A)}else if(S.depthBuffer&&S.stencilBuffer){if(K){let Z=Ie(S);t.renderbufferStorageMultisample(36161,Z,35056,S.width,S.height)}else t.renderbufferStorage(36161,34041,S.width,S.height);t.framebufferRenderbuffer(36160,33306,36161,A)}else{let Z=a.convert(S.texture.format),I=a.convert(S.texture.type),ee=E(S.texture.internalFormat,Z,I);if(K){let ae=Ie(S);t.renderbufferStorageMultisample(36161,ae,ee,S.width,S.height)}else t.renderbufferStorage(36161,ee,S.width,S.height)}t.bindRenderbuffer(36161,null)}function _t(A,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,A),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),z(S.depthTexture,0);let Z=r.get(S.depthTexture).__webglTexture;if(S.depthTexture.format===Xa)t.framebufferTexture2D(36160,36096,3553,Z,0);else if(S.depthTexture.format===Dl)t.framebufferTexture2D(36160,33306,3553,Z,0);else throw new Error("Unknown depthTexture format")}function we(A){let S=r.get(A),K=A.isWebGLCubeRenderTarget===!0;if(A.depthTexture){if(K)throw new Error("target.depthTexture not supported in Cube render targets");_t(S.__webglFramebuffer,A)}else if(K){S.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)t.bindFramebuffer(36160,S.__webglFramebuffer[Z]),S.__webglDepthbuffer[Z]=t.createRenderbuffer(),V(S.__webglDepthbuffer[Z],A,!1)}else t.bindFramebuffer(36160,S.__webglFramebuffer),S.__webglDepthbuffer=t.createRenderbuffer(),V(S.__webglDepthbuffer,A,!1);t.bindFramebuffer(36160,null)}function Ve(A){let S=r.get(A),K=r.get(A.texture);A.addEventListener("dispose",H),K.__webglTexture=t.createTexture(),c.memory.textures++;let Z=A.isWebGLCubeRenderTarget===!0,I=A.isWebGLMultisampleRenderTarget===!0,ee=y(A)||l;if(l&&A.texture.format===Ms&&(A.texture.type===Bo||A.texture.type===cf)&&(A.texture.format=ar,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),Z){S.__webglFramebuffer=[];for(let ae=0;ae<6;ae++)S.__webglFramebuffer[ae]=t.createFramebuffer()}else if(S.__webglFramebuffer=t.createFramebuffer(),I)if(l){S.__webglMultisampledFramebuffer=t.createFramebuffer(),S.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,S.__webglColorRenderbuffer);let ae=a.convert(A.texture.format),ve=a.convert(A.texture.type),oe=E(A.texture.internalFormat,ae,ve),pe=Ie(A);t.renderbufferStorageMultisample(36161,pe,oe,A.width,A.height),t.bindFramebuffer(36160,S.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,S.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),A.depthBuffer&&(S.__webglDepthRenderbuffer=t.createRenderbuffer(),V(S.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(Z){n.bindTexture(34067,K.__webglTexture),ge(34067,A.texture,ee);for(let ae=0;ae<6;ae++)st(S.__webglFramebuffer[ae],A,36064,34069+ae);M(A.texture,ee)&&C(34067,A.texture,A.width,A.height),n.bindTexture(34067,null)}else n.bindTexture(3553,K.__webglTexture),ge(3553,A.texture,ee),st(S.__webglFramebuffer,A,36064,3553),M(A.texture,ee)&&C(3553,A.texture,A.width,A.height),n.bindTexture(3553,null);A.depthBuffer&&we(A)}function Ce(A){let S=A.texture,K=y(A)||l;if(M(S,K)){let Z=A.isWebGLCubeRenderTarget?34067:3553,I=r.get(S).__webglTexture;n.bindTexture(Z,I),C(Z,S,A.width,A.height),n.bindTexture(Z,null)}}function $e(A){if(A.isWebGLMultisampleRenderTarget)if(l){let S=r.get(A);t.bindFramebuffer(36008,S.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,S.__webglFramebuffer);let K=A.width,Z=A.height,I=16384;A.depthBuffer&&(I|=256),A.stencilBuffer&&(I|=1024),t.blitFramebuffer(0,0,K,Z,0,0,K,Z,I,9728),t.bindFramebuffer(36160,S.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function Ie(A){return l&&A.isWebGLMultisampleRenderTarget?Math.min(f,A.samples):0}function Q(A){let S=c.render.frame;p.get(A)!==S&&(p.set(A,S),A.update())}let re=!1,ie=!1;function _e(A,S){A&&A.isWebGLRenderTarget&&(re===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),re=!0),A=A.texture),z(A,S)}function le(A,S){A&&A.isWebGLCubeRenderTarget&&(ie===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ie=!0),A=A.texture),q(A,S)}this.allocateTextureUnit=G,this.resetTextureUnits=N,this.setTexture2D=z,this.setTexture2DArray=D,this.setTexture3D=B,this.setTextureCube=q,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=Ce,this.updateMultisampleRenderTarget=$e,this.safeSetTexture2D=_e,this.safeSetTextureCube=le}function s3(t,e,n){let r=n.isWebGL2;function o(a){let c;if(a===Fg)return 5121;if(a===QA)return 32819;if(a===KA)return 32820;if(a===e2)return 33635;if(a===$A)return 5120;if(a===ZA)return 5122;if(a===af)return 5123;if(a===JA)return 5124;if(a===rf)return 5125;if(a===Bo)return 5126;if(a===cf)return r?5131:(c=e.get("OES_texture_half_float"),c!==null?c.HALF_FLOAT_OES:null);if(a===t2)return 6406;if(a===Ms)return 6407;if(a===ar)return 6408;if(a===n2)return 6409;if(a===r2)return 6410;if(a===Xa)return 6402;if(a===Dl)return 34041;if(a===i2)return 6403;if(a===o2)return 36244;if(a===s2)return 33319;if(a===a2)return 33320;if(a===c2)return 36248;if(a===l2)return 36249;if(a===cx||a===lx||a===ux||a===hx)if(c=e.get("WEBGL_compressed_texture_s3tc"),c!==null){if(a===cx)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===lx)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ux)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===hx)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===fx||a===dx||a===px||a===mx)if(c=e.get("WEBGL_compressed_texture_pvrtc"),c!==null){if(a===fx)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===dx)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===px)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===mx)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===u2)return c=e.get("WEBGL_compressed_texture_etc1"),c!==null?c.COMPRESSED_RGB_ETC1_WEBGL:null;if((a===gx||a===vx)&&(c=e.get("WEBGL_compressed_texture_etc"),c!==null)){if(a===gx)return c.COMPRESSED_RGB8_ETC2;if(a===vx)return c.COMPRESSED_RGBA8_ETC2_EAC}if(a===h2||a===f2||a===d2||a===p2||a===m2||a===g2||a===v2||a===y2||a===x2||a===_2||a===b2||a===w2||a===M2||a===E2||a===T2||a===A2||a===C2||a===R2||a===P2||a===L2||a===F2||a===I2||a===D2||a===B2||a===O2||a===U2||a===N2||a===G2)return c=e.get("WEBGL_compressed_texture_astc"),c!==null?a:null;if(a===S2)return c=e.get("EXT_texture_compression_bptc"),c!==null?a:null;if(a===Cl)return r?34042:(c=e.get("WEBGL_depth_texture"),c!==null?c.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:o}}function Ym(t){on.call(this),this.cameras=t||[]}Ym.prototype=Object.assign(Object.create(on.prototype),{constructor:Ym,isArrayCamera:!0});function ja(){Je.call(this),this.type="Group"}ja.prototype=Object.assign(Object.create(Je.prototype),{constructor:ja,isGroup:!0});function Pl(){this._targetRay=null,this._grip=null,this._hand=null}Object.assign(Pl.prototype,{constructor:Pl,getHandSpace:function(){if(this._hand===null&&(this._hand=new ja,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(let t=0;t<=window.XRHand.LITTLE_PHALANX_TIP;t++){let e=new ja;e.matrixAutoUpdate=!1,e.visible=!1,this._hand.joints.push(e),this._hand.add(e)}return this._hand},getTargetRaySpace:function(){return this._targetRay===null&&(this._targetRay=new ja,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return this._grip===null&&(this._grip=new ja,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},update:function(t,e,n){let r=null,o=null,a=null,c=this._targetRay,l=this._grip,u=this._hand;if(t)if(u&&t.hand){a=!0;for(let h=0;h<=window.XRHand.LITTLE_PHALANX_TIP;h++)if(t.hand[h]){let d=e.getJointPose(t.hand[h],n),f=u.joints[h];d!==null&&(f.matrix.fromArray(d.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.jointRadius=d.radius),f.visible=d!==null;let p=u.joints[window.XRHand.INDEX_PHALANX_TIP],m=u.joints[window.XRHand.THUMB_PHALANX_TIP],v=p.position.distanceTo(m.position),x=.02,b=.005;u.inputState.pinching&&v>x+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&v<=x-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}}else c!==null&&(r=e.getPose(t.targetRaySpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale))),l!==null&&t.gripSpace&&(o=e.getPose(t.gripSpace,n),o!==null&&(l.matrix.fromArray(o.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale)));return c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),u!==null&&(u.visible=a!==null),this}});function n_(t,e){let n=this,r=null,o=1,a=null,c="local-floor",l=null,u=[],h=new Map,d=new on;d.layers.enable(1),d.viewport=new Rt;let f=new on;f.layers.enable(2),f.viewport=new Rt;let p=[d,f],m=new Ym;m.layers.enable(1),m.layers.enable(2);let v=null,x=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let N=u[L];return N===void 0&&(N=new Pl,u[L]=N),N.getTargetRaySpace()},this.getControllerGrip=function(L){let N=u[L];return N===void 0&&(N=new Pl,u[L]=N),N.getGripSpace()},this.getHand=function(L){let N=u[L];return N===void 0&&(N=new Pl,u[L]=N),N.getHandSpace()};function b(L){let N=h.get(L.inputSource);N&&N.dispatchEvent({type:L.type,data:L.inputSource})}function y(){h.forEach(function(L,N){L.disconnect(N)}),h.clear(),t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function g(L){a=L,Y.setContext(r),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}this.setFramebufferScaleFactor=function(L){o=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){c=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getSession=function(){return r},this.setSession=function(L){if(r=L,r!==null){r.addEventListener("select",b),r.addEventListener("selectstart",b),r.addEventListener("selectend",b),r.addEventListener("squeeze",b),r.addEventListener("squeezestart",b),r.addEventListener("squeezeend",b),r.addEventListener("end",y);let N=e.getContextAttributes();N.xrCompatible!==!0&&e.makeXRCompatible();let G={antialias:N.antialias,alpha:N.alpha,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:o},z=new XRWebGLLayer(r,e,G);r.updateRenderState({baseLayer:z}),r.requestReferenceSpace(c).then(g),r.addEventListener("inputsourceschange",M)}};function M(L){let N=r.inputSources;for(let G=0;G<u.length;G++)h.set(N[G],u[G]);for(let G=0;G<L.removed.length;G++){let z=L.removed[G],D=h.get(z);D&&(D.dispatchEvent({type:"disconnected",data:z}),h.delete(z))}for(let G=0;G<L.added.length;G++){let z=L.added[G],D=h.get(z);D&&D.dispatchEvent({type:"connected",data:z})}}let C=new W,E=new W;function w(L,N,G){C.setFromMatrixPosition(N.matrixWorld),E.setFromMatrixPosition(G.matrixWorld);let z=C.distanceTo(E),D=N.projectionMatrix.elements,B=G.projectionMatrix.elements,q=D[14]/(D[10]-1),$=D[14]/(D[10]+1),ce=(D[9]+1)/D[5],ge=(D[9]-1)/D[5],he=(D[8]-1)/D[0],Pe=(B[8]+1)/B[0],Fe=q*he,st=q*Pe,V=z/(-he+Pe),_t=V*-he;N.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(_t),L.translateZ(V),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.getInverse(L.matrixWorld);let we=q+V,Ve=$+V,Ce=Fe-_t,$e=st+(z-_t),Ie=ce*$/Ve*we,Q=ge*$/Ve*we;L.projectionMatrix.makePerspective(Ce,$e,Ie,Q,we,Ve)}function F(L,N){N===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(N.matrixWorld,L.matrix),L.matrixWorldInverse.getInverse(L.matrixWorld)}this.getCamera=function(L){m.near=f.near=d.near=L.near,m.far=f.far=d.far=L.far,(v!==m.near||x!==m.far)&&(r.updateRenderState({depthNear:m.near,depthFar:m.far}),v=m.near,x=m.far);let N=L.parent,G=m.cameras;F(m,N);for(let D=0;D<G.length;D++)F(G[D],N);L.matrixWorld.copy(m.matrixWorld);let z=L.children;for(let D=0,B=z.length;D<B;D++)z[D].updateMatrixWorld(!0);return G.length===2?w(m,d,f):m.projectionMatrix.copy(d.projectionMatrix),m};let H=null;function ne(L,N){if(l=N.getViewerPose(a),l!==null){let z=l.views,D=r.renderState.baseLayer;t.setFramebuffer(D.framebuffer);let B=!1;z.length!==m.cameras.length&&(m.cameras.length=0,B=!0);for(let q=0;q<z.length;q++){let $=z[q],ce=D.getViewport($),ge=p[q];ge.matrix.fromArray($.transform.matrix),ge.projectionMatrix.fromArray($.projectionMatrix),ge.viewport.set(ce.x,ce.y,ce.width,ce.height),q===0&&m.matrix.copy(ge.matrix),B===!0&&m.cameras.push(ge)}}let G=r.inputSources;for(let z=0;z<u.length;z++){let D=u[z],B=G[z];D.update(B,N,a)}H&&H(L,N)}let Y=new X0;Y.setAnimationLoop(ne),this.setAnimationLoop=function(L){H=L},this.dispose=function(){}}Object.assign(n_.prototype,Ji.prototype);function a3(t){function e(y,g){y.fogColor.value.copy(g.color),g.isFog?(y.fogNear.value=g.near,y.fogFar.value=g.far):g.isFogExp2&&(y.fogDensity.value=g.density)}function n(y,g,M,C){g.isMeshBasicMaterial?r(y,g):g.isMeshLambertMaterial?(r(y,g),u(y,g)):g.isMeshToonMaterial?(r(y,g),d(y,g)):g.isMeshPhongMaterial?(r(y,g),h(y,g)):g.isMeshStandardMaterial?(r(y,g),g.isMeshPhysicalMaterial?p(y,g):f(y,g)):g.isMeshMatcapMaterial?(r(y,g),m(y,g)):g.isMeshDepthMaterial?(r(y,g),v(y,g)):g.isMeshDistanceMaterial?(r(y,g),x(y,g)):g.isMeshNormalMaterial?(r(y,g),b(y,g)):g.isLineBasicMaterial?(o(y,g),g.isLineDashedMaterial&&a(y,g)):g.isPointsMaterial?c(y,g,M,C):g.isSpriteMaterial?l(y,g):g.isShadowMaterial?(y.color.value.copy(g.color),y.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(y,g){y.opacity.value=g.opacity,g.color&&y.diffuse.value.copy(g.color),g.emissive&&y.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap),g.specularMap&&(y.specularMap.value=g.specularMap);let M=t.get(g).envMap;if(M){y.envMap.value=M,y.flipEnvMap.value=M.isCubeTexture&&M._needsFlipEnvMap?-1:1,y.reflectivity.value=g.reflectivity,y.refractionRatio.value=g.refractionRatio;let w=t.get(M).__maxMipLevel;w!==void 0&&(y.maxMipLevel.value=w)}g.lightMap&&(y.lightMap.value=g.lightMap,y.lightMapIntensity.value=g.lightMapIntensity),g.aoMap&&(y.aoMap.value=g.aoMap,y.aoMapIntensity.value=g.aoMapIntensity);let C;g.map?C=g.map:g.specularMap?C=g.specularMap:g.displacementMap?C=g.displacementMap:g.normalMap?C=g.normalMap:g.bumpMap?C=g.bumpMap:g.roughnessMap?C=g.roughnessMap:g.metalnessMap?C=g.metalnessMap:g.alphaMap?C=g.alphaMap:g.emissiveMap?C=g.emissiveMap:g.clearcoatMap?C=g.clearcoatMap:g.clearcoatNormalMap?C=g.clearcoatNormalMap:g.clearcoatRoughnessMap&&(C=g.clearcoatRoughnessMap),C!==void 0&&(C.isWebGLRenderTarget&&(C=C.texture),C.matrixAutoUpdate===!0&&C.updateMatrix(),y.uvTransform.value.copy(C.matrix));let E;g.aoMap?E=g.aoMap:g.lightMap&&(E=g.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),y.uv2Transform.value.copy(E.matrix))}function o(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity}function a(y,g){y.dashSize.value=g.dashSize,y.totalSize.value=g.dashSize+g.gapSize,y.scale.value=g.scale}function c(y,g,M,C){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.size.value=g.size*M,y.scale.value=C*.5,g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap);let E;g.map?E=g.map:g.alphaMap&&(E=g.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),y.uvTransform.value.copy(E.matrix))}function l(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.rotation.value=g.rotation,g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap);let M;g.map?M=g.map:g.alphaMap&&(M=g.alphaMap),M!==void 0&&(M.matrixAutoUpdate===!0&&M.updateMatrix(),y.uvTransform.value.copy(M.matrix))}function u(y,g){g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap)}function h(y,g){y.specular.value.copy(g.specular),y.shininess.value=Math.max(g.shininess,1e-4),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===rn&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===rn&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function d(y,g){g.gradientMap&&(y.gradientMap.value=g.gradientMap),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===rn&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===rn&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function f(y,g){y.roughness.value=g.roughness,y.metalness.value=g.metalness,g.roughnessMap&&(y.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(y.metalnessMap.value=g.metalnessMap),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===rn&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===rn&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias),t.get(g).envMap&&(y.envMapIntensity.value=g.envMapIntensity)}function p(y,g){f(y,g),y.reflectivity.value=g.reflectivity,y.clearcoat.value=g.clearcoat,y.clearcoatRoughness.value=g.clearcoatRoughness,g.sheen&&y.sheen.value.copy(g.sheen),g.clearcoatMap&&(y.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(y.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),y.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===rn&&y.clearcoatNormalScale.value.negate()),y.transmission.value=g.transmission,g.transmissionMap&&(y.transmissionMap.value=g.transmissionMap)}function m(y,g){g.matcap&&(y.matcap.value=g.matcap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===rn&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===rn&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function v(y,g){g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function x(y,g){g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias),y.referencePosition.value.copy(g.referencePosition),y.nearDistance.value=g.nearDistance,y.farDistance.value=g.farDistance}function b(y,g){g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===rn&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===rn&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function lc(t){t=t||{};let e=t.canvas!==void 0?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=t.context!==void 0?t.context:null,r=t.alpha!==void 0?t.alpha:!1,o=t.depth!==void 0?t.depth:!0,a=t.stencil!==void 0?t.stencil:!0,c=t.antialias!==void 0?t.antialias:!1,l=t.premultipliedAlpha!==void 0?t.premultipliedAlpha:!0,u=t.preserveDrawingBuffer!==void 0?t.preserveDrawingBuffer:!1,h=t.powerPreference!==void 0?t.powerPreference:"default",d=t.failIfMajorPerformanceCaveat!==void 0?t.failIfMajorPerformanceCaveat:!1,f=null,p=null;this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=sc,this.physicallyCorrectLights=!1,this.toneMapping=Al,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;let m=this,v=!1,x=null,b=0,y=0,g=null,M=null,C=-1,E=null,w=null,F=new Rt,H=new Rt,ne=null,Y=e.width,L=e.height,N=1,G=null,z=null,D=new Rt(0,0,Y,L),B=new Rt(0,0,Y,L),q=!1,$=new Ja,ce=!1,ge=!1,he=new vt,Pe=new W,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function st(){return g===null?N:1}let V=n;function _t(T,k){for(let U=0;U<T.length;U++){let X=T[U],se=e.getContext(X,k);if(se!==null)return se}return null}try{let T={alpha:r,depth:o,stencil:a,antialias:c,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:h,failIfMajorPerformanceCaveat:d};if(e.addEventListener("webglcontextlost",ot,!1),e.addEventListener("webglcontextrestored",Mt,!1),V===null){let k=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&k.shift(),V=_t(k,T),V===null)throw _t(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(T){throw console.error("THREE.WebGLRenderer: "+T.message),T}let we,Ve,Ce,$e,Ie,Q,re,ie,_e,le,A,S,K,Z,I,ee,ae,ve,oe,pe,be;function Te(){we=new NP(V),Ve=new BP(V,we,t),Ve.isWebGL2===!1&&(we.get("WEBGL_depth_texture"),we.get("OES_texture_float"),we.get("OES_texture_half_float"),we.get("OES_texture_half_float_linear"),we.get("OES_standard_derivatives"),we.get("OES_element_index_uint"),we.get("OES_vertex_array_object"),we.get("ANGLE_instanced_arrays")),we.get("OES_texture_float_linear"),pe=new s3(V,we,Ve),Ce=new i3(V,we,Ve),Ce.scissor(H.copy(B).multiplyScalar(N).floor()),Ce.viewport(F.copy(D).multiplyScalar(N).floor()),$e=new HP(V),Ie=new qL,Q=new o3(V,we,Ce,Ie,Ve,pe,$e),re=new UP(m),ie=new uC(V,Ve),be=new IP(V,we,ie,Ve),_e=new GP(V,ie,$e,be),le=new jP(V,_e,ie,$e),ae=new WP(V),I=new OP(Ie),A=new jL(m,re,we,Ve,be,I),S=new a3(Ie),K=new $L(Ie),Z=new t3(we,Ve),ee=new FP(m,re,Ce,le,l),ve=new DP(V,we,$e,Ve),oe=new kP(V,we,$e,Ve),$e.programs=A.programs,m.capabilities=Ve,m.extensions=we,m.properties=Ie,m.renderLists=K,m.state=Ce,m.info=$e}Te();let de=new n_(m,V);this.xr=de;let Me=new t_(m,le,Ve.maxTextureSize);this.shadowMap=Me,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let T=we.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){let T=we.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(T){T!==void 0&&(N=T,this.setSize(Y,L,!1))},this.getSize=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),T=new fe),T.set(Y,L)},this.setSize=function(T,k,U){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=T,L=k,e.width=Math.floor(T*N),e.height=Math.floor(k*N),U!==!1&&(e.style.width=T+"px",e.style.height=k+"px"),this.setViewport(0,0,T,k)},this.getDrawingBufferSize=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),T=new fe),T.set(Y*N,L*N).floor()},this.setDrawingBufferSize=function(T,k,U){Y=T,L=k,N=U,e.width=Math.floor(T*U),e.height=Math.floor(k*U),this.setViewport(0,0,T,k)},this.getCurrentViewport=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),T=new Rt),T.copy(F)},this.getViewport=function(T){return T.copy(D)},this.setViewport=function(T,k,U,X){T.isVector4?D.set(T.x,T.y,T.z,T.w):D.set(T,k,U,X),Ce.viewport(F.copy(D).multiplyScalar(N).floor())},this.getScissor=function(T){return T.copy(B)},this.setScissor=function(T,k,U,X){T.isVector4?B.set(T.x,T.y,T.z,T.w):B.set(T,k,U,X),Ce.scissor(H.copy(B).multiplyScalar(N).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(T){Ce.setScissorTest(q=T)},this.setOpaqueSort=function(T){G=T},this.setTransparentSort=function(T){z=T},this.getClearColor=function(){return ee.getClearColor()},this.setClearColor=function(){ee.setClearColor.apply(ee,arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha.apply(ee,arguments)},this.clear=function(T,k,U){let X=0;(T===void 0||T)&&(X|=16384),(k===void 0||k)&&(X|=256),(U===void 0||U)&&(X|=1024),V.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ot,!1),e.removeEventListener("webglcontextrestored",Mt,!1),K.dispose(),Z.dispose(),Ie.dispose(),re.dispose(),le.dispose(),be.dispose(),de.dispose(),fn.stop()};function ot(T){T.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Mt(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1,Te()}function ms(T){let k=T.target;k.removeEventListener("dispose",ms),sl(k)}function sl(T){gs(T),Ie.remove(T)}function gs(T){let k=Ie.get(T).program;k!==void 0&&A.releaseProgram(k)}function al(T,k){T.render(function(U){m.renderBufferImmediate(U,k)})}this.renderBufferImmediate=function(T,k){be.initAttributes();let U=Ie.get(T);T.hasPositions&&!U.position&&(U.position=V.createBuffer()),T.hasNormals&&!U.normal&&(U.normal=V.createBuffer()),T.hasUvs&&!U.uv&&(U.uv=V.createBuffer()),T.hasColors&&!U.color&&(U.color=V.createBuffer());let X=k.getAttributes();T.hasPositions&&(V.bindBuffer(34962,U.position),V.bufferData(34962,T.positionArray,35048),be.enableAttribute(X.position),V.vertexAttribPointer(X.position,3,5126,!1,0,0)),T.hasNormals&&(V.bindBuffer(34962,U.normal),V.bufferData(34962,T.normalArray,35048),be.enableAttribute(X.normal),V.vertexAttribPointer(X.normal,3,5126,!1,0,0)),T.hasUvs&&(V.bindBuffer(34962,U.uv),V.bufferData(34962,T.uvArray,35048),be.enableAttribute(X.uv),V.vertexAttribPointer(X.uv,2,5126,!1,0,0)),T.hasColors&&(V.bindBuffer(34962,U.color),V.bufferData(34962,T.colorArray,35048),be.enableAttribute(X.color),V.vertexAttribPointer(X.color,3,5126,!1,0,0)),be.disableUnusedAttributes(),V.drawArrays(4,0,T.count),T.count=0},this.renderBufferDirect=function(T,k,U,X,se,Ge){k===null&&(k=Fe);let De=se.isMesh&&se.matrixWorld.determinant()<0,ze=Eo(T,k,X,se);Ce.setMaterial(X,De);let Be=U.index,lt=U.attributes.position;if(Be===null){if(lt===void 0||lt.count===0)return}else if(Be.count===0)return;let ct=1;X.wireframe===!0&&(Be=_e.getWireframeAttribute(U),ct=2),(X.morphTargets||X.morphNormals)&&ae.update(se,U,X,ze),be.setup(se,X,ze,U,Be);let Re,nt=ve;Be!==null&&(Re=ie.get(Be),nt=oe,nt.setIndex(Re));let Qt=Be!==null?Be.count:lt.count,et=U.drawRange.start*ct,tn=U.drawRange.count*ct,ht=Ge!==null?Ge.start*ct:0,Gi=Ge!==null?Ge.count*ct:1/0,Et=Math.max(et,ht),wn=Math.min(Qt,et+tn,ht+Gi)-1,Gn=Math.max(0,wn-Et+1);if(Gn!==0){if(se.isMesh)X.wireframe===!0?(Ce.setLineWidth(X.wireframeLinewidth*st()),nt.setMode(1)):nt.setMode(4);else if(se.isLine){let rr=X.linewidth;rr===void 0&&(rr=1),Ce.setLineWidth(rr*st()),se.isLineSegments?nt.setMode(1):se.isLineLoop?nt.setMode(2):nt.setMode(3)}else se.isPoints?nt.setMode(0):se.isSprite&&nt.setMode(4);if(se.isInstancedMesh)nt.renderInstances(Et,Gn,se.count);else if(U.isInstancedBufferGeometry){let rr=Math.min(U.instanceCount,U._maxInstanceCount);nt.renderInstances(Et,Gn,rr)}else nt.render(Et,Gn)}},this.compile=function(T,k){p=Z.get(T,k),p.init(),T.traverseVisible(function(X){X.isLight&&X.layers.test(k.layers)&&(p.pushLight(X),X.castShadow&&p.pushShadow(X))}),p.setupLights(k);let U=new WeakMap;T.traverse(function(X){let se=X.material;if(se)if(Array.isArray(se))for(let Ge=0;Ge<se.length;Ge++){let De=se[Ge];U.has(De)===!1&&(it(De,T,X),U.set(De))}else U.has(se)===!1&&(it(se,T,X),U.set(se))})};let si=null;function bn(T){de.isPresenting||si&&si(T)}let fn=new X0;fn.setAnimationLoop(bn),typeof window!="undefined"&&fn.setContext(window),this.setAnimationLoop=function(T){si=T,de.setAnimationLoop(T),T===null?fn.stop():fn.start()},this.render=function(T,k){let U,X;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),U=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),X=arguments[3]),k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;be.resetDefaultState(),C=-1,E=null,T.autoUpdate===!0&&T.updateMatrixWorld(),k.parent===null&&k.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(k=de.getCamera(k)),T.isScene===!0&&T.onBeforeRender(m,T,k,U||g),p=Z.get(T,k),p.init(),he.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),$.setFromProjectionMatrix(he),ge=this.localClippingEnabled,ce=I.init(this.clippingPlanes,ge,k),f=K.get(T,k),f.init(),nr(T,k,0,m.sortObjects),f.finish(),m.sortObjects===!0&&f.sort(G,z),ce===!0&&I.beginShadows();let se=p.state.shadowsArray;Me.render(se,T,k),p.setupLights(k),ce===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),U!==void 0&&this.setRenderTarget(U),ee.render(f,T,k,X);let Ge=f.opaque,De=f.transparent;Ge.length>0&&ai(Ge,T,k),De.length>0&&ai(De,T,k),T.isScene===!0&&T.onAfterRender(m,T,k),g!==null&&(Q.updateRenderTargetMipmap(g),Q.updateMultisampleRenderTarget(g)),Ce.buffers.depth.setTest(!0),Ce.buffers.depth.setMask(!0),Ce.buffers.color.setMask(!0),Ce.setPolygonOffset(!1),f=null,p=null};function nr(T,k,U,X){if(T.visible===!1)return;if(T.layers.test(k.layers)){if(T.isGroup)U=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(k);else if(T.isLight)p.pushLight(T),T.castShadow&&p.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||$.intersectsSprite(T)){X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he);let De=le.update(T),ze=T.material;ze.visible&&f.push(T,De,ze,U,Pe.z,null)}}else if(T.isImmediateRenderObject)X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he),f.push(T,null,T.material,U,Pe.z,null);else if((T.isMesh||T.isLine||T.isPoints)&&(T.isSkinnedMesh&&T.skeleton.frame!==$e.render.frame&&(T.skeleton.update(),T.skeleton.frame=$e.render.frame),!T.frustumCulled||$.intersectsObject(T))){X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he);let De=le.update(T),ze=T.material;if(Array.isArray(ze)){let Be=De.groups;for(let lt=0,ct=Be.length;lt<ct;lt++){let Re=Be[lt],nt=ze[Re.materialIndex];nt&&nt.visible&&f.push(T,De,nt,U,Pe.z,Re)}}else ze.visible&&f.push(T,De,ze,U,Pe.z,null)}}let Ge=T.children;for(let De=0,ze=Ge.length;De<ze;De++)nr(Ge[De],k,U,X)}function ai(T,k,U){let X=k.isScene===!0?k.overrideMaterial:null;for(let se=0,Ge=T.length;se<Ge;se++){let De=T[se],ze=De.object,Be=De.geometry,lt=X===null?De.material:X,ct=De.group;if(U.isArrayCamera){w=U;let Re=U.cameras;for(let nt=0,Qt=Re.length;nt<Qt;nt++){let et=Re[nt];ze.layers.test(et.layers)&&(Ce.viewport(F.copy(et.viewport)),p.setupLights(et),br(ze,k,et,Be,lt,ct))}}else w=null,br(ze,k,U,Be,lt,ct)}}function br(T,k,U,X,se,Ge){if(T.onBeforeRender(m,k,U,X,se,Ge),p=Z.get(k,w||U),T.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix),T.isImmediateRenderObject){let De=Eo(U,k,se,T);Ce.setMaterial(se),be.reset(),al(T,De)}else m.renderBufferDirect(U,k,X,se,T,Ge);T.onAfterRender(m,k,U,X,se,Ge),p=Z.get(k,w||U)}function it(T,k,U){k.isScene!==!0&&(k=Fe);let X=Ie.get(T),se=p.state.lights,Ge=p.state.shadowsArray,De=se.state.version,ze=A.getParameters(T,se.state,Ge,k,U),Be=A.getProgramCacheKey(ze),lt=X.program,ct=!0;if(lt===void 0)T.addEventListener("dispose",ms);else if(lt.cacheKey!==Be)gs(T);else if(X.lightsStateVersion!==De)ct=!1;else if(ze.shaderID!==void 0){let et=T.isMeshStandardMaterial?k.environment:null;X.envMap=re.get(T.envMap||et);return}else ct=!1;ct&&(ze.uniforms=A.getUniforms(T),T.onBeforeCompile(ze,m),lt=A.acquireProgram(ze,Be),X.program=lt,X.uniforms=ze.uniforms,X.outputEncoding=ze.outputEncoding);let Re=X.uniforms;(!T.isShaderMaterial&&!T.isRawShaderMaterial||T.clipping===!0)&&(X.numClippingPlanes=I.numPlanes,X.numIntersection=I.numIntersection,Re.clippingPlanes=I.uniform),X.environment=T.isMeshStandardMaterial?k.environment:null,X.fog=k.fog,X.envMap=re.get(T.envMap||X.environment),X.needsLights=ci(T),X.lightsStateVersion=De,X.needsLights&&(Re.ambientLightColor.value=se.state.ambient,Re.lightProbe.value=se.state.probe,Re.directionalLights.value=se.state.directional,Re.directionalLightShadows.value=se.state.directionalShadow,Re.spotLights.value=se.state.spot,Re.spotLightShadows.value=se.state.spotShadow,Re.rectAreaLights.value=se.state.rectArea,Re.ltc_1.value=se.state.rectAreaLTC1,Re.ltc_2.value=se.state.rectAreaLTC2,Re.pointLights.value=se.state.point,Re.pointLightShadows.value=se.state.pointShadow,Re.hemisphereLights.value=se.state.hemi,Re.directionalShadowMap.value=se.state.directionalShadowMap,Re.directionalShadowMatrix.value=se.state.directionalShadowMatrix,Re.spotShadowMap.value=se.state.spotShadowMap,Re.spotShadowMatrix.value=se.state.spotShadowMatrix,Re.pointShadowMap.value=se.state.pointShadowMap,Re.pointShadowMatrix.value=se.state.pointShadowMatrix);let nt=X.program.getUniforms(),Qt=Uo.seqWithValue(nt.seq,Re);X.uniformsList=Qt}function Eo(T,k,U,X){k.isScene!==!0&&(k=Fe),Q.resetTextureUnits();let se=k.fog,Ge=U.isMeshStandardMaterial?k.environment:null,De=g===null?m.outputEncoding:g.texture.encoding,ze=re.get(U.envMap||Ge),Be=Ie.get(U),lt=p.state.lights;if(ce===!0&&(ge===!0||T!==E)){let ht=T===E&&U.id===C;I.setState(U,T,ht)}U.version===Be.__version?(U.fog&&Be.fog!==se||Be.environment!==Ge||Be.needsLights&&Be.lightsStateVersion!==lt.state.version||Be.numClippingPlanes!==void 0&&(Be.numClippingPlanes!==I.numPlanes||Be.numIntersection!==I.numIntersection)||Be.outputEncoding!==De||Be.envMap!==ze)&&it(U,k,X):(it(U,k,X),Be.__version=U.version);let ct=!1,Re=!1,nt=!1,Qt=Be.program,et=Qt.getUniforms(),tn=Be.uniforms;if(Ce.useProgram(Qt.program)&&(ct=!0,Re=!0,nt=!0),U.id!==C&&(C=U.id,Re=!0),ct||E!==T){if(et.setValue(V,"projectionMatrix",T.projectionMatrix),Ve.logarithmicDepthBuffer&&et.setValue(V,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),E!==T&&(E=T,Re=!0,nt=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let ht=et.map.cameraPosition;ht!==void 0&&ht.setValue(V,Pe.setFromMatrixPosition(T.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&et.setValue(V,"isOrthographic",T.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||U.skinning)&&et.setValue(V,"viewMatrix",T.matrixWorldInverse)}if(U.skinning){et.setOptional(V,X,"bindMatrix"),et.setOptional(V,X,"bindMatrixInverse");let ht=X.skeleton;if(ht){let Gi=ht.bones;if(Ve.floatVertexTextures){if(ht.boneTexture===void 0){let Et=Math.sqrt(Gi.length*4);Et=dt.ceilPowerOfTwo(Et),Et=Math.max(Et,4);let wn=new Float32Array(Et*Et*4);wn.set(ht.boneMatrices);let Gn=new xi(wn,Et,Et,ar,Bo);ht.boneMatrices=wn,ht.boneTexture=Gn,ht.boneTextureSize=Et}et.setValue(V,"boneTexture",ht.boneTexture,Q),et.setValue(V,"boneTextureSize",ht.boneTextureSize)}else et.setOptional(V,ht,"boneMatrices")}}return(Re||Be.receiveShadow!==X.receiveShadow)&&(Be.receiveShadow=X.receiveShadow,et.setValue(V,"receiveShadow",X.receiveShadow)),Re&&(et.setValue(V,"toneMappingExposure",m.toneMappingExposure),Be.needsLights&&So(tn,nt),se&&U.fog&&S.refreshFogUniforms(tn,se),S.refreshMaterialUniforms(tn,U,N,L),Uo.upload(V,Be.uniformsList,tn,Q)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(Uo.upload(V,Be.uniformsList,tn,Q),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&et.setValue(V,"center",X.center),et.setValue(V,"modelViewMatrix",X.modelViewMatrix),et.setValue(V,"normalMatrix",X.normalMatrix),et.setValue(V,"modelMatrix",X.matrixWorld),Qt}function So(T,k){T.ambientLightColor.needsUpdate=k,T.lightProbe.needsUpdate=k,T.directionalLights.needsUpdate=k,T.directionalLightShadows.needsUpdate=k,T.pointLights.needsUpdate=k,T.pointLightShadows.needsUpdate=k,T.spotLights.needsUpdate=k,T.spotLightShadows.needsUpdate=k,T.rectAreaLights.needsUpdate=k,T.hemisphereLights.needsUpdate=k}function ci(T){return T.isMeshLambertMaterial||T.isMeshToonMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isShadowMaterial||T.isShaderMaterial&&T.lights===!0}this.setFramebuffer=function(T){x!==T&&g===null&&V.bindFramebuffer(36160,T),x=T},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return y},this.getRenderList=function(){return f},this.setRenderList=function(T){f=T},this.getRenderState=function(){return p},this.setRenderState=function(T){p=T},this.getRenderTarget=function(){return g},this.setRenderTarget=function(T,k=0,U=0){g=T,b=k,y=U,T&&Ie.get(T).__webglFramebuffer===void 0&&Q.setupRenderTarget(T);let X=x,se=!1;if(T){let Ge=Ie.get(T).__webglFramebuffer;T.isWebGLCubeRenderTarget?(X=Ge[k],se=!0):T.isWebGLMultisampleRenderTarget?X=Ie.get(T).__webglMultisampledFramebuffer:X=Ge,F.copy(T.viewport),H.copy(T.scissor),ne=T.scissorTest}else F.copy(D).multiplyScalar(N).floor(),H.copy(B).multiplyScalar(N).floor(),ne=q;if(M!==X&&(V.bindFramebuffer(36160,X),M=X),Ce.viewport(F),Ce.scissor(H),Ce.setScissorTest(ne),se){let Ge=Ie.get(T.texture);V.framebufferTexture2D(36160,36064,34069+k,Ge.__webglTexture,U)}},this.readRenderTargetPixels=function(T,k,U,X,se,Ge,De){if(!(T&&T.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=Ie.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&De!==void 0&&(ze=ze[De]),ze){let Be=!1;ze!==M&&(V.bindFramebuffer(36160,ze),Be=!0);try{let lt=T.texture,ct=lt.format,Re=lt.type;if(ct!==ar&&pe.convert(ct)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re!==Fg&&pe.convert(Re)!==V.getParameter(35738)&&!(Re===Bo&&(Ve.isWebGL2||we.get("OES_texture_float")||we.get("WEBGL_color_buffer_float")))&&!(Re===cf&&(Ve.isWebGL2?we.get("EXT_color_buffer_float"):we.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V.checkFramebufferStatus(36160)===36053?k>=0&&k<=T.width-X&&U>=0&&U<=T.height-se&&V.readPixels(k,U,X,se,pe.convert(ct),pe.convert(Re),Ge):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Be&&V.bindFramebuffer(36160,M)}}},this.copyFramebufferToTexture=function(T,k,U){U===void 0&&(U=0);let X=Math.pow(2,-U),se=Math.floor(k.image.width*X),Ge=Math.floor(k.image.height*X),De=pe.convert(k.format);Q.setTexture2D(k,0),V.copyTexImage2D(3553,U,De,T.x,T.y,se,Ge,0),Ce.unbindTexture()},this.copyTextureToTexture=function(T,k,U,X){X===void 0&&(X=0);let se=k.image.width,Ge=k.image.height,De=pe.convert(U.format),ze=pe.convert(U.type);Q.setTexture2D(U,0),V.pixelStorei(37440,U.flipY),V.pixelStorei(37441,U.premultiplyAlpha),V.pixelStorei(3317,U.unpackAlignment),k.isDataTexture?V.texSubImage2D(3553,X,T.x,T.y,se,Ge,De,ze,k.image.data):k.isCompressedTexture?V.compressedTexSubImage2D(3553,X,T.x,T.y,k.mipmaps[0].width,k.mipmaps[0].height,De,k.mipmaps[0].data):V.texSubImage2D(3553,X,T.x,T.y,De,ze,k.image),X===0&&U.generateMipmaps&&V.generateMipmap(3553),Ce.unbindTexture()},this.initTexture=function(T){Q.setTexture2D(T,0),Ce.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Wx(t){lc.call(this,t)}Wx.prototype=Object.assign(Object.create(lc.prototype),{constructor:Wx,isWebGL1Renderer:!0});var $m=class extends Je{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let n=super.toJSON(e);return this.background!==null&&(n.object.background=this.background.toJSON(e)),this.environment!==null&&(n.object.environment=this.environment.toJSON(e)),this.fog!==null&&(n.object.fog=this.fog.toJSON()),n}};function Er(t,e){this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Rf,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=dt.generateUUID()}Object.defineProperty(Er.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(Er.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,o=this.stride;r<o;r++)this.array[t+r]=e.array[n+r];return this},set:function(t,e){return e===void 0&&(e=0),this.array.set(t,e),this},clone:function(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dt.generateUUID()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new Er(e,this.stride);return n.setUsage(this.usage),n},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dt.generateUUID()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});var bs=new W;function Rs(t,e,n,r){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r===!0}Object.defineProperties(Rs.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}});Object.assign(Rs.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,n=this.data.count;e<n;e++)bs.x=this.getX(e),bs.y=this.getY(e),bs.z=this.getZ(e),bs.applyMatrix4(t),this.setXYZ(e,bs.x,bs.y,bs.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this},setXYZW:function(t,e,n,r,o){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=o,this},clone:function(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)e.push(this.data.array[r+o])}return new ut(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Rs(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)e.push(this.data.array[r+o])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});function Ps(t){at.call(this),this.type="SpriteMaterial",this.color=new We(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Ps.prototype=Object.create(at.prototype);Ps.prototype.constructor=Ps;Ps.prototype.isSpriteMaterial=!0;Ps.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var Da,xl=new W,Ba=new W,Oa=new W,Ua=new fe,_l=new fe,r_=new vt,Nh=new W,bl=new W,Gh=new W,jx=new fe,Pm=new fe,qx=new fe;function Xx(t){if(Je.call(this),this.type="Sprite",Da===void 0){Da=new Tt;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Er(e,5);Da.setIndex([0,1,2,0,2,3]),Da.setAttribute("position",new Rs(n,3,0,!1)),Da.setAttribute("uv",new Rs(n,2,3,!1))}this.geometry=Da,this.material=t!==void 0?t:new Ps,this.center=new fe(.5,.5)}Xx.prototype=Object.assign(Object.create(Je.prototype),{constructor:Xx,isSprite:!0,raycast:function(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ba.setFromMatrixScale(this.matrixWorld),r_.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Oa.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ba.multiplyScalar(-Oa.z);let n=this.material.rotation,r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));let a=this.center;kh(Nh.set(-.5,-.5,0),Oa,a,Ba,r,o),kh(bl.set(.5,-.5,0),Oa,a,Ba,r,o),kh(Gh.set(.5,.5,0),Oa,a,Ba,r,o),jx.set(0,0),Pm.set(1,0),qx.set(1,1);let c=t.ray.intersectTriangle(Nh,bl,Gh,!1,xl);if(c===null&&(kh(bl.set(-.5,.5,0),Oa,a,Ba,r,o),Pm.set(0,1),c=t.ray.intersectTriangle(Nh,Gh,bl,!1,xl),c===null))return;let l=t.ray.origin.distanceTo(xl);l<t.near||l>t.far||e.push({distance:l,point:xl.clone(),uv:Sr.getUV(xl,Nh,bl,Gh,jx,Pm,qx,new fe),face:null,object:this})},copy:function(t){return Je.prototype.copy.call(this,t),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}});function kh(t,e,n,r,o,a){Ua.subVectors(t,n).addScalar(.5).multiply(r),o!==void 0?(_l.x=a*Ua.x-o*Ua.y,_l.y=o*Ua.x+a*Ua.y):_l.copy(Ua),t.copy(e),t.x+=_l.x,t.y+=_l.y,t.applyMatrix4(r_)}var Hh=new W,Yx=new W;function Zm(){Je.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Zm.prototype=Object.assign(Object.create(Je.prototype),{constructor:Zm,isLOD:!0,copy:function(t){Je.prototype.copy.call(this,t,!1);let e=t.levels;for(let n=0,r=e.length;n<r;n++){let o=e[n];this.addLevel(o.object.clone(),o.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e){e===void 0&&(e=0),e=Math.abs(e);let n=this.levels,r;for(r=0;r<n.length&&!(e<n[r].distance);r++);return n.splice(r,0,{distance:e,object:t}),this.add(t),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(t){let e=this.levels;if(e.length>0){let n,r;for(n=1,r=e.length;n<r&&!(t<e[n].distance);n++);return e[n-1].object}return null},raycast:function(t,e){if(this.levels.length>0){Hh.setFromMatrixPosition(this.matrixWorld);let r=t.ray.origin.distanceTo(Hh);this.getObjectForDistance(r).raycast(t,e)}},update:function(t){let e=this.levels;if(e.length>1){Hh.setFromMatrixPosition(t.matrixWorld),Yx.setFromMatrixPosition(this.matrixWorld);let n=Hh.distanceTo(Yx)/t.zoom;e[0].object.visible=!0;let r,o;for(r=1,o=e.length;r<o&&n>=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(this._currentLevel=r-1;r<o;r++)e[r].object.visible=!1}},toJSON:function(t){let e=Je.prototype.toJSON.call(this,t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];let n=this.levels;for(let r=0,o=n.length;r<o;r++){let a=n[r];e.object.levels.push({object:a.object.uuid,distance:a.distance})}return e}});function Jm(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Wt.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new vt,this.bindMatrixInverse=new vt}Jm.prototype=Object.assign(Object.create(Wt.prototype),{constructor:Jm,isSkinnedMesh:!0,copy:function(t){return Wt.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){let t=new Rt,e=this.geometry.attributes.skinWeight;for(let n=0,r=e.count;n<r;n++){t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.w=e.getW(n);let o=1/t.manhattanLength();o!==1/0?t.multiplyScalar(o):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){Wt.prototype.updateMatrixWorld.call(this,t),this.bindMode==="attached"?this.bindMatrixInverse.getInverse(this.matrixWorld):this.bindMode==="detached"?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(){let t=new W,e=new Rt,n=new Rt,r=new W,o=new vt;return function(a,c){let l=this.skeleton,u=this.geometry;e.fromBufferAttribute(u.attributes.skinIndex,a),n.fromBufferAttribute(u.attributes.skinWeight,a),t.fromBufferAttribute(u.attributes.position,a).applyMatrix4(this.bindMatrix),c.set(0,0,0);for(let h=0;h<4;h++){let d=n.getComponent(h);if(d!==0){let f=e.getComponent(h);o.multiplyMatrices(l.bones[f].matrixWorld,l.boneInverses[f]),c.addScaledVector(r.copy(t).applyMatrix4(o),d)}}return c.applyMatrix4(this.bindMatrixInverse)}}()});var $x=new vt,c3=new vt;function Qm(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(this.bones.length*16),this.frame=-1,e===void 0)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new vt)}}Object.assign(Qm.prototype,{calculateInverses:function(){this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++){let n=new vt;this.bones[t]&&n.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(n)}},pose:function(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.getInverse(this.boneInverses[t])}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.getInverse(n.parent.matrixWorld),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}},update:function(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let o=0,a=t.length;o<a;o++){let c=t[o]?t[o].matrixWorld:c3;$x.multiplyMatrices(c,e[o]),$x.toArray(n,o*16)}r!==void 0&&(r.needsUpdate=!0)},clone:function(){return new Qm(this.bones,this.boneInverses)},getBoneByName:function(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}});function Zx(){Je.call(this),this.type="Bone"}Zx.prototype=Object.assign(Object.create(Je.prototype),{constructor:Zx,isBone:!0});var Jx=new vt,Qx=new vt,zh=[],wl=new Wt;function Kx(t,e,n){Wt.call(this,t,e),this.instanceMatrix=new ut(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}Kx.prototype=Object.assign(Object.create(Wt.prototype),{constructor:Kx,isInstancedMesh:!0,copy:function(t){return Wt.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),this.count=t.count,this},setColorAt:function(t,e){this.instanceColor===null&&(this.instanceColor=new ut(new Float32Array(this.count*3),3)),e.toArray(this.instanceColor.array,t*3)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,t*16)},raycast:function(t,e){let n=this.matrixWorld,r=this.count;if(wl.geometry=this.geometry,wl.material=this.material,wl.material!==void 0)for(let o=0;o<r;o++){this.getMatrixAt(o,Jx),Qx.multiplyMatrices(n,Jx),wl.matrixWorld=Qx,wl.raycast(t,zh);for(let a=0,c=zh.length;a<c;a++){let l=zh[a];l.instanceId=o,l.object=this,e.push(l)}zh.length=0}},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,t*16)},updateMorphTargets:function(){}});function Rr(t){at.call(this),this.type="LineBasicMaterial",this.color=new We(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}Rr.prototype=Object.create(at.prototype);Rr.prototype.constructor=Rr;Rr.prototype.isLineBasicMaterial=!0;Rr.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this};var e0=new W,t0=new W,n0=new vt,Vh=new Ss,Wh=new yi;function Qa(t,e,n){n===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),Je.call(this),this.type="Line",this.geometry=t!==void 0?t:new Tt,this.material=e!==void 0?e:new Rr,this.updateMorphTargets()}Qa.prototype=Object.assign(Object.create(Je.prototype),{constructor:Qa,isLine:!0,copy:function(t){return Je.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){let t=this.geometry;if(t.isBufferGeometry)if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,o=e.count;r<o;r++)e0.fromBufferAttribute(e,r-1),t0.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=e0.distanceTo(t0);t.setAttribute("lineDistance",new St(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){let e=t.vertices,n=t.lineDistances;n[0]=0;for(let r=1,o=e.length;r<o;r++)n[r]=n[r-1],n[r]+=e[r-1].distanceTo(e[r])}return this},raycast:function(t,e){let n=this.geometry,r=this.matrixWorld,o=t.params.Line.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),Wh.copy(n.boundingSphere),Wh.applyMatrix4(r),Wh.radius+=o,t.ray.intersectsSphere(Wh)===!1)return;n0.getInverse(r),Vh.copy(t.ray).applyMatrix4(n0);let a=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new W,u=new W,h=new W,d=new W,f=this.isLineSegments?2:1;if(n.isBufferGeometry){let p=n.index,v=n.attributes.position;if(p!==null){let x=p.array;for(let b=0,y=x.length-1;b<y;b+=f){let g=x[b],M=x[b+1];if(l.fromBufferAttribute(v,g),u.fromBufferAttribute(v,M),Vh.distanceSqToSegment(l,u,d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(d);E<t.near||E>t.far||e.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else for(let x=0,b=v.count-1;x<b;x+=f){if(l.fromBufferAttribute(v,x),u.fromBufferAttribute(v,x+1),Vh.distanceSqToSegment(l,u,d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let g=t.ray.origin.distanceTo(d);g<t.near||g>t.far||e.push({distance:g,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else if(n.isGeometry){let p=n.vertices,m=p.length;for(let v=0;v<m-1;v+=f){if(Vh.distanceSqToSegment(p[v],p[v+1],d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});var jh=new W,qh=new W;function pf(t,e){Qa.call(this,t,e),this.type="LineSegments"}pf.prototype=Object.assign(Object.create(Qa.prototype),{constructor:pf,isLineSegments:!0,computeLineDistances:function(){let t=this.geometry;if(t.isBufferGeometry)if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,o=e.count;r<o;r+=2)jh.fromBufferAttribute(e,r),qh.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+jh.distanceTo(qh);t.setAttribute("lineDistance",new St(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){let e=t.vertices,n=t.lineDistances;for(let r=0,o=e.length;r<o;r+=2)jh.copy(e[r]),qh.copy(e[r+1]),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+jh.distanceTo(qh)}return this}});function r0(t,e){Qa.call(this,t,e),this.type="LineLoop"}r0.prototype=Object.assign(Object.create(Qa.prototype),{constructor:r0,isLineLoop:!0});function Ls(t){at.call(this),this.type="PointsMaterial",this.color=new We(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}Ls.prototype=Object.create(at.prototype);Ls.prototype.constructor=Ls;Ls.prototype.isPointsMaterial=!0;Ls.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};var i0=new vt,Km=new Ss,Xh=new yi,Yh=new W;function o0(t,e){Je.call(this),this.type="Points",this.geometry=t!==void 0?t:new Tt,this.material=e!==void 0?e:new Ls,this.updateMorphTargets()}o0.prototype=Object.assign(Object.create(Je.prototype),{constructor:o0,isPoints:!0,copy:function(t){return Je.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){let n=this.geometry,r=this.matrixWorld,o=t.params.Points.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),Xh.copy(n.boundingSphere),Xh.applyMatrix4(r),Xh.radius+=o,t.ray.intersectsSphere(Xh)===!1)return;i0.getInverse(r),Km.copy(t.ray).applyMatrix4(i0);let a=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a;if(n.isBufferGeometry){let l=n.index,h=n.attributes.position;if(l!==null){let d=l.array;for(let f=0,p=d.length;f<p;f++){let m=d[f];Yh.fromBufferAttribute(h,m),Lm(Yh,m,c,r,t,e,this)}}else for(let d=0,f=h.count;d<f;d++)Yh.fromBufferAttribute(h,d),Lm(Yh,d,c,r,t,e,this)}else{let l=n.vertices;for(let u=0,h=l.length;u<h;u++)Lm(l[u],u,c,r,t,e,this)}},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});function Lm(t,e,n,r,o,a,c){let l=Km.distanceSqToPoint(t);if(l<n){let u=new W;Km.closestPointToPoint(t,u),u.applyMatrix4(r);let h=o.ray.origin.distanceTo(u);if(h<o.near||h>o.far)return;a.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:c})}}function s0(t,e,n,r,o,a,c,l,u){At.call(this,t,e,n,r,o,a,c,l,u),this.format=c!==void 0?c:Ms,this.minFilter=a!==void 0?a:sn,this.magFilter=o!==void 0?o:sn,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}s0.prototype=Object.assign(Object.create(At.prototype),{constructor:s0,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Hl(t,e,n,r,o,a,c,l,u,h,d,f){At.call(this,null,a,c,l,u,h,r,o,d,f),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}Hl.prototype=Object.create(At.prototype);Hl.prototype.constructor=Hl;Hl.prototype.isCompressedTexture=!0;function mf(t,e,n,r,o,a,c,l,u){At.call(this,t,e,n,r,o,a,c,l,u),this.needsUpdate=!0}mf.prototype=Object.create(At.prototype);mf.prototype.constructor=mf;mf.prototype.isCanvasTexture=!0;function gf(t,e,n,r,o,a,c,l,u,h){if(h=h!==void 0?h:Xa,h!==Xa&&h!==Dl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Xa&&(n=af),n===void 0&&h===Dl&&(n=Cl),At.call(this,null,r,o,a,c,l,h,n,u),this.image={width:t,height:e},this.magFilter=c!==void 0?c:Hn,this.minFilter=l!==void 0?l:Hn,this.flipY=!1,this.generateMipmaps=!1}gf.prototype=Object.create(At.prototype);gf.prototype.constructor=gf;gf.prototype.isDepthTexture=!0;var l3=0,fi=new vt,Fm=new Je,$h=new W;function Kt(){Object.defineProperty(this,"id",{value:l3+=2}),this.uuid=dt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Kt.prototype=Object.assign(Object.create(Ji.prototype),{constructor:Kt,isGeometry:!0,applyMatrix4:function(t){let e=new Fn().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n];o.normal.applyMatrix3(e).normalize();for(let a=0,c=o.vertexNormals.length;a<c;a++)o.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return fi.makeRotationX(t),this.applyMatrix4(fi),this},rotateY:function(t){return fi.makeRotationY(t),this.applyMatrix4(fi),this},rotateZ:function(t){return fi.makeRotationZ(t),this.applyMatrix4(fi),this},translate:function(t,e,n){return fi.makeTranslation(t,e,n),this.applyMatrix4(fi),this},scale:function(t,e,n){return fi.makeScale(t,e,n),this.applyMatrix4(fi),this},lookAt:function(t){return Fm.lookAt(t),Fm.updateMatrix(),this.applyMatrix4(Fm.matrix),this},fromBufferGeometry:function(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let o=r.position,a=r.normal,c=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let f=0;f<o.count;f++)e.vertices.push(new W().fromBufferAttribute(o,f)),c!==void 0&&e.colors.push(new We().fromBufferAttribute(c,f));function h(f,p,m,v){let x=c===void 0?[]:[e.colors[f].clone(),e.colors[p].clone(),e.colors[m].clone()],b=a===void 0?[]:[new W().fromBufferAttribute(a,f),new W().fromBufferAttribute(a,p),new W().fromBufferAttribute(a,m)],y=new Ar(f,p,m,b,x,v);e.faces.push(y),l!==void 0&&e.faceVertexUvs[0].push([new fe().fromBufferAttribute(l,f),new fe().fromBufferAttribute(l,p),new fe().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new fe().fromBufferAttribute(u,f),new fe().fromBufferAttribute(u,p),new fe().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let f=0;f<d.length;f++){let p=d[f],m=p.start,v=p.count;for(let x=m,b=m+v;x<b;x+=3)n!==void 0?h(n.getX(x),n.getX(x+1),n.getX(x+2),p.materialIndex):h(x,x+1,x+2,p.materialIndex)}else if(n!==void 0)for(let f=0;f<n.count;f+=3)h(n.getX(f),n.getX(f+1),n.getX(f+2));else for(let f=0;f<o.count;f+=3)h(f,f+1,f+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter($h).negate(),this.translate($h.x,$h.y,$h.z),this},normalize:function(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new vt;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){let t=new W,e=new W;for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n],a=this.vertices[o.a],c=this.vertices[o.b],l=this.vertices[o.c];t.subVectors(l,c),e.subVectors(a,c),t.cross(e),t.normalize(),o.normal.copy(t)}},computeVertexNormals:function(t){t===void 0&&(t=!0);let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new W;if(t){let n=new W,r=new W;for(let o=0,a=this.faces.length;o<a;o++){let c=this.faces[o],l=this.vertices[c.a],u=this.vertices[c.b],h=this.vertices[c.c];n.subVectors(h,u),r.subVectors(l,u),n.cross(r),e[c.a].add(n),e[c.b].add(n),e[c.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n];e[o.a].add(o.normal),e[o.b].add(o.normal),e[o.c].add(o.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n],a=o.vertexNormals;a.length===3?(a[0].copy(e[o.a]),a[1].copy(e[o.b]),a[2].copy(e[o.c])):(a[0]=e[o.a].clone(),a[1]=e[o.b].clone(),a[2]=e[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let o=0,a=r.vertexNormals.length;o<a;o++)r.__originalVertexNormals[o]?r.__originalVertexNormals[o].copy(r.vertexNormals[o]):r.__originalVertexNormals[o]=r.vertexNormals[o].clone()}let t=new Kt;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let o=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let c=0,l=this.faces.length;c<l;c++){let u=new W,h={a:new W,b:new W,c:new W};o.push(u),a.push(h)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let o=0,a=this.faces.length;o<a;o++){let c=this.faces[o],l=r.faceNormals[o],u=r.vertexNormals[o];l.copy(c.normal),u.a.copy(c.vertexNormals[0]),u.b.copy(c.vertexNormals[1]),u.c.copy(c.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new vi),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new yi),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,n){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,o=this.vertices.length,a=this.vertices,c=t.vertices,l=this.faces,u=t.faces,h=this.colors,d=t.colors;n===void 0&&(n=0),e!==void 0&&(r=new Fn().getNormalMatrix(e));for(let f=0,p=c.length;f<p;f++){let v=c[f].clone();e!==void 0&&v.applyMatrix4(e),a.push(v)}for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone());for(let f=0,p=u.length;f<p;f++){let m=u[f],v,x,b=m.vertexNormals,y=m.vertexColors,g=new Ar(m.a+o,m.b+o,m.c+o);g.normal.copy(m.normal),r!==void 0&&g.normal.applyMatrix3(r).normalize();for(let M=0,C=b.length;M<C;M++)v=b[M].clone(),r!==void 0&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(m.color);for(let M=0,C=y.length;M<C;M++)x=y[M],g.vertexColors.push(x.clone());g.materialIndex=m.materialIndex+n,l.push(g)}for(let f=0,p=t.faceVertexUvs.length;f<p;f++){let m=t.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let v=0,x=m.length;v<x;v++){let b=m[v],y=[];for(let g=0,M=b.length;g<M;g++)y.push(b[g].clone());this.faceVertexUvs[f].push(y)}}},mergeMesh:function(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)},mergeVertices:function(){let t={},e=[],n=[],o=Math.pow(10,4);for(let l=0,u=this.vertices.length;l<u;l++){let h=this.vertices[l],d=Math.round(h.x*o)+"_"+Math.round(h.y*o)+"_"+Math.round(h.z*o);t[d]===void 0?(t[d]=l,e.push(this.vertices[l]),n[l]=e.length-1):n[l]=n[t[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let h=this.faces[l];h.a=n[h.a],h.b=n[h.b],h.c=n[h.c];let d=[h.a,h.b,h.c];for(let f=0;f<3;f++)if(d[f]===d[(f+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(u,1)}let c=this.vertices.length-e.length;return this.vertices=e,c},setFromPoints:function(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new W(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],o=this.faceVertexUvs[1],a,c;r&&r.length===e&&(a=[]),o&&o.length===e&&(c=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(r[u]),c&&c.push(o[u])}a&&(this.faceVertexUvs[0]=a),c&&(this.faceVertexUvs[1]=c)},toJSON:function(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let v in m)m[v]!==void 0&&(t[v]=m[v]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let v=this.vertices[m];e.push(v.x,v.y,v.z)}let n=[],r=[],o={},a=[],c={},l=[],u={};for(let m=0;m<this.faces.length;m++){let v=this.faces[m],x=!0,b=!1,y=this.faceVertexUvs[0][m]!==void 0,g=v.normal.length()>0,M=v.vertexNormals.length>0,C=v.color.r!==1||v.color.g!==1||v.color.b!==1,E=v.vertexColors.length>0,w=0;if(w=h(w,0,0),w=h(w,1,x),w=h(w,2,b),w=h(w,3,y),w=h(w,4,g),w=h(w,5,M),w=h(w,6,C),w=h(w,7,E),n.push(w),n.push(v.a,v.b,v.c),n.push(v.materialIndex),y){let F=this.faceVertexUvs[0][m];n.push(p(F[0]),p(F[1]),p(F[2]))}if(g&&n.push(d(v.normal)),M){let F=v.vertexNormals;n.push(d(F[0]),d(F[1]),d(F[2]))}if(C&&n.push(f(v.color)),E){let F=v.vertexColors;n.push(f(F[0]),f(F[1]),f(F[2]))}}function h(m,v,x){return x?m|1<<v:m&~(1<<v)}function d(m){let v=m.x.toString()+m.y.toString()+m.z.toString();return o[v]!==void 0||(o[v]=r.length/3,r.push(m.x,m.y,m.z)),o[v]}function f(m){let v=m.r.toString()+m.g.toString()+m.b.toString();return c[v]!==void 0||(c[v]=a.length,a.push(m.getHex())),c[v]}function p(m){let v=m.x.toString()+m.y.toString();return u[v]!==void 0||(u[v]=l.length/2,l.push(m.x,m.y)),u[v]}return t.data={},t.data.vertices=e,t.data.normals=r,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t},clone:function(){return new Kt().copy(this)},copy:function(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let f=0,p=e.length;f<p;f++)this.vertices.push(e[f].clone());let n=t.colors;for(let f=0,p=n.length;f<p;f++)this.colors.push(n[f].clone());let r=t.faces;for(let f=0,p=r.length;f<p;f++)this.faces.push(r[f].clone());for(let f=0,p=t.faceVertexUvs.length;f<p;f++){let m=t.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let v=0,x=m.length;v<x;v++){let b=m[v],y=[];for(let g=0,M=b.length;g<M;g++){let C=b[g];y.push(C.clone())}this.faceVertexUvs[f].push(y)}}let o=t.morphTargets;for(let f=0,p=o.length;f<p;f++){let m={};if(m.name=o[f].name,o[f].vertices!==void 0){m.vertices=[];for(let v=0,x=o[f].vertices.length;v<x;v++)m.vertices.push(o[f].vertices[v].clone())}if(o[f].normals!==void 0){m.normals=[];for(let v=0,x=o[f].normals.length;v<x;v++)m.normals.push(o[f].normals[v].clone())}this.morphTargets.push(m)}let a=t.morphNormals;for(let f=0,p=a.length;f<p;f++){let m={};if(a[f].vertexNormals!==void 0){m.vertexNormals=[];for(let v=0,x=a[f].vertexNormals.length;v<x;v++){let b=a[f].vertexNormals[v],y={};y.a=b.a.clone(),y.b=b.b.clone(),y.c=b.c.clone(),m.vertexNormals.push(y)}}if(a[f].faceNormals!==void 0){m.faceNormals=[];for(let v=0,x=a[f].faceNormals.length;v<x;v++)m.faceNormals.push(a[f].faceNormals[v].clone())}this.morphNormals.push(m)}let c=t.skinWeights;for(let f=0,p=c.length;f<p;f++)this.skinWeights.push(c[f].clone());let l=t.skinIndices;for(let f=0,p=l.length;f<p;f++)this.skinIndices.push(l[f].clone());let u=t.lineDistances;for(let f=0,p=u.length;f<p;f++)this.lineDistances.push(u[f]);let h=t.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var DB=new W,BB=new W,OB=new W,UB=new Sr;var u3={triangulate:function(t,e,n){n=n||2;let r=e&&e.length,o=r?e[0]*n:t.length,a=i_(t,0,o,n,!0),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,f,p,m;if(r&&(a=m3(t,e,a,n)),t.length>80*n){l=h=t[0],u=d=t[1];for(let v=n;v<o;v+=n)f=t[v],p=t[v+1],f<l&&(l=f),p<u&&(u=p),f>h&&(h=f),p>d&&(d=p);m=Math.max(h-l,d-u),m=m!==0?1/m:0}return zl(a,c,n,l,u,m),c}};function i_(t,e,n,r,o){let a,c;if(o===T3(t,e,n,r)>0)for(a=e;a<n;a+=r)c=a0(a,t[a],t[a+1],c);else for(a=n-r;a>=e;a-=r)c=a0(a,t[a],t[a+1],c);return c&&Pf(c,c.next)&&(Wl(c),c=c.next),c}function Ho(t,e){if(!t)return t;e||(e=t);let n=t,r;do if(r=!1,!n.steiner&&(Pf(n,n.next)||qt(n.prev,n,n.next)===0)){if(Wl(n),n=e=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==e);return e}function zl(t,e,n,r,o,a,c){if(!t)return;!c&&a&&_3(t,r,o,a);let l=t,u,h;for(;t.prev!==t.next;){if(u=t.prev,h=t.next,a?f3(t,r,o,a):h3(t)){e.push(u.i/n),e.push(t.i/n),e.push(h.i/n),Wl(t),t=h.next,l=h.next;continue}if(t=h,t===l){c?c===1?(t=d3(Ho(t),e,n),zl(t,e,n,r,o,a,2)):c===2&&p3(t,e,n,r,o,a):zl(Ho(t),e,n,r,o,a,1);break}}}function h3(t){let e=t.prev,n=t,r=t.next;if(qt(e,n,r)>=0)return!1;let o=t.next.next;for(;o!==t.prev;){if(qa(e.x,e.y,n.x,n.y,r.x,r.y,o.x,o.y)&&qt(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function f3(t,e,n,r){let o=t.prev,a=t,c=t.next;if(qt(o,a,c)>=0)return!1;let l=o.x<a.x?o.x<c.x?o.x:c.x:a.x<c.x?a.x:c.x,u=o.y<a.y?o.y<c.y?o.y:c.y:a.y<c.y?a.y:c.y,h=o.x>a.x?o.x>c.x?o.x:c.x:a.x>c.x?a.x:c.x,d=o.y>a.y?o.y>c.y?o.y:c.y:a.y>c.y?a.y:c.y,f=eg(l,u,e,n,r),p=eg(h,d,e,n,r),m=t.prevZ,v=t.nextZ;for(;m&&m.z>=f&&v&&v.z<=p;){if(m!==t.prev&&m!==t.next&&qa(o.x,o.y,a.x,a.y,c.x,c.y,m.x,m.y)&&qt(m.prev,m,m.next)>=0||(m=m.prevZ,v!==t.prev&&v!==t.next&&qa(o.x,o.y,a.x,a.y,c.x,c.y,v.x,v.y)&&qt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;m&&m.z>=f;){if(m!==t.prev&&m!==t.next&&qa(o.x,o.y,a.x,a.y,c.x,c.y,m.x,m.y)&&qt(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;v&&v.z<=p;){if(v!==t.prev&&v!==t.next&&qa(o.x,o.y,a.x,a.y,c.x,c.y,v.x,v.y)&&qt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function d3(t,e,n){let r=t;do{let o=r.prev,a=r.next.next;!Pf(o,a)&&o_(o,r,r.next,a)&&Vl(o,a)&&Vl(a,o)&&(e.push(o.i/n),e.push(r.i/n),e.push(a.i/n),Wl(r),Wl(r.next),r=t=a),r=r.next}while(r!==t);return Ho(r)}function p3(t,e,n,r,o,a){let c=t;do{let l=c.next.next;for(;l!==c.prev;){if(c.i!==l.i&&M3(c,l)){let u=s_(c,l);c=Ho(c,c.next),u=Ho(u,u.next),zl(c,e,n,r,o,a),zl(u,e,n,r,o,a);return}l=l.next}c=c.next}while(c!==t)}function m3(t,e,n,r){let o=[],a,c,l,u,h;for(a=0,c=e.length;a<c;a++)l=e[a]*r,u=a<c-1?e[a+1]*r:t.length,h=i_(t,l,u,r,!1),h===h.next&&(h.steiner=!0),o.push(w3(h));for(o.sort(g3),a=0;a<o.length;a++)v3(o[a],n),n=Ho(n,n.next);return n}function g3(t,e){return t.x-e.x}function v3(t,e){if(e=y3(t,e),e){let n=s_(e,t);Ho(e,e.next),Ho(n,n.next)}}function y3(t,e){let n=e,r=t.x,o=t.y,a=-1/0,c;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let p=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=r&&p>a){if(a=p,p===r){if(o===n.y)return n;if(o===n.next.y)return n.next}c=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!c)return null;if(r===a)return c;let l=c,u=c.x,h=c.y,d=1/0,f;n=c;do r>=n.x&&n.x>=u&&r!==n.x&&qa(o<h?r:a,o,u,h,o<h?a:r,o,n.x,n.y)&&(f=Math.abs(o-n.y)/(r-n.x),Vl(n,t)&&(f<d||f===d&&(n.x>c.x||n.x===c.x&&x3(c,n)))&&(c=n,d=f)),n=n.next;while(n!==l);return c}function x3(t,e){return qt(t.prev,t,e.prev)<0&&qt(e.next,t,t.next)<0}function _3(t,e,n,r){let o=t;do o.z===null&&(o.z=eg(o.x,o.y,e,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,b3(o)}function b3(t){let e,n,r,o,a,c,l,u,h=1;do{for(n=t,t=null,a=null,c=0;n;){for(c++,r=n,l=0,e=0;e<h&&(l++,r=r.nextZ,!!r);e++);for(u=h;l>0||u>0&&r;)l!==0&&(u===0||!r||n.z<=r.z)?(o=n,n=n.nextZ,l--):(o=r,r=r.nextZ,u--),a?a.nextZ=o:t=o,o.prevZ=a,a=o;n=r}a.nextZ=null,h*=2}while(c>1);return t}function eg(t,e,n,r,o){return t=32767*(t-n)*o,e=32767*(e-r)*o,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function w3(t){let e=t,n=t;do(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next;while(e!==t);return n}function qa(t,e,n,r,o,a,c,l){return(o-c)*(e-l)-(t-c)*(a-l)>=0&&(t-c)*(r-l)-(n-c)*(e-l)>=0&&(n-c)*(a-l)-(o-c)*(r-l)>=0}function M3(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!E3(t,e)&&(Vl(t,e)&&Vl(e,t)&&S3(t,e)&&(qt(t.prev,t,e.prev)||qt(t,e.prev,e))||Pf(t,e)&&qt(t.prev,t,t.next)>0&&qt(e.prev,e,e.next)>0)}function qt(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Pf(t,e){return t.x===e.x&&t.y===e.y}function o_(t,e,n,r){let o=Jh(qt(t,e,n)),a=Jh(qt(t,e,r)),c=Jh(qt(n,r,t)),l=Jh(qt(n,r,e));return!!(o!==a&&c!==l||o===0&&Zh(t,n,e)||a===0&&Zh(t,r,e)||c===0&&Zh(n,t,r)||l===0&&Zh(n,e,r))}function Zh(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Jh(t){return t>0?1:t<0?-1:0}function E3(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&o_(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function Vl(t,e){return qt(t.prev,t,t.next)<0?qt(t,e,t.next)>=0&&qt(t,t.prev,e)>=0:qt(t,e,t.prev)<0||qt(t,t.next,e)<0}function S3(t,e){let n=t,r=!1,o=(t.x+e.x)/2,a=(t.y+e.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&o<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==t);return r}function s_(t,e){let n=new tg(t.i,t.x,t.y),r=new tg(e.i,e.x,e.y),o=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function a0(t,e,n,r){let o=new tg(t,e,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Wl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function tg(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T3(t,e,n,r){let o=0;for(let a=e,c=n-r;a<n;a+=r)o+=(t[c]-t[a])*(t[a+1]+t[c+1]),c=a;return o}var No={area:function(t){let e=t.length,n=0;for(let r=e-1,o=0;o<e;r=o++)n+=t[r].x*t[o].y-t[o].x*t[r].y;return n*.5},isClockWise:function(t){return No.area(t)<0},triangulateShape:function(t,e){let n=[],r=[],o=[];c0(t),l0(n,t);let a=t.length;e.forEach(c0);for(let l=0;l<e.length;l++)r.push(a),a+=e[l].length,l0(n,e[l]);let c=u3.triangulate(n,r);for(let l=0;l<c.length;l+=3)o.push(c.slice(l,l+3));return o}};function c0(t){let e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function l0(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}var vf=class extends Tt{constructor(e,n){super(),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:n},e=Array.isArray(e)?e:[e];let r=this,o=[],a=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];c(h)}this.setAttribute("position",new St(o,3)),this.setAttribute("uv",new St(a,2)),this.computeVertexNormals();function c(l){let u=[],h=n.curveSegments!==void 0?n.curveSegments:12,d=n.steps!==void 0?n.steps:1,f=n.depth!==void 0?n.depth:100,p=n.bevelEnabled!==void 0?n.bevelEnabled:!0,m=n.bevelThickness!==void 0?n.bevelThickness:6,v=n.bevelSize!==void 0?n.bevelSize:m-2,x=n.bevelOffset!==void 0?n.bevelOffset:0,b=n.bevelSegments!==void 0?n.bevelSegments:3,y=n.extrudePath,g=n.UVGenerator!==void 0?n.UVGenerator:A3;n.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),f=n.amount);let M,C=!1,E,w,F,H;y&&(M=y.getSpacedPoints(d),C=!0,p=!1,E=y.computeFrenetFrames(d,!1),w=new W,F=new W,H=new W),p||(b=0,m=0,v=0,x=0);let ne=l.extractPoints(h),Y=ne.shape,L=ne.holes;if(!No.isClockWise(Y)){Y=Y.reverse();for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];No.isClockWise(ie)&&(L[Q]=ie.reverse())}}let G=No.triangulateShape(Y,L),z=Y;for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];Y=Y.concat(ie)}function D(Q,re,ie){return re||console.error("THREE.ExtrudeGeometry: vec does not exist"),re.clone().multiplyScalar(ie).add(Q)}let B=Y.length,q=G.length;function $(Q,re,ie){let _e,le,A,S=Q.x-re.x,K=Q.y-re.y,Z=ie.x-Q.x,I=ie.y-Q.y,ee=S*S+K*K,ae=S*I-K*Z;if(Math.abs(ae)>Number.EPSILON){let ve=Math.sqrt(ee),oe=Math.sqrt(Z*Z+I*I),pe=re.x-K/ve,be=re.y+S/ve,Te=ie.x-I/oe,de=ie.y+Z/oe,Me=((Te-pe)*I-(de-be)*Z)/(S*I-K*Z);_e=pe+S*Me-Q.x,le=be+K*Me-Q.y;let ot=_e*_e+le*le;if(ot<=2)return new fe(_e,le);A=Math.sqrt(ot/2)}else{let ve=!1;S>Number.EPSILON?Z>Number.EPSILON&&(ve=!0):S<-Number.EPSILON?Z<-Number.EPSILON&&(ve=!0):Math.sign(K)===Math.sign(I)&&(ve=!0),ve?(_e=-K,le=S,A=Math.sqrt(ee)):(_e=S,le=K,A=Math.sqrt(ee/2))}return new fe(_e/A,le/A)}let ce=[];for(let Q=0,re=z.length,ie=re-1,_e=Q+1;Q<re;Q++,ie++,_e++)ie===re&&(ie=0),_e===re&&(_e=0),ce[Q]=$(z[Q],z[ie],z[_e]);let ge=[],he,Pe=ce.concat();for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];he=[];for(let _e=0,le=ie.length,A=le-1,S=_e+1;_e<le;_e++,A++,S++)A===le&&(A=0),S===le&&(S=0),he[_e]=$(ie[_e],ie[A],ie[S]);ge.push(he),Pe=Pe.concat(he)}for(let Q=0;Q<b;Q++){let re=Q/b,ie=m*Math.cos(re*Math.PI/2),_e=v*Math.sin(re*Math.PI/2)+x;for(let le=0,A=z.length;le<A;le++){let S=D(z[le],ce[le],_e);we(S.x,S.y,-ie)}for(let le=0,A=L.length;le<A;le++){let S=L[le];he=ge[le];for(let K=0,Z=S.length;K<Z;K++){let I=D(S[K],he[K],_e);we(I.x,I.y,-ie)}}}let Fe=v+x;for(let Q=0;Q<B;Q++){let re=p?D(Y[Q],Pe[Q],Fe):Y[Q];C?(F.copy(E.normals[0]).multiplyScalar(re.x),w.copy(E.binormals[0]).multiplyScalar(re.y),H.copy(M[0]).add(F).add(w),we(H.x,H.y,H.z)):we(re.x,re.y,0)}for(let Q=1;Q<=d;Q++)for(let re=0;re<B;re++){let ie=p?D(Y[re],Pe[re],Fe):Y[re];C?(F.copy(E.normals[Q]).multiplyScalar(ie.x),w.copy(E.binormals[Q]).multiplyScalar(ie.y),H.copy(M[Q]).add(F).add(w),we(H.x,H.y,H.z)):we(ie.x,ie.y,f/d*Q)}for(let Q=b-1;Q>=0;Q--){let re=Q/b,ie=m*Math.cos(re*Math.PI/2),_e=v*Math.sin(re*Math.PI/2)+x;for(let le=0,A=z.length;le<A;le++){let S=D(z[le],ce[le],_e);we(S.x,S.y,f+ie)}for(let le=0,A=L.length;le<A;le++){let S=L[le];he=ge[le];for(let K=0,Z=S.length;K<Z;K++){let I=D(S[K],he[K],_e);C?we(I.x,I.y+M[d-1].y,M[d-1].x+ie):we(I.x,I.y,f+ie)}}}st(),V();function st(){let Q=o.length/3;if(p){let re=0,ie=B*re;for(let _e=0;_e<q;_e++){let le=G[_e];Ve(le[2]+ie,le[1]+ie,le[0]+ie)}re=d+b*2,ie=B*re;for(let _e=0;_e<q;_e++){let le=G[_e];Ve(le[0]+ie,le[1]+ie,le[2]+ie)}}else{for(let re=0;re<q;re++){let ie=G[re];Ve(ie[2],ie[1],ie[0])}for(let re=0;re<q;re++){let ie=G[re];Ve(ie[0]+B*d,ie[1]+B*d,ie[2]+B*d)}}r.addGroup(Q,o.length/3-Q,0)}function V(){let Q=o.length/3,re=0;_t(z,re),re+=z.length;for(let ie=0,_e=L.length;ie<_e;ie++){let le=L[ie];_t(le,re),re+=le.length}r.addGroup(Q,o.length/3-Q,1)}function _t(Q,re){let ie=Q.length;for(;--ie>=0;){let _e=ie,le=ie-1;le<0&&(le=Q.length-1);for(let A=0,S=d+b*2;A<S;A++){let K=B*A,Z=B*(A+1),I=re+_e+K,ee=re+le+K,ae=re+le+Z,ve=re+_e+Z;Ce(I,ee,ae,ve)}}}function we(Q,re,ie){u.push(Q),u.push(re),u.push(ie)}function Ve(Q,re,ie){$e(Q),$e(re),$e(ie);let _e=o.length/3,le=g.generateTopUV(r,o,_e-3,_e-2,_e-1);Ie(le[0]),Ie(le[1]),Ie(le[2])}function Ce(Q,re,ie,_e){$e(Q),$e(re),$e(_e),$e(re),$e(ie),$e(_e);let le=o.length/3,A=g.generateSideWallUV(r,o,le-6,le-3,le-2,le-1);Ie(A[0]),Ie(A[1]),Ie(A[3]),Ie(A[1]),Ie(A[2]),Ie(A[3])}function $e(Q){o.push(u[Q*3+0]),o.push(u[Q*3+1]),o.push(u[Q*3+2])}function Ie(Q){a.push(Q.x),a.push(Q.y)}}}toJSON(){let e=Tt.prototype.toJSON.call(this),n=this.parameters.shapes,r=this.parameters.options;return C3(n,r,e)}},A3={generateTopUV:function(t,e,n,r,o){let a=e[n*3],c=e[n*3+1],l=e[r*3],u=e[r*3+1],h=e[o*3],d=e[o*3+1];return[new fe(a,c),new fe(l,u),new fe(h,d)]},generateSideWallUV:function(t,e,n,r,o,a){let c=e[n*3],l=e[n*3+1],u=e[n*3+2],h=e[r*3],d=e[r*3+1],f=e[r*3+2],p=e[o*3],m=e[o*3+1],v=e[o*3+2],x=e[a*3],b=e[a*3+1],y=e[a*3+2];return Math.abs(l-d)<.01?[new fe(c,1-u),new fe(h,1-f),new fe(p,1-v),new fe(x,1-y)]:[new fe(l,1-u),new fe(d,1-f),new fe(m,1-v),new fe(b,1-y)]}};function C3(t,e,n){if(n.shapes=[],Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);return e.extrudePath!==void 0&&(n.options.extrudePath=e.extrudePath.toJSON()),n}var ng=class extends Kt{constructor(e,n){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:n},this.fromBufferGeometry(new vf(e,n)),this.mergeVertices()}toJSON(){let e=super.toJSON(),n=this.parameters.shapes,r=this.parameters.options;return R3(n,r,e)}};function R3(t,e,n){if(n.shapes=[],Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);return e.extrudePath!==void 0&&(n.options.extrudePath=e.extrudePath.toJSON()),n}function yf(t,e,n){Tt.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:n};let r=[],o=[],a=[],c=[],l=1e-5,u=new W,h=new W,d=new W,f=new W,p=new W;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");let m=e+1;for(let v=0;v<=n;v++){let x=v/n;for(let b=0;b<=e;b++){let y=b/e;t(y,x,h),o.push(h.x,h.y,h.z),y-l>=0?(t(y-l,x,d),f.subVectors(h,d)):(t(y+l,x,d),f.subVectors(d,h)),x-l>=0?(t(y,x-l,d),p.subVectors(h,d)):(t(y,x+l,d),p.subVectors(d,h)),u.crossVectors(f,p).normalize(),a.push(u.x,u.y,u.z),c.push(y,x)}}for(let v=0;v<n;v++)for(let x=0;x<e;x++){let b=v*m+x,y=v*m+x+1,g=(v+1)*m+x+1,M=(v+1)*m+x;r.push(b,y,M),r.push(y,g,M)}this.setIndex(r),this.setAttribute("position",new St(o,3)),this.setAttribute("normal",new St(a,3)),this.setAttribute("uv",new St(c,2))}yf.prototype=Object.create(Tt.prototype);yf.prototype.constructor=yf;function rg(t,e,n){Kt.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n},this.fromBufferGeometry(new yf(t,e,n)),this.mergeVertices()}rg.prototype=Object.create(Kt.prototype);rg.prototype.constructor=rg;var xf=class extends Kt{constructor(e,n,r,o){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:o},this.fromBufferGeometry(new df(e,n,r,o)),this.mergeVertices()}};var ig=class extends Tt{constructor(e,n){super(),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:n},n=n||12;let r=[],o=[],a=[],c=[],l=0,u=0;if(Array.isArray(e)===!1)h(e);else for(let d=0;d<e.length;d++)h(e[d]),this.addGroup(l,u,d),l+=u,u=0;this.setIndex(r),this.setAttribute("position",new St(o,3)),this.setAttribute("normal",new St(a,3)),this.setAttribute("uv",new St(c,2));function h(d){let f=o.length/3,p=d.extractPoints(n),m=p.shape,v=p.holes;No.isClockWise(m)===!1&&(m=m.reverse());for(let b=0,y=v.length;b<y;b++){let g=v[b];No.isClockWise(g)===!0&&(v[b]=g.reverse())}let x=No.triangulateShape(m,v);for(let b=0,y=v.length;b<y;b++){let g=v[b];m=m.concat(g)}for(let b=0,y=m.length;b<y;b++){let g=m[b];o.push(g.x,g.y,0),a.push(0,0,1),c.push(g.x,g.y)}for(let b=0,y=x.length;b<y;b++){let g=x[b],M=g[0]+f,C=g[1]+f,E=g[2]+f;r.push(M,C,E),u+=3}}}toJSON(){let e=Tt.prototype.toJSON.call(this),n=this.parameters.shapes;return P3(n,e)}};function P3(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,r=t.length;n<r;n++){let o=t[n];e.shapes.push(o.uuid)}else e.shapes.push(t.uuid);return e}var og=class extends Kt{constructor(e,n){super(),this.type="ShapeGeometry",typeof n=="object"&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),n=n.curveSegments),this.parameters={shapes:e,curveSegments:n},this.fromBufferGeometry(new ig(e,n)),this.mergeVertices()}toJSON(){let e=Kt.prototype.toJSON.call(this),n=this.parameters.shapes;return L3(n,e)}};function L3(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,r=t.length;n<r;n++){let o=t[n];e.shapes.push(o.uuid)}else e.shapes.push(t.uuid);return e}function Ka(t){at.call(this),this.type="ShadowMaterial",this.color=new We(0),this.transparent=!0,this.setValues(t)}Ka.prototype=Object.create(at.prototype);Ka.prototype.constructor=Ka;Ka.prototype.isShadowMaterial=!0;Ka.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this};function jl(t){In.call(this,t),this.type="RawShaderMaterial"}jl.prototype=Object.create(In.prototype);jl.prototype.constructor=jl;jl.prototype.isRawShaderMaterial=!0;function qi(t){at.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new We(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ac,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}qi.prototype=Object.create(at.prototype);qi.prototype.constructor=qi;qi.prototype.isMeshStandardMaterial=!0;qi.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this};function Fs(t){qi.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new fe(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(e){this.reflectivity=dt.clamp(2.5*(e-1)/(e+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}Fs.prototype=Object.create(qi.prototype);Fs.prototype.constructor=Fs;Fs.prototype.isMeshPhysicalMaterial=!0;Fs.prototype.copy=function(t){return qi.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new We).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this};function Is(t){at.call(this),this.type="MeshPhongMaterial",this.color=new We(16777215),this.specular=new We(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ac,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Af,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}Is.prototype=Object.create(at.prototype);Is.prototype.constructor=Is;Is.prototype.isMeshPhongMaterial=!0;Is.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function ec(t){at.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new We(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ac,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}ec.prototype=Object.create(at.prototype);ec.prototype.constructor=ec;ec.prototype.isMeshToonMaterial=!0;ec.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function tc(t){at.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ac,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}tc.prototype=Object.create(at.prototype);tc.prototype.constructor=tc;tc.prototype.isMeshNormalMaterial=!0;tc.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function nc(t){at.call(this),this.type="MeshLambertMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Af,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}nc.prototype=Object.create(at.prototype);nc.prototype.constructor=nc;nc.prototype.isMeshLambertMaterial=!0;nc.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function rc(t){at.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new We(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ac,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}rc.prototype=Object.create(at.prototype);rc.prototype.constructor=rc;rc.prototype.isMeshMatcapMaterial=!0;rc.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function ic(t){Rr.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}ic.prototype=Object.create(Rr.prototype);ic.prototype.constructor=ic;ic.prototype.isLineDashedMaterial=!0;ic.prototype.copy=function(t){return Rr.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var F3=Object.freeze({__proto__:null,ShadowMaterial:Ka,SpriteMaterial:Ps,RawShaderMaterial:jl,ShaderMaterial:In,PointsMaterial:Ls,MeshPhysicalMaterial:Fs,MeshStandardMaterial:qi,MeshPhongMaterial:Is,MeshToonMaterial:ec,MeshNormalMaterial:tc,MeshLambertMaterial:nc,MeshDepthMaterial:As,MeshDistanceMaterial:Cs,MeshBasicMaterial:Xr,MeshMatcapMaterial:rc,LineDashedMaterial:ic,LineBasicMaterial:Rr,Material:at}),Vt={arraySlice:function(t,e,n){return Vt.isTypedArray(t)?new t.constructor(t.subarray(e,n!==void 0?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:typeof e.BYTES_PER_ELEMENT=="number"?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(o,a){return t[o]-t[a]}let n=t.length,r=new Array(n);for(let o=0;o!==n;++o)r[o]=o;return r.sort(e),r},sortedArray:function(t,e,n){let r=t.length,o=new t.constructor(r);for(let a=0,c=0;c!==r;++a){let l=n[a]*e;for(let u=0;u!==e;++u)o[c++]=t[l+u]}return o},flattenJSON:function(t,e,n,r){let o=1,a=t[0];for(;a!==void 0&&a[r]===void 0;)a=t[o++];if(a===void 0)return;let c=a[r];if(c!==void 0)if(Array.isArray(c))do c=a[r],c!==void 0&&(e.push(a.time),n.push.apply(n,c)),a=t[o++];while(a!==void 0);else if(c.toArray!==void 0)do c=a[r],c!==void 0&&(e.push(a.time),c.toArray(n,n.length)),a=t[o++];while(a!==void 0);else do c=a[r],c!==void 0&&(e.push(a.time),n.push(c)),a=t[o++];while(a!==void 0)},subclip:function(t,e,n,r,o){o=o||30;let a=t.clone();a.name=e;let c=[];for(let u=0;u<a.tracks.length;++u){let h=a.tracks[u],d=h.getValueSize(),f=[],p=[];for(let m=0;m<h.times.length;++m){let v=h.times[m]*o;if(!(v<n||v>=r)){f.push(h.times[m]);for(let x=0;x<d;++x)p.push(h.values[m*d+x])}}f.length!==0&&(h.times=Vt.convertArray(f,h.times.constructor),h.values=Vt.convertArray(p,h.values.constructor),c.push(h))}a.tracks=c;let l=1/0;for(let u=0;u<a.tracks.length;++u)l>a.tracks[u].times[0]&&(l=a.tracks[u].times[0]);for(let u=0;u<a.tracks.length;++u)a.tracks[u].shift(-1*l);return a.resetDuration(),a},makeClipAdditive:function(t,e,n,r){e===void 0&&(e=0),n===void 0&&(n=t),(r===void 0||r<=0)&&(r=30);let o=n.tracks.length,a=e/r;for(let c=0;c<o;++c){let l=n.tracks[c],u=l.ValueTypeName;if(u==="bool"||u==="string")continue;let h=t.tracks.find(function(y){return y.name===l.name&&y.ValueTypeName===u});if(h===void 0)continue;let d=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let p=0,m=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);let v=l.times.length-1,x;if(a<=l.times[0]){let y=d,g=f-d;x=Vt.arraySlice(l.values,y,g)}else if(a>=l.times[v]){let y=v*f+d,g=y+f-d;x=Vt.arraySlice(l.values,y,g)}else{let y=l.createInterpolant(),g=d,M=f-d;y.evaluate(a),x=Vt.arraySlice(y.resultBuffer,g,M)}u==="quaternion"&&new zn().fromArray(x).normalize().conjugate().toArray(x);let b=h.times.length;for(let y=0;y<b;++y){let g=y*m+p;if(u==="quaternion")zn.multiplyQuaternionsFlat(h.values,g,x,0,h.values,g);else{let M=m-p*2;for(let C=0;C<M;++C)h.values[g+C]-=x[C]}}}return t.blendMode=N0,t}};function Tr(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n}Object.assign(Tr.prototype,{evaluate:function(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],o=e[n-1];e:{t:{let a;n:{r:if(!(t<r)){for(let c=n+2;;){if(r===void 0){if(t<o)break r;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,o)}if(n===c)break;if(o=r,r=e[++n],t<r)break t}a=e.length;break n}if(!(t>=o)){let c=e[1];t<c&&(n=2,o=c);for(let l=n-2;;){if(o===void 0)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(n===l)break;if(r=o,o=e[--n-1],t>=o)break t}a=n,n=0;break n}break e}for(;n<a;){let c=n+a>>>1;t<e[c]?a=c:n=c+1}if(r=e[n],o=e[n-1],o===void 0)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(r===void 0)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,o,t)}this._cachedIndex=n,this.intervalChanged_(n,o,r)}return this.interpolate_(n,o,t,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=t*r;for(let a=0;a!==r;++a)e[a]=n[o+a];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}});Object.assign(Tr.prototype,{beforeStart_:Tr.prototype.copySampleValue_,afterEnd_:Tr.prototype.copySampleValue_});function sg(t,e,n,r){Tr.call(this,t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}sg.prototype=Object.assign(Object.create(Tr.prototype),{constructor:sg,DefaultSettings_:{endingStart:ka,endingEnd:ka},intervalChanged_:function(t,e,n){let r=this.parameterPositions,o=t-2,a=t+1,c=r[o],l=r[a];if(c===void 0)switch(this.getSettings_().endingStart){case Ha:o=t,c=2*e-n;break;case uf:o=r.length-2,c=e+r[o]-r[o+1];break;default:o=t,c=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ha:a=t,l=2*n-e;break;case uf:a=1,l=n+r[1]-r[0];break;default:a=t-1,l=e}let u=(n-e)*.5,h=this.valueSize;this._weightPrev=u/(e-c),this._weightNext=u/(l-n),this._offsetPrev=o*h,this._offsetNext=a*h},interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=t*c,u=l-c,h=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,m=(n-e)/(r-e),v=m*m,x=v*m,b=-f*x+2*f*v-f*m,y=(1+f)*x+(-1.5-2*f)*v+(-.5+f)*m+1,g=(-1-p)*x+(1.5+p)*v+.5*m,M=p*x-p*v;for(let C=0;C!==c;++C)o[C]=b*a[h+C]+y*a[u+C]+g*a[l+C]+M*a[d+C];return o}});function _f(t,e,n,r){Tr.call(this,t,e,n,r)}_f.prototype=Object.assign(Object.create(Tr.prototype),{constructor:_f,interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=t*c,u=l-c,h=(n-e)/(r-e),d=1-h;for(let f=0;f!==c;++f)o[f]=a[u+f]*d+a[l+f]*h;return o}});function ag(t,e,n,r){Tr.call(this,t,e,n,r)}ag.prototype=Object.assign(Object.create(Tr.prototype),{constructor:ag,interpolate_:function(t){return this.copySampleValue_(t-1)}});function Dn(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Vt.convertArray(e,this.TimeBufferType),this.values=Vt.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}Object.assign(Dn,{toJSON:function(t){let e=t.constructor,n;if(e.toJSON!==void 0)n=e.toJSON(t);else{n={name:t.name,times:Vt.convertArray(t.times,Array),values:Vt.convertArray(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}});Object.assign(Dn.prototype,{constructor:Dn,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:of,InterpolantFactoryMethodDiscrete:function(t){return new ag(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new _f(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new sg(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){let e;switch(t){case lf:e=this.InterpolantFactoryMethodDiscrete;break;case of:e=this.InterpolantFactoryMethodLinear;break;case cm:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return lf;case this.InterpolantFactoryMethodLinear:return of;case this.InterpolantFactoryMethodSmooth:return cm}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this},scale:function(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this},trim:function(t,e){let n=this.times,r=n.length,o=0,a=r-1;for(;o!==r&&n[o]<t;)++o;for(;a!==-1&&n[a]>e;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);let c=this.getValueSize();this.times=Vt.arraySlice(n,o,a),this.values=Vt.arraySlice(this.values,o*c,a*c)}return this},validate:function(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let c=0;c!==o;c++){let l=n[c];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,l,a),t=!1;break}a=l}if(r!==void 0&&Vt.isTypedArray(r))for(let c=0,l=r.length;c!==l;++c){let u=r[c];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,u),t=!1;break}}return t},optimize:function(){let t=Vt.arraySlice(this.times),e=Vt.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===cm,o=t.length-1,a=1;for(let c=1;c<o;++c){let l=!1,u=t[c],h=t[c+1];if(u!==h&&(c!==1||u!==u[0]))if(r)l=!0;else{let d=c*n,f=d-n,p=d+n;for(let m=0;m!==n;++m){let v=e[d+m];if(v!==e[f+m]||v!==e[p+m]){l=!0;break}}}if(l){if(c!==a){t[a]=t[c];let d=c*n,f=a*n;for(let p=0;p!==n;++p)e[f+p]=e[d+p]}++a}}if(o>0){t[a]=t[o];for(let c=o*n,l=a*n,u=0;u!==n;++u)e[l+u]=e[c+u];++a}return a!==t.length?(this.times=Vt.arraySlice(t,0,a),this.values=Vt.arraySlice(e,0,a*n)):(this.times=t,this.values=e),this},clone:function(){let t=Vt.arraySlice(this.times,0),e=Vt.arraySlice(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}});function cg(t,e,n){Dn.call(this,t,e,n)}cg.prototype=Object.assign(Object.create(Dn.prototype),{constructor:cg,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:lf,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function lg(t,e,n,r){Dn.call(this,t,e,n,r)}lg.prototype=Object.assign(Object.create(Dn.prototype),{constructor:lg,ValueTypeName:"color"});function ql(t,e,n,r){Dn.call(this,t,e,n,r)}ql.prototype=Object.assign(Object.create(Dn.prototype),{constructor:ql,ValueTypeName:"number"});function ug(t,e,n,r){Tr.call(this,t,e,n,r)}ug.prototype=Object.assign(Object.create(Tr.prototype),{constructor:ug,interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=(n-e)/(r-e),u=t*c;for(let h=u+c;u!==h;u+=4)zn.slerpFlat(o,0,a,u-c,a,u,l);return o}});function bf(t,e,n,r){Dn.call(this,t,e,n,r)}bf.prototype=Object.assign(Object.create(Dn.prototype),{constructor:bf,ValueTypeName:"quaternion",DefaultInterpolation:of,InterpolantFactoryMethodLinear:function(t){return new ug(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0});function hg(t,e,n,r){Dn.call(this,t,e,n,r)}hg.prototype=Object.assign(Object.create(Dn.prototype),{constructor:hg,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:lf,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Xl(t,e,n,r){Dn.call(this,t,e,n,r)}Xl.prototype=Object.assign(Object.create(Dn.prototype),{constructor:Xl,ValueTypeName:"vector"});function pi(t,e,n,r){this.name=t,this.tracks=n,this.duration=e!==void 0?e:-1,this.blendMode=r!==void 0?r:Ig,this.uuid=dt.generateUUID(),this.duration<0&&this.resetDuration()}function I3(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ql;case"vector":case"vector2":case"vector3":case"vector4":return Xl;case"color":return lg;case"quaternion":return bf;case"bool":case"boolean":return cg;case"string":return hg}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function D3(t){if(t.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=I3(t.type);if(t.times===void 0){let n=[],r=[];Vt.flattenJSON(t.keys,n,r,"value"),t.times=n,t.values=r}return e.parse!==void 0?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(pi,{parse:function(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(D3(n[o]).scale(r));return new pi(t.name,t.duration,e,t.blendMode)},toJSON:function(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let o=0,a=n.length;o!==a;++o)e.push(Dn.toJSON(n[o]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){let o=e.length,a=[];for(let c=0;c<o;c++){let l=[],u=[];l.push((c+o-1)%o,c,(c+1)%o),u.push(0,1,0);let h=Vt.getKeyframeOrder(l);l=Vt.sortedArray(l,1,h),u=Vt.sortedArray(u,1,h),!r&&l[0]===0&&(l.push(o),u.push(u[0])),a.push(new ql(".morphTargetInfluences["+e[c].name+"]",l,u).scale(1/n))}return new pi(t,-1,a)},findByName:function(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null},CreateClipsFromMorphTargetSequences:function(t,e,n){let r={},o=/^([\w-]*?)([\d]+)$/;for(let c=0,l=t.length;c<l;c++){let u=t[c],h=u.name.match(o);if(h&&h.length>1){let d=h[1],f=r[d];f||(r[d]=f=[]),f.push(u)}}let a=[];for(let c in r)a.push(pi.CreateFromMorphTargetSequence(c,r[c],e,n));return a},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,f,p,m,v){if(p.length!==0){let x=[],b=[];Vt.flattenJSON(p,x,b,m),x.length!==0&&v.push(new d(f,x,b))}},r=[],o=t.name||"default",a=t.fps||30,c=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let f=u[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let v=0;v<f[m].morphTargets.length;v++)p[f[m].morphTargets[v]]=-1;for(let v in p){let x=[],b=[];for(let y=0;y!==f[m].morphTargets.length;++y){let g=f[m];x.push(g.time),b.push(g.morphTarget===v?1:0)}r.push(new ql(".morphTargetInfluence["+v+"]",x,b))}l=p.length*(a||1)}else{let p=".bones["+e[d].name+"]";n(Xl,p+".position",f,"pos",r),n(bf,p+".quaternion",f,"rot",r),n(Xl,p+".scale",f,"scl",r)}}return r.length===0?null:new pi(o,l,r,c)}});Object.assign(pi.prototype,{resetDuration:function(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let o=this.tracks[n];e=Math.max(e,o.times[o.times.length-1])}return this.duration=e,this},trim:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new pi(this.name,this.duration,t,this.blendMode)}});var oc={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function B3(t,e,n){let r=this,o=!1,a=0,c=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){c++,o===!1&&r.onStart!==void 0&&r.onStart(h,a,c),o=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,c),a===c&&(o=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return u.push(h,d),this},this.removeHandler=function(h){let d=u.indexOf(h);return d!==-1&&u.splice(d,2),this},this.getHandler=function(h){for(let d=0,f=u.length;d<f;d+=2){let p=u[d],m=u[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null}}var O3=new B3;function Lt(t){this.manager=t!==void 0?t:O3,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(Lt.prototype,{load:function(){},loadAsync:function(t,e){let n=this;return new Promise(function(r,o){n.load(t,r,e,o)})},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});var jr={};function Xi(t){Lt.call(this,t)}Xi.prototype=Object.assign(Object.create(Lt.prototype),{constructor:Xi,load:function(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=oc.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;if(jr[t]!==void 0){jr[t].push({onLoad:e,onProgress:n,onError:r});return}let c=/^data:(.*?)(;base64)?,(.*)$/,l=t.match(c),u;if(l){let h=l[1],d=!!l[2],f=l[3];f=decodeURIComponent(f),d&&(f=atob(f));try{let p,m=(this.responseType||"").toLowerCase();switch(m){case"arraybuffer":case"blob":let v=new Uint8Array(f.length);for(let b=0;b<f.length;b++)v[b]=f.charCodeAt(b);m==="blob"?p=new Blob([v.buffer],{type:h}):p=v.buffer;break;case"document":p=new DOMParser().parseFromString(f,h);break;case"json":p=JSON.parse(f);break;default:p=f;break}setTimeout(function(){e&&e(p),o.manager.itemEnd(t)},0)}catch(p){setTimeout(function(){r&&r(p),o.manager.itemError(t),o.manager.itemEnd(t)},0)}}else{jr[t]=[],jr[t].push({onLoad:e,onProgress:n,onError:r}),u=new XMLHttpRequest,u.open("GET",t,!0),u.addEventListener("load",function(h){let d=this.response,f=jr[t];if(delete jr[t],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),oc.add(t,d);for(let p=0,m=f.length;p<m;p++){let v=f[p];v.onLoad&&v.onLoad(d)}o.manager.itemEnd(t)}else{for(let p=0,m=f.length;p<m;p++){let v=f[p];v.onError&&v.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)}},!1),u.addEventListener("progress",function(h){let d=jr[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onProgress&&m.onProgress(h)}},!1),u.addEventListener("error",function(h){let d=jr[t];delete jr[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onError&&m.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)},!1),u.addEventListener("abort",function(h){let d=jr[t];delete jr[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onError&&m.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)},!1),this.responseType!==void 0&&(u.responseType=this.responseType),this.withCredentials!==void 0&&(u.withCredentials=this.withCredentials),u.overrideMimeType&&u.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(let h in this.requestHeader)u.setRequestHeader(h,this.requestHeader[h]);u.send(null)}return o.manager.itemStart(t),u},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}});function u0(t){Lt.call(this,t)}u0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:u0,load:function(t,e,n,r){let o=this,a=new Xi(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e=[];for(let n=0;n<t.length;n++){let r=pi.parse(t[n]);e.push(r)}return e}});function h0(t){Lt.call(this,t)}h0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:h0,load:function(t,e,n,r){let o=this,a=[],c=new Hl;c.image=a;let l=new Xi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(o.withCredentials);let u=0;function h(d){l.load(t[d],function(f){let p=o.parse(f,!0);a[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},u+=1,u===6&&(p.mipmapCount===1&&(c.minFilter=sn),c.format=p.format,c.needsUpdate=!0,e&&e(c))},n,r)}if(Array.isArray(t))for(let d=0,f=t.length;d<f;++d)h(d);else l.load(t,function(d){let f=o.parse(d,!0);if(f.isCubemap){let p=f.mipmaps.length/f.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)a[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+v]),a[m].format=f.format,a[m].width=f.width,a[m].height=f.height}}else c.image.width=f.width,c.image.height=f.height,c.mipmaps=f.mipmaps;f.mipmapCount===1&&(c.minFilter=sn),c.format=f.format,c.needsUpdate=!0,e&&e(c)},n,r);return c}});function wf(t){Lt.call(this,t)}wf.prototype=Object.assign(Object.create(Lt.prototype),{constructor:wf,load:function(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=oc.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;let c=document.createElementNS("http://www.w3.org/1999/xhtml","img");function l(){c.removeEventListener("load",l,!1),c.removeEventListener("error",u,!1),oc.add(t,this),e&&e(this),o.manager.itemEnd(t)}function u(h){c.removeEventListener("load",l,!1),c.removeEventListener("error",u,!1),r&&r(h),o.manager.itemError(t),o.manager.itemEnd(t)}return c.addEventListener("load",l,!1),c.addEventListener("error",u,!1),t.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),o.manager.itemStart(t),c.src=t,c}});function fg(t){Lt.call(this,t)}fg.prototype=Object.assign(Object.create(Lt.prototype),{constructor:fg,load:function(t,e,n,r){let o=new ko,a=new wf(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function l(u){a.load(t[u],function(h){o.images[u]=h,c++,c===6&&(o.needsUpdate=!0,e&&e(o))},void 0,r)}for(let u=0;u<t.length;++u)l(u);return o}});function f0(t){Lt.call(this,t)}f0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:f0,load:function(t,e,n,r){let o=this,a=new xi,c=new Xi(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(o.withCredentials),c.load(t,function(l){let u=o.parse(l);u&&(u.image!==void 0?a.image=u.image:u.data!==void 0&&(a.image.width=u.width,a.image.height=u.height,a.image.data=u.data),a.wrapS=u.wrapS!==void 0?u.wrapS:sr,a.wrapT=u.wrapT!==void 0?u.wrapT:sr,a.magFilter=u.magFilter!==void 0?u.magFilter:sn,a.minFilter=u.minFilter!==void 0?u.minFilter:sn,a.anisotropy=u.anisotropy!==void 0?u.anisotropy:1,u.format!==void 0&&(a.format=u.format),u.type!==void 0&&(a.type=u.type),u.mipmaps!==void 0&&(a.mipmaps=u.mipmaps,a.minFilter=Cf),u.mipmapCount===1&&(a.minFilter=sn),a.needsUpdate=!0,e&&e(a,u))},n,r),a}});function Yl(t){Lt.call(this,t)}Yl.prototype=Object.assign(Object.create(Lt.prototype),{constructor:Yl,load:function(t,e,n,r){let o=new At,a=new wf(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(c){o.image=c;let l=t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0;o.format=l?Ms:ar,o.needsUpdate=!0,e!==void 0&&e(o)},n,r),o}});function rt(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(rt.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){t===void 0&&(t=5);let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){t===void 0&&(t=5);let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){let t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(t===void 0&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),o=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),o+=n.distanceTo(r),e.push(o),r=n;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){let n=this.getLengths(),r=0,o=n.length,a;e?a=e:a=t*n[o-1];let c=0,l=o-1,u;for(;c<=l;)if(r=Math.floor(c+(l-c)/2),u=n[r]-a,u<0)c=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(o-1);let h=n[r],f=n[r+1]-h,p=(a-h)/f;return(r+p)/(o-1)},getTangent:function(t,e){let r=t-1e-4,o=t+1e-4;r<0&&(r=0),o>1&&(o=1);let a=this.getPoint(r),c=this.getPoint(o),l=e||(a.isVector2?new fe:new W);return l.copy(c).sub(a).normalize(),l},getTangentAt:function(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)},computeFrenetFrames:function(t,e){let n=new W,r=[],o=[],a=[],c=new W,l=new vt;for(let p=0;p<=t;p++){let m=p/t;r[p]=this.getTangentAt(m,new W),r[p].normalize()}o[0]=new W,a[0]=new W;let u=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),f=Math.abs(r[0].z);h<=u&&(u=h,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),f<=u&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],c),a[0].crossVectors(r[0],o[0]);for(let p=1;p<=t;p++){if(o[p]=o[p-1].clone(),a[p]=a[p-1].clone(),c.crossVectors(r[p-1],r[p]),c.length()>Number.EPSILON){c.normalize();let m=Math.acos(dt.clamp(r[p-1].dot(r[p]),-1,1));o[p].applyMatrix4(l.makeRotationAxis(c,m))}a[p].crossVectors(r[p],o[p])}if(e===!0){let p=Math.acos(dt.clamp(o[0].dot(o[t]),-1,1));p/=t,r[0].dot(c.crossVectors(o[0],o[t]))>0&&(p=-p);for(let m=1;m<=t;m++)o[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],o[m])}return{tangents:r,normals:o,binormals:a}},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}});function Pr(t,e,n,r,o,a,c,l){rt.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=n||1,this.yRadius=r||1,this.aStartAngle=o||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=c||!1,this.aRotation=l||0}Pr.prototype=Object.create(rt.prototype);Pr.prototype.constructor=Pr;Pr.prototype.isEllipseCurve=!0;Pr.prototype.getPoint=function(t,e){let n=e||new fe,r=Math.PI*2,o=this.aEndAngle-this.aStartAngle,a=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=r;for(;o>r;)o-=r;o<Number.EPSILON&&(a?o=0:o=r),this.aClockwise===!0&&!a&&(o===r?o=-r:o=o-r);let c=this.aStartAngle+t*o,l=this.aX+this.xRadius*Math.cos(c),u=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),f=l-this.aX,p=u-this.aY;l=f*h-p*d+this.aX,u=f*d+p*h+this.aY}return n.set(l,u)};Pr.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this};Pr.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t};Pr.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this};function $l(t,e,n,r,o,a){Pr.call(this,t,e,n,n,r,o,a),this.type="ArcCurve"}$l.prototype=Object.create(Pr.prototype);$l.prototype.constructor=$l;$l.prototype.isArcCurve=!0;function Bg(){let t=0,e=0,n=0,r=0;function o(a,c,l,u){t=a,e=l,n=-3*a+3*c-2*l-u,r=2*a-2*c+l+u}return{initCatmullRom:function(a,c,l,u,h){o(c,l,h*(l-a),h*(u-c))},initNonuniformCatmullRom:function(a,c,l,u,h,d,f){let p=(c-a)/h-(l-a)/(h+d)+(l-c)/d,m=(l-c)/d-(u-c)/(d+f)+(u-l)/f;p*=d,m*=d,o(c,l,p,m)},calc:function(a){let c=a*a,l=c*a;return t+e*a+n*c+r*l}}}var Qh=new W,Im=new Bg,Dm=new Bg,Bm=new Bg;function Wn(t,e,n,r){rt.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=n||"centripetal",this.tension=r!==void 0?r:.5}Wn.prototype=Object.create(rt.prototype);Wn.prototype.constructor=Wn;Wn.prototype.isCatmullRomCurve3=!0;Wn.prototype.getPoint=function(t,e){let n=e||new W,r=this.points,o=r.length,a=(o-(this.closed?0:1))*t,c=Math.floor(a),l=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:l===0&&c===o-1&&(c=o-2,l=1);let u,h;this.closed||c>0?u=r[(c-1)%o]:(Qh.subVectors(r[0],r[1]).add(r[0]),u=Qh);let d=r[c%o],f=r[(c+1)%o];if(this.closed||c+2<o?h=r[(c+2)%o]:(Qh.subVectors(r[o-1],r[o-2]).add(r[o-1]),h=Qh),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),p),v=Math.pow(d.distanceToSquared(f),p),x=Math.pow(f.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),x<1e-4&&(x=v),Im.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,m,v,x),Dm.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,m,v,x),Bm.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,m,v,x)}else this.curveType==="catmullrom"&&(Im.initCatmullRom(u.x,d.x,f.x,h.x,this.tension),Dm.initCatmullRom(u.y,d.y,f.y,h.y,this.tension),Bm.initCatmullRom(u.z,d.z,f.z,h.z,this.tension));return n.set(Im.calc(l),Dm.calc(l),Bm.calc(l)),n};Wn.prototype.copy=function(t){rt.prototype.copy.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this};Wn.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t};Wn.prototype.fromJSON=function(t){rt.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new W().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this};function d0(t,e,n,r,o){let a=(r-e)*.5,c=(o-n)*.5,l=t*t,u=t*l;return(2*n-2*r+a+c)*u+(-3*n+3*r-2*a-c)*l+a*t+n}function U3(t,e){let n=1-t;return n*n*e}function N3(t,e){return 2*(1-t)*t*e}function G3(t,e){return t*t*e}function Ll(t,e,n,r){return U3(t,e)+N3(t,n)+G3(t,r)}function k3(t,e){let n=1-t;return n*n*n*e}function H3(t,e){let n=1-t;return 3*n*n*t*e}function z3(t,e){return 3*(1-t)*t*t*e}function V3(t,e){return t*t*t*e}function Fl(t,e,n,r,o){return k3(t,e)+H3(t,n)+z3(t,r)+V3(t,o)}function _i(t,e,n,r){rt.call(this),this.type="CubicBezierCurve",this.v0=t||new fe,this.v1=e||new fe,this.v2=n||new fe,this.v3=r||new fe}_i.prototype=Object.create(rt.prototype);_i.prototype.constructor=_i;_i.prototype.isCubicBezierCurve=!0;_i.prototype.getPoint=function(t,e){let n=e||new fe,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(Fl(t,r.x,o.x,a.x,c.x),Fl(t,r.y,o.y,a.y,c.y)),n};_i.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this};_i.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t};_i.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this};function Yi(t,e,n,r){rt.call(this),this.type="CubicBezierCurve3",this.v0=t||new W,this.v1=e||new W,this.v2=n||new W,this.v3=r||new W}Yi.prototype=Object.create(rt.prototype);Yi.prototype.constructor=Yi;Yi.prototype.isCubicBezierCurve3=!0;Yi.prototype.getPoint=function(t,e){let n=e||new W,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(Fl(t,r.x,o.x,a.x,c.x),Fl(t,r.y,o.y,a.y,c.y),Fl(t,r.z,o.z,a.z,c.z)),n};Yi.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this};Yi.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t};Yi.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this};function lr(t,e){rt.call(this),this.type="LineCurve",this.v1=t||new fe,this.v2=e||new fe}lr.prototype=Object.create(rt.prototype);lr.prototype.constructor=lr;lr.prototype.isLineCurve=!0;lr.prototype.getPoint=function(t,e){let n=e||new fe;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n};lr.prototype.getPointAt=function(t,e){return this.getPoint(t,e)};lr.prototype.getTangent=function(t,e){let n=e||new fe;return n.copy(this.v2).sub(this.v1).normalize(),n};lr.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this};lr.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};lr.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function bi(t,e){rt.call(this),this.type="LineCurve3",this.v1=t||new W,this.v2=e||new W}bi.prototype=Object.create(rt.prototype);bi.prototype.constructor=bi;bi.prototype.isLineCurve3=!0;bi.prototype.getPoint=function(t,e){let n=e||new W;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n};bi.prototype.getPointAt=function(t,e){return this.getPoint(t,e)};bi.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this};bi.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};bi.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function wi(t,e,n){rt.call(this),this.type="QuadraticBezierCurve",this.v0=t||new fe,this.v1=e||new fe,this.v2=n||new fe}wi.prototype=Object.create(rt.prototype);wi.prototype.constructor=wi;wi.prototype.isQuadraticBezierCurve=!0;wi.prototype.getPoint=function(t,e){let n=e||new fe,r=this.v0,o=this.v1,a=this.v2;return n.set(Ll(t,r.x,o.x,a.x),Ll(t,r.y,o.y,a.y)),n};wi.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this};wi.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};wi.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function $i(t,e,n){rt.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new W,this.v1=e||new W,this.v2=n||new W}$i.prototype=Object.create(rt.prototype);$i.prototype.constructor=$i;$i.prototype.isQuadraticBezierCurve3=!0;$i.prototype.getPoint=function(t,e){let n=e||new W,r=this.v0,o=this.v1,a=this.v2;return n.set(Ll(t,r.x,o.x,a.x),Ll(t,r.y,o.y,a.y),Ll(t,r.z,o.z,a.z)),n};$i.prototype.copy=function(t){return rt.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this};$i.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};$i.prototype.fromJSON=function(t){return rt.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function Mi(t){rt.call(this),this.type="SplineCurve",this.points=t||[]}Mi.prototype=Object.create(rt.prototype);Mi.prototype.constructor=Mi;Mi.prototype.isSplineCurve=!0;Mi.prototype.getPoint=function(t,e){let n=e||new fe,r=this.points,o=(r.length-1)*t,a=Math.floor(o),c=o-a,l=r[a===0?a:a-1],u=r[a],h=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return n.set(d0(c,l.x,u.x,h.x,d.x),d0(c,l.y,u.y,h.y,d.y)),n};Mi.prototype.copy=function(t){rt.prototype.copy.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this};Mi.prototype.toJSON=function(){let t=rt.prototype.toJSON.call(this);t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t};Mi.prototype.fromJSON=function(t){rt.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new fe().fromArray(r))}return this};var W3=Object.freeze({__proto__:null,ArcCurve:$l,CatmullRomCurve3:Wn,CubicBezierCurve:_i,CubicBezierCurve3:Yi,EllipseCurve:Pr,LineCurve:lr,LineCurve3:bi,QuadraticBezierCurve:wi,QuadraticBezierCurve3:$i,SplineCurve:Mi});function Oo(){rt.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}Oo.prototype=Object.assign(Object.create(rt.prototype),{constructor:Oo,add:function(t){this.curves.push(t)},closePath:function(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new lr(e,t))},getPoint:function(t){let e=t*this.getLength(),n=this.getCurveLengths(),r=0;for(;r<n.length;){if(n[r]>=e){let o=n[r]-e,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l)}r++}return null},getLength:function(){let t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){t===void 0&&(t=40);let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;let e=[],n;for(let r=0,o=this.curves;r<o.length;r++){let a=o[r],c=a&&a.isEllipseCurve?t*2:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?t*a.points.length:t,l=a.getPoints(c);for(let u=0;u<l.length;u++){let h=l[u];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){rt.prototype.copy.call(this,t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){let t=rt.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t},fromJSON:function(t){rt.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new W3[r.type]().fromJSON(r))}return this}});function mi(t){Oo.call(this),this.type="Path",this.currentPoint=new fe,t&&this.setFromPoints(t)}mi.prototype=Object.assign(Object.create(Oo.prototype),{constructor:mi,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){let n=new lr(this.currentPoint.clone(),new fe(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,n,r){let o=new wi(this.currentPoint.clone(),new fe(t,e),new fe(n,r));return this.curves.push(o),this.currentPoint.set(n,r),this},bezierCurveTo:function(t,e,n,r,o,a){let c=new _i(this.currentPoint.clone(),new fe(t,e),new fe(n,r),new fe(o,a));return this.curves.push(c),this.currentPoint.set(o,a),this},splineThru:function(t){let e=[this.currentPoint.clone()].concat(t),n=new Mi(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,n,r,o,a){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+c,e+l,n,r,o,a),this},absarc:function(t,e,n,r,o,a){return this.absellipse(t,e,n,n,r,o,a),this},ellipse:function(t,e,n,r,o,a,c,l){let u=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+u,e+h,n,r,o,a,c,l),this},absellipse:function(t,e,n,r,o,a,c,l){let u=new Pr(t,e,n,r,o,a,c,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let h=u.getPoint(1);return this.currentPoint.copy(h),this},copy:function(t){return Oo.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){let t=Oo.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Oo.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}});function Ya(t){mi.call(this,t),this.uuid=dt.generateUUID(),this.type="Shape",this.holes=[]}Ya.prototype=Object.assign(Object.create(mi.prototype),{constructor:Ya,getPointsHoles:function(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){mi.prototype.copy.call(this,t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this},toJSON:function(){let t=mi.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t},fromJSON:function(t){mi.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new mi().fromJSON(r))}return this}});function Gt(t,e){Je.call(this),this.type="Light",this.color=new We(t),this.intensity=e!==void 0?e:1}Gt.prototype=Object.assign(Object.create(Je.prototype),{constructor:Gt,isLight:!0,copy:function(t){return Je.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){let e=Je.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}});function p0(t,e,n){Gt.call(this,t,n),this.type="HemisphereLight",this.position.copy(Je.DefaultUp),this.updateMatrix(),this.groundColor=new We(e)}p0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:p0,isHemisphereLight:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}});function Zi(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new fe(512,512),this.map=null,this.mapPass=null,this.matrix=new vt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ja,this._frameExtents=new fe(1,1),this._viewportCount=1,this._viewports=[new Rt(0,0,1,1)]}Object.assign(Zi.prototype,{_projScreenMatrix:new vt,_lightPositionWorld:new W,_lookTarget:new W,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){let e=this.camera,n=this.matrix,r=this._projScreenMatrix,o=this._lookTarget,a=this._lightPositionWorld;a.setFromMatrixPosition(t.matrixWorld),e.position.copy(a),o.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(o),e.updateMatrixWorld(),r.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(e.projectionMatrix),n.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}});function dg(){Zi.call(this,new on(50,1,.5,500)),this.focus=1}dg.prototype=Object.assign(Object.create(Zi.prototype),{constructor:dg,isSpotLightShadow:!0,updateMatrices:function(t){let e=this.camera,n=dt.RAD2DEG*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=t.distance||e.far;(n!==e.fov||r!==e.aspect||o!==e.far)&&(e.fov=n,e.aspect=r,e.far=o,e.updateProjectionMatrix()),Zi.prototype.updateMatrices.call(this,t)}});function m0(t,e,n,r,o,a){Gt.call(this,t,e),this.type="SpotLight",this.position.copy(Je.DefaultUp),this.updateMatrix(),this.target=new Je,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(c){this.intensity=c/Math.PI}}),this.distance=n!==void 0?n:0,this.angle=r!==void 0?r:Math.PI/3,this.penumbra=o!==void 0?o:0,this.decay=a!==void 0?a:1,this.shadow=new dg}m0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:m0,isSpotLight:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}});function pg(){Zi.call(this,new on(90,1,.5,500)),this._frameExtents=new fe(4,2),this._viewportCount=6,this._viewports=[new Rt(2,1,1,1),new Rt(0,1,1,1),new Rt(3,1,1,1),new Rt(1,1,1,1),new Rt(3,0,1,1),new Rt(1,0,1,1)],this._cubeDirections=[new W(1,0,0),new W(-1,0,0),new W(0,0,1),new W(0,0,-1),new W(0,1,0),new W(0,-1,0)],this._cubeUps=[new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,0,1),new W(0,0,-1)]}pg.prototype=Object.assign(Object.create(Zi.prototype),{constructor:pg,isPointLightShadow:!0,updateMatrices:function(t,e){e===void 0&&(e=0);let n=this.camera,r=this.matrix,o=this._lightPositionWorld,a=this._lookTarget,c=this._projScreenMatrix;o.setFromMatrixPosition(t.matrixWorld),n.position.copy(o),a.copy(n.position),a.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(a),n.updateMatrixWorld(),r.makeTranslation(-o.x,-o.y,-o.z),c.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(c)}});function g0(t,e,n,r){Gt.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(o){this.intensity=o/(4*Math.PI)}}),this.distance=n!==void 0?n:0,this.decay=r!==void 0?r:1,this.shadow=new pg}g0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:g0,isPointLight:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}});function Zl(t,e,n,r,o,a){Go.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t!==void 0?t:-1,this.right=e!==void 0?e:1,this.top=n!==void 0?n:1,this.bottom=r!==void 0?r:-1,this.near=o!==void 0?o:.1,this.far=a!==void 0?a:2e3,this.updateProjectionMatrix()}Zl.prototype=Object.assign(Object.create(Go.prototype),{constructor:Zl,isOrthographicCamera:!0,copy:function(t,e){return Go.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this},setViewOffset:function(t,e,n,r,o,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,o=n-t,a=n+t,c=r+e,l=r-e;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=u*this.view.offsetX,a=o+u*this.view.width,c-=h*this.view.offsetY,l=c-h*this.view.height}this.projectionMatrix.makeOrthographic(o,a,c,l,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){let e=Je.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}});function mg(){Zi.call(this,new Zl(-5,5,5,-5,.5,500))}mg.prototype=Object.assign(Object.create(Zi.prototype),{constructor:mg,isDirectionalLightShadow:!0,updateMatrices:function(t){Zi.prototype.updateMatrices.call(this,t)}});function v0(t,e){Gt.call(this,t,e),this.type="DirectionalLight",this.position.copy(Je.DefaultUp),this.updateMatrix(),this.target=new Je,this.shadow=new mg}v0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:v0,isDirectionalLight:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}});function y0(t,e){Gt.call(this,t,e),this.type="AmbientLight"}y0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:y0,isAmbientLight:!0});function x0(t,e,n,r){Gt.call(this,t,e),this.type="RectAreaLight",this.width=n!==void 0?n:10,this.height=r!==void 0?r:10}x0.prototype=Object.assign(Object.create(Gt.prototype),{constructor:x0,isRectAreaLight:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){let e=Gt.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var gg=class{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new W)}set(e){for(let n=0;n<9;n++)this.coefficients[n].copy(e[n]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,n){let r=e.x,o=e.y,a=e.z,c=this.coefficients;return n.copy(c[0]).multiplyScalar(.282095),n.addScaledVector(c[1],.488603*o),n.addScaledVector(c[2],.488603*a),n.addScaledVector(c[3],.488603*r),n.addScaledVector(c[4],1.092548*(r*o)),n.addScaledVector(c[5],1.092548*(o*a)),n.addScaledVector(c[6],.315392*(3*a*a-1)),n.addScaledVector(c[7],1.092548*(r*a)),n.addScaledVector(c[8],.546274*(r*r-o*o)),n}getIrradianceAt(e,n){let r=e.x,o=e.y,a=e.z,c=this.coefficients;return n.copy(c[0]).multiplyScalar(.886227),n.addScaledVector(c[1],2*.511664*o),n.addScaledVector(c[2],2*.511664*a),n.addScaledVector(c[3],2*.511664*r),n.addScaledVector(c[4],2*.429043*r*o),n.addScaledVector(c[5],2*.429043*o*a),n.addScaledVector(c[6],.743125*a*a-.247708),n.addScaledVector(c[7],2*.429043*r*a),n.addScaledVector(c[8],.429043*(r*r-o*o)),n}add(e){for(let n=0;n<9;n++)this.coefficients[n].add(e.coefficients[n]);return this}addScaledSH(e,n){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],n);return this}scale(e){for(let n=0;n<9;n++)this.coefficients[n].multiplyScalar(e);return this}lerp(e,n){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],n);return this}equals(e){for(let n=0;n<9;n++)if(!this.coefficients[n].equals(e.coefficients[n]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,n=0){let r=this.coefficients;for(let o=0;o<9;o++)r[o].fromArray(e,n+o*3);return this}toArray(e=[],n=0){let r=this.coefficients;for(let o=0;o<9;o++)r[o].toArray(e,n+o*3);return e}static getBasisAt(e,n){let r=e.x,o=e.y,a=e.z;n[0]=.282095,n[1]=.488603*o,n[2]=.488603*a,n[3]=.488603*r,n[4]=1.092548*r*o,n[5]=1.092548*o*a,n[6]=.315392*(3*a*a-1),n[7]=1.092548*r*a,n[8]=.546274*(r*r-o*o)}};function gi(t,e){Gt.call(this,void 0,e),this.type="LightProbe",this.sh=t!==void 0?t:new gg}gi.prototype=Object.assign(Object.create(Gt.prototype),{constructor:gi,isLightProbe:!0,copy:function(t){return Gt.prototype.copy.call(this,t),this.sh.copy(t.sh),this},fromJSON:function(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this},toJSON:function(t){let e=Gt.prototype.toJSON.call(this,t);return e.object.sh=this.sh.toArray(),e}});function _0(t){Lt.call(this,t),this.textures={}}_0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:_0,load:function(t,e,n,r){let o=this,a=new Xi(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e=this.textures;function n(o){return e[o]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",o),e[o]}let r=new F3[t.type];if(t.uuid!==void 0&&(r.uuid=t.uuid),t.name!==void 0&&(r.name=t.name),t.color!==void 0&&r.color!==void 0&&r.color.setHex(t.color),t.roughness!==void 0&&(r.roughness=t.roughness),t.metalness!==void 0&&(r.metalness=t.metalness),t.sheen!==void 0&&(r.sheen=new We().setHex(t.sheen)),t.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(t.emissive),t.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(t.specular),t.shininess!==void 0&&(r.shininess=t.shininess),t.clearcoat!==void 0&&(r.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=t.clearcoatRoughness),t.fog!==void 0&&(r.fog=t.fog),t.flatShading!==void 0&&(r.flatShading=t.flatShading),t.blending!==void 0&&(r.blending=t.blending),t.combine!==void 0&&(r.combine=t.combine),t.side!==void 0&&(r.side=t.side),t.opacity!==void 0&&(r.opacity=t.opacity),t.transparent!==void 0&&(r.transparent=t.transparent),t.alphaTest!==void 0&&(r.alphaTest=t.alphaTest),t.depthTest!==void 0&&(r.depthTest=t.depthTest),t.depthWrite!==void 0&&(r.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(r.colorWrite=t.colorWrite),t.stencilWrite!==void 0&&(r.stencilWrite=t.stencilWrite),t.stencilWriteMask!==void 0&&(r.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(r.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(r.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(r.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(r.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(r.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(r.stencilZPass=t.stencilZPass),t.wireframe!==void 0&&(r.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(r.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(r.rotation=t.rotation),t.linewidth!==1&&(r.linewidth=t.linewidth),t.dashSize!==void 0&&(r.dashSize=t.dashSize),t.gapSize!==void 0&&(r.gapSize=t.gapSize),t.scale!==void 0&&(r.scale=t.scale),t.polygonOffset!==void 0&&(r.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=t.polygonOffsetUnits),t.skinning!==void 0&&(r.skinning=t.skinning),t.morphTargets!==void 0&&(r.morphTargets=t.morphTargets),t.morphNormals!==void 0&&(r.morphNormals=t.morphNormals),t.dithering!==void 0&&(r.dithering=t.dithering),t.vertexTangents!==void 0&&(r.vertexTangents=t.vertexTangents),t.visible!==void 0&&(r.visible=t.visible),t.toneMapped!==void 0&&(r.toneMapped=t.toneMapped),t.userData!==void 0&&(r.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?r.vertexColors=t.vertexColors>0:r.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let o in t.uniforms){let a=t.uniforms[o];switch(r.uniforms[o]={},a.type){case"t":r.uniforms[o].value=n(a.value);break;case"c":r.uniforms[o].value=new We().setHex(a.value);break;case"v2":r.uniforms[o].value=new fe().fromArray(a.value);break;case"v3":r.uniforms[o].value=new W().fromArray(a.value);break;case"v4":r.uniforms[o].value=new Rt().fromArray(a.value);break;case"m3":r.uniforms[o].value=new Fn().fromArray(a.value);break;case"m4":r.uniforms[o].value=new vt().fromArray(a.value);break;default:r.uniforms[o].value=a.value}}if(t.defines!==void 0&&(r.defines=t.defines),t.vertexShader!==void 0&&(r.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(r.fragmentShader=t.fragmentShader),t.extensions!==void 0)for(let o in t.extensions)r.extensions[o]=t.extensions[o];if(t.shading!==void 0&&(r.flatShading=t.shading===1),t.size!==void 0&&(r.size=t.size),t.sizeAttenuation!==void 0&&(r.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(r.map=n(t.map)),t.matcap!==void 0&&(r.matcap=n(t.matcap)),t.alphaMap!==void 0&&(r.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(r.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(r.bumpScale=t.bumpScale),t.normalMap!==void 0&&(r.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(r.normalMapType=t.normalMapType),t.normalScale!==void 0){let o=t.normalScale;Array.isArray(o)===!1&&(o=[o,o]),r.normalScale=new fe().fromArray(o)}return t.displacementMap!==void 0&&(r.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(r.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(r.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(r.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(r.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(r.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(r.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(r.specularMap=n(t.specularMap)),t.envMap!==void 0&&(r.envMap=n(t.envMap)),t.envMapIntensity!==void 0&&(r.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(r.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(r.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(r.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(r.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(r.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(r.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(r.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(r.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new fe().fromArray(t.clearcoatNormalScale)),t.transmission!==void 0&&(r.transmission=t.transmission),t.transmissionMap!==void 0&&(r.transmissionMap=n(t.transmissionMap)),r},setTextures:function(t){return this.textures=t,this}});var j3={decodeText:function(t){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(t);let e="";for(let n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(n){return e}},extractUrlBase:function(t){let e=t.lastIndexOf("/");return e===-1?"./":t.substr(0,e+1)}};function Mf(){Tt.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}Mf.prototype=Object.assign(Object.create(Tt.prototype),{constructor:Mf,isInstancedBufferGeometry:!0,copy:function(t){return Tt.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let t=Tt.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}});function vg(t,e,n,r){typeof n=="number"&&(r=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),ut.call(this,t,e,n),this.meshPerAttribute=r||1}vg.prototype=Object.assign(Object.create(ut.prototype),{constructor:vg,isInstancedBufferAttribute:!0,copy:function(t){return ut.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){let t=ut.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}});function b0(t){Lt.call(this,t)}b0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:b0,load:function(t,e,n,r){let o=this,a=new Xi(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e={},n={};function r(p,m){if(e[m]!==void 0)return e[m];let x=p.interleavedBuffers[m],b=o(p,x.buffer),y=new Kh[x.type](b),g=new Er(y,x.stride);return g.uuid=x.uuid,e[m]=g,g}function o(p,m){if(n[m]!==void 0)return n[m];let x=p.arrayBuffers[m],b=new Uint32Array(x).buffer;return n[m]=b,b}let a=t.isInstancedBufferGeometry?new Mf:new Tt,c=t.data.index;if(c!==void 0){let p=new Kh[c.type](c.array);a.setIndex(new ut(p,1))}let l=t.data.attributes;for(let p in l){let m=l[p],v;if(m.isInterleavedBufferAttribute){let x=r(t.data,m.data);v=new Rs(x,m.itemSize,m.offset,m.normalized)}else{let x=new Kh[m.type](m.array),b=m.isInstancedBufferAttribute?vg:ut;v=new b(x,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),a.setAttribute(p,v)}let u=t.data.morphAttributes;if(u)for(let p in u){let m=u[p],v=[];for(let x=0,b=m.length;x<b;x++){let y=m[x],g;if(y.isInterleavedBufferAttribute){let M=r(t.data,y.data);g=new Rs(M,y.itemSize,y.offset,y.normalized)}else{let M=new Kh[y.type](y.array);g=new ut(M,y.itemSize,y.normalized)}y.name!==void 0&&(g.name=y.name),v.push(g)}a.morphAttributes[p]=v}t.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){let v=d[p];a.addGroup(v.start,v.count,v.materialIndex)}let f=t.data.boundingSphere;if(f!==void 0){let p=new W;f.center!==void 0&&p.fromArray(f.center),a.boundingSphere=new yi(p,f.radius)}return t.name&&(a.name=t.name),t.userData&&(a.userData=t.userData),a}});var Kh={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray!="undefined"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function w0(t){typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Lt.call(this,t),this.options={premultiplyAlpha:"none"}}w0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:w0,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=oc.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;let c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",fetch(t,c).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,o.options)}).then(function(l){oc.add(t,l),e&&e(l),o.manager.itemEnd(t)}).catch(function(l){r&&r(l),o.manager.itemError(t),o.manager.itemEnd(t)}),o.manager.itemStart(t)}});function a_(){this.type="ShapePath",this.color=new We,this.subPaths=[],this.currentPath=null}Object.assign(a_.prototype,{moveTo:function(t,e){return this.currentPath=new mi,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,n,r){return this.currentPath.quadraticCurveTo(t,e,n,r),this},bezierCurveTo:function(t,e,n,r,o,a){return this.currentPath.bezierCurveTo(t,e,n,r,o,a),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function n(y){let g=[];for(let M=0,C=y.length;M<C;M++){let E=y[M],w=new Ya;w.curves=E.curves,g.push(w)}return g}function r(y,g){let M=g.length,C=!1;for(let E=M-1,w=0;w<M;E=w++){let F=g[E],H=g[w],ne=H.x-F.x,Y=H.y-F.y;if(Math.abs(Y)>Number.EPSILON){if(Y<0&&(F=g[w],ne=-ne,H=g[E],Y=-Y),y.y<F.y||y.y>H.y)continue;if(y.y===F.y){if(y.x===F.x)return!0}else{let L=Y*(y.x-F.x)-ne*(y.y-F.y);if(L===0)return!0;if(L<0)continue;C=!C}}else{if(y.y!==F.y)continue;if(H.x<=y.x&&y.x<=F.x||F.x<=y.x&&y.x<=H.x)return!0}}return C}let o=No.isClockWise,a=this.subPaths;if(a.length===0)return[];if(e===!0)return n(a);let c,l,u,h=[];if(a.length===1)return l=a[0],u=new Ya,u.curves=l.curves,h.push(u),h;let d=!o(a[0].getPoints());d=t?!d:d;let f=[],p=[],m=[],v=0,x;p[v]=void 0,m[v]=[];for(let y=0,g=a.length;y<g;y++)l=a[y],x=l.getPoints(),c=o(x),c=t?!c:c,c?(!d&&p[v]&&v++,p[v]={s:new Ya,p:x},p[v].s.curves=l.curves,d&&v++,m[v]=[]):m[v].push({h:l,p:x[0]});if(!p[0])return n(a);if(p.length>1){let y=!1,g=[];for(let M=0,C=p.length;M<C;M++)f[M]=[];for(let M=0,C=p.length;M<C;M++){let E=m[M];for(let w=0;w<E.length;w++){let F=E[w],H=!0;for(let ne=0;ne<p.length;ne++)r(F.p,p[ne].p)&&(M!==ne&&g.push({froms:M,tos:ne,hole:w}),H?(H=!1,f[ne].push(F)):y=!0);H&&f[M].push(F)}}g.length>0&&(y||(m=f))}let b;for(let y=0,g=p.length;y<g;y++){u=p[y].s,h.push(u),b=m[y];for(let M=0,C=b.length;M<C;M++)u.holes.push(b[M].h)}return h}});function c_(t){this.type="Font",this.data=t}Object.assign(c_.prototype,{isFont:!0,generateShapes:function(t,e){e===void 0&&(e=100);let n=[],r=q3(t,e,this.data);for(let o=0,a=r.length;o<a;o++)Array.prototype.push.apply(n,r[o].toShapes());return n}});function q3(t,e,n){let r=Array.from?Array.from(t):String(t).split(""),o=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,c=[],l=0,u=0;for(let h=0;h<r.length;h++){let d=r[h];if(d===`
`)l=0,u-=a;else{let f=X3(d,o,l,u,n);l+=f.offsetX,c.push(f.path)}}return c}function X3(t,e,n,r,o){let a=o.glyphs[t]||o.glyphs["?"];if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+o.familyName+".");return}let c=new a_,l,u,h,d,f,p,m,v;if(a.o){let x=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let b=0,y=x.length;b<y;)switch(x[b++]){case"m":l=x[b++]*e+n,u=x[b++]*e+r,c.moveTo(l,u);break;case"l":l=x[b++]*e+n,u=x[b++]*e+r,c.lineTo(l,u);break;case"q":h=x[b++]*e+n,d=x[b++]*e+r,f=x[b++]*e+n,p=x[b++]*e+r,c.quadraticCurveTo(f,p,h,d);break;case"b":h=x[b++]*e+n,d=x[b++]*e+r,f=x[b++]*e+n,p=x[b++]*e+r,m=x[b++]*e+n,v=x[b++]*e+r,c.bezierCurveTo(f,p,m,v,h,d);break}}return{offsetX:a.ha*e,path:c}}function M0(t){Lt.call(this,t)}M0.prototype=Object.assign(Object.create(Lt.prototype),{constructor:M0,load:function(t,e,n,r){let o=this,a=new Xi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){let l;try{l=JSON.parse(c)}catch(h){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(c.substring(65,c.length-2))}let u=o.parse(l);e&&e(u)},n,r)},parse:function(t){return new c_(t)}});var ef,Y3={getContext:function(){return ef===void 0&&(ef=new(window.AudioContext||window.webkitAudioContext)),ef},setContext:function(t){ef=t}};function yg(t){Lt.call(this,t)}yg.prototype=Object.assign(Object.create(Lt.prototype),{constructor:yg,load:function(t,e,n,r){let o=this,a=new Xi(o.manager);a.setResponseType("arraybuffer"),a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{let l=c.slice(0);Y3.getContext().decodeAudioData(l,function(h){e(h)})}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)}});function E0(t,e,n){gi.call(this,void 0,n);let r=new We().set(t),o=new We().set(e),a=new W(r.r,r.g,r.b),c=new W(o.r,o.g,o.b),l=Math.sqrt(Math.PI),u=l*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(c).multiplyScalar(l),this.sh.coefficients[1].copy(a).sub(c).multiplyScalar(u)}E0.prototype=Object.assign(Object.create(gi.prototype),{constructor:E0,isHemisphereLightProbe:!0,copy:function(t){return gi.prototype.copy.call(this,t),this},toJSON:function(t){return gi.prototype.toJSON.call(this,t)}});function S0(t,e){gi.call(this,void 0,e);let n=new We().set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}S0.prototype=Object.assign(Object.create(gi.prototype),{constructor:S0,isAmbientLightProbe:!0,copy:function(t){return gi.prototype.copy.call(this,t),this},toJSON:function(t){return gi.prototype.toJSON.call(this,t)}});var T0=new vt,A0=new vt;function $3(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new on,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new on,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign($3.prototype,{update:function(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;let r=t.projectionMatrix.clone(),o=e.eyeSep/2,a=o*e.near/e.focus,c=e.near*Math.tan(dt.DEG2RAD*e.fov*.5)/e.zoom,l,u;A0.elements[12]=-o,T0.elements[12]=o,l=-c*e.aspect+a,u=c*e.aspect+a,r.elements[0]=2*e.near/(u-l),r.elements[8]=(u+l)/(u-l),this.cameraL.projectionMatrix.copy(r),l=-c*e.aspect-a,u=c*e.aspect-a,r.elements[0]=2*e.near/(u-l),r.elements[8]=(u+l)/(u-l),this.cameraR.projectionMatrix.copy(r)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(A0),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(T0)}});var xg=class extends Je{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e){if(e===void 0&&(e=0),this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let n=this.context.createBufferSource();return n.buffer=this.buffer,n.loop=this.loop,n.loopStart=this.loopStart,n.loopEnd=this.loopEnd,n.onended=this.onEnded.bind(this),n.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=n,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}};var _g=class{constructor(e,n){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=n!==void 0?n:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,n=this.getFrequencyData();for(let r=0;r<n.length;r++)e+=n[r];return e/n.length}};function l_(t,e,n){this.binding=t,this.valueSize=n;let r,o,a;switch(e){case"quaternion":r=this._slerp,o=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,o=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,o=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=o,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(l_.prototype,{accumulate:function(t,e){let n=this.buffer,r=this.valueSize,o=t*r+r,a=this.cumulativeWeight;if(a===0){for(let c=0;c!==r;++c)n[o+c]=n[c];a=e}else{a+=e;let c=e/a;this._mixBufferRegion(n,o,0,c,r)}this.cumulativeWeight=a},accumulateAdditive:function(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t},apply:function(t){let e=this.valueSize,n=this.buffer,r=t*e+e,o=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-o,e)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){c.setValue(n,r);break}},saveOriginalState:function(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let o=n,a=r;o!==a;++o)e[o]=e[r+o%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)},_setAdditiveIdentityNumeric:function(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]},_select:function(t,e,n,r,o){if(r>=.5)for(let a=0;a!==o;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){zn.slerpFlat(t,e,t,e,t,n,r)},_slerpAdditive:function(t,e,n,r,o){let a=this._workIndex*o;zn.multiplyQuaternionsFlat(t,a,t,e,t,n),zn.slerpFlat(t,e,t,e,t,a,r)},_lerp:function(t,e,n,r,o){let a=1-r;for(let c=0;c!==o;++c){let l=e+c;t[l]=t[l]*a+t[n+c]*r}},_lerpAdditive:function(t,e,n,r,o){for(let a=0;a!==o;++a){let c=e+a;t[c]=t[c]+t[n+a]*r}}});var Og="\\[\\]\\.:\\/",Z3=new RegExp("["+Og+"]","g"),Ug="[^"+Og+"]",J3="[^"+Og.replace("\\.","")+"]",Q3=/((?:WC+[\/:])*)/.source.replace("WC",Ug),K3=/(WCOD+)?/.source.replace("WCOD",J3),eF=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ug),tF=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ug),nF=new RegExp("^"+Q3+K3+eF+tF+"$"),rF=["material","materials","bones"];function u_(t,e,n){let r=n||Vn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}Object.assign(u_.prototype,{getValue:function(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)},setValue:function(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(t,e)},bind:function(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()},unbind:function(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}});function Vn(t,e,n){this.path=e,this.parsedPath=n||Vn.parseTrackName(e),this.node=Vn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(Vn,{Composite:u_,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new Vn.Composite(t,e,n):new Vn(t,e,n)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Z3,"")},parseTrackName:function(t){let e=nF.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let o=n.nodeName.substring(r+1);rF.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n},findNode:function(t,e){if(!e||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(o){for(let a=0;a<o.length;a++){let c=o[a];if(c.name===e||c.uuid===e)return c;let l=n(c.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}});Object.assign(Vn.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,n){e[n]=this.node[this.propertyName]},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)e[n++]=r[o]},function(e,n){e[n]=this.resolvedProperty[this.propertyIndex]},function(e,n){this.resolvedProperty.toArray(e,n)}],SetterByBindingTypeAndVersioning:[[function(e,n){this.targetObject[this.propertyName]=e[n]},function(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.needsUpdate=!0},function(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++]},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++];this.targetObject.needsUpdate=!0},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){this.resolvedProperty[this.propertyIndex]=e[n]},function(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.needsUpdate=!0},function(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){this.resolvedProperty.fromArray(e,n)},function(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.needsUpdate=!0},function(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,n){this.bind(),this.getValue(e,n)},setValue:function(e,n){this.bind(),this.setValue(e,n)},bind:function(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,o=e.propertyIndex;if(t||(t=Vn.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===u){u=h;break}break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let a=t[r];if(a===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let c=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?c=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(o!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[o]!==void 0&&(o=t.morphTargetDictionary[o])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][c]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}});Object.assign(Vn.prototype,{_getValue_unbound:Vn.prototype.getValue,_setValue_unbound:Vn.prototype.setValue});function iF(){this.uuid=dt.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let t={};this._indicesByUUID=t;for(let n=0,r=arguments.length;n!==r;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}Object.assign(iF.prototype,{isAnimationObjectGroup:!0,add:function(){let t=this._objects,e=this._indicesByUUID,n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length,c,l=t.length,u=this.nCachedObjects_;for(let h=0,d=arguments.length;h!==d;++h){let f=arguments[h],p=f.uuid,m=e[p];if(m===void 0){m=l++,e[p]=m,t.push(f);for(let v=0,x=a;v!==x;++v)o[v].push(new Vn(f,n[v],r[v]))}else if(m<u){c=t[m];let v=--u,x=t[v];e[x.uuid]=m,t[m]=x,e[p]=v,t[v]=f;for(let b=0,y=a;b!==y;++b){let g=o[b],M=g[v],C=g[m];g[m]=M,C===void 0&&(C=new Vn(f,n[b],r[b])),g[v]=C}}else t[m]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=u},remove:function(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,o=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=e[u];if(h!==void 0&&h>=o){let d=o++,f=t[d];e[f.uuid]=h,t[h]=f,e[u]=d,t[d]=l;for(let p=0,m=r;p!==m;++p){let v=n[p],x=v[d],b=v[h];v[h]=x,v[d]=b}}}this.nCachedObjects_=o},uncache:function(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,o=this.nCachedObjects_,a=t.length;for(let c=0,l=arguments.length;c!==l;++c){let u=arguments[c],h=u.uuid,d=e[h];if(d!==void 0)if(delete e[h],d<o){let f=--o,p=t[f],m=--a,v=t[m];e[p.uuid]=d,t[d]=p,e[v.uuid]=f,t[f]=v,t.pop();for(let x=0,b=r;x!==b;++x){let y=n[x],g=y[f],M=y[m];y[d]=g,y[f]=M,y.pop()}}else{let f=--a,p=t[f];f>0&&(e[p.uuid]=d),t[d]=p,t.pop();for(let m=0,v=r;m!==v;++m){let x=n[m];x[d]=x[f],x.pop()}}}this.nCachedObjects_=o},subscribe_:function(t,e){let n=this._bindingsIndicesByPath,r=n[t],o=this._bindings;if(r!==void 0)return o[r];let a=this._paths,c=this._parsedPaths,l=this._objects,u=l.length,h=this.nCachedObjects_,d=new Array(u);r=o.length,n[t]=r,a.push(t),c.push(e),o.push(d);for(let f=h,p=l.length;f!==p;++f){let m=l[f];d[f]=new Vn(m,t,e)}return d},unsubscribe_:function(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let r=this._paths,o=this._parsedPaths,a=this._bindings,c=a.length-1,l=a[c],u=t[c];e[u]=n,a[n]=l,a.pop(),o[n]=o[c],o.pop(),r[n]=r[c],r.pop()}}});var bg=class{constructor(e,n,r,o){this._mixer=e,this._clip=n,this._localRoot=r||null,this.blendMode=o||n.blendMode;let a=n.tracks,c=a.length,l=new Array(c),u={endingStart:ka,endingEnd:ka};for(let h=0;h!==c;++h){let d=a[h].createInterpolant(null);l[h]=d,d.settings=u}this._interpolantSettings=u,this._interpolants=l,this._propertyBindings=new Array(c),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=H2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,n){return this.loop=e,this.repetitions=n,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,n,r){if(e.fadeOut(n),this.fadeIn(n),r){let o=this._clip.duration,a=e._clip.duration,c=a/o,l=o/a;e.warp(1,c,n),this.warp(l,1,n)}return this}crossFadeTo(e,n,r){return e.crossFadeFrom(this,n,r)}stopFading(){let e=this._weightInterpolant;return e!==null&&(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,n,r){let o=this._mixer,a=o.time,c=this.timeScale,l=this._timeScaleInterpolant;l===null&&(l=o._lendControlInterpolant(),this._timeScaleInterpolant=l);let u=l.parameterPositions,h=l.sampleValues;return u[0]=a,u[1]=a+r,h[0]=e/c,h[1]=n/c,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(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,n,r,o){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let u=(e-a)*r;if(u<0||r===0)return;this._startTime=null,n=r*u}n*=this._updateTimeScale(e);let c=this._updateTime(n),l=this._updateWeight(e);if(l>0){let u=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case N0:for(let d=0,f=u.length;d!==f;++d)u[d].evaluate(c),h[d].accumulateAdditive(l);break;case Ig:default:for(let d=0,f=u.length;d!==f;++d)u[d].evaluate(c),h[d].accumulate(o,l)}}}_updateWeight(e){let n=0;if(this.enabled){n=this.weight;let r=this._weightInterpolant;if(r!==null){let o=r.evaluate(e)[0];n*=o,e>r.parameterPositions[1]&&(this.stopFading(),o===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n}_updateTimeScale(e){let n=0;if(!this.paused){n=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let o=r.evaluate(e)[0];n*=o,e>r.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n}_updateTime(e){let n=this._clip.duration,r=this.loop,o=this.time+e,a=this._loopCount,c=r===z2;if(e===0)return a===-1?o:c&&(a&1)===1?n-o:o;if(r===k2){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(o>=n)o=n;else if(o<0)o=0;else{this.time=o;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=o,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,c)):this._setEndings(this.repetitions===0,!0,c)),o>=n||o<0){let l=Math.floor(o/n);o-=n*l,a+=Math.abs(l);let u=this.repetitions-a;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o=e>0?n:0,this.time=o,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){let h=e<0;this._setEndings(h,!h,c)}else this._setEndings(!1,!1,c);this._loopCount=a,this.time=o,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}else this.time=o;if(c&&(a&1)===1)return n-o}return o}_setEndings(e,n,r){let o=this._interpolantSettings;r?(o.endingStart=Ha,o.endingEnd=Ha):(e?o.endingStart=this.zeroSlopeAtStart?Ha:ka:o.endingStart=uf,n?o.endingEnd=this.zeroSlopeAtEnd?Ha:ka:o.endingEnd=uf)}_scheduleFading(e,n,r){let o=this._mixer,a=o.time,c=this._weightInterpolant;c===null&&(c=o._lendControlInterpolant(),this._weightInterpolant=c);let l=c.parameterPositions,u=c.sampleValues;return l[0]=a,u[0]=n,l[1]=a+e,u[1]=r,this}};function C0(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}C0.prototype=Object.assign(Object.create(Ji.prototype),{constructor:C0,_bindAction:function(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,o=r.length,a=t._propertyBindings,c=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,h=u[l];h===void 0&&(h={},u[l]=h);for(let d=0;d!==o;++d){let f=r[d],p=f.name,m=h[p];if(m!==void 0)a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}let v=e&&e._propertyBindings[d].binding.parsedPath;m=new l_(Vn.create(n,p,v),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[d]=m}c[d].resultBuffer=m.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,o=this._actionsByClip[r];this._bindAction(t,o&&o.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions},_addInactiveAction:function(t,e,n){let r=this._actions,o=this._actionsByClip,a=o[e];if(a===void 0)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,o[e]=a;else{let c=a.knownActions;t._byClipCacheIndex=c.length,c.push(t)}t._cacheIndex=r.length,r.push(t),a.actionByRoot[n]=t},_removeInactiveAction:function(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let o=t._clip.uuid,a=this._actionsByClip,c=a[o],l=c.knownActions,u=l[l.length-1],h=t._byClipCacheIndex;u._byClipCacheIndex=h,l[h]=u,l.pop(),t._byClipCacheIndex=null;let d=c.actionByRoot,f=(t._localRoot||this._root).uuid;delete d[f],l.length===0&&delete a[o],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];--o.referenceCount===0&&this._removeInactiveBinding(o)}},_lendAction:function(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_takeBackAction:function(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_addInactiveBinding:function(t,e,n){let r=this._bindingsByRootAndName,o=this._bindings,a=r[e];a===void 0&&(a={},r[e]=a),a[n]=t,t._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,o=n.path,a=this._bindingsByRootAndName,c=a[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete c[o],Object.keys(c).length===0&&delete a[r]},_lendBinding:function(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_takeBackBinding:function(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_lendControlInterpolant:function(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new _f(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=e,t[e]=n),n},_takeBackControlInterpolant:function(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,o=e[r];t.__cacheIndex=r,e[r]=t,o.__cacheIndex=n,e[n]=o},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e,n){let r=e||this._root,o=r.uuid,a=typeof t=="string"?pi.findByName(r,t):t,c=a!==null?a.uuid:t,l=this._actionsByClip[c],u=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Ig),l!==void 0){let d=l.actionByRoot[o];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],a===null&&(a=u._clip)}if(a===null)return null;let h=new bg(this,a,e,n);return this._bindAction(h,u),this._addInactiveAction(h,c,o),h},existingAction:function(t,e){let n=e||this._root,r=n.uuid,o=typeof t=="string"?pi.findByName(n,t):t,a=o?o.uuid:t,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[r]||null},stopAllAction:function(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this},update:function(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,o=Math.sign(t),a=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,o,a);let c=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)c[u].apply(a);return this},setTime:function(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,o=r[n];if(o!==void 0){let a=o.knownActions;for(let c=0,l=a.length;c!==l;++c){let u=a[c];this._deactivateAction(u);let h=u._cacheIndex,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=h,e[h]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}},uncacheRoot:function(t){let e=t.uuid,n=this._actionsByClip;for(let a in n){let c=n[a].actionByRoot,l=c[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,o=r[e];if(o!==void 0)for(let a in o){let c=o[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}},uncacheAction:function(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}});var wg=class t{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new t(this.value.clone===void 0?this.value:this.value.clone())}};function R0(t,e,n){Er.call(this,t,e),this.meshPerAttribute=n||1}R0.prototype=Object.assign(Object.create(Er.prototype),{constructor:R0,isInstancedInterleavedBuffer:!0,copy:function(t){return Er.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){let e=Er.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){let e=Er.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}});function h_(t,e,n,r,o){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=r,this.count=o,this.version=0}Object.defineProperty(h_.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(h_.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}});function Lf(t,e,n,r){this.ray=new Ss(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,this.layers=new hf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function P0(t,e){return t.distance-e.distance}function Mg(t,e,n,r){if(t.layers.test(e.layers)&&t.raycast(e,n),r===!0){let o=t.children;for(let a=0,c=o.length;a<c;a++)Mg(o[a],e,n,!0)}}Object.assign(Lf.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e,n){let r=n||[];return Mg(t,this,r,e),r.sort(P0),r},intersectObjects:function(t,e,n){let r=n||[];if(Array.isArray(t)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(let o=0,a=t.length;o<a;o++)Mg(t[o],this,r,e);return r.sort(P0),r}});var L0=new fe,Eg=class{constructor(e,n){Object.defineProperty(this,"isBox2",{value:!0}),this.min=e!==void 0?e:new fe(1/0,1/0),this.max=n!==void 0?n:new fe(-1/0,-1/0)}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){let r=L0.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return e===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new fe),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new fe),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.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,n){return n===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),n=new fe),n.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,n){return n===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),n=new fe),n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return L0.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)}},F0=new W,tf=new W,Sg=class{constructor(e,n){this.start=e!==void 0?e:new W,this.end=n!==void 0?n:new W}set(e,n){return this.start.copy(e),this.end.copy(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e===void 0&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new W),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e===void 0&&(console.warn("THREE.Line3: .delta() target is now required"),e=new W),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return n===void 0&&(console.warn("THREE.Line3: .at() target is now required"),n=new W),this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){F0.subVectors(e,this.start),tf.subVectors(this.end,this.start);let r=tf.dot(tf),a=tf.dot(F0)/r;return n&&(a=dt.clamp(a,0,1)),a}closestPointToPoint(e,n,r){let o=this.closestPointToPointParameter(e,n);return r===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),r=new W),this.delta(r).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)}};function Ef(t){Je.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Ef.prototype=Object.create(Je.prototype);Ef.prototype.constructor=Ef;Ef.prototype.isImmediateRenderObject=!0;var Do=new W,nf=new vt,Om=new vt,Tg=class extends pf{constructor(e){let n=f_(e),r=new Tt,o=[],a=[],c=new We(0,0,1),l=new We(0,1,0);for(let h=0;h<n.length;h++){let d=n[h];d.parent&&d.parent.isBone&&(o.push(0,0,0),o.push(0,0,0),a.push(c.r,c.g,c.b),a.push(l.r,l.g,l.b))}r.setAttribute("position",new St(o,3)),r.setAttribute("color",new St(a,3));let u=new Rr({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(r,u),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=n,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let n=this.bones,r=this.geometry,o=r.getAttribute("position");Om.getInverse(this.root.matrixWorld);for(let a=0,c=0;a<n.length;a++){let l=n[a];l.parent&&l.parent.isBone&&(nf.multiplyMatrices(Om,l.matrixWorld),Do.setFromMatrixPosition(nf),o.setXYZ(c,Do.x,Do.y,Do.z),nf.multiplyMatrices(Om,l.parent.matrixWorld),Do.setFromMatrixPosition(nf),o.setXYZ(c+1,Do.x,Do.y,Do.z),c+=2)}r.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}};function f_(t){let e=[];t&&t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push.apply(e,f_(t.children[n]));return e}var Ag=class extends pf{constructor(e,n,r,o){e=e||10,n=n||10,r=new We(r!==void 0?r:4473924),o=new We(o!==void 0?o:8947848);let a=n/2,c=e/n,l=e/2,u=[],h=[];for(let p=0,m=0,v=-l;p<=n;p++,v+=c){u.push(-l,0,v,l,0,v),u.push(v,0,-l,v,0,l);let x=p===a?r:o;x.toArray(h,m),m+=3,x.toArray(h,m),m+=3,x.toArray(h,m),m+=3,x.toArray(h,m),m+=3}let d=new Tt;d.setAttribute("position",new St(u,3)),d.setAttribute("color",new St(h,3));let f=new Rr({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}};var sf=4,Il=8,NB=Math.pow(2,Il),d_=[.125,.215,.35,.446,.526,.582],oF=Il-sf+1+d_.length;var GB={[sc]:0,[Dg]:1,[k0]:2,[H0]:3,[z0]:4,[V0]:5,[G0]:6};var{_lodPlanes:kB,_sizeLods:HB,_sigmas:zB}=sF();var ws=(1+Math.sqrt(5))/2,Na=1/ws,VB=[new W(1,1,1),new W(-1,1,1),new W(1,1,-1),new W(-1,1,-1),new W(0,ws,Na),new W(0,ws,-Na),new W(Na,0,ws),new W(-Na,0,ws),new W(ws,Na,0),new W(-ws,Na,0)];function sF(){let t=[],e=[],n=[],r=Il;for(let o=0;o<oF;o++){let a=Math.pow(2,r);e.push(a);let c=1/a;o>Il-sf?c=d_[o-Il+sf-1]:o==0&&(c=0),n.push(c);let l=1/(a-1),u=-l/2,h=1+l/2,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,p=6,m=3,v=2,x=1,b=new Float32Array(m*p*f),y=new Float32Array(v*p*f),g=new Float32Array(x*p*f);for(let C=0;C<f;C++){let E=C%3*2/3-1,w=C>2?0:-1,F=[E,w,0,E+2/3,w,0,E+2/3,w+1,0,E,w,0,E+2/3,w+1,0,E,w+1,0];b.set(F,m*p*C),y.set(d,v*p*C);let H=[C,C,C,C,C,C];g.set(H,x*p*C)}let M=new Tt;M.setAttribute("position",new ut(b,m)),M.setAttribute("uv",new ut(y,v)),M.setAttribute("faceIndex",new ut(g,x)),t.push(M),r>sf&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}rt.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(rt.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t};Object.assign(Oo.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=new Kt;for(let n=0,r=t.length;n<r;n++){let o=t[n];e.vertices.push(new W(o.x,o.y,o.z||0))}return e}});Object.assign(mi.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}});function aF(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Wn.call(this,t),this.type="catmullrom",this.closed=!0}aF.prototype=Object.create(Wn.prototype);function cF(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Wn.call(this,t),this.type="catmullrom"}cF.prototype=Object.create(Wn.prototype);function p_(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Wn.call(this,t),this.type="catmullrom"}p_.prototype=Object.create(Wn.prototype);Object.assign(p_.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});Ag.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Tg.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(Lt.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),j3.extractUrlBase(t)}});Lt.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};Object.assign(Eg.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}});Object.assign(vi.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}});Object.assign(yi.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}});Ja.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)};Sg.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)};Object.assign(dt,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),dt.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),dt.ceilPowerOfTwo(t)}});Object.assign(Fn.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(vt.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new W().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,n,r,o,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,n,o,a)}});qr.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)};zn.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)};Object.assign(Ss.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}});Object.assign(Sr.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}});Object.assign(Sr,{barycoordFromPoint:function(t,e,n,r,o){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Sr.getBarycoord(t,e,n,r,o)},normal:function(t,e,n,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Sr.getNormal(t,e,n,r)}});Object.assign(Ya.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ng(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new og(this,t)}});Object.assign(fe.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(W.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(Rt.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(Kt.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.assign(Je.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.defineProperties(Je.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.assign(Wt.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}});Object.defineProperties(Wt.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),V2},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});Object.defineProperties(Zm.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}});Object.defineProperty(Qm.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});Jm.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Object.defineProperty(rt.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}});on.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),e!==void 0&&(this.filmGauge=e),this.setFocalLength(t)};Object.defineProperties(Gt.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}});Object.defineProperties(ut.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Bl},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Bl)}}});Object.assign(ut.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(t===!0?Bl:Rf),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(Tt.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(e&&e.isBufferAttribute)&&!(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new ut(arguments[1],arguments[2]))):t==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e)},addDrawCall:function(t,e,n){n!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},applyMatrix:function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.defineProperties(Tt.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}});Object.defineProperties(Mf.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}});Object.defineProperties(Lf.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}});Object.defineProperties(Er.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===Bl},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}});Object.assign(Er.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(t===!0?Bl:Rf),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(vf.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.assign($m.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}});Object.defineProperties(wg.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}});Object.defineProperties(at.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new We}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=t===D0}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}});Object.defineProperties(Is.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(Fs.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}});Object.defineProperties(In.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}});Object.assign(lc.prototype,{clearTarget:function(t,e,n,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,n,r)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}});Object.defineProperties(lc.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=t===!0?Dg:sc}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}});Object.defineProperties(t_.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(an.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}});Object.defineProperties(xg.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");let e=this;return new yg().load(t,function(r){e.setBuffer(r)}),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}});_g.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};Za.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)};Za.prototype.clear=function(t,e,n,r){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,r)};Es.crossOrigin=void 0;Es.loadTexture=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");let o=new Yl;o.setCrossOrigin(this.crossOrigin);let a=o.load(t,n,void 0,r);return e&&(a.mapping=e),a};Es.loadTextureCube=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");let o=new fg;o.setCrossOrigin(this.crossOrigin);let a=o.load(t,n,void 0,r);return e&&(a.mapping=e),a};Es.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Es.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yA}}));var Yr=class Yr{static SetRenderer(e){Yr.renderer=e}static Update(){Yr.renderer.getSize(Yr.size)}static Width(){return Yr.Update(),Yr.size.width}static Height(){return Yr.Update(),Yr.size.height}};te(Yr,"renderer"),te(Yr,"size",new fe);var Jt=Yr;function*lF(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r++)yield[t[r],e[r]]}var Ng=class{constructor(e,n){this.avg=e;this.max=n}get Avg(){return this.avg}get Max(){return this.max}},Ff=class{constructor(e,n){this.size=e;te(this,"values",[]);n==null||n.forEach(this.push_front)}push_front(e){this.values.push(e),this.values.length>this.size&&this.values.shift()}get average(){return this.values.reduce((e,n)=>e+n,0)/this.values.length}};function uF(t,{xPercent:e,yPercent:n}){let r=t.width*4,o=t.height,a=r*Math.trunc(o*n)+Math.trunc(r*e),c=a-a%4;return[...t.data.slice(c,c+4)]}function m_([t,e,n]){return .299*t+.587*e+.1148*n}var If=class{constructor(){te(this,"avgQueue",new Ff(10));te(this,"maxQueue",new Ff(10));te(this,"frameCount",0);te(this,"tracker");te(this,"fpToRecPercentage",e=>({xPercent:e.x,yPercent:1-e.y}));te(this,"CalculateAverageColor",e=>e.reduce((n,r)=>n.map((o,a)=>o+r[a]),[0,0,0,0]).map(n=>n/e.length));te(this,"CalculateLuminance",e=>{let[n,r]=e.map(m_).reduce((d,f)=>[Math.min(d[0],f),Math.max(d[1],f)],[1/0,-1/0]),o=this.CalculateAverageColor(e),a=e.reduce((d,f)=>f.map((p,m)=>d[m]+qy(p-o[m],2)),[0,0,0,0]).map(d=>Math.sqrt(d/e.length)),c=e.filter(d=>d.every((f,p)=>Math.abs(f-o[p])<=a[p])),[l,u,h]=this.CalculateAverageColor(c);return{min:n/255,max:r/255,avg:m_([l/255,u/255,h/255,1])}});te(this,"extractFp2DPositions",(e,n,r)=>r.map(o=>e.GetPos(n,o)));te(this,"interpolate",(e,n,r)=>{let o=[],a=(c,l,u)=>c*(1-u)+l*u;for(let c=0;c<=r;c+=1)o.push({xPercent:a(e.xPercent,n.xPercent,c/r),yPercent:a(e.yPercent,n.yPercent,c/r)});return o})}Update(e){if(!this.tracker)if(Le.tracker)this.tracker=Le.tracker;else return;this.frameCount=(this.frameCount+1)%10;let n=this.tracker.Get();if(n.status!==this.tracker.statuses.OK)return;let r=n.GetFeaturePoints2D(),o=this.extractFp2DPositions(r,8,[1,5,3,7,2,8,4,6]),a=this.extractFp2DPositions(r,2,[2,6,4,8,3,9,5,7]),l=this.calculateMidpoints(o,a).flatMap((d,f,p)=>f!==p.length-1?this.interpolate(d,p[f+1],4):d);r.delete();let u=l.map(d=>uF(e,d)),h=this.CalculateLuminance(u);this.avgQueue.push_front(h.avg),this.maxQueue.push_front(h.max)}LateUpdate(){}Process(){return new Ng(this.avgQueue.average,this.maxQueue.average)}calculateMidpoints(e,n){return[...lF(e,n)].map(([r,o])=>[this.fpToRecPercentage(r),this.fpToRecPercentage(o)]).map(([r,o])=>({xPercent:(r.xPercent+o.xPercent)/2,yPercent:(r.yPercent+o.yPercent)/2}))}};var Le=class{};te(Le,"pathToAssets",""),te(Le,"tracker"),te(Le,"lumGatherer",new If),te(Le,"controllableObjects");var Gg={};function Df(t,e,n){let r=Gg[t];r&&clearTimeout(r),Gg[t]=setTimeout(()=>{delete Gg[t],e()},n)}var uc=class{constructor(e,n){this.generator=e;this.mesh=n;te(this,"meshObtianed",!1)}Update(){}LateUpdate(){var r,o;let e=(r=Le.tracker)==null?void 0:r.Get();!e||e.status!=((o=Le.tracker)==null?void 0:o.statuses.OK)||(this.meshObtianed?(this.mesh.geometry=this.generator.mesh.geometry,this.mesh.geometry instanceof Kt&&(this.mesh.geometry.verticesNeedUpdate=!0)):(this.mesh.geometry=this.generator.mesh.geometry,this.mesh.geometry instanceof Kt&&(this.mesh.geometry.verticesNeedUpdate=!0,this.mesh.geometry.normalsNeedUpdate=!0,this.mesh.geometry.uvsNeedUpdate=!0,this.mesh.geometry.elementsNeedUpdate=!0),this.meshObtianed=!0))}};var hF=(t,e,n)=>t||t===0?Math.min(Math.max(t,e),n):null,Bf=t=>hF(t,0,1),jn=class{constructor(e,n,r,o){this.r=e;this.g=n;this.b=r;this.a=o;var a,c,l,u;this.r=(a=Bf(e))!=null?a:0,this.g=(c=Bf(n))!=null?c:0,this.b=(l=Bf(r))!=null?l:0,this.a=(u=Bf(o))!=null?u:0}};function fF(t,e,n){return`${Le.pathToAssets}Assets/StreamingAssets/Textures/${t}/${e}/${n}`}var Jl=class{constructor(e,n,r,o,a,c,l,u,h){this.color=n;this.transparency=o;this.effect=c;this.type=l;this.useColor=u;this.useTexture=h;te(this,"masks",[]);te(this,"texture");te(this,"area");let d=f=>fF(f,l,e);this.texture=d(r),this.area=d("Area"),this.masks=a.map(({name:f,texture:p})=>({name:f,path:d(p)}))}},Of=class extends Jl{constructor(n,r,o,a,c,l,u,h,d,f){super(n,o,a,c,l,u,h,d,f);this.initialPipe=r}};var Uf=class Uf{constructor(e){this.tracker=e;te(this,"mesh",new Wt)}static SetModulePath(e){Uf.pathToModule=e}Update(){let e=this.tracker.Get();e.status===this.tracker.statuses.OK&&this.UpdateInner(e)}GetMesh(){return this.mesh}};te(Uf,"pathToModule","");var hc=Uf;var fc=[.575135,.262559,.6071,.2455,.5955,.2922,.628,.2346,.6263,.2535,.601,.569,.5764,.5703,.5766,.554,.7378,.3964,.6633,.4031,.6897,.3639,.9639,.3138,.9587,.6584,.9131,.3786,.7742,.5575,.8172,.5589,.786,.5876,.7845,.502,.8515,.5457,.8385,.5989,.781,.4456,.8249,.4927,.784224,.633746,.425965,.258364,.4056,.2924,.394,.2458,.3731,.235,.3748,.2538,.403,.573,.4247,.5586,.4217,.583,.2647,.3968,.3123,.3642,.3392,.4033,.0377,.3145,.0884,.3792,.0431,.6586,.2299,.5585,.2242,.5839,.1869,.5591,.2195,.5022,.152,.546,.1652,.5991,.2222,.4459,.1785,.493,.221529,.636287,.5435,.1149,.5669,.0849,.6122,.1575,.6191,.1023,.708,.5202,.728,.53,.717851,.546974,.735651,.552174,.609,.345,.5831,.3293,.6202,.306,.5993,.4245,.6166,.4502,.5967,.4615,.6029,.4861,.741951,.575574,.755051,.562074,.7357,.6006,.6558,.2322,.6529,.1681,.6121,.2126,.6796,.023,.6998,.1462,.7655,.0642,.6266,.7821,.5742,.7654,.6123,.7177,.5535,.6932,.9034,.5736,.8622,.7399,.8768,.5378,.8563,.6449,.5602,.4955,.5558,.4602,.5865,.4363,.5249,.2209,.525023,.206606,.5627,.228,.5661,.2186,.586641,.228435,.6004,.2289,.601242,.24123,.5006,.3492,.559,.3817,.5006,.3656,.5507,.3567,.4987,.6525,.4975,.6009,.5761,.6628,.5383,.5937,.5351,.5217,.5616,.5161,.8486,.1265,.7777,.1827,.3888,.1578,.4233,.1988,.3481,.1686,.389,.2129,.3694,.3682,.4028,.4246,.3859,.4504,.3811,.3063,.2762,.5302,.2665,.4647,.2952,.6092,.284524,.586449,.3229,.6137,.314124,.593249,.2056,.3775,.245,.3333,.2698,.6287,.319,.6371,.2718,.6759,.321,.6841,.3254,.729,.2669,.7085,.1262,.5381,.1468,.6451,.2724,.7904,.2735,.8724,.196,.7436,.212,.8353,.5005,.2205,.4761,.221,.500012,.205818,.475977,.208171,.443641,.256035,.427141,.247559,.4436,.2428,.404741,.236547,.4779,.2664,.5005,.2682,.4813,.2907,.5006,.2876,.4233,.6634,.3934,.6194,.4574,.5946,.4358,.5176,.3975,.4868,.4371,.4963,.4042,.4619,.2918,.3036,.3055,.229,.2484,.2482,.6508,.5294,.649651,.553074,.7371,.4645,.7007,.4622,.7073,.6113,.719951,.586574,.6577,.2814,.7321,.6758,.7344,.6286,.8035,.6878,.7364,.7084,.8638,.454,.7896,.8353,.8066,.7435,.9012,.784,.5246,.241,.5588,.2386,.5764,.2498,.5198,.2906,.4973,.5236,.8787,.4103,.4349,.2188,.4007,.2292,.3925,.3452,.3558,.3275,.4464,.2733,.4181,.3295,.265924,.554449,.246124,.565549,.354424,.590649,.3659,.6057,.3706,.6788,.3668,.6329,.3903,.7178,.1399,.74,.1998,.6879,.328,.7932,.3265,.8739,.4764,.2411,.5005,.2404,.4782,.2456,.5005,.2459,.4464,.6937,.4996,.6908,.3898,.5142,.2233,.1834,.3011,.1469,.5777,.1986,.6324,.368,.6794,.6153,.687051,.593974,.7566,.3329,.7963,.3771,.6851,.6361,.6825,.684,.6775,.7289,.7279,.8724,.7299,.7903,.5599,.2573,.5574,.2426,.5232,.2664,.591,.6128,.7096,.3032,.6957,.2284,.7528,.2479,.4574,.115,.4728,.1746,.3435,.2818,.4507,.3568,.3843,.5475,.375124,.561349,.382124,.567849,.2685,.5987,.0771,.1938,.1458,.2642,.3935,.8625,.3756,.7821,.4109,.0113,.5003,.01,.4339,.0851,.5004,.0775,.4603,.5222,.4741,.4703,.443,.4606,.5001,.4125,.482,.4146,.5002,.402,.4787,.4035,.4587,.4285,.4803,.433,.1708,.3217,.1232,.4108,.1385,.4544,.5282,.1746,.6456,.3272,.5547,.2732,.6189,.5465,.626551,.559174,.619451,.564774,.6294,.6036,.647051,.588874,.6324,.6787,.6359,.6324,.9243,.1928,.8556,.2635,.6749,.8739,.608,.8625,.6742,.7932,.5898,.011,.5229,.2456,.5234,.4701,.5181,.4144,.522,.4034,.5412,.4282,.5189,.4329,.8306,.3212,.5004,.1144,.5005,.1713,.415,.3875,.4147,.4366,.3028,.4625,.3719,.4895,.2962,.5204,.3537,.5304,.4286,.3958,.4426,.3818,.1525,.1274,.1005,.7841,.0991,.5739,.4545,.4153,.4606,.3998,.4383,.2281,.414947,.228147,.4997,.429,.4986,.4681,.5004,.3887,.4381,.4209,.4278,.7655,.5005,.7519,.6121,.5124,.4472,.8521,.3453,.2327,.587,.3874,.6307,.4892,.5732,.3957,.5403,.3996,.546,.4151,.5627,.4206,.3817,.1027,.284124,.548049,.261924,.574149,.3211,.0236,.2354,.0651,.5007,.8466,.5542,.8522,.352124,.553549,.4423,.2388,.5353,.2839,.6777,.5206,.5978,.37,.565,.3496,.689751,.542174,.5399,.2623,.6189,.3972,.6343,.4343,.66,.4777,.5461,.2445,.5461,.2238,.5812,.1283,.548023,.211965,.5604,.1879,.5447,.2398,.4564,.2399,.4549,.224,.452977,.214606,.4197,.1285,.4406,.1881,.4549,.2446,.3263,.5207,.3832,.3973,.3683,.4344,.3434,.4779,.312324,.543349,.4612,.2624,.4658,.284,.4039,.3702,.4363,.3497,.9795,.4436,.9936,.5671,.0221,.4441,.008,.5674,0,0,.2703,.9655,.2266,.9429,.7749,.943,.8438,.8894,.3271,.9817,.7311,.9655,.3794,.9885,.6743,.9817,.622,.9886,.1577,.8894,.4384,.9901,.5007,.9884,.563,.9901,0,0,0,0,.435393,.239665,.426758,.233398,.424754,.23873,.570312,.240234,.575195,.234619,.576904,.23999,.369806,.58031,.333674,.593006,.299494,.591052,.335627,.546131,.299494,.545154,.632751,.578559,.664977,.593207,.705017,.59223,.667907,.546332,.70404,.544379,0,0,0,0,0,0,0,0],kg=[345,344,347,349,350,354,353,352,348,346,342,343,351],g_=[.0448,.0672,.0896,.0952,.1008,.1064,.112,.1064,.1008,.0952,.0896,.0672,.0448],dF=-.5,dc=class extends hc{constructor(n){super(n);this.tracker=n;te(this,"meshGenerated",!1)}GenerateMesh(n){let r=new Kt;r.faceVertexUvs[0]=[];let o=n.GetFaceModelVertices(),a=n.GetFaceModelVertexCount();for(let u=0,h=a*3;u<h;u+=3)r.vertices.push(new W(o[u],o[u+1],o[u+2]));let c=n.GetFaceModelTriangles(),l=n.GetFaceModelTriangleCount();for(let u=0,h=l*3;u<h;u+=3)r.faces.push(new Ar(c[u],c[u+1],c[u+2])),r.faceVertexUvs[0].push([new fe(fc[c[u]*2],fc[c[u]*2+1]),new fe(fc[c[u+1]*2],fc[c[u+1]*2+1]),new fe(fc[c[u+2]*2],fc[c[u+2]*2+1])]);return r.computeVertexNormals(),r.verticesNeedUpdate=!0,r.normalsNeedUpdate=!0,r.uvsNeedUpdate=!0,r}UpdateInner(n){this.meshGenerated||(this.mesh.geometry=this.GenerateMesh(n),this.meshGenerated=!0);let r=n.GetFaceModelVertexCount(),o=n.GetFaceModelVertices();this.UpdateMesh(r,o)}UpdateMesh(n,r){let o=this.mesh.geometry.vertices;for(let c=0,l=n;c<l;c++)o[c].x=r[c*3],o[c].y=r[c*3+1],o[c].z=r[c*3+2];let a=Math.abs(o[338].x-o[340].x);for(let c=0;c<kg.length;c++)o[kg[c]].y+=a*g_[c],o[kg[c]].z+=a*dF*g_[c];this.mesh.geometry.verticesNeedUpdate=!0}};function pF(t,e){return t.LoadMeshGenerator().then(n=>{switch(e){case"LipstickGenerator":return new n.LipstickGenerator;case"EyeshadowGenerator":return new n.EyeshadowGenerator;case"EyelinerMeshGenerator":return new n.EyelinerMeshGenerator;case"EyebrowsGenerator":return new n.EyebrowsGenerator;case"EyebrowsGenerator1":return new n.OldEyebrowsGenerator(.125);case"EyebrowsGenerator2":return new n.OldEyebrowsGenerator(.145);case"EyebrowsGenerator3":return new n.OldEyebrowsGenerator(.165);case"CurvedMascaraGenerator":return new n.CurvedMascaraGenerator;case"FullMeshGenerator":return new n.FullMeshGenerator;default:throw new Error(`Native generator '${e}' is not supported`)}})}var Nf=class t extends hc{constructor(n,r,o){super(n);this.generator=r;this.name=o;te(this,"meshGenerated",!1)}get generatorName(){return this.name}static Create(n,r,o){return xe(this,null,function*(){let a=yield pF(n,r);return new t(o,a,r)})}GenerateMesh(){let n=new Kt;n.faceVertexUvs[0]=[];let r=this.generator.GetVertexCount(),o=this.generator.GetVertexBuffer();for(let u=0,h=r*3;u<h;u+=3)n.vertices.push(new W(o[u],o[u+1],o[u+2]));let a=this.generator.GetTexCoordBuffer(),c=this.generator.GetTriangleCount(),l=this.generator.GetTriangleBuffer();for(let u=0,h=c*3;u<h;u+=3)n.faces.push(new Ar(l[u],l[u+1],l[u+2])),n.faceVertexUvs[0].push([new fe(a[l[u]*2],a[l[u]*2+1]),new fe(a[l[u+1]*2],a[l[u+1]*2+1]),new fe(a[l[u+2]*2],a[l[u+2]*2+1])]);return n.computeVertexNormals(),n.verticesNeedUpdate=!0,n.normalsNeedUpdate=!0,n.uvsNeedUpdate=!0,n}UpdateInner(){this.generator.Update(),this.meshGenerated||(this.mesh.geometry=this.GenerateMesh(),this.meshGenerated=!0);let n=this.generator.GetVertexCount(),r=this.generator.GetVertexBuffer();this.UpdateMesh(n,r)}UpdateMesh(n,r){let o=this.mesh.geometry.vertices;for(let a=0,c=n;a<c;a++)o[a].x=r[a*3],o[a].y=r[a*3+1],o[a].z=r[a*3+2];this.mesh.geometry.verticesNeedUpdate=!0}};function zo(t){switch(t){case"Lipstick":case"Lipliner":return"LipstickGenerator";case"Mascara":return"CurvedMascaraGenerator";case"Foundation":case"EyebrowLine":case"Blush":case"Concealer":case"Highlighter":return"FaceMeshGenerator";case"FullMesh":return"FullMeshGenerator";case"Eyeliner":return"EyelinerMeshGenerator";case"Eyeshadow":return"EyeshadowGenerator";case"Eyebrows":return"EyebrowsGenerator";case"Eyebrows_1":return"EyebrowsGenerator1";case"Eyebrows_2":return"EyebrowsGenerator2";case"Eyebrows_3":return"EyebrowsGenerator3";default:return t}}var Ql=class{constructor(e){this.modulesManager=e;te(this,"generators",{});if(!Le.tracker)throw new Error("Tracker not defined");this.modulesManager=e}get tracker(){return Le.tracker}Update(){}LateUpdate(){return xe(this,null,function*(){if(this.modulesManager.modules.meshGenerator.inited){let e=this.modulesManager.modules.meshGenerator.module,n=e.GetFPBuffer(),r=e.GetFPGroups(),o=e.GetFPIndices(),c=this.tracker.Get().GetFeaturePoints3DRelative();for(let l=0;l<r.length;l++){let u=c.GetPos(r[l],o[l]);n[3*l]=u.x,n[3*l+1]=u.y,n[3*l+2]=u.z}}Object.keys(this.generators).map(e=>this.generators[e]).filter(e=>!!e).forEach(e=>e.Update())})}GetGenerator(e){return xe(this,null,function*(){if(!e)throw new Error("The requested generator type is invalid");if(e=zo(e),this.generators[e])return this.generators[e];switch(e){case"FaceMeshGenerator":this.generators[e]=new dc(this.tracker);break;default:this.generators[e]=yield Nf.Create(this.modulesManager,e,this.tracker);break}return this.generators[e]})}};function v_(){return`
uniform sampler2D _MainTex;
uniform sampler2D _OverlayTexture;
uniform sampler2D _MaskTexture;
uniform vec4 _BoundingBox;

vec4 lerp(vec4 main, vec4 overlay, float alpha){
	vec4 final = main * alpha + overlay * (1.0 - alpha);
	return final;
}

varying vec2 vUv;

void main() {
	vec4 mainTexColor = texture2D(_MainTex, vUv);

	if (vUv.x > _BoundingBox.x && vUv.x < _BoundingBox.z && vUv.y > _BoundingBox.y && vUv.y < _BoundingBox.w)
	{
		vec4 overlayTexColor = texture2D(_OverlayTexture, vUv);
		vec4 maskTexColor = texture2D(_MaskTexture, vUv);
		gl_FragColor.x = overlayTexColor.x * maskTexColor.x + mainTexColor.x * (1.0 - maskTexColor.x);
		gl_FragColor.y = overlayTexColor.y * maskTexColor.y + mainTexColor.y * (1.0 - maskTexColor.y);
		gl_FragColor.z = overlayTexColor.z * maskTexColor.z + mainTexColor.z * (1.0 - maskTexColor.z);
		gl_FragColor.w = 1.0;
	}
	else
	{
		gl_FragColor = vec4(mainTexColor.xyz, 1.0);
	}
}`}function y_(){return`uniform sampler2D _MainTex;
	uniform sampler2D _OverlayTexture;
	uniform sampler2D _MaskTexture;

	varying vec2 vUv;

	float Overlay(float x, float y) {
	if(x < 0.5) {
	return 2.0 * x * y;
	}
	return 1.0 - 2.0 * (1.0 - x) * (1.0 - y);

	}
	//Overlay
	void main() {

	vec4 colMain = texture2D(_MainTex, vUv);
	vec4 colOver = texture2D(_OverlayTexture, vUv);
	vec4 colMask = texture2D(_MaskTexture, vUv);

	vec4 col;
	col.x = Overlay(colMain.x, colOver.x);
	col.y = Overlay(colMain.y, colOver.y);
	col.z = Overlay(colMain.z, colOver.z);
	col.w = 1.0;

	gl_FragColor.x = col.x * colMask.x + colMain.x * (1.0 - colMask.x);
	gl_FragColor.y = col.y * colMask.y + colMain.y * (1.0 - colMask.y);
	gl_FragColor.z = col.z * colMask.z + colMain.z * (1.0 - colMask.z);
	gl_FragColor.w = 1.0;

	}`}function x_(){return`
uniform sampler2D _MainTex;
uniform sampler2D _MaskTexture;
uniform sampler2D _OverlayTexture;

varying vec2 vUv;


void main() {

	vec4 colMain = texture2D(_MainTex, vUv);
	vec4 colMask = texture2D(_MaskTexture, vUv);
	vec4 colOver = texture2D(_OverlayTexture, vUv);

	vec4 col;
	col.x = colMain.x * colOver.x;
	col.y = colMain.y * colOver.y;
	col.z = colMain.z * colOver.z;
	col.w = 1.0;

	gl_FragColor.x = col.x * colMask.x + colMain.x * (1.0 - colMask.x);
	gl_FragColor.y = col.y * colMask.y + colMain.y * (1.0 - colMask.y);
	gl_FragColor.z = col.z * colMask.z + colMain.z * (1.0 - colMask.z);
	gl_FragColor.w = 1.0;
}
`}var mF={fragmentShader:["uniform sampler2D _MainTex;","uniform sampler2D _OverlayTexture;","uniform sampler2D _MaskTexture;","varying vec2 vUv;","void main() {","vec4 mainTexColor = texture2D(_MainTex, vUv);","vec4 overlayTexColor = texture2D(_OverlayTexture, vUv);","vec4 maskTexColor = texture2D(_MaskTexture, vUv);","vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);","vec4 col = ones - (ones - mainTexColor) * (ones - overlayTexColor);","gl_FragColor.x = col.x * maskTexColor.x + mainTexColor.x * (1.0 - maskTexColor.x);","gl_FragColor.y = col.y * maskTexColor.y + mainTexColor.y * (1.0 - maskTexColor.y);","gl_FragColor.z = col.z * maskTexColor.z + mainTexColor.z * (1.0 - maskTexColor.z);","gl_FragColor.w = 1.0;","}"].join(`
`)};function __(){return mF.fragmentShader}var gF={fragmentShader:["uniform sampler2D _MainTex;","varying vec2 vUv;","void main() {","vec4 mainTexColor = texture2D(_MainTex, vUv);","float grey = 0.299 * mainTexColor.r + 0.587 * mainTexColor.g + 0.1148 * mainTexColor.b;","gl_FragColor = vec4(grey, grey, grey, 1.0);","}"].join(`
`)};function b_(){return gF.fragmentShader}function w_(){return`
uniform sampler2D _MainTex;

varying vec2 vUv;

void main()
{
	vec4 mainTexColor = texture2D(_MainTex, vUv);
	vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);

	gl_FragColor = ones - (ones - mainTexColor) * (ones - mainTexColor);
}`}var vF={vertexShader:["varying vec2 vUv;","void main(){","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join(`
`)};function M_(){return vF.vertexShader}function E_(){return`
	uniform sampler2D _MainTex;
	varying vec2 vUv;
	//copy shader
	void main() {
	vec4 colMain = texture2D(_MainTex, vUv);

	gl_FragColor = colMain;

	}`}function S_(){return`uniform sampler2D _MainTex;
	uniform sampler2D _OverlayTexture;
	varying vec2 vUv;

	void main() {
		vec4 colMain = texture2D(_MainTex, vUv);
		vec4 colOverlay = texture2D(_OverlayTexture, vUv);
		
		gl_FragColor = colMain * colOverlay;
	}`}var yF={fragmentShader:["uniform sampler2D _MainTex;","uniform float _Threshold;","varying vec2 vUv;","void main() {","vec4 texColor = texture2D(_MainTex, vUv);","float luminance = 0.2126 * texColor.r + 0.7152 * texColor.g + 0.0722 * texColor.b;","float A1 = -1.0 / (-_Threshold); //0.2126 * mainTexColor.r + 0.7152 * mainTexColor.g + 0.0722 * mainTexColor.b;","float A0 = 0.0;","float B1 = -1.0 / (_Threshold - 1.0);","float B0 = -1.0 / (_Threshold - 1.0);","float col = luminance < _Threshold ? 0.0 : 1.0;","gl_FragColor = vec4(col, col, col, 1.0);","}"].join(`
`)};function T_(){return yF.fragmentShader}function A_(){return`
uniform sampler2D _PreviousTex;
varying vec2 vUv;

// 11 steps in transparency occur at mask edge after blur with kernel size 11x11 is applied.
// 5 of those steps occur in region outside mask, making threshold = 5/11 in the following linear transformation 
// ideal for discarding them and creating 6 steps in range from 100 % down to 0%. A slightly lower treshold (5-1)
// is chosen because steps can have lower opacity values close to obtuse angles in mask (chin).
const float threshold = 0.363636; // (5-1)/11

void main()
{
	vec4 color = texture2D(_PreviousTex, vUv);
	if (color.r > threshold){  // works in grayscale use-cases, such as mask image.
		float a = ( color.r - threshold ) / ( 1.0 - threshold );
		gl_FragColor = vec4(a, a, a, 1.0);
	} else {
		gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
	}
}`}var xF={fragmentShader:["uniform sampler2D _MainTex;","uniform sampler2D _PreviousTex;","varying vec2 vUv;","void main() {","vec4 blurCol = texture2D(_PreviousTex, vUv); //MainTex is always the output of previous filter, so here it is blur color","vec4 mainCol = texture2D(_MainTex, vUv);","vec4 unsharpenMask = vec4(mainCol.xyz - blurCol.xyz, 1.0); ","gl_FragColor = unsharpenMask;","}"].join(`
`)};function C_(){return xF.fragmentShader}var _F={fragmentShader:["uniform sampler2D _MainTex;","uniform sampler2D _PreviousTex;","uniform float _Amount;","varying vec2 vUv;","void main() {","vec4 blurCol = texture2D(_PreviousTex, vUv); //PreviousTex is the output of previous pass of this material, in case of GaussianSharpen it is blurred image","vec4 mainCol = texture2D(_MainTex, vUv);","vec4 unsharpenMask = vec4(mainCol.xyz - blurCol.xyz, 1.0); ","vec4 invCol = vec4(1.0, 1.0, 1.0, 1.0) - blurCol;","invCol = mainCol + invCol;","invCol = vec4(1.0, 1.0, 1.0, 1.0) - invCol;","gl_FragColor = mainCol + (unsharpenMask - invCol) * _Amount;","}"].join(`
`)};function R_(){return _F.fragmentShader}function P_(){return`
	uniform sampler2D _PreviousTex;
	uniform float BlurX;
	uniform float BlurY;
	uniform float BlurZ;
	varying vec2 vUv;
	varying vec4 blurTexcoord_1;
	varying vec4 blurTexcoord_2;

	void main() {
		vec4 prev = texture2D(_PreviousTex, vUv);
		vec3 sum = prev.xyz * 0.22702702;
		sum += texture2D(_PreviousTex, blurTexcoord_1.xy).xyz * 0.31621621;
		sum += texture2D(_PreviousTex, blurTexcoord_1.zw).xyz * 0.31621621;
		sum += texture2D(_PreviousTex, blurTexcoord_2.xy).xyz * 0.07027027;
		sum += texture2D(_PreviousTex, blurTexcoord_2.zw).xyz * 0.07027027;

		sum = sum * vec3(BlurX, BlurY, BlurZ) + prev.xyz * (vec3(1.0) - vec3(BlurX, BlurY, BlurZ));

		gl_FragColor = vec4(sum, 1.0);

	}`}function L_(){return`
	uniform sampler2D _PreviousTex;
	varying vec2 vUv;
	
	uniform float _Radius;
	uniform float Direction;
	uniform vec2 _PreviousTexSize;

	vec3 get_pair_sum(vec2 texels_offset){
		return texture2D(_PreviousTex, vUv + texels_offset).xyz + texture2D(_PreviousTex, vUv - texels_offset).xyz;
	}
	// distances obtained by integrating 11 equal ajdacent areas under gaussian ( http://gitlab.visagetechnologies.com/solutions/makeupsdk_html5/-/merge_requests/144 )
	const float first_texels_factor = 1.0;
	const float second_texels_factor = 3.04529141;
	const float third_texels_factor = 5.24232216;
	const float forth_texels_factor = 7.76250576;
	const float fifth_texels_factor = 10.99408763;

	void main() {
		
		vec2 TexelSize = vec2(1.0, 1.0) / _PreviousTexSize; //instead of passing texture size we can just get it
		vec2 offset = vec2(Direction * TexelSize.x * _Radius, (1.0 - Direction) * TexelSize.y * _Radius);

		vec3 average_color = (texture2D(_PreviousTex, vUv).xyz 
							+ get_pair_sum(offset * first_texels_factor)
							+ get_pair_sum(offset * second_texels_factor)
							+ get_pair_sum(offset * third_texels_factor)
							+ get_pair_sum(offset * forth_texels_factor)
							+ get_pair_sum(offset * fifth_texels_factor)) / 11.0;

		gl_FragColor = vec4(average_color, 1.0);
	}`}var bF={fragmentShader:["uniform sampler2D _PreviousTex;","varying vec2 vUv;","varying vec4 blurTexcoord_1;","varying vec4 blurTexcoord_2;","vec4 gbChannelOverlayStep(vec4 inputColor)","{","vec4 base = vec4(inputColor.g, inputColor.g, inputColor.g, 1.0);","vec4 overlay = vec4(inputColor.b, inputColor.b, inputColor.b, 1.0);","float overlayResult = 2.0 * overlay.b * base.b + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);","return vec4(overlayResult, overlayResult, overlayResult, inputColor.a);","}","void main() {","vec3 sum = texture2D(_PreviousTex, vUv).xyz * 0.22702702;","sum += gbChannelOverlayStep(texture2D(_PreviousTex, blurTexcoord_1.xy)).xyz * 0.31621621;","sum += gbChannelOverlayStep(texture2D(_PreviousTex, blurTexcoord_1.zw)).xyz * 0.31621621;","sum += gbChannelOverlayStep(texture2D(_PreviousTex, blurTexcoord_2.xy)).xyz * 0.07027027;","sum += gbChannelOverlayStep(texture2D(_PreviousTex, blurTexcoord_2.zw)).xyz * 0.07027027;","gl_FragColor = vec4(sum, 1.0);","}"].join(`
`)};function F_(){return bF.fragmentShader}var wF={vertexShader:["varying vec2 vUv;","varying vec4 blurTexcoord_1;","varying vec4 blurTexcoord_2;","uniform float _Radius;","uniform float Direction;","uniform sampler2D _PreviousTex;","uniform vec2 _PreviousTexSize;","void main(){","vUv = uv;","vec2 texSize = _PreviousTexSize;","vec2 TexelSize = vec2(1.0, 1.0) / texSize; //instead of passing texture size we can just get it","vec2 offset1 = vec2(Direction * TexelSize.x * _Radius * 1.38461538, (1.0 - Direction) * TexelSize.y * _Radius * 1.38461538);","vec2 offset2 = vec2(Direction * TexelSize.x * _Radius * 3.23076923, (1.0 - Direction) * TexelSize.y * _Radius * 3.23076923);","blurTexcoord_1.xy = vUv + offset1;","blurTexcoord_1.zw = vUv - offset1;","blurTexcoord_2.xy = vUv + offset2;","blurTexcoord_2.zw = vUv - offset2;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join(`
`)};function I_(){return wF.vertexShader}var MF={fragmentShader:["uniform sampler2D _MainTex;","varying vec2 vUv;","#define MAX_HUE 360.0","#define MAX_SAT 100.0","#define MAX_LIGHT 1.0","vec3 rgb_to_hsl(vec3 rgbValue)","{","vec3 maxHSL = vec3(MAX_HUE, MAX_SAT, MAX_LIGHT);","float hue, sat, light;","float maxComponent = max(rgbValue.x, max(rgbValue.y, rgbValue.z));","float minComponent = min(rgbValue.x, min(rgbValue.y, rgbValue.z));","float delta = maxComponent - minComponent;","float sum = maxComponent + minComponent;","if(delta == 0.0)","{","return vec3(0.0, 0.0, maxComponent * MAX_LIGHT);","}","light = sum / 2.0;","if(light < 0.5)","{","sat = delta / sum;","}","else","{","sat = delta / (2.0 - maxComponent - minComponent);","}","if(rgbValue.x == maxComponent)","{","hue = (rgbValue.y - rgbValue.z) / delta;","}","else if (rgbValue.y == maxComponent)","{","hue = 2.0 + (rgbValue.z - rgbValue.x) / delta;","}","else","{","hue = 4.0 + (rgbValue.x - rgbValue.y) / delta;","}","hue /= 6.0;","if(hue < 0.0)","{","hue++;","}","return vec3(hue, sat, light) * maxHSL;","}","vec3 hsl_to_rgb(vec3 hslValue)","{","vec3 maxHSL = vec3(MAX_HUE, MAX_SAT, MAX_LIGHT);","float r, g, b;","float temp1, temp2, tempr, tempg, tempb;","hslValue /= maxHSL;","if(hslValue.y == 0.0)","{","return vec3(hslValue.z, hslValue.z, hslValue.z);","}","if(hslValue.z < 0.5)","{","temp2 = hslValue.z * (1.0 + hslValue.y);","}","else","{","temp2 = (hslValue.z + hslValue.y) - (hslValue.z * hslValue.y);","}","temp1 = 2.0 * hslValue.z - temp2;","tempr = hslValue.x + 1.0 / 3.0;","if(tempr > 1.0)","{","tempr--;","}","tempg = hslValue.x;","tempb = hslValue.x - 1.0 / 3.0;","if(tempb < 0.0)","{","tempb++;","}","if(tempr < 1.0 / 6.0)","{","r = temp1 + (temp2 - temp1) * 6.0 * tempr;","}","else if (tempr < 0.5)","{","r = temp2;","}","else if (tempr < 2.0 / 3.0)","{","r = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempr) * 6.0;","}","else","{","r = temp1;","}","if(tempg < 1.0 / 6.0)","{","g = temp1 + (temp2 - temp1) * 6.0 * tempg;","}","else if (tempg < 0.5)","{","g = temp2;","}","else if (tempg < 2.0 / 3.0)","{","g = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempg) * 6.0;","}","else","{","g = temp1;","}","if(tempb < 1.0 / 6.0)","{","b = temp1 + (temp2 - temp1) * 6.0 * tempb;","}","else if (tempb < 0.5)","{","b = temp2;","}","else if (tempb < 2.0 / 3.0)","{","b = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempb) * 6.0;","}","else","{","b = temp1;","}","return vec3(r, g, b);","}","float curveFunction(float x)","{","float intervalBorder = 0.470588;","if(x <= intervalBorder)","{","return (-1.3379675863711415 * pow(x, 3.0) + 0.9444472358028341 * pow(x, 2.0) + 1.018518721399622 * x);","}","else","{","return (1.1893033979872438 * pow(x, 3.0) - 2.6234629581588975 * pow(x, 2.0) + 2.697534443755685 * x - 0.2633748835840317);","}","}","void main() {","vec4 ioColor = texture2D(_MainTex, vUv);","vec3 hslColor = rgb_to_hsl(ioColor.rgb);","hslColor.b = curveFunction(hslColor.b);","ioColor = vec4(hsl_to_rgb(hslColor), ioColor.a);","gl_FragColor = ioColor;","}"].join(`
`)};function D_(){return MF.fragmentShader}var EF={fragmentShader:["#define MAX_HARD_LIGHT 5","uniform sampler2D _MainTex;","uniform sampler2D _GaussianTex;","uniform sampler2D _CurveEffect;","uniform float _Normalize;","uniform int _HardLightCount;","varying vec2 vUv;","vec4 gbChannelOverlayStep(vec4 inputColor)","{","vec4 base = vec4(inputColor.g, inputColor.g, inputColor.g, 1.0);","vec4 overlay = vec4(inputColor.b, inputColor.b, inputColor.b, 1.0);","float overlayResult = 2.0 * overlay.b * base.b + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);","return vec4(overlayResult, overlayResult, overlayResult, inputColor.a);","}","void main() {","vec4 originalTexColor = texture2D(_MainTex, vUv);","vec4 ioColor;","vec4 greyscaleTexColor = gbChannelOverlayStep(originalTexColor);","vec4 lowFilterTexColor = texture2D(_GaussianTex, vUv);","vec3 highFilterColor = vec3(greyscaleTexColor.rgb - lowFilterTexColor.rgb + vec3(0.5, 0.5, 0.5) * _Normalize);","ioColor = vec4(highFilterColor, greyscaleTexColor.a);","float hardLightColor = ioColor.b;","for(int j = 0; j < MAX_HARD_LIGHT; j++)","{","//old hardware workaround for dynamic loop boundaries","if(j >= _HardLightCount) { break; }","if(hardLightColor < 0.5)","{","hardLightColor = hardLightColor * hardLightColor * 2.0;","}","else","{","hardLightColor = 1.0 - (1.0 - hardLightColor) * (1.0 - hardLightColor) * 2.0;","}","}","float k = 255.0 / (164.0 - 75.0);","hardLightColor = (hardLightColor - 75.0 / 255.0) * k;","ioColor = vec4(hardLightColor, hardLightColor, hardLightColor, ioColor.a);","vec4 effectTexColor = texture2D(_CurveEffect, vUv);","vec3 lerpResult = mix(originalTexColor.rgb, effectTexColor.rgb, clamp(1.0 - ioColor.b, 0.0, 1.0));","ioColor = vec4(lerpResult.r, lerpResult.g, lerpResult.b, 1.0);","gl_FragColor = ioColor;","}"].join(`
`)};function B_(){return EF.fragmentShader}function O_(){return`
varying vec2 vUv;

uniform sampler2D _MainTex;
uniform sampler2D _OverlayTexture;
uniform sampler2D _MaskTexture;
uniform float AverageLuminance;
uniform vec3 TargetColor;

vec3 yuv2rgb(vec3 yuv)
{
	yuv.y = yuv.y - 0.5;
	yuv.z = yuv.z - 0.5;

	vec3 rgb = vec3(0.0);
	rgb.r = yuv.x * 1.0 + yuv.y * 0.0 + yuv.z * 1.4;
	rgb.g = yuv.x * 1.0 + yuv.y * -0.343 + yuv.z * -0.711;
	rgb.b = yuv.x * 1.0 + yuv.y * 1.765 + yuv.z * 0.0;
	return rgb;
}

const mat4 rgb2yuvMat = mat4(
	0.257, -0.148,  0.439, 1.0,
	0.504, -0.291, -0.368, 1.0,
	0.098,  0.439, -0.071, 1.0,
	0.0625, 0.5,    0.5, 1.0
);

vec3 rgb2yuv(vec3 rgb)
{
	vec3 yuv = vec3(0.0);
	yuv.x = rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114;
	yuv.y = rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5;
	yuv.z = rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5;
	return yuv;
}


void main()
{
	vec4 cameraFeed = texture2D(_MainTex, vUv);
	vec4 vMaskColor = texture2D(_MaskTexture, vUv);
	vec4 effect = texture2D(_OverlayTexture, vUv);

	vec3 cameraBrightness = rgb2yuv(cameraFeed.xyz);

	float perceptualVideoBrightness = sqrt(0.241 * cameraFeed.x * cameraFeed.x + 0.691 * cameraFeed.y * cameraFeed.y + 0.068 * cameraFeed.z * cameraFeed.z);
	float perceptualColorBrightness = 0.299 * effect.x + 0.587 * effect.y + 0.1148 * effect.z;
	//sqrt(0.241 * effect.x * effect.x + 0.691 * effect.y * effect.y + 0.068 * effect.z * effect.z);

	vec3 effectBrightness = rgb2yuv(effect.xyz);
	//effectBrightness.x = effectBrightness.x * AverageLuminance / 0.3;
	//float direction = cameraBrightness.x - AverageLuminance;

	//effectBrightness.x = effectBrightness.x + direction;

	float direction = cameraBrightness.x / AverageLuminance;

	effectBrightness.x = effectBrightness.x * direction;

	vec3 rgbColor = yuv2rgb(effectBrightness.xyz);

	gl_FragColor = vec4(rgbColor, 1.0) * vMaskColor.r + (1.0 - vMaskColor.r) * cameraFeed;
}`}function U_(){return`
varying vec2 vUv;

uniform sampler2D _MainTex;
uniform sampler2D _OverlayTexture;
uniform sampler2D _MaskTexture;
uniform float AverageLuminance;
uniform vec3 TargetColor;

vec3 yuv2rgb(vec3 yuv)
{
	yuv.y = yuv.y - 0.5;
	yuv.z = yuv.z - 0.5;

	vec3 rgb = vec3(0.0);
	rgb.r = yuv.x * 1.0 + yuv.y * 0.0 + yuv.z * 1.4;
	rgb.g = yuv.x * 1.0 + yuv.y * -0.343 + yuv.z * -0.711;
	rgb.b = yuv.x * 1.0 + yuv.y * 1.765 + yuv.z * 0.0;
	return rgb;
}

const mat4 rgb2yuvMat = mat4(
	0.257, -0.148,  0.439, 1.0,
	0.504, -0.291, -0.368, 1.0,
	0.098,  0.439, -0.071, 1.0,
	0.0625, 0.5,    0.5, 1.0
);

vec3 rgb2yuv(vec3 rgb)
{
	vec3 yuv = vec3(0.0);
	yuv.x = rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114;
	yuv.y = rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5;
	yuv.z = rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5;
	return yuv;
}

float Overlay(float x, float y)
{
	if(x < 0.5) {
		return 2.0 * x * y;
	}
	return 1.0 - 2.0 * (1.0 - x) * (1.0 - y);
}

void main()
{
	vec4 colMain = texture2D(_MainTex, vUv);
	vec4 colMask = texture2D(_MaskTexture, vUv);
	vec4 colOver = texture2D(_OverlayTexture, vUv);

	vec3 cameraBrightness = rgb2yuv(colMain.xyz);
	float direction = cameraBrightness.x / AverageLuminance;

	vec3 colMainNormalized = yuv2rgb(cameraBrightness.xyz);

	vec3 overlayBrightness = rgb2yuv(colOver.xyz);
	overlayBrightness.x = overlayBrightness.x * direction;
	vec3 overlayNormalized = yuv2rgb(overlayBrightness);

	vec3 col;
	col.x = Overlay(colMain.x, overlayNormalized.x);
	col.y = Overlay(colMain.y, overlayNormalized.y);
	col.z = Overlay(colMain.z, overlayNormalized.z);

	//vec3 yuv = rgb2yuv(col);
	//yuv.x = yuv.x * direction;
	//col = yuv2rgb(yuv);

	gl_FragColor = vec4(col, 1.0) * colMask.r + (1.0 - colMask.r) * colMain;
}`}function N_(){return`
varying vec2 vUv;

uniform sampler2D _MainTex;
uniform sampler2D _OverlayTexture;
uniform sampler2D _MaskTexture;
uniform sampler2D _PreviousTex;
uniform vec4 _BoundingBox;
uniform float AverageLuminance;


const lowp float flt_epsilon = 0.001;
vec3 RGBtoHCV(vec3 rgb)
{
    vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 0.66666667) : vec4(rgb.gb, 0.0, -0.33333333);
    vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
    float c = q.x - min(q.w, q.y);
    float h = abs((q.w - q.y) / (6.0 * c + flt_epsilon) + q.z);
    return vec3(h, c, q.x);
}

vec3 RGBtoHSL(vec3 rgb)
{
    vec3 hcv = RGBtoHCV(rgb);
    float l = hcv.z - hcv.y * 0.5;
    float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + flt_epsilon);
    return vec3(hcv.x, s, l);
}

vec3 HSLtoRGB(vec3 hsl)
{
    vec3 rgb;
    float x = hsl.x * 6.0;
    rgb.r = abs(x - 3.0) - 1.0;
    rgb.g = 2.0 - abs(x - 2.0);
    rgb.b = 2.0 - abs(x - 4.0);
    rgb = clamp(rgb, 0.0, 1.0);
    float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    rgb = clamp((rgb - vec3(0.5)) * vec3(c) + vec3(hsl.z), 0.0, 1.0);
    return rgb;
}

float HardLight(float color, float layer)
{
	return color < 0.5
		? 2.0 * layer * color
		: 1.0 - 2.0 * (1.0 - layer) * (1.0 - color);
}

float step0(float x) {
	return x < 0.0 ? 0.0 : 1.0;
}

float blend_weight_curve(float gray){
	float x = gray * 255.0;
	float lowerPart =(1.0 - step0(x-136.0)) * (1.29411 * x);
	float upperPart =step0(x-136.0) * (0.6638655462184874 * x + 85.71428571428572);
	return clamp((lowerPart + upperPart) / 255.0, 0.0, 1.0);
}

float level_weight_curve(float gray){
	float x = gray * 255.0;

	if(x < 160.0)
		return 158.0 / 255.0;
	if(x < 200.0)
		return (-2.75 * x + 600.0)  / 255.0;

	return clamp((-1.6842105263157894 * x + 429.4736842105263) / 255.0, 0.0, 1.0);
}

void main()
{
	vec3 cameraFeed = texture2D(_MainTex, vUv).xyz;

	if (vUv.x > _BoundingBox.x && vUv.x < _BoundingBox.z && vUv.y > _BoundingBox.y && vUv.y < _BoundingBox.w)
	{
		vec3 vMaskColor = texture2D(_MaskTexture, vUv).xyz;
		vec3 effect = texture2D(_OverlayTexture, vUv).xyz;

		float alpha = vMaskColor.r;
		float gray = 0.299 * cameraFeed.x + 0.587 * cameraFeed.y + 0.1148 * cameraFeed.z;

		float blend_weight = blend_weight_curve(gray);
		float level_weight = level_weight_curve(gray) * alpha;

		vec3 dst_color = mix(effect * cameraFeed, effect, blend_weight);
		dst_color = mix(cameraFeed, dst_color, level_weight);

		gl_FragColor = vec4(dst_color, 1.0);
	}
	else
	{
		gl_FragColor = vec4(cameraFeed.xyz, 1.0);
	}
}`}function G_(){return`
		uniform sampler2D _MainTex;
		uniform sampler2D _OverlayTexture;
		uniform sampler2D _MaskTexture;
		
		varying vec2 vUv;

		float HardLight(float color, float layer)
		{
			if (color < 0.5)
			{
				color = 2.0 * layer * color;
			}
			else
			{
				color = 1.0 - 2.0 * (1.0 - layer) * (1.0 - color);
			}
			return color;
		}
		//ContrastHardLight
		void main() {
			
			vec4 glos_con_gray = texture2D(_MainTex, vUv);
			float gloss = glos_con_gray.x;
			float contrast_mask = glos_con_gray.y;
			float gray = glos_con_gray.z;
			
			vec4 source = texture2D(_OverlayTexture, vUv);
			float gloss_contrast_scale = 0.3;
			float gloss_contrast_shift = 0.45;
			float force_bright_threshold = 0.55;
			
			float no_contrast_default = 0.6;
			float contrast = min((gray * gloss_contrast_scale + gloss_contrast_shift) * contrast_mask + no_contrast_default * (1.0 - contrast_mask), 1.0);
			contrast = max(contrast, 0.0);

			float alpha = texture2D(_MaskTexture, vUv).x;
			float diff = max(gray - force_bright_threshold, 0.0)  * alpha;
			vec3 dst_color = vec3(1.0) - (vec3(1.0) - vec3(source)) * vec3(1.0 - diff);

			dst_color.r = HardLight(dst_color.r, contrast);
			dst_color.g = HardLight(dst_color.g, contrast);
			dst_color.b = HardLight(dst_color.b, contrast);
			
			dst_color = mix(vec3(source), vec3(1.0) - (vec3(1.0) - dst_color) * vec3(1.0 - gloss), alpha);

			gl_FragColor = vec4(dst_color, 1.0);
		}
	`}function k_(){return`
		uniform sampler2D _MainTex;
		uniform sampler2D _OverlayTexture;
		uniform sampler2D _MaskTexture;
		
		varying vec2 vUv;
		const lowp float flt_epsilon = 0.001;
		vec3 RGBtoHCV(vec3 rgb)
		{
			vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 0.66666667) : vec4(rgb.gb, 0.0, -0.33333333);
			vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
			float c = q.x - min(q.w, q.y);
			float h = abs((q.w - q.y) / (6.0 * c + flt_epsilon) + q.z);
			return vec3(h, c, q.x);
		}

		vec3 RGBtoHSL(vec3 rgb)
		{
			vec3 hcv = RGBtoHCV(rgb);
			float l = hcv.z - hcv.y * 0.5;
			float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + flt_epsilon);
			return vec3(hcv.x, s, l);
		}

		vec3 HSLtoRGB(vec3 hsl)
		{
			vec3 rgb;
			float x = hsl.x * 6.0;
			rgb.r = abs(x - 3.0) - 1.0;
			rgb.g = 2.0 - abs(x - 2.0);
			rgb.b = 2.0 - abs(x - 4.0);
			rgb = clamp(rgb, 0.0, 1.0);
			float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
			rgb = clamp((rgb - vec3(0.5)) * vec3(c) + vec3(hsl.z), 0.0, 1.0);
			return rgb;
		}

		//Shimmer
		void main() {
			float alpha = texture2D(_MaskTexture, vUv).x;
			vec4 source = texture2D(_OverlayTexture, vUv);
			vec4 shim_null_gray = texture2D(_MainTex, vUv);
			float shimmer = shim_null_gray.x * shim_null_gray.x;
			float gray = shim_null_gray.z;
			
			vec4 ShimmerColor = vec4(1.0,1.0,1.0,1.0);
			float ShimmerBrightness = 0.25;
			float ShimmerColorIntensity = 0.2;
			float shimerBrightnessNormalized = 100.0 * ShimmerBrightness;
			float colorIntensityNormalized = 100.0 * ShimmerColorIntensity;
			
			float lumWeight = gray * shimerBrightnessNormalized;
			float range = 0.25;
			float shimmerWeight = 1.0;
			
			vec4 dst_color = source;
			if(gray < 0.95){
				vec3 hsl = RGBtoHSL(source.xyz);
				hsl.z = min(hsl.z + shimmer * shimmerWeight * lumWeight * alpha, 1.0);
				dst_color = vec4(HSLtoRGB(hsl), 1);
			}

			float contrastWeight = max(min(gray * 0.5 + 0.25, 0.75), 0.25);
			float colorWeight = max(min(shimmer * 2.5 * alpha * shimmerWeight * contrastWeight * colorIntensityNormalized, 0.8), 0.0);

			dst_color = mix(dst_color, ShimmerColor, colorWeight);

			gl_FragColor = vec4(dst_color.xyz, 1.0);
			
		}
	`}function H_(){return`
		uniform sampler2D _MainTex;
		uniform sampler2D _OverlayTexture;
		uniform sampler2D _MaskTexture;
		
		varying vec2 vUv;
		const lowp float flt_epsilon = 0.001;
		vec3 RGBtoHCV(vec3 rgb)
		{
			vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 0.66666667) : vec4(rgb.gb, 0.0, -0.33333333);
			vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
			float c = q.x - min(q.w, q.y);
			float h = abs((q.w - q.y) / (6.0 * c + flt_epsilon) + q.z);
			return vec3(h, c, q.x);
		}

		vec3 RGBtoHSL(vec3 rgb)
		{
			vec3 hcv = RGBtoHCV(rgb);
			float l = hcv.z - hcv.y * 0.5;
			float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + flt_epsilon);
			return vec3(hcv.x, s, l);
		}

		vec3 HSLtoRGB(vec3 hsl)
		{
			vec3 rgb;
			float x = hsl.x * 6.0;
			rgb.r = abs(x - 3.0) - 1.0;
			rgb.g = 2.0 - abs(x - 2.0);
			rgb.b = 2.0 - abs(x - 4.0);
			rgb = clamp(rgb, 0.0, 1.0);
			float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
			rgb = clamp((rgb - vec3(0.5)) * vec3(c) + vec3(hsl.z), 0.0, 1.0);
			return rgb;
		}

		//Shimmer
		void main() {
			float alpha = texture2D(_MaskTexture, vUv).x;
			vec4 source = texture2D(_OverlayTexture, vUv);
			vec4 shim_null_gray = texture2D(_MainTex, vUv);
			float shimmer = shim_null_gray.x * shim_null_gray.x;
			float gray = shim_null_gray.z;
			
			vec4 ShimmerColor = vec4(1.0,1.0,1.0,1.0);
			float ShimmerBrightness = 1.0;
			float ShimmerColorIntensity = 0.4;
			float shimerBrightnessNormalized = 100.0 * ShimmerBrightness;
			float colorIntensityNormalized = 100.0 * ShimmerColorIntensity;
			
			float lumWeight = gray * shimerBrightnessNormalized;
			float range = 0.25;
			float shimmerWeight = 1.0;
			
			vec4 dst_color = source;
			if(gray < 0.95){
				vec3 hsl = RGBtoHSL(source.xyz);
				hsl.z = min(hsl.z + shimmer * shimmerWeight * lumWeight * alpha, 1.0);
				dst_color = vec4(HSLtoRGB(hsl), 1);
			}

			float contrastWeight = max(min(gray * 0.5 + 0.25, 0.75), 0.25);
			float colorWeight = max(min(shimmer * 2.5 * alpha * shimmerWeight * contrastWeight * colorIntensityNormalized, 0.8), 0.0);

			dst_color = mix(dst_color, ShimmerColor, colorWeight);

			gl_FragColor = vec4(dst_color.xyz, 1.0);
			
		}
	`}function z_(){return`
	uniform sampler2D _MainTex;
	uniform sampler2D _OverlayTexture;
	uniform sampler2D _GlossTexture;
	uniform float AverageLuminance;
	uniform float MaxLuminance;
	varying vec2 vUv;
	//bright shader


	float threshold (float luminance, float threshold ){
		return luminance < threshold ? 0.0 : 1.0;
	}

	void main() {
	vec4 cameraFeed = texture2D(_MainTex, vUv);
	float gray = 0.299 * cameraFeed.x + 0.587 * cameraFeed.y + 0.1148 * cameraFeed.z;
    float thresh = threshold(gray, AverageLuminance + (MaxLuminance - AverageLuminance ));

	vec4 dst = vec4(0.0, 0.0, 0.0, 1.0);
	dst.x = thresh * MaxLuminance * texture2D(_GlossTexture, vUv).x; // gloss
	dst.y = texture2D(_OverlayTexture, vUv).x; // contrast
	dst.z = gray; //grayscale
	gl_FragColor = dst;
	}`}function V_(){return`
	uniform sampler2D _MainTex;
	uniform sampler2D _OverlayTexture;
	uniform sampler2D _GlossTexture;
	uniform sampler2D DataTexture;
	varying vec2 vUv;
	//MaskData

	void main() {
		vec4 cameraFeed = texture2D(_MainTex, vUv);
		float gray = 0.299 * cameraFeed.x + 0.587 * cameraFeed.y + 0.1148 * cameraFeed.z;
	

		vec4 dst = vec4(0.0, 0.0, 0.0, 1.0);
		dst.x = texture2D(DataTexture, vUv).x; // gloss
		dst.y = 0.0;
		dst.z = gray; //grayscale
		gl_FragColor = dst;
	}`}var Kl=t=>e=>()=>`
varying vec2 vUv;

uniform sampler2D _MainTex;
uniform sampler2D _OverlayTexture;
uniform sampler2D _MaskTexture;
uniform vec4 _BoundingBox;

${t}

void main()
{
	vec3 cam = texture2D(_MainTex, vUv).xyz;

	if (vUv.x > _BoundingBox.x && vUv.x < _BoundingBox.z && vUv.y > _BoundingBox.y && vUv.y < _BoundingBox.w)
	{
		float alpha = texture2D(_MaskTexture, vUv).x;
		vec3 effect = texture2D(_OverlayTexture, vUv).xyz;
		float gray = 0.299 * cam.x + 0.587 * cam.y + 0.1148 * cam.z;

        ${e}

		gl_FragColor = vec4(dst_color, 1.0);
	}
	else
	{
		gl_FragColor = vec4(1.0,1.0,1.0,1.0);
	}
}`,W_=`
// y-component of bezier curve:
//      | b(t) = 3*(1-t)^2*t*py1 + 3*(1-t)*t^2*py2 + t^3, 
//      |        t>0 \u2227 t<1, py0=0, py1=0.1 py2=0.1, py3=0
// this function aproximates:
//      | (1-b(1-t))^2
float purity_w(float x) {
    return x < 0.53333 ? 1.29411 * x : (0.6638655*x + 0.3361);
}

float level_w(float x) {
    if(x < 0.177777777) return 0.6 + 2.25 * x;
    if(x < 0.625) return 1.0;
    if(x < 0.785) return -4.45 * x + 3.790323;
    return -1.38173 * x + 1.38173; 
}
`,j_=Kl(W_)(`
vec3 dst_color = cam.xyz;
{
    // Step 1
    // blends how much of the multiply vs pure color is applied
    float purity_t = purity_w(gray);
    dst_color = mix(effect*cam, effect, purity_t);
}
{
    // Step 2
    // defines the strenght of the blend (0 strenght: the original sample is drawn)
    float level_t = level_w(gray);
    dst_color = mix(cam, dst_color, level_t * alpha);
}`),q_=Kl(W_)(`
vec3 dst_color = cam.xyz;
{
    // Step 1
    // blends how much of the multiply vs pure color is applied
    float purity_t = purity_w(gray);
    dst_color = mix(effect*cam, effect, purity_t);
}
{
    // Step 2
    // defines the strenght of the blend (0 strenght: the original sample is drawn)
    float level_t = 0.5 + level_w(gray)/2.0;
    dst_color = mix(cam, dst_color, level_t * alpha);
}`),Hg=`
// the magic number 1.79 == pow(2, 0.84);
// the magic number '0.84' is arbitrary
// exposure: f(x, compensation) = x * pow(2, compensation) 
float e_gray = clamp(gray * 1.79, 0.0, 1.0);
vec3 dst_color = e_gray*effect;
`,X_=Kl("")(`
${Hg}
dst_color=dst_color*alpha;
`),Y_=Kl("")(`
${Hg}
dst_color = mix(e_gray*effect, effect, gray*alpha);
`),$_=Kl("")(`
${Hg}
dst_color = mix(e_gray*effect, effect, e_gray*alpha);
`);var zg={AlphaBlendUseMaskAlphaBlend:v_,OverlayBlend:y_,MultiplyBlend:x_,ScreenBlend:__,GreyscaleShader:b_,ScreenShader:w_,SimpleVertexShader:M_,CopyShader:E_,MultiplyShader:S_,ThresholdShader:T_,HighPassShader:C_,UnsharpenMaskShader:R_,GaussianBlurShader:P_,GaussianGBOverlayBlurShader:F_,GaussianBlurVertexShader:I_,CurveEffectShader:D_,SmoothingPostProcessingShader:B_,ColorStabilizerAlphaBlend:O_,ColorStabilizerOverlayBlend:U_,LuminanceMixBlend:N_,ContrastHardLight:G_,BrightSpotsShader:z_,MaskDataShader:V_,ShimmerShader:k_,GlitterShader:H_,LinearTransformationShader:A_,MaskEdgeBlurShader:L_,ExposureMultiplyAndEffectExposureBlend:$_,ExposureMultiplyAndEffectGrayscaleBlend:Y_,ExposureMultiplyBlend:X_,CurvesBlend:j_,CurvesDampenBlend:q_};function Z_(t,e,n){return new Promise((r,o)=>{t.load(e,a=>{r(a)},n,a=>{o(new Error("Texture not found for path "+e+`
 Underlying error:
`+a.message))})})}function Vg(t){var n;let e=(n=zg[t])==null?void 0:n.call(zg);if(!e)throw new Error(`Case for shader ${t} not defined.`);return e}var Gf=new Wt;Gf.lookAt(new W(0,0,-1));Gf.updateWorldMatrix(!0,!0);function pc(){return Gf}function J_(t){let e=Vg(t.vertexShader),n=Vg(t.fragmentShader),r=new In({uniforms:t.uniforms,vertexShader:e,fragmentShader:n,depthWrite:!1});return{mesh:Gf,material:r}}var $r=class $r{constructor(){}static cacheMaterial(e){return xe(this,null,function*(){try{let r=yield(yield fetch(e,{credentials:"same-origin"})).json();return $r.materials[e]=r,r}catch(n){throw console.error("Loading material '"+e+"' failed"),n}})}static loadCopyOfCachedMaterial(e){return $r.materials[e]?JSON.parse(JSON.stringify($r.materials[e])):void 0}static loadMaterial(e){return xe(this,null,function*(){return $r.materials[e]===void 0&&(yield this.cacheMaterial(e)),this.loadCopyOfCachedMaterial(e)})}static loadTexture(e){return xe(this,null,function*(){var n;if($r.textures[e]===void 0)try{let r=new Yl,o=yield Z_(r,e);if(o)o.name=e,$r.textures[e]=o;else throw new Error("Texture is undefined!")}catch(r){console.error("Loading texture '"+e+"' failed")}return(n=$r.textures[e])!=null?n:null})}};te($r,"materials",{}),te($r,"textures",{});var Bn=$r;function Wg(t){return!!t.fragmentShader}function Ds(t){return!Wg(t)}var qn=class{constructor(e,n){this.name=e;this.p=n}SetParameter(e){this.p=e}GetParameter(){return this.p}Apply(e){this.p.Apply(this.name,e)}SetName(e){this.name=e}GetName(){return this.name}},Xn=class{constructor(e){this.value=e}Apply(e,n){if(Ds(n))switch(e){case"_Color":if(Array.isArray(this.value)&&this.value[2]!==void 0)n.color=new We(this.value[0],this.value[1],this.value[2]);else throw"Invalid uniform error";break;default:throw`${e} uniform not implemented exception`}else Wg(n)&&(n.uniforms[e]={value:this.value})}Get(){return this.value}},Qi=class t{constructor(e){this.texture=e}static isDataTexture(e){return e.isDataTexture}static isWebGLRenderTarget(e){return e.isWebGLRenderTarget}static isTexture(e){return e.isTexture}Apply(e,n){let r=null,o=new fe(1,1);this.texture&&(r=t.isDataTexture(this.texture)||t.isTexture(this.texture)?this.texture:this.texture.texture,o=new fe(r.image.width,r.image.height)),Ds(n)?e==="_MainTex"&&(n.map=r):(n.uniforms[e]={value:r},n.uniforms[e+"Size"]={value:o})}Set(e){this.texture=e}Get(){return this.texture}SetTarget(e){this.Set(e)}GetTarget(){return this.Get()}GetDepth(){return 0}},kf=class{constructor(e){this.value=e}get isIRenderPass(){return!0}set target(e){this.value.target=e}get target(){return this.value.target}get queue(){return this.value.queue}get inputRenderPasses(){return this.value.inputRenderPasses}get depth(){return this.value.depth}Apply(e,n){this.value.target&&(Ds(n)?e==="_MainTex"&&(n.map=this.value.target.texture):(n.uniforms[e]={value:this.value.target.texture},n.uniforms[e+"Size"]={value:new fe(this.value.target.texture.image.width,this.value.target.texture.image.height)}))}},Hf=class{constructor(e){this.camera=e}get depth(){return this.camera.depth}set depth(e){this.camera.depth=e}get isIRenderPass(){return!0}Apply(e,n){var r,o;if(Ds(n))e==="_MainTex"&&(n.map=(o=(r=this.camera.target)==null?void 0:r.texture)!=null?o:null);else{let a=this.camera.target;n.uniforms[e]={value:a==null?void 0:a.texture},n.uniforms[e+"Size"]={value:new fe(a==null?void 0:a.texture.image.width,a==null?void 0:a.texture.image.height)}}}Get(){return this.camera}set target(e){this.camera.target=e}get target(){var e;return(e=this.camera.target)!=null?e:null}};var eu=class{constructor(e){this.queue=e}GetDepth(){return this.queue.renderPasses.length>0?this.queue.renderPasses[this.queue.renderPasses.length-1].depth:0}Destroy(){}Update(){}LateUpdate(){}},zf=class extends eu{Apply(){this.queue.renderPasses.forEach(e=>{e.target=this.queue.target})}},Vf=class extends eu{constructor(){super(...arguments);te(this,"renderPassTargets",{})}Apply(){if(this.queue.target){for(let n in this.renderPassTargets)this.queue.renderPasses.some(o=>o.id===n)||(this.renderPassTargets[n].dispose(),delete this.renderPassTargets[n]);this.queue.renderPasses.forEach(n=>{if(n.id in this.renderPassTargets||(this.renderPassTargets[n.id]=new an(this.queue.target.width,this.queue.target.height)),this.renderPassTargets[n.id].width!=this.queue.target.width||this.renderPassTargets[n.id].height!=this.queue.target.height){let r=this.renderPassTargets[n.id].texture.name;this.renderPassTargets[n.id].dispose(),this.renderPassTargets[n.id]=new an(this.queue.target.width,this.queue.target.height),this.renderPassTargets[n.id].texture.name=r}n.target=this.renderPassTargets[n.id]}),this.queue.renderPasses.length>0&&(this.queue.renderPasses[this.queue.renderPasses.length-1].target=this.queue.target)}}Destroy(){super.Destroy(),Object.values(this.renderPassTargets).forEach(n=>n.dispose()),this.renderPassTargets={}}},Wf=class extends eu{constructor(n){super(n);te(this,"altTarget");this.altTarget=this.construct_target_from_queue(n)}construct_target_from_queue(n){return new an(n.target.width,n.target.height)}Apply(){this.UpdateAlternativeTarget();let n=this.queue.target;this.queue.renderPasses.forEach(r=>{r.target=n,n=n===this.queue.target?this.altTarget:this.queue.target})}UpdateAlternativeTarget(){this.queue.renderPasses.length>1&&(this.altTarget.width!==this.queue.target.width||this.altTarget.height!==this.queue.target.height)&&(this.altTarget.dispose(),this.altTarget=this.construct_target_from_queue(this.queue))}Destroy(){super.Destroy(),this.altTarget.dispose()}};function SF(t,e){switch(t){case"DEDICATED_TARGET":return new Vf(e);case"SHARED_TARGET":return new zf(e);case"SWITCH_TARGET":return new Wf(e)}}var cn=class{constructor(e,n){te(this,"policy");te(this,"renderPasses");te(this,"queueType");te(this,"currentQueueType");te(this,"_target");this.renderPasses=[],this.queueType=e,this.currentQueueType=this.queueType,this._target=new an(Jt.Width(),Jt.Height()),this._target.texture.name=n,this.policy=SF(this.currentQueueType,this),this.policy.Apply()}Destroy(){this._target.dispose(),this.policy.Destroy()}Add(e){this.renderPasses.push(e),this.policy.Apply()}Remove(e){let n=this.renderPasses.indexOf(e);n>-1&&this.renderPasses.splice(n,1),this.policy.Apply()}Clear(){this.renderPasses=[]}get target(){return this._target}set target(e){this._target=e,this.policy.Apply()}Update(){this.renderPasses.sort((e,n)=>e.depth-n.depth),this.policy.Apply()}};var ur=class{constructor(e,n,r,o){this.gpuParameter=e;this.cpuParameter=n;this.isParameterCropped=r;this.isImageCropped=o}get parameter(){return this.gpuParameter}get image(){return this.cpuParameter}get imageCropped(){return this.isImageCropped}get parameterCropped(){return this.isParameterCropped}};function TF(t,e){return t|e}function AF(t,e){return t&~e}function CF(t,e){return(t&e)===e}var jf={Union:TF,RemoveFromFirst:AF,TypeContains:CF};var hr=class{constructor(){te(this,"listeners",new Map)}AddListener(e,n){var o;let r=(o=this.listeners.get(e))!=null?o:0;this.listeners.set(e,jf.Union(r,n))}RemoveTypesFromListener(e,n){var o;let r=(o=this.listeners.get(e))!=null?o:0;r=jf.RemoveFromFirst(r,n),r===0?this.RemoveListener(e):this.listeners.set(e,r)}RemoveListener(e){this.listeners.delete(e)}HasListeners(){return this.listeners.size>0}HasListenerType(e){for(let n of this.listeners.values())if(jf.TypeContains(n,e))return!0;return!1}HasCpuListeners(){return this.HasListenerType(1)}HasGpuListeners(){return this.HasListenerType(2)}GetListeners(){return this.listeners.keys()}NotifyListeners(e,n){if(typeof n=="number")this.listeners.forEach((r,o)=>o.DepthChangedEventHandler(e,n));else if(n instanceof ur)this.listeners.forEach((r,o)=>o.FilterInputPreparedHandler(e,n));else{console.warn(`Unknown parameter: ${n}. was passed to NotifyListeners`);return}}};function K_(t){return t.isIRenderPass}var Qn=class{constructor(...e){te(this,"passes",[]);this.Visit(...e)}Visit(...e){return e.forEach(this.add_if_pass,this),this}add_if_pass(e){K_(e)&&this.passes.push(e)}get renderPasses(){return this.passes.values()}clear(){this.passes=[]}*[Symbol.iterator](){yield*Zy(this.passes)}};var eb="122";var tb=0,jg=1,nb=2;var qf=1,rb=2,Bs=3,Vo=0,kt=1,Wo=2,Xf=1;var Ki=0,Os=1,qg=2,Xg=3,Yg=4,ib=5,jo=100,ob=101,sb=102,$g=103,Zg=104,ab=200,cb=201,lb=202,ub=203,Yf=204,$f=205,hb=206,fb=207,db=208,pb=209,mb=210,gb=0,vb=1,yb=2,tu=3,xb=4,_b=5,bb=6,wb=7,qo=0,Mb=1,Eb=2,eo=0,Sb=1,Tb=2,Ab=3,Cb=4,Rb=5,Zf=300,Us=301,mc=302,Jf=303,Qf=304,Xo=306,gc=307,vc=1e3,ln=1001,yc=1002,Xt=1003,Kf=1004;var ed=1005;var Ht=1006,Jg=1007;var to=1008;var Ns=1009,Pb=1010,Lb=1011,Gs=1012,Fb=1013,xc=1014,Zr=1015,ks=1016,Ib=1017,Db=1018,Bb=1019,Yo=1020,Ob=1021,Lr=1022,mn=1023,Ub=1024,Nb=1025;var no=1026,$o=1027,Gb=1028,kb=1029,Hb=1030,zb=1031,Vb=1032,Wb=1033,Qg=33776,Kg=33777,ev=33778,tv=33779,nv=35840,rv=35841,iv=35842,ov=35843,jb=36196,sv=37492,av=37496,qb=37808,Xb=37809,Yb=37810,$b=37811,Zb=37812,Jb=37813,Qb=37814,Kb=37815,ew=37816,tw=37817,nw=37818,rw=37819,iw=37820,ow=37821,sw=36492,aw=37840,cw=37841,lw=37842,uw=37843,hw=37844,fw=37845,dw=37846,pw=37847,mw=37848,gw=37849,vw=37850,yw=37851,xw=37852,_w=37853,bw=2200,ww=2201,Mw=2202,Hs=2300,_c=2301,td=2302,Zo=2400,Jo=2401,bc=2402,wc=2500,nd=2501,Ew=0;var Fr=3e3,Mc=3001,rd=3007,id=3002,Sw=3003,od=3004,sd=3005,ad=3006,Tw=3200,Aw=3201,Ir=0,Cw=1;var cd=7680;var Rw=519,zs=35044,Ec=35048;var cv="300 es";function gn(){}Object.assign(gn.prototype,{addEventListener:function(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)},hasEventListener:function(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1},removeEventListener:function(t,e){if(this._listeners===void 0)return;let r=this._listeners[t];if(r!==void 0){let o=r.indexOf(e);o!==-1&&r.splice(o,1)}},dispatchEvent:function(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,t)}}});var En=[];for(let t=0;t<256;t++)En[t]=(t<16?"0":"")+t.toString(16);var ld=1234567,je={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(En[t&255]+En[t>>8&255]+En[t>>16&255]+En[t>>24&255]+"-"+En[e&255]+En[e>>8&255]+"-"+En[e>>16&15|64]+En[e>>24&255]+"-"+En[n&63|128]+En[n>>8&255]+"-"+En[n>>16&255]+En[n>>24&255]+En[r&255]+En[r>>8&255]+En[r>>16&255]+En[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,o){return r+(t-e)*(o-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return t!==void 0&&(ld=t%2147483647),ld=ld*16807%2147483647,(ld-1)/2147483646},degToRad:function(t){return t*je.DEG2RAD},radToDeg:function(t){return t*je.RAD2DEG},isPowerOfTwo:function(t){return(t&t-1)===0&&t!==0},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,r,o){let a=Math.cos,c=Math.sin,l=a(n/2),u=c(n/2),h=a((e+r)/2),d=c((e+r)/2),f=a((e-r)/2),p=c((e-r)/2),m=a((r-e)/2),v=c((r-e)/2);switch(o){case"XYX":t.set(l*d,u*f,u*p,l*h);break;case"YZY":t.set(u*p,l*d,u*f,l*h);break;case"ZXZ":t.set(u*f,u*p,l*d,l*h);break;case"XZX":t.set(l*d,u*v,u*m,l*h);break;case"YXY":t.set(u*m,l*d,u*v,l*h);break;case"ZYZ":t.set(u*v,u*m,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+o)}}};var ue=class{constructor(e=0,n=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let n=this.x,r=this.y,o=e.elements;return this.x=o[0]*n+o[3]*r+o[6],this.y=o[1]*n+o[4]*r+o[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){let r=Math.cos(n),o=Math.sin(n),a=this.x-e.x,c=this.y-e.y;return this.x=a*r-c*o+e.x,this.y=a*o+c*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}};var Ft=class{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,n,r,o,a,c,l,u,h){let d=this.elements;return d[0]=e,d[1]=o,d[2]=l,d[3]=n,d[4]=a,d[5]=u,d[6]=r,d[7]=c,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(e){let n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let r=e.elements,o=n.elements,a=this.elements,c=r[0],l=r[3],u=r[6],h=r[1],d=r[4],f=r[7],p=r[2],m=r[5],v=r[8],x=o[0],b=o[3],y=o[6],g=o[1],M=o[4],C=o[7],E=o[2],w=o[5],F=o[8];return a[0]=c*x+l*g+u*E,a[3]=c*b+l*M+u*w,a[6]=c*y+l*C+u*F,a[1]=h*x+d*g+f*E,a[4]=h*b+d*M+f*w,a[7]=h*y+d*C+f*F,a[2]=p*x+m*g+v*E,a[5]=p*b+m*M+v*w,a[8]=p*y+m*C+v*F,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){let e=this.elements,n=e[0],r=e[1],o=e[2],a=e[3],c=e[4],l=e[5],u=e[6],h=e[7],d=e[8];return n*c*d-n*l*h-r*a*d+r*l*u+o*a*h-o*c*u}getInverse(e,n){n!==void 0&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");let r=e.elements,o=this.elements,a=r[0],c=r[1],l=r[2],u=r[3],h=r[4],d=r[5],f=r[6],p=r[7],m=r[8],v=m*h-d*p,x=d*f-m*u,b=p*u-h*f,y=a*v+c*x+l*b;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/y;return o[0]=v*g,o[1]=(l*p-m*c)*g,o[2]=(d*c-l*h)*g,o[3]=x*g,o[4]=(m*a-l*f)*g,o[5]=(l*u-d*a)*g,o[6]=b*g,o[7]=(c*f-p*a)*g,o[8]=(h*a-c*u)*g,this}transpose(){let e,n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).getInverse(this).transpose()}transposeIntoArray(e){let n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,o,a,c,l){let u=Math.cos(a),h=Math.sin(a);this.set(r*u,r*h,-r*(u*c+h*l)+c+e,-o*h,o*u,-o*(-h*c+u*l)+l+n,0,0,1)}scale(e,n){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=n,r[4]*=n,r[7]*=n,this}rotate(e){let n=Math.cos(e),r=Math.sin(e),o=this.elements,a=o[0],c=o[3],l=o[6],u=o[1],h=o[4],d=o[7];return o[0]=n*a+r*u,o[3]=n*c+r*h,o[6]=n*l+r*d,o[1]=-r*a+n*u,o[4]=-r*c+n*h,o[7]=-r*l+n*d,this}translate(e,n){let r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=n*r[2],r[4]+=n*r[5],r[7]+=n*r[8],this}equals(e){let n=this.elements,r=e.elements;for(let o=0;o<9;o++)if(n[o]!==r[o])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){let r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}};var Sc,Si={getDataURL:function(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Sc===void 0&&(Sc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Sc.width=t.width,Sc.height=t.height;let n=Sc.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Sc}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}};var RF=0;function yt(t,e,n,r,o,a,c,l,u,h){Object.defineProperty(this,"id",{value:RF++}),this.uuid=je.generateUUID(),this.name="",this.image=t!==void 0?t:yt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=e!==void 0?e:yt.DEFAULT_MAPPING,this.wrapS=n!==void 0?n:ln,this.wrapT=r!==void 0?r:ln,this.magFilter=o!==void 0?o:Ht,this.minFilter=a!==void 0?a:to,this.anisotropy=u!==void 0?u:1,this.format=c!==void 0?c:mn,this.internalFormat=null,this.type=l!==void 0?l:Ns,this.offset=new ue(0,0),this.repeat=new ue(1,1),this.center=new ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ft,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h!==void 0?h:Fr,this.version=0,this.onUpdate=null}yt.DEFAULT_IMAGE=void 0;yt.DEFAULT_MAPPING=Zf;yt.prototype=Object.assign(Object.create(gn.prototype),{constructor:yt,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let r=this.image;if(r.uuid===void 0&&(r.uuid=je.generateUUID()),!e&&t.images[r.uuid]===void 0){let o;if(Array.isArray(r)){o=[];for(let a=0,c=r.length;a<c;a++)o.push(Si.getDataURL(r[a]))}else o=Si.getDataURL(r);t.images[r.uuid]={uuid:r.uuid,url:o}}n.image=r.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping!==Zf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case vc:t.x=t.x-Math.floor(t.x);break;case ln:t.x=t.x<0?0:1;break;case yc:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case vc:t.y=t.y-Math.floor(t.y);break;case ln:t.y=t.y<0?0:1;break;case yc:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}});Object.defineProperty(yt.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});var mt=class{constructor(e=0,n=0,r=0,o=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=e,this.y=n,this.z=r,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,n,r,o){return this.x=e,this.y=n,this.z=r,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw 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=e.w!==void 0?e.w:1,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let n=this.x,r=this.y,o=this.z,a=this.w,c=e.elements;return this.x=c[0]*n+c[4]*r+c[8]*o+c[12]*a,this.y=c[1]*n+c[5]*r+c[9]*o+c[13]*a,this.z=c[2]*n+c[6]*r+c[10]*o+c[14]*a,this.w=c[3]*n+c[7]*r+c[11]*o+c[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,o,a,u=e.elements,h=u[0],d=u[4],f=u[8],p=u[1],m=u[5],v=u[9],x=u[2],b=u[6],y=u[10];if(Math.abs(d-p)<.01&&Math.abs(f-x)<.01&&Math.abs(v-b)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+x)<.1&&Math.abs(v+b)<.1&&Math.abs(h+m+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;let M=(h+1)/2,C=(m+1)/2,E=(y+1)/2,w=(d+p)/4,F=(f+x)/4,H=(v+b)/4;return M>C&&M>E?M<.01?(r=0,o=.707106781,a=.707106781):(r=Math.sqrt(M),o=w/r,a=F/r):C>E?C<.01?(r=.707106781,o=0,a=.707106781):(o=Math.sqrt(C),r=w/o,a=H/o):E<.01?(r=.707106781,o=.707106781,a=0):(a=Math.sqrt(E),r=F/a,o=H/a),this.set(r,o,a,n),this}let g=Math.sqrt((b-v)*(b-v)+(f-x)*(f-x)+(p-d)*(p-d));return Math.abs(g)<.001&&(g=1),this.x=(b-v)/g,this.y=(f-x)/g,this.z=(p-d)/g,this.w=Math.acos((h+m+y-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}};function Sn(t,e,n){this.width=t,this.height=e,this.scissor=new mt(0,0,t,e),this.scissorTest=!1,this.viewport=new mt(0,0,t,e),n=n||{},this.texture=new yt(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Ht,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null}Sn.prototype=Object.assign(Object.create(gn.prototype),{constructor:Sn,isWebGLRenderTarget:!0,setSize:function(t,e){(this.width!==t||this.height!==e)&&(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});function lv(t,e,n){Sn.call(this,t,e,n),this.samples=4}lv.prototype=Object.assign(Object.create(Sn.prototype),{constructor:lv,isWebGLMultisampleRenderTarget:!0,copy:function(t){return Sn.prototype.copy.call(this,t),this.samples=t.samples,this}});var zt=class{constructor(e=0,n=0,r=0,o=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=e,this._y=n,this._z=r,this._w=o}static slerp(e,n,r,o){return r.copy(e).slerp(n,o)}static slerpFlat(e,n,r,o,a,c,l){let u=r[o+0],h=r[o+1],d=r[o+2],f=r[o+3],p=a[c+0],m=a[c+1],v=a[c+2],x=a[c+3];if(f!==x||u!==p||h!==m||d!==v){let b=1-l,y=u*p+h*m+d*v+f*x,g=y>=0?1:-1,M=1-y*y;if(M>Number.EPSILON){let E=Math.sqrt(M),w=Math.atan2(E,y*g);b=Math.sin(b*w)/E,l=Math.sin(l*w)/E}let C=l*g;if(u=u*b+p*C,h=h*b+m*C,d=d*b+v*C,f=f*b+x*C,b===1-l){let E=1/Math.sqrt(u*u+h*h+d*d+f*f);u*=E,h*=E,d*=E,f*=E}}e[n]=u,e[n+1]=h,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,o,a,c){let l=r[o],u=r[o+1],h=r[o+2],d=r[o+3],f=a[c],p=a[c+1],m=a[c+2],v=a[c+3];return e[n]=l*v+d*f+u*m-h*p,e[n+1]=u*v+d*p+h*f-l*m,e[n+2]=h*v+d*m+l*p-u*f,e[n+3]=d*v-l*f-u*p-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,o){return this._x=e,this._y=n,this._z=r,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,n){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let r=e._x,o=e._y,a=e._z,c=e._order,l=Math.cos,u=Math.sin,h=l(r/2),d=l(o/2),f=l(a/2),p=u(r/2),m=u(o/2),v=u(a/2);switch(c){case"XYZ":this._x=p*d*f+h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f-p*m*v;break;case"YXZ":this._x=p*d*f+h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f+p*m*v;break;case"ZXY":this._x=p*d*f-h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f-p*m*v;break;case"ZYX":this._x=p*d*f-h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f+p*m*v;break;case"YZX":this._x=p*d*f+h*m*v,this._y=h*m*f+p*d*v,this._z=h*d*v-p*m*f,this._w=h*d*f-p*m*v;break;case"XZY":this._x=p*d*f-h*m*v,this._y=h*m*f-p*d*v,this._z=h*d*v+p*m*f,this._w=h*d*f+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){let r=n/2,o=Math.sin(r);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){let n=e.elements,r=n[0],o=n[4],a=n[8],c=n[1],l=n[5],u=n[9],h=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){let m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-u)*m,this._y=(a-h)*m,this._z=(c-o)*m}else if(r>l&&r>f){let m=2*Math.sqrt(1+r-l-f);this._w=(d-u)/m,this._x=.25*m,this._y=(o+c)/m,this._z=(a+h)/m}else if(l>f){let m=2*Math.sqrt(1+l-r-f);this._w=(a-h)/m,this._x=(o+c)/m,this._y=.25*m,this._z=(u+d)/m}else{let m=2*Math.sqrt(1+f-r-l);this._w=(c-o)/m,this._x=(a+h)/m,this._y=(u+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let o=e.dot(n)+1;return o<1e-6?(o=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=o):(this._x=0,this._y=-e.z,this._z=e.y,this._w=o)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=o),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je.clamp(this.dot(e),-1,1)))}rotateTowards(e,n){let r=this.angleTo(e);if(r===0)return this;let o=Math.min(1,n/r);return this.slerp(e,o),this}identity(){return this.set(0,0,0,1)}inverse(){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 e===0?(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,n){return n!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,n)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){let r=e._x,o=e._y,a=e._z,c=e._w,l=n._x,u=n._y,h=n._z,d=n._w;return this._x=r*d+c*l+o*h-a*u,this._y=o*d+c*u+a*l-r*h,this._z=a*d+c*h+r*u-o*l,this._w=c*d-r*l-o*u-a*h,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);let r=this._x,o=this._y,a=this._z,c=this._w,l=c*e._w+r*e._x+o*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=c,this._x=r,this._y=o,this._z=a,this;let u=1-l*l;if(u<=Number.EPSILON){let m=1-n;return this._w=m*c+n*this._w,this._x=m*r+n*this._x,this._y=m*o+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}let h=Math.sqrt(u),d=Math.atan2(h,l),f=Math.sin((1-n)*d)/h,p=Math.sin(n*d)/h;return this._w=c*f+this._w*p,this._x=r*f+this._x*p,this._y=o*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};var O=class{constructor(e=0,n=0,r=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw 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,n){return n!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,n)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Pw.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Pw.setFromAxisAngle(e,n))}applyMatrix3(e){let n=this.x,r=this.y,o=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*o,this.y=a[1]*n+a[4]*r+a[7]*o,this.z=a[2]*n+a[5]*r+a[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let n=this.x,r=this.y,o=this.z,a=e.elements,c=1/(a[3]*n+a[7]*r+a[11]*o+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*o+a[12])*c,this.y=(a[1]*n+a[5]*r+a[9]*o+a[13])*c,this.z=(a[2]*n+a[6]*r+a[10]*o+a[14])*c,this}applyQuaternion(e){let n=this.x,r=this.y,o=this.z,a=e.x,c=e.y,l=e.z,u=e.w,h=u*n+c*o-l*r,d=u*r+l*n-a*o,f=u*o+a*r-c*n,p=-a*n-c*r-l*o;return this.x=h*u+p*-a+d*-l-f*-c,this.y=d*u+p*-c+f*-a-h*-l,this.z=f*u+p*-l+h*-c-d*-a,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let n=this.x,r=this.y,o=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*o,this.y=a[1]*n+a[5]*r+a[9]*o,this.z=a[2]*n+a[6]*r+a[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,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e,n){return n!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,n)):this.crossVectors(this,e)}crossVectors(e,n){let r=e.x,o=e.y,a=e.z,c=n.x,l=n.y,u=n.z;return this.x=o*u-a*l,this.y=a*c-r*u,this.z=r*l-o*c,this}projectOnVector(e){let n=e.lengthSq();if(n===0)return this.set(0,0,0);let r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return uv.copy(this).projectOnVector(e),this.sub(uv)}reflect(e){return this.sub(uv.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;let r=this.dot(e)/n;return Math.acos(je.clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let n=this.x-e.x,r=this.y-e.y,o=this.z-e.z;return n*n+r*r+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,n,r){let o=Math.sin(n)*e;return this.x=o*Math.sin(r),this.y=Math.cos(n)*e,this.z=o*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){let n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){let n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=o,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n,r){return r!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}},uv=new O,Pw=new zt;var On=class{constructor(e,n){Object.defineProperty(this,"isBox3",{value:!0}),this.min=e!==void 0?e:new O(1/0,1/0,1/0),this.max=n!==void 0?n:new O(-1/0,-1/0,-1/0)}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let u=0,h=e.length;u<h;u+=3){let d=e[u],f=e[u+1],p=e[u+2];d<n&&(n=d),f<r&&(r=f),p<o&&(o=p),d>a&&(a=d),f>c&&(c=f),p>l&&(l=p)}return this.min.set(n,r,o),this.max.set(a,c,l),this}setFromBufferAttribute(e){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let u=0,h=e.count;u<h;u++){let d=e.getX(u),f=e.getY(u),p=e.getZ(u);d<n&&(n=d),f<r&&(r=f),p<o&&(o=p),d>a&&(a=d),f>c&&(c=f),p>l&&(l=p)}return this.min.set(n,r,o),this.max.set(a,c,l),this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){let r=nu.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return e===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new O),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new O),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);let n=e.geometry;n!==void 0&&(n.boundingBox===null&&n.computeBoundingBox(),fv.copy(n.boundingBox),fv.applyMatrix4(e.matrixWorld),this.union(fv));let r=e.children;for(let o=0,a=r.length;o<a;o++)this.expandByObject(r[o]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new O),n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,nu),nu.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ru),ud.subVectors(this.max,ru),Tc.subVectors(e.a,ru),Ac.subVectors(e.b,ru),Cc.subVectors(e.c,ru),Qo.subVectors(Ac,Tc),Ko.subVectors(Cc,Ac),Vs.subVectors(Tc,Cc);let n=[0,-Qo.z,Qo.y,0,-Ko.z,Ko.y,0,-Vs.z,Vs.y,Qo.z,0,-Qo.x,Ko.z,0,-Ko.x,Vs.z,0,-Vs.x,-Qo.y,Qo.x,0,-Ko.y,Ko.x,0,-Vs.y,Vs.x,0];return!hv(n,Tc,Ac,Cc,ud)||(n=[1,0,0,0,1,0,0,0,1],!hv(n,Tc,Ac,Cc,ud))?!1:(hd.crossVectors(Qo,Ko),n=[hd.x,hd.y,hd.z],hv(n,Tc,Ac,Cc,ud))}clampPoint(e,n){return n===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new O),n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return nu.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return e===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=this.getSize(nu).length()*.5,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()?this:(ro[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ro[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ro[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ro[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ro[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ro[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ro[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ro[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ro),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)}};function hv(t,e,n,r,o){for(let a=0,c=t.length-3;a<=c;a+=3){Ws.fromArray(t,a);let l=o.x*Math.abs(Ws.x)+o.y*Math.abs(Ws.y)+o.z*Math.abs(Ws.z),u=e.dot(Ws),h=n.dot(Ws),d=r.dot(Ws);if(Math.max(-Math.max(u,h,d),Math.min(u,h,d))>l)return!1}return!0}var ro=[new O,new O,new O,new O,new O,new O,new O,new O],nu=new O,fv=new On,Tc=new O,Ac=new O,Cc=new O,Qo=new O,Ko=new O,Vs=new O,ru=new O,ud=new O,hd=new O,Ws=new O;var PF=new On,un=class{constructor(e,n){this.center=e!==void 0?e:new O,this.radius=n!==void 0?n:-1}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){let r=this.center;n!==void 0?r.copy(n):PF.setFromPoints(e).getCenter(r);let o=0;for(let a=0,c=e.length;a<c;a++)o=Math.max(o,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(o),this}clone(){return new this.constructor().copy(this)}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){let r=this.center.distanceToSquared(e);return n===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),n=new O),n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new On),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}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}};var io=new O,dv=new O,fd=new O,es=new O,pv=new O,dd=new O,mv=new O,fr=class{constructor(e,n){this.origin=e!==void 0?e:new O,this.direction=n!==void 0?n:new O(0,0,-1)}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n===void 0&&(console.warn("THREE.Ray: .at() target is now required"),n=new O),n.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,io)),this}closestPointToPoint(e,n){n===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new O),n.subVectors(e,this.origin);let r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let n=io.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(io.copy(this.direction).multiplyScalar(n).add(this.origin),io.distanceToSquared(e))}distanceSqToSegment(e,n,r,o){dv.copy(e).add(n).multiplyScalar(.5),fd.copy(n).sub(e).normalize(),es.copy(this.origin).sub(dv);let a=e.distanceTo(n)*.5,c=-this.direction.dot(fd),l=es.dot(this.direction),u=-es.dot(fd),h=es.lengthSq(),d=Math.abs(1-c*c),f,p,m,v;if(d>0)if(f=c*u-l,p=c*l-u,v=a*d,f>=0)if(p>=-v)if(p<=v){let x=1/d;f*=x,p*=x,m=f*(f+c*p+2*l)+p*(c*f+p+2*u)+h}else p=a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;else p=-a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;else p<=-v?(f=Math.max(0,-(-c*a+l)),p=f>0?-a:Math.min(Math.max(-a,-u),a),m=-f*f+p*(p+2*u)+h):p<=v?(f=0,p=Math.min(Math.max(-a,-u),a),m=p*(p+2*u)+h):(f=Math.max(0,-(c*a+l)),p=f>0?a:Math.min(Math.max(-a,-u),a),m=-f*f+p*(p+2*u)+h);else p=c>0?-a:a,f=Math.max(0,-(c*p+l)),m=-f*f+p*(p+2*u)+h;return r&&r.copy(this.direction).multiplyScalar(f).add(this.origin),o&&o.copy(fd).multiplyScalar(p).add(dv),m}intersectSphere(e,n){io.subVectors(e.center,this.origin);let r=io.dot(this.direction),o=io.dot(io)-r*r,a=e.radius*e.radius;if(o>a)return null;let c=Math.sqrt(a-o),l=r-c,u=r+c;return l<0&&u<0?null:l<0?this.at(u,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;let r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){let r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){let n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,o,a,c,l,u,h=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return h>=0?(r=(e.min.x-p.x)*h,o=(e.max.x-p.x)*h):(r=(e.max.x-p.x)*h,o=(e.min.x-p.x)*h),d>=0?(a=(e.min.y-p.y)*d,c=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,c=(e.min.y-p.y)*d),r>c||a>o||((a>r||r!==r)&&(r=a),(c<o||o!==o)&&(o=c),f>=0?(l=(e.min.z-p.z)*f,u=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,u=(e.min.z-p.z)*f),r>u||l>o)||((l>r||r!==r)&&(r=l),(u<o||o!==o)&&(o=u),o<0)?null:this.at(r>=0?r:o,n)}intersectsBox(e){return this.intersectBox(e,io)!==null}intersectTriangle(e,n,r,o,a){pv.subVectors(n,e),dd.subVectors(r,e),mv.crossVectors(pv,dd);let c=this.direction.dot(mv),l;if(c>0){if(o)return null;l=1}else if(c<0)l=-1,c=-c;else return null;es.subVectors(this.origin,e);let u=l*this.direction.dot(dd.crossVectors(es,dd));if(u<0)return null;let h=l*this.direction.dot(pv.cross(es));if(h<0||u+h>c)return null;let d=-l*es.dot(mv);return d<0?null:this.at(d/c,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}};var Qe=class t{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,n,r,o,a,c,l,u,h,d,f,p,m,v,x,b){let y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=o,y[1]=a,y[5]=c,y[9]=l,y[13]=u,y[2]=h,y[6]=d,y[10]=f,y[14]=p,y[3]=m,y[7]=v,y[11]=x,y[15]=b,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 t().fromArray(this.elements)}copy(e){let n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){let n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){let n=this.elements,r=e.elements,o=1/Rc.setFromMatrixColumn(e,0).length(),a=1/Rc.setFromMatrixColumn(e,1).length(),c=1/Rc.setFromMatrixColumn(e,2).length();return n[0]=r[0]*o,n[1]=r[1]*o,n[2]=r[2]*o,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*c,n[9]=r[9]*c,n[10]=r[10]*c,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let n=this.elements,r=e.x,o=e.y,a=e.z,c=Math.cos(r),l=Math.sin(r),u=Math.cos(o),h=Math.sin(o),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let p=c*d,m=c*f,v=l*d,x=l*f;n[0]=u*d,n[4]=-u*f,n[8]=h,n[1]=m+v*h,n[5]=p-x*h,n[9]=-l*u,n[2]=x-p*h,n[6]=v+m*h,n[10]=c*u}else if(e.order==="YXZ"){let p=u*d,m=u*f,v=h*d,x=h*f;n[0]=p+x*l,n[4]=v*l-m,n[8]=c*h,n[1]=c*f,n[5]=c*d,n[9]=-l,n[2]=m*l-v,n[6]=x+p*l,n[10]=c*u}else if(e.order==="ZXY"){let p=u*d,m=u*f,v=h*d,x=h*f;n[0]=p-x*l,n[4]=-c*f,n[8]=v+m*l,n[1]=m+v*l,n[5]=c*d,n[9]=x-p*l,n[2]=-c*h,n[6]=l,n[10]=c*u}else if(e.order==="ZYX"){let p=c*d,m=c*f,v=l*d,x=l*f;n[0]=u*d,n[4]=v*h-m,n[8]=p*h+x,n[1]=u*f,n[5]=x*h+p,n[9]=m*h-v,n[2]=-h,n[6]=l*u,n[10]=c*u}else if(e.order==="YZX"){let p=c*u,m=c*h,v=l*u,x=l*h;n[0]=u*d,n[4]=x-p*f,n[8]=v*f+m,n[1]=f,n[5]=c*d,n[9]=-l*d,n[2]=-h*d,n[6]=m*f+v,n[10]=p-x*f}else if(e.order==="XZY"){let p=c*u,m=c*h,v=l*u,x=l*h;n[0]=u*d,n[4]=-f,n[8]=h*d,n[1]=p*f+x,n[5]=c*d,n[9]=m*f-v,n[2]=v*f-m,n[6]=l*d,n[10]=x*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(LF,e,FF)}lookAt(e,n,r){let o=this.elements;return dr.subVectors(e,n),dr.lengthSq()===0&&(dr.z=1),dr.normalize(),ts.crossVectors(r,dr),ts.lengthSq()===0&&(Math.abs(r.z)===1?dr.x+=1e-4:dr.z+=1e-4,dr.normalize(),ts.crossVectors(r,dr)),ts.normalize(),pd.crossVectors(dr,ts),o[0]=ts.x,o[4]=pd.x,o[8]=dr.x,o[1]=ts.y,o[5]=pd.y,o[9]=dr.y,o[2]=ts.z,o[6]=pd.z,o[10]=dr.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,n)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){let r=e.elements,o=n.elements,a=this.elements,c=r[0],l=r[4],u=r[8],h=r[12],d=r[1],f=r[5],p=r[9],m=r[13],v=r[2],x=r[6],b=r[10],y=r[14],g=r[3],M=r[7],C=r[11],E=r[15],w=o[0],F=o[4],H=o[8],ne=o[12],Y=o[1],L=o[5],N=o[9],G=o[13],z=o[2],D=o[6],B=o[10],q=o[14],$=o[3],ce=o[7],ge=o[11],he=o[15];return a[0]=c*w+l*Y+u*z+h*$,a[4]=c*F+l*L+u*D+h*ce,a[8]=c*H+l*N+u*B+h*ge,a[12]=c*ne+l*G+u*q+h*he,a[1]=d*w+f*Y+p*z+m*$,a[5]=d*F+f*L+p*D+m*ce,a[9]=d*H+f*N+p*B+m*ge,a[13]=d*ne+f*G+p*q+m*he,a[2]=v*w+x*Y+b*z+y*$,a[6]=v*F+x*L+b*D+y*ce,a[10]=v*H+x*N+b*B+y*ge,a[14]=v*ne+x*G+b*q+y*he,a[3]=g*w+M*Y+C*z+E*$,a[7]=g*F+M*L+C*D+E*ce,a[11]=g*H+M*N+C*B+E*ge,a[15]=g*ne+M*G+C*q+E*he,this}multiplyScalar(e){let n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){let e=this.elements,n=e[0],r=e[4],o=e[8],a=e[12],c=e[1],l=e[5],u=e[9],h=e[13],d=e[2],f=e[6],p=e[10],m=e[14],v=e[3],x=e[7],b=e[11],y=e[15];return v*(+a*u*f-o*h*f-a*l*p+r*h*p+o*l*m-r*u*m)+x*(+n*u*m-n*h*p+a*c*p-o*c*m+o*h*d-a*u*d)+b*(+n*h*f-n*l*m-a*c*f+r*c*m+a*l*d-r*h*d)+y*(-o*l*d-n*u*f+n*l*p+o*c*f-r*c*p+r*u*d)}transpose(){let e=this.elements,n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){let o=this.elements;return e.isVector3?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=n,o[14]=r),this}getInverse(e,n){n!==void 0&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");let r=this.elements,o=e.elements,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],f=o[6],p=o[7],m=o[8],v=o[9],x=o[10],b=o[11],y=o[12],g=o[13],M=o[14],C=o[15],E=v*M*p-g*x*p+g*f*b-d*M*b-v*f*C+d*x*C,w=y*x*p-m*M*p-y*f*b+h*M*b+m*f*C-h*x*C,F=m*g*p-y*v*p+y*d*b-h*g*b-m*d*C+h*v*C,H=y*v*f-m*g*f-y*d*x+h*g*x+m*d*M-h*v*M,ne=a*E+c*w+l*F+u*H;if(ne===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Y=1/ne;return r[0]=E*Y,r[1]=(g*x*u-v*M*u-g*l*b+c*M*b+v*l*C-c*x*C)*Y,r[2]=(d*M*u-g*f*u+g*l*p-c*M*p-d*l*C+c*f*C)*Y,r[3]=(v*f*u-d*x*u-v*l*p+c*x*p+d*l*b-c*f*b)*Y,r[4]=w*Y,r[5]=(m*M*u-y*x*u+y*l*b-a*M*b-m*l*C+a*x*C)*Y,r[6]=(y*f*u-h*M*u-y*l*p+a*M*p+h*l*C-a*f*C)*Y,r[7]=(h*x*u-m*f*u+m*l*p-a*x*p-h*l*b+a*f*b)*Y,r[8]=F*Y,r[9]=(y*v*u-m*g*u-y*c*b+a*g*b+m*c*C-a*v*C)*Y,r[10]=(h*g*u-y*d*u+y*c*p-a*g*p-h*c*C+a*d*C)*Y,r[11]=(m*d*u-h*v*u-m*c*p+a*v*p+h*c*b-a*d*b)*Y,r[12]=H*Y,r[13]=(m*g*l-y*v*l+y*c*x-a*g*x-m*c*M+a*v*M)*Y,r[14]=(y*d*l-h*g*l-y*c*f+a*g*f+h*c*M-a*d*M)*Y,r[15]=(h*v*l-m*d*l+m*c*f-a*v*f-h*c*x+a*d*x)*Y,this}scale(e){let n=this.elements,r=e.x,o=e.y,a=e.z;return n[0]*=r,n[4]*=o,n[8]*=a,n[1]*=r,n[5]*=o,n[9]*=a,n[2]*=r,n[6]*=o,n[10]*=a,n[3]*=r,n[7]*=o,n[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=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(n,r,o))}makeTranslation(e,n,r){return this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){let n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){let n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){let n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){let r=Math.cos(n),o=Math.sin(n),a=1-r,c=e.x,l=e.y,u=e.z,h=a*c,d=a*l;return this.set(h*c+r,h*l-o*u,h*u+o*l,0,h*l+o*u,d*l+r,d*u-o*c,0,h*u-o*l,d*u+o*c,a*u*u+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r){return this.set(1,n,r,0,e,1,r,0,e,n,1,0,0,0,0,1),this}compose(e,n,r){let o=this.elements,a=n._x,c=n._y,l=n._z,u=n._w,h=a+a,d=c+c,f=l+l,p=a*h,m=a*d,v=a*f,x=c*d,b=c*f,y=l*f,g=u*h,M=u*d,C=u*f,E=r.x,w=r.y,F=r.z;return o[0]=(1-(x+y))*E,o[1]=(m+C)*E,o[2]=(v-M)*E,o[3]=0,o[4]=(m-C)*w,o[5]=(1-(p+y))*w,o[6]=(b+g)*w,o[7]=0,o[8]=(v+M)*F,o[9]=(b-g)*F,o[10]=(1-(p+x))*F,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,n,r){let o=this.elements,a=Rc.set(o[0],o[1],o[2]).length(),c=Rc.set(o[4],o[5],o[6]).length(),l=Rc.set(o[8],o[9],o[10]).length();this.determinant()<0&&(a=-a),e.x=o[12],e.y=o[13],e.z=o[14],Jr.copy(this);let h=1/a,d=1/c,f=1/l;return Jr.elements[0]*=h,Jr.elements[1]*=h,Jr.elements[2]*=h,Jr.elements[4]*=d,Jr.elements[5]*=d,Jr.elements[6]*=d,Jr.elements[8]*=f,Jr.elements[9]*=f,Jr.elements[10]*=f,n.setFromRotationMatrix(Jr),r.x=a,r.y=c,r.z=l,this}makePerspective(e,n,r,o,a,c){c===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let l=this.elements,u=2*a/(n-e),h=2*a/(r-o),d=(n+e)/(n-e),f=(r+o)/(r-o),p=-(c+a)/(c-a),m=-2*c*a/(c-a);return l[0]=u,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,o,a,c){let l=this.elements,u=1/(n-e),h=1/(r-o),d=1/(c-a),f=(n+e)*u,p=(r+o)*h,m=(c+a)*d;return l[0]=2*u,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=-2*d,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let n=this.elements,r=e.elements;for(let o=0;o<16;o++)if(n[o]!==r[o])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){let r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}},Rc=new O,Jr=new Qe,LF=new O(0,0,0),FF=new O(1,1,1),ts=new O,pd=new O,dr=new O;var js=class t{constructor(e=0,n=0,r=0,o=t.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=e,this._y=n,this._z=r,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,n,r,o){return this._x=e,this._y=n,this._z=r,this._order=o||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n,r){let o=je.clamp,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],p=a[2],m=a[6],v=a[10];switch(n=n||this._order,n){case"XYZ":this._y=Math.asin(o(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-f,v),this._z=Math.atan2(-l,c)):(this._x=Math.atan2(m,d),this._z=0);break;case"YXZ":this._x=Math.asin(-o(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(u,v),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-p,c),this._z=0);break;case"ZXY":this._x=Math.asin(o(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,v),this._z=Math.atan2(-l,d)):(this._y=0,this._z=Math.atan2(h,c));break;case"ZYX":this._y=Math.asin(-o(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(h,c)):(this._x=0,this._z=Math.atan2(-l,d));break;case"YZX":this._z=Math.asin(o(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-f,d),this._y=Math.atan2(-p,c)):(this._x=0,this._y=Math.atan2(u,v));break;case"XZY":this._z=Math.asin(-o(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(m,d),this._y=Math.atan2(u,c)):(this._x=Math.atan2(-f,v),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r!==!1&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return Lw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Lw,n,r)}setFromVector3(e,n){return this.set(e.x,e.y,e.z,n||this._order)}reorder(e){return Fw.setFromEuler(this),this.setFromQuaternion(Fw,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],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new O(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};js.DefaultOrder="XYZ";js.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Lw=new Qe,Fw=new zt;var qs=class{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}};var IF=0,Iw=new O,Pc=new zt,oo=new Qe,md=new O,iu=new O,DF=new O,BF=new zt,Dw=new O(1,0,0),Bw=new O(0,1,0),Ow=new O(0,0,1),OF={type:"added"},Uw={type:"removed"};function Ue(){Object.defineProperty(this,"id",{value:IF++}),this.uuid=je.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ue.DefaultUp.clone();let t=new O,e=new js,n=new zt,r=new O(1,1,1);function o(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(o),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Qe},normalMatrix:{value:new Ft}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=Ue.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new qs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}Ue.DefaultUp=new O(0,1,0);Ue.DefaultMatrixAutoUpdate=!0;Ue.prototype=Object.assign(Object.create(gn.prototype),{constructor:Ue,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return Pc.setFromAxisAngle(t,e),this.quaternion.multiply(Pc),this},rotateOnWorldAxis:function(t,e){return Pc.setFromAxisAngle(t,e),this.quaternion.premultiply(Pc),this},rotateX:function(t){return this.rotateOnAxis(Dw,t)},rotateY:function(t){return this.rotateOnAxis(Bw,t)},rotateZ:function(t){return this.rotateOnAxis(Ow,t)},translateOnAxis:function(t,e){return Iw.copy(t).applyQuaternion(this.quaternion),this.position.add(Iw.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(Dw,t)},translateY:function(t){return this.translateOnAxis(Bw,t)},translateZ:function(t){return this.translateOnAxis(Ow,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(oo.getInverse(this.matrixWorld))},lookAt:function(t,e,n){t.isVector3?md.copy(t):md.set(t,e,n);let r=this.parent;this.updateWorldMatrix(!0,!1),iu.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?oo.lookAt(iu,md,this.up):oo.lookAt(md,iu,this.up),this.quaternion.setFromRotationMatrix(oo),r&&(oo.extractRotation(r.matrixWorld),Pc.setFromRotationMatrix(oo),this.quaternion.premultiply(Pc.inverse()))},add:function(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(OF)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Uw)),this},clear:function(){for(let t=0;t<this.children.length;t++){let e=this.children[t];e.parent=null,e.dispatchEvent(Uw)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),oo.getInverse(this.matrixWorld),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),oo.multiply(t.parent.matrixWorld)),t.applyMatrix4(oo),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}},getWorldPosition:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new O),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new zt),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(iu,t,DF),t},getWorldScale:function(t){return t===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new O),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(iu,BF,t),t},getWorldDirection:function(t){t===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new O),this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)},traverseVisible:function(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)},traverseAncestors:function(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0)}},toJSON:function(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON());function o(c,l){return c[l.uuid]===void 0&&(c[l.uuid]=l.toJSON(t)),l.uuid}if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(t.geometries,this.geometry);let c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){let l=c.shapes;if(Array.isArray(l))for(let u=0,h=l.length;u<h;u++){let d=l[u];o(t.shapes,d)}else o(t.shapes,l)}}if(this.material!==void 0)if(Array.isArray(this.material)){let c=[];for(let l=0,u=this.material.length;l<u;l++)c.push(o(t.materials,this.material[l]));r.material=c}else r.material=o(t.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(t).object)}if(e){let c=a(t.geometries),l=a(t.materials),u=a(t.textures),h=a(t.images),d=a(t.shapes);c.length>0&&(n.geometries=c),l.length>0&&(n.materials=l),u.length>0&&(n.textures=u),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d)}return n.object=r,n;function a(c){let l=[];for(let u in c){let h=c[u];delete h.metadata,l.push(h)}return l}},clone:function(t){return new this.constructor().copy(this,t)},copy:function(t,e){if(e===void 0&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let r=t.children[n];this.add(r.clone())}return this}});var gv=new O,UF=new O,NF=new Ft,Un=class{constructor(e,n){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=e!==void 0?e:new O(1,0,0),this.constant=n!==void 0?n:0}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,o){return this.normal.set(e,n,r),this.constant=o,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){let o=gv.subVectors(r,n).cross(UF.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(o,e),this}clone(){return new this.constructor().copy(this)}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new O),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,n){n===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new O);let r=e.delta(gv),o=this.normal.dot(r);if(o===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):void 0;let a=-(e.start.dot(this.normal)+this.constant)/o;if(!(a<0||a>1))return n.copy(r).multiplyScalar(a).add(e.start)}intersectsLine(e){let n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new O),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){let r=n||NF.getNormalMatrix(e),o=this.coplanarPoint(gv).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-o.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}};var Qr=new O,so=new O,vv=new O,ao=new O,Lc=new O,Fc=new O,Nw=new O,yv=new O,xv=new O,_v=new O,Tn=class t{constructor(e,n,r){this.a=e!==void 0?e:new O,this.b=n!==void 0?n:new O,this.c=r!==void 0?r:new O}static getNormal(e,n,r,o){o===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),o=new O),o.subVectors(r,n),Qr.subVectors(e,n),o.cross(Qr);let a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}static getBarycoord(e,n,r,o,a){Qr.subVectors(o,n),so.subVectors(r,n),vv.subVectors(e,n);let c=Qr.dot(Qr),l=Qr.dot(so),u=Qr.dot(vv),h=so.dot(so),d=so.dot(vv),f=c*h-l*l;if(a===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),a=new O),f===0)return a.set(-2,-1,-1);let p=1/f,m=(h*u-l*d)*p,v=(c*d-l*u)*p;return a.set(1-m-v,v,m)}static containsPoint(e,n,r,o){return this.getBarycoord(e,n,r,o,ao),ao.x>=0&&ao.y>=0&&ao.x+ao.y<=1}static getUV(e,n,r,o,a,c,l,u){return this.getBarycoord(e,n,r,o,ao),u.set(0,0),u.addScaledVector(a,ao.x),u.addScaledVector(c,ao.y),u.addScaledVector(l,ao.z),u}static isFrontFacing(e,n,r,o){return Qr.subVectors(r,n),so.subVectors(e,n),Qr.cross(so).dot(o)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,o){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(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 Qr.subVectors(this.c,this.b),so.subVectors(this.a,this.b),Qr.cross(so).length()*.5}getMidpoint(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new O),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return t.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new Un),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return t.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,o,a){return t.getUV(e,this.a,this.b,this.c,n,r,o,a)}containsPoint(e){return t.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return t.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){n===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new O);let r=this.a,o=this.b,a=this.c,c,l;Lc.subVectors(o,r),Fc.subVectors(a,r),yv.subVectors(e,r);let u=Lc.dot(yv),h=Fc.dot(yv);if(u<=0&&h<=0)return n.copy(r);xv.subVectors(e,o);let d=Lc.dot(xv),f=Fc.dot(xv);if(d>=0&&f<=d)return n.copy(o);let p=u*f-d*h;if(p<=0&&u>=0&&d<=0)return c=u/(u-d),n.copy(r).addScaledVector(Lc,c);_v.subVectors(e,a);let m=Lc.dot(_v),v=Fc.dot(_v);if(v>=0&&m<=v)return n.copy(a);let x=m*h-u*v;if(x<=0&&h>=0&&v<=0)return l=h/(h-v),n.copy(r).addScaledVector(Fc,l);let b=d*v-m*f;if(b<=0&&f-d>=0&&m-v>=0)return Nw.subVectors(a,o),l=(f-d)/(f-d+(m-v)),n.copy(o).addScaledVector(Nw,l);let y=1/(b+x+p);return c=x*y,l=p*y,n.copy(r).addScaledVector(Lc,c).addScaledVector(Fc,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};var Gw={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},Kr={h:0,s:0,l:0},gd={h:0,s:0,l:0};function bv(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}function wv(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Mv(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}var Ae=class{constructor(e,n,r){return Object.defineProperty(this,"isColor",{value:!0}),n===void 0&&r===void 0?this.set(e):this.setRGB(e,n,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,n,r){return this.r=e,this.g=n,this.b=r,this}setHSL(e,n,r){if(e=je.euclideanModulo(e,1),n=je.clamp(n,0,1),r=je.clamp(r,0,1),n===0)this.r=this.g=this.b=r;else{let o=r<=.5?r*(1+n):r+n-r*n,a=2*r-o;this.r=bv(a,o,e+1/3),this.g=bv(a,o,e),this.b=bv(a,o,e-1/3)}return this}setStyle(e){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){let o,a=r[1],c=r[2];switch(a){case"rgb":case"rgba":if(o=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c))return this.r=Math.min(255,parseInt(o[1],10))/255,this.g=Math.min(255,parseInt(o[2],10))/255,this.b=Math.min(255,parseInt(o[3],10))/255,n(o[5]),this;if(o=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c))return this.r=Math.min(100,parseInt(o[1],10))/100,this.g=Math.min(100,parseInt(o[2],10))/100,this.b=Math.min(100,parseInt(o[3],10))/100,n(o[5]),this;break;case"hsl":case"hsla":if(o=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(c)){let l=parseFloat(o[1])/360,u=parseInt(o[2],10)/100,h=parseInt(o[3],10)/100;return n(o[5]),this.setHSL(l,u,h)}break}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){let o=r[1],a=o.length;if(a===3)return this.r=parseInt(o.charAt(0)+o.charAt(0),16)/255,this.g=parseInt(o.charAt(1)+o.charAt(1),16)/255,this.b=parseInt(o.charAt(2)+o.charAt(2),16)/255,this;if(a===6)return this.r=parseInt(o.charAt(0)+o.charAt(1),16)/255,this.g=parseInt(o.charAt(2)+o.charAt(3),16)/255,this.b=parseInt(o.charAt(4)+o.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let n=Gw[e];return n!==void 0?this.setHex(n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,n){return n===void 0&&(n=2),this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}copyLinearToGamma(e,n){n===void 0&&(n=2);let r=n>0?1/n:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=wv(e.r),this.g=wv(e.g),this.b=wv(e.b),this}copyLinearToSRGB(e){return this.r=Mv(e.r),this.g=Mv(e.g),this.b=Mv(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){e===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});let n=this.r,r=this.g,o=this.b,a=Math.max(n,r,o),c=Math.min(n,r,o),l,u,h=(c+a)/2;if(c===a)l=0,u=0;else{let d=a-c;switch(u=h<=.5?d/(a+c):d/(2-a-c),a){case n:l=(r-o)/d+(r<o?6:0);break;case r:l=(o-n)/d+2;break;case o:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=u,e.l=h,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,n,r){return this.getHSL(Kr),Kr.h+=e,Kr.s+=n,Kr.l+=r,this.setHSL(Kr.h,Kr.s,Kr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpHSL(e,n){this.getHSL(Kr),e.getHSL(gd);let r=je.lerp(Kr.h,gd.h,n),o=je.lerp(Kr.s,gd.s,n),a=je.lerp(Kr.l,gd.l,n);return this.setHSL(r,o,a),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}};Ae.NAMES=Gw;Ae.prototype.r=1;Ae.prototype.g=1;Ae.prototype.b=1;var co=class{constructor(e,n,r,o,a,c){this.a=e,this.b=n,this.c=r,this.normal=o&&o.isVector3?o:new O,this.vertexNormals=Array.isArray(o)?o:[],this.color=a&&a.isColor?a:new Ae,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=c!==void 0?c:0}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let n=0,r=e.vertexNormals.length;n<r;n++)this.vertexNormals[n]=e.vertexNormals[n].clone();for(let n=0,r=e.vertexColors.length;n<r;n++)this.vertexColors[n]=e.vertexColors[n].clone();return this}};var GF=0;function Ye(){Object.defineProperty(this,"id",{value:GF++}),this.uuid=je.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=Os,this.side=Vo,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Yf,this.blendDst=$f,this.blendEquation=jo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=tu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Rw,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cd,this.stencilZFail=cd,this.stencilZPass=cd,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Ye.prototype=Object.assign(Object.create(gn.prototype),{constructor:Ye,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if(e==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===Xf;continue}let r=this[e];if(r===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}},toJSON:function(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,this.combine!==void 0&&(n.combine=this.combine),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Os&&(n.blending=this.blending),this.flatShading===!0&&(n.flatShading=this.flatShading),this.side!==Vo&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(n.morphTargets=!0),this.morphNormals===!0&&(n.morphNormals=!0),this.skinning===!0&&(n.skinning=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function r(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}if(e){let o=r(t.textures),a=r(t.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n},clone:function(){return new this.constructor().copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let r=e.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=e[o].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(Ye.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});function pr(t){Ye.call(this),this.type="MeshBasicMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}pr.prototype=Object.create(Ye.prototype);pr.prototype.constructor=pr;pr.prototype.isMeshBasicMaterial=!0;pr.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};var Nt=new O,vd=new ue;function tt(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n===!0,this.usage=zs,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(tt.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(tt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,o=this.itemSize;r<o;r++)this.array[t+r]=e.array[n+r];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Ae),e[n++]=a.r,e[n++]=a.g,e[n++]=a.b}return this},copyVector2sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new ue),e[n++]=a.x,e[n++]=a.y}return this},copyVector3sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new O),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z}return this},copyVector4sArray:function(t){let e=this.array,n=0;for(let r=0,o=t.length;r<o;r++){let a=t[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new mt),e[n++]=a.x,e[n++]=a.y,e[n++]=a.z,e[n++]=a.w}return this},applyMatrix3:function(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)vd.fromBufferAttribute(this,e),vd.applyMatrix3(t),this.setXY(e,vd.x,vd.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Nt.fromBufferAttribute(this,e),Nt.applyMatrix3(t),this.setXYZ(e,Nt.x,Nt.y,Nt.z);return this},applyMatrix4:function(t){for(let e=0,n=this.count;e<n;e++)Nt.x=this.getX(e),Nt.y=this.getY(e),Nt.z=this.getZ(e),Nt.applyMatrix4(t),this.setXYZ(e,Nt.x,Nt.y,Nt.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)Nt.x=this.getX(e),Nt.y=this.getY(e),Nt.z=this.getZ(e),Nt.applyNormalMatrix(t),this.setXYZ(e,Nt.x,Nt.y,Nt.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)Nt.x=this.getX(e),Nt.y=this.getY(e),Nt.z=this.getZ(e),Nt.transformDirection(t),this.setXYZ(e,Nt.x,Nt.y,Nt.z);return this},set:function(t,e){return e===void 0&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this},setXYZW:function(t,e,n,r,o){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=o,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function yd(t,e,n){tt.call(this,new Int8Array(t),e,n)}yd.prototype=Object.create(tt.prototype);yd.prototype.constructor=yd;function xd(t,e,n){tt.call(this,new Uint8Array(t),e,n)}xd.prototype=Object.create(tt.prototype);xd.prototype.constructor=xd;function _d(t,e,n){tt.call(this,new Uint8ClampedArray(t),e,n)}_d.prototype=Object.create(tt.prototype);_d.prototype.constructor=_d;function bd(t,e,n){tt.call(this,new Int16Array(t),e,n)}bd.prototype=Object.create(tt.prototype);bd.prototype.constructor=bd;function ns(t,e,n){tt.call(this,new Uint16Array(t),e,n)}ns.prototype=Object.create(tt.prototype);ns.prototype.constructor=ns;function wd(t,e,n){tt.call(this,new Int32Array(t),e,n)}wd.prototype=Object.create(tt.prototype);wd.prototype.constructor=wd;function rs(t,e,n){tt.call(this,new Uint32Array(t),e,n)}rs.prototype=Object.create(tt.prototype);rs.prototype.constructor=rs;function Ke(t,e,n){tt.call(this,new Float32Array(t),e,n)}Ke.prototype=Object.create(tt.prototype);Ke.prototype.constructor=Ke;function Md(t,e,n){tt.call(this,new Float64Array(t),e,n)}Md.prototype=Object.create(tt.prototype);Md.prototype.constructor=Md;var Ed=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let n=[],r,o,a,c=e.faces;for(o=0;o<c.length;o++){let l=c[o];l.materialIndex!==a&&(a=l.materialIndex,r!==void 0&&(r.count=o*3-r.start,n.push(r)),r={start:o*3,materialIndex:a})}r!==void 0&&(r.count=o*3-r.start,n.push(r)),this.groups=n}fromGeometry(e){let n=e.faces,r=e.vertices,o=e.faceVertexUvs,a=o[0]&&o[0].length>0,c=o[1]&&o[1].length>0,l=e.morphTargets,u=l.length,h;if(u>0){h=[];for(let y=0;y<u;y++)h[y]={name:l[y].name,data:[]};this.morphTargets.position=h}let d=e.morphNormals,f=d.length,p;if(f>0){p=[];for(let y=0;y<f;y++)p[y]={name:d[y].name,data:[]};this.morphTargets.normal=p}let m=e.skinIndices,v=e.skinWeights,x=m.length===r.length,b=v.length===r.length;r.length>0&&n.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<n.length;y++){let g=n[y];this.vertices.push(r[g.a],r[g.b],r[g.c]);let M=g.vertexNormals;if(M.length===3)this.normals.push(M[0],M[1],M[2]);else{let E=g.normal;this.normals.push(E,E,E)}let C=g.vertexColors;if(C.length===3)this.colors.push(C[0],C[1],C[2]);else{let E=g.color;this.colors.push(E,E,E)}if(a===!0){let E=o[0][y];E!==void 0?this.uvs.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new ue,new ue,new ue))}if(c===!0){let E=o[1][y];E!==void 0?this.uvs2.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new ue,new ue,new ue))}for(let E=0;E<u;E++){let w=l[E].vertices;h[E].data.push(w[g.a],w[g.b],w[g.c])}for(let E=0;E<f;E++){let w=d[E].vertexNormals[y];p[E].data.push(w.a,w.b,w.c)}x&&this.skinIndices.push(m[g.a],m[g.b],m[g.c]),b&&this.skinWeights.push(v[g.a],v[g.b],v[g.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}};function Sd(t){if(t.length===0)return-1/0;let e=t[0];for(let n=1,r=t.length;n<r;++n)t[n]>e&&(e=t[n]);return e}var kF=1,Ti=new Qe,Ev=new Ue,Ic=new O,mr=new On,ou=new On,vn=new O;function qe(){Object.defineProperty(this,"id",{value:kF+=2}),this.uuid=je.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}qe.prototype=Object.assign(Object.create(gn.prototype),{constructor:qe,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(Sd(t)>65535?rs:ns)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:n!==void 0?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let o=new Ft().getNormalMatrix(t);n.applyNormalMatrix(o),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(t){return Ti.makeRotationX(t),this.applyMatrix4(Ti),this},rotateY:function(t){return Ti.makeRotationY(t),this.applyMatrix4(Ti),this},rotateZ:function(t){return Ti.makeRotationZ(t),this.applyMatrix4(Ti),this},translate:function(t,e,n){return Ti.makeTranslation(t,e,n),this.applyMatrix4(Ti),this},scale:function(t,e,n){return Ti.makeScale(t,e,n),this.applyMatrix4(Ti),this},lookAt:function(t){return Ev.lookAt(t),Ev.updateMatrix(),this.applyMatrix4(Ev.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ic).negate(),this.translate(Ic.x,Ic.y,Ic.z),this},setFromObject:function(t){let e=t.geometry;if(t.isPoints||t.isLine){let n=new Ke(e.vertices.length*3,3),r=new Ke(e.colors.length*3,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){let o=new Ke(e.lineDistances.length,1);this.setAttribute("lineDistance",o.copyArray(e.lineDistances))}e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){let e=[];for(let n=0,r=t.length;n<r;n++){let o=t[n];e.push(o.x,o.y,o.z||0)}return this.setAttribute("position",new Ke(e,3)),this},updateFromObject:function(t){let e=t.geometry;if(t.isMesh){let n=e.__directGeometry;if(e.elementsNeedUpdate===!0&&(n=void 0,e.elementsNeedUpdate=!1),n===void 0)return this.fromGeometry(e);n.verticesNeedUpdate=e.verticesNeedUpdate,n.normalsNeedUpdate=e.normalsNeedUpdate,n.colorsNeedUpdate=e.colorsNeedUpdate,n.uvsNeedUpdate=e.uvsNeedUpdate,n.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=n}if(e.verticesNeedUpdate===!0){let n=this.attributes.position;n!==void 0&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1}if(e.normalsNeedUpdate===!0){let n=this.attributes.normal;n!==void 0&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1}if(e.colorsNeedUpdate===!0){let n=this.attributes.color;n!==void 0&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1}if(e.uvsNeedUpdate){let n=this.attributes.uv;n!==void 0&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1}if(e.lineDistancesNeedUpdate){let n=this.attributes.lineDistance;n!==void 0&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1}return e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=new Ed().fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){let e=new Float32Array(t.vertices.length*3);if(this.setAttribute("position",new tt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);this.setAttribute("normal",new tt(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);this.setAttribute("color",new tt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);this.setAttribute("uv",new tt(n,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);this.setAttribute("uv2",new tt(n,2).copyVector2sArray(t.uvs2))}this.groups=t.groups;for(let n in t.morphTargets){let r=[],o=t.morphTargets[n];for(let a=0,c=o.length;a<c;a++){let l=o[a],u=new Ke(l.data.length*3,3);u.name=l.name,r.push(u.copyVector3sArray(l.data))}this.morphAttributes[n]=r}if(t.skinIndices.length>0){let n=new Ke(t.skinIndices.length*4,4);this.setAttribute("skinIndex",n.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let n=new Ke(t.skinWeights.length*4,4);this.setAttribute("skinWeight",n.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new On);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){let o=e[n];mr.setFromBufferAttribute(o),this.morphTargetsRelative?(vn.addVectors(this.boundingBox.min,mr.min),this.boundingBox.expandByPoint(vn),vn.addVectors(this.boundingBox.max,mr.max),this.boundingBox.expandByPoint(vn)):(this.boundingBox.expandByPoint(mr.min),this.boundingBox.expandByPoint(mr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new un);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new O,1/0);return}if(t){let n=this.boundingSphere.center;if(mr.setFromBufferAttribute(t),e)for(let o=0,a=e.length;o<a;o++){let c=e[o];ou.setFromBufferAttribute(c),this.morphTargetsRelative?(vn.addVectors(mr.min,ou.min),mr.expandByPoint(vn),vn.addVectors(mr.max,ou.max),mr.expandByPoint(vn)):(mr.expandByPoint(ou.min),mr.expandByPoint(ou.max))}mr.getCenter(n);let r=0;for(let o=0,a=t.count;o<a;o++)vn.fromBufferAttribute(t,o),r=Math.max(r,n.distanceToSquared(vn));if(e)for(let o=0,a=e.length;o<a;o++){let c=e[o],l=this.morphTargetsRelative;for(let u=0,h=c.count;u<h;u++)vn.fromBufferAttribute(c,u),l&&(Ic.fromBufferAttribute(t,u),vn.add(Ic)),r=Math.max(r,n.distanceToSquared(vn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new tt(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let r=new O,o=new O,a=new O,c=new O,l=new O,u=new O,h=new O,d=new O;if(t)for(let f=0,p=t.count;f<p;f+=3){let m=t.getX(f+0),v=t.getX(f+1),x=t.getX(f+2);r.fromBufferAttribute(e,m),o.fromBufferAttribute(e,v),a.fromBufferAttribute(e,x),h.subVectors(a,o),d.subVectors(r,o),h.cross(d),c.fromBufferAttribute(n,m),l.fromBufferAttribute(n,v),u.fromBufferAttribute(n,x),c.add(h),l.add(h),u.add(h),n.setXYZ(m,c.x,c.y,c.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(x,u.x,u.y,u.z)}else for(let f=0,p=e.count;f<p;f+=3)r.fromBufferAttribute(e,f+0),o.fromBufferAttribute(e,f+1),a.fromBufferAttribute(e,f+2),h.subVectors(a,o),d.subVectors(r,o),h.cross(d),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(t,e){if(!(t&&t.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);return}e===void 0&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let r in n){if(t.attributes[r]===void 0)continue;let a=n[r].array,c=t.attributes[r],l=c.array,u=c.itemSize*e,h=Math.min(l.length,a.length-u);for(let d=0,f=u;d<h;d++,f++)a[f]=l[d]}return this},normalizeNormals:function(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)vn.fromBufferAttribute(t,e),vn.normalize(),t.setXYZ(e,vn.x,vn.y,vn.z)},toNonIndexed:function(){function t(c,l){let u=c.array,h=c.itemSize,d=c.normalized,f=new u.constructor(l.length*h),p=0,m=0;for(let v=0,x=l.length;v<x;v++){p=l[v]*h;for(let b=0;b<h;b++)f[m++]=u[p++]}return new tt(f,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;let e=new qe,n=this.index.array,r=this.attributes;for(let c in r){let l=r[c],u=t(l,n);e.setAttribute(c,u)}let o=this.morphAttributes;for(let c in o){let l=[],u=o[c];for(let h=0,d=u.length;h<d;h++){let f=u[h],p=t(f,n);l.push(p)}e.morphAttributes[c]=l}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let c=0,l=a.length;c<l;c++){let u=a[c];e.addGroup(u.start,u.count,u.materialIndex)}return e},toJSON:function(){let t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(t[u]=l[u]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let u=n[l],h=u.toJSON(t.data);u.name!==""&&(h.name=u.name),t.data.attributes[l]=h}let r={},o=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],h=[];for(let d=0,f=u.length;d<f;d++){let p=u[d],m=p.toJSON(t.data);p.name!==""&&(m.name=p.name),h.push(m)}h.length>0&&(r[l]=h,o=!0)}o&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let c=this.boundingSphere;return c!==null&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return new qe().copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let r=t.attributes;for(let u in r){let h=r[u];this.setAttribute(u,h.clone(e))}let o=t.morphAttributes;for(let u in o){let h=[],d=o[u];for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone(e));this.morphAttributes[u]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let u=0,h=a.length;u<h;u++){let d=a[u];this.addGroup(d.start,d.count,d.materialIndex)}let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var kw=new Qe,Xs=new fr,Sv=new un,is=new O,os=new O,ss=new O,Tv=new O,Av=new O,Cv=new O,Td=new O,Ad=new O,Cd=new O,Dc=new ue,Bc=new ue,Oc=new ue,su=new O,Rd=new O;function Pt(t,e){Ue.call(this),this.type="Mesh",this.geometry=t!==void 0?t:new qe,this.material=e!==void 0?e:new pr,this.updateMorphTargets()}Pt.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Pt,isMesh:!0,copy:function(t){return Ue.prototype.copy.call(this,t),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){let n=this.geometry,r=this.material,o=this.matrixWorld;if(r===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Sv.copy(n.boundingSphere),Sv.applyMatrix4(o),t.ray.intersectsSphere(Sv)===!1)||(kw.getInverse(o),Xs.copy(t.ray).applyMatrix4(kw),n.boundingBox!==null&&Xs.intersectsBox(n.boundingBox)===!1))return;let a;if(n.isBufferGeometry){let c=n.index,l=n.attributes.position,u=n.morphAttributes.position,h=n.morphTargetsRelative,d=n.attributes.uv,f=n.attributes.uv2,p=n.groups,m=n.drawRange;if(c!==null)if(Array.isArray(r))for(let v=0,x=p.length;v<x;v++){let b=p[v],y=r[b.materialIndex],g=Math.max(b.start,m.start),M=Math.min(b.start+b.count,m.start+m.count);for(let C=g,E=M;C<E;C+=3){let w=c.getX(C),F=c.getX(C+1),H=c.getX(C+2);a=Pd(this,y,t,Xs,l,u,h,d,f,w,F,H),a&&(a.faceIndex=Math.floor(C/3),a.face.materialIndex=b.materialIndex,e.push(a))}}else{let v=Math.max(0,m.start),x=Math.min(c.count,m.start+m.count);for(let b=v,y=x;b<y;b+=3){let g=c.getX(b),M=c.getX(b+1),C=c.getX(b+2);a=Pd(this,r,t,Xs,l,u,h,d,f,g,M,C),a&&(a.faceIndex=Math.floor(b/3),e.push(a))}}else if(l!==void 0)if(Array.isArray(r))for(let v=0,x=p.length;v<x;v++){let b=p[v],y=r[b.materialIndex],g=Math.max(b.start,m.start),M=Math.min(b.start+b.count,m.start+m.count);for(let C=g,E=M;C<E;C+=3){let w=C,F=C+1,H=C+2;a=Pd(this,y,t,Xs,l,u,h,d,f,w,F,H),a&&(a.faceIndex=Math.floor(C/3),a.face.materialIndex=b.materialIndex,e.push(a))}}else{let v=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let b=v,y=x;b<y;b+=3){let g=b,M=b+1,C=b+2;a=Pd(this,r,t,Xs,l,u,h,d,f,g,M,C),a&&(a.faceIndex=Math.floor(b/3),e.push(a))}}}else if(n.isGeometry){let c=Array.isArray(r),l=n.vertices,u=n.faces,h,d=n.faceVertexUvs[0];d.length>0&&(h=d);for(let f=0,p=u.length;f<p;f++){let m=u[f],v=c?r[m.materialIndex]:r;if(v===void 0)continue;let x=l[m.a],b=l[m.b],y=l[m.c];if(a=Hw(this,v,t,Xs,x,b,y,su),a){if(h&&h[f]){let g=h[f];Dc.copy(g[0]),Bc.copy(g[1]),Oc.copy(g[2]),a.uv=Tn.getUV(su,x,b,y,Dc,Bc,Oc,new ue)}a.face=m,a.faceIndex=f,e.push(a)}}}}});function Hw(t,e,n,r,o,a,c,l){let u;if(e.side===kt?u=r.intersectTriangle(c,a,o,!0,l):u=r.intersectTriangle(o,a,c,e.side!==Wo,l),u===null)return null;Rd.copy(l),Rd.applyMatrix4(t.matrixWorld);let h=n.ray.origin.distanceTo(Rd);return h<n.near||h>n.far?null:{distance:h,point:Rd.clone(),object:t}}function Pd(t,e,n,r,o,a,c,l,u,h,d,f){is.fromBufferAttribute(o,h),os.fromBufferAttribute(o,d),ss.fromBufferAttribute(o,f);let p=t.morphTargetInfluences;if(e.morphTargets&&a&&p){Td.set(0,0,0),Ad.set(0,0,0),Cd.set(0,0,0);for(let v=0,x=a.length;v<x;v++){let b=p[v],y=a[v];b!==0&&(Tv.fromBufferAttribute(y,h),Av.fromBufferAttribute(y,d),Cv.fromBufferAttribute(y,f),c?(Td.addScaledVector(Tv,b),Ad.addScaledVector(Av,b),Cd.addScaledVector(Cv,b)):(Td.addScaledVector(Tv.sub(is),b),Ad.addScaledVector(Av.sub(os),b),Cd.addScaledVector(Cv.sub(ss),b)))}is.add(Td),os.add(Ad),ss.add(Cd)}t.isSkinnedMesh&&(t.boneTransform(h,is),t.boneTransform(d,os),t.boneTransform(f,ss));let m=Hw(t,e,n,r,is,os,ss,su);if(m){l&&(Dc.fromBufferAttribute(l,h),Bc.fromBufferAttribute(l,d),Oc.fromBufferAttribute(l,f),m.uv=Tn.getUV(su,is,os,ss,Dc,Bc,Oc,new ue)),u&&(Dc.fromBufferAttribute(u,h),Bc.fromBufferAttribute(u,d),Oc.fromBufferAttribute(u,f),m.uv2=Tn.getUV(su,is,os,ss,Dc,Bc,Oc,new ue));let v=new co(h,d,f);Tn.getNormal(is,os,ss,v.normal),m.face=v}return m}var as=class extends qe{constructor(e=1,n=1,r=1,o=1,a=1,c=1){super(),this.type="BoxBufferGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:o,heightSegments:a,depthSegments:c};let l=this;o=Math.floor(o),a=Math.floor(a),c=Math.floor(c);let u=[],h=[],d=[],f=[],p=0,m=0;v("z","y","x",-1,-1,r,n,e,c,a,0),v("z","y","x",1,-1,r,n,-e,c,a,1),v("x","z","y",1,1,e,r,n,o,c,2),v("x","z","y",1,-1,e,r,-n,o,c,3),v("x","y","z",1,-1,e,n,r,o,a,4),v("x","y","z",-1,-1,e,n,-r,o,a,5),this.setIndex(u),this.setAttribute("position",new Ke(h,3)),this.setAttribute("normal",new Ke(d,3)),this.setAttribute("uv",new Ke(f,2));function v(x,b,y,g,M,C,E,w,F,H,ne){let Y=C/F,L=E/H,N=C/2,G=E/2,z=w/2,D=F+1,B=H+1,q=0,$=0,ce=new O;for(let ge=0;ge<B;ge++){let he=ge*L-G;for(let Pe=0;Pe<D;Pe++){let Fe=Pe*Y-N;ce[x]=Fe*g,ce[b]=he*M,ce[y]=z,h.push(ce.x,ce.y,ce.z),ce[x]=0,ce[b]=0,ce[y]=w>0?1:-1,d.push(ce.x,ce.y,ce.z),f.push(Pe/F),f.push(1-ge/H),q+=1}}for(let ge=0;ge<H;ge++)for(let he=0;he<F;he++){let Pe=p+he+D*ge,Fe=p+he+D*(ge+1),st=p+(he+1)+D*(ge+1),V=p+(he+1)+D*ge;u.push(Pe,Fe,V),u.push(Fe,st,V),$+=6}l.addGroup(m,$,ne),m+=$,p+=q}}};function lo(t){let e={};for(let n in t){e[n]={};for(let r in t[n]){let o=t[n][r];o&&(o.isColor||o.isMatrix3||o.isMatrix4||o.isVector2||o.isVector3||o.isVector4||o.isTexture)?e[n][r]=o.clone():Array.isArray(o)?e[n][r]=o.slice():e[n][r]=o}}return e}function An(t){let e={};for(let n=0;n<t.length;n++){let r=lo(t[n]);for(let o in r)e[o]=r[o]}return e}var Rv={clone:lo,merge:An};var zw=`
void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`;var Vw=`
void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}
`;function en(t){Ye.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=zw,this.fragmentShader=Vw,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&(t.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}en.prototype=Object.create(Ye.prototype);en.prototype.constructor=en;en.prototype.isShaderMaterial=!0;en.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=lo(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this};en.prototype.toJSON=function(t){let e=Ye.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(let r in this.uniforms){let a=this.uniforms[r].value;a&&a.isTexture?e.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[r]={type:"m4",value:a.toArray()}:e.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e};function Dr(){Ue.call(this),this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe}Dr.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Dr,isCamera:!0,copy:function(t,e){return Ue.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){t===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new O),this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){Ue.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(t,e){Ue.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function It(t,e,n,r){Dr.call(this),this.type="PerspectiveCamera",this.fov=t!==void 0?t:50,this.zoom=1,this.near=n!==void 0?n:.1,this.far=r!==void 0?r:2e3,this.focus=10,this.aspect=e!==void 0?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}It.prototype=Object.assign(Object.create(Dr.prototype),{constructor:It,isPerspectiveCamera:!0,copy:function(t,e){return Dr.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){let e=.5*this.getFilmHeight()/t;this.fov=je.RAD2DEG*2*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){let t=Math.tan(je.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/t},getEffectiveFOV:function(){return je.RAD2DEG*2*Math.atan(Math.tan(je.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,n,r,o,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let t=this.near,e=t*Math.tan(je.DEG2RAD*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,o=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,u=a.fullHeight;o+=a.offsetX*r/l,e-=a.offsetY*n/u,r*=a.width/l,n*=a.height/u}let c=this.filmOffset;c!==0&&(o+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){let e=Ue.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var Uc=90,Nc=1;function uo(t,e,n){if(Ue.call(this),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;let r=new It(Uc,Nc,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new O(1,0,0)),this.add(r);let o=new It(Uc,Nc,t,e);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new O(-1,0,0)),this.add(o);let a=new It(Uc,Nc,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new O(0,1,0)),this.add(a);let c=new It(Uc,Nc,t,e);c.layers=this.layers,c.up.set(0,0,-1),c.lookAt(new O(0,-1,0)),this.add(c);let l=new It(Uc,Nc,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new O(0,0,1)),this.add(l);let u=new It(Uc,Nc,t,e);u.layers=this.layers,u.up.set(0,-1,0),u.lookAt(new O(0,0,-1)),this.add(u),this.update=function(h,d){this.parent===null&&this.updateMatrixWorld();let f=h.xr.enabled,p=h.getRenderTarget();h.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,h.setRenderTarget(n,0),h.render(d,r),h.setRenderTarget(n,1),h.render(d,o),h.setRenderTarget(n,2),h.render(d,a),h.setRenderTarget(n,3),h.render(d,c),h.setRenderTarget(n,4),h.render(d,l),n.texture.generateMipmaps=m,h.setRenderTarget(n,5),h.render(d,u),h.setRenderTarget(p),h.xr.enabled=f}}uo.prototype=Object.create(Ue.prototype);uo.prototype.constructor=uo;function gr(t,e,n,r,o,a,c,l,u,h){t=t!==void 0?t:[],e=e!==void 0?e:Us,c=c!==void 0?c:Lr,yt.call(this,t,e,n,r,o,a,c,l,u,h),this.flipY=!1,this._needsFlipEnvMap=!0}gr.prototype=Object.create(yt.prototype);gr.prototype.constructor=gr;gr.prototype.isCubeTexture=!0;Object.defineProperty(gr.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});function Ai(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),Sn.call(this,t,t,e),e=e||{},this.texture=new gr(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture._needsFlipEnvMap=!1}Ai.prototype=Object.create(Sn.prototype);Ai.prototype.constructor=Ai;Ai.prototype.isWebGLCubeRenderTarget=!0;Ai.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=mn,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`

			varying vec3 vWorldDirection;

			vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

				return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

			}

			void main() {

				vWorldDirection = transformDirection( position, modelMatrix );

				#include <begin_vertex>
				#include <project_vertex>

			}
		`,fragmentShader:`

			uniform sampler2D tEquirect;

			varying vec3 vWorldDirection;

			#include <common>

			void main() {

				vec3 direction = normalize( vWorldDirection );

				vec2 sampleUV = equirectUv( direction );

				gl_FragColor = texture2D( tEquirect, sampleUV );

			}
		`},r=new as(5,5,5),o=new en({name:"CubemapFromEquirect",uniforms:lo(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:kt,blending:Ki});o.uniforms.tEquirect.value=e;let a=new Pt(r,o),c=e.minFilter;return e.minFilter===to&&(e.minFilter=Ht),new uo(1,10,this).update(t,a),e.minFilter=c,a.geometry.dispose(),a.material.dispose(),this};Ai.prototype.clear=function(t,e,n,r){let o=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(o)};function ho(t,e,n,r,o,a,c,l,u,h,d,f){yt.call(this,null,a,c,l,u,h,r,o,d,f),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=u!==void 0?u:Xt,this.minFilter=h!==void 0?h:Xt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}ho.prototype=Object.create(yt.prototype);ho.prototype.constructor=ho;ho.prototype.isDataTexture=!0;var Gc=new un,Ld=new O,ei=class{constructor(e,n,r,o,a,c){this.planes=[e!==void 0?e:new Un,n!==void 0?n:new Un,r!==void 0?r:new Un,o!==void 0?o:new Un,a!==void 0?a:new Un,c!==void 0?c:new Un]}set(e,n,r,o,a,c){let l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(o),l[4].copy(a),l[5].copy(c),this}clone(){return new this.constructor().copy(this)}copy(e){let n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e){let n=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],u=r[4],h=r[5],d=r[6],f=r[7],p=r[8],m=r[9],v=r[10],x=r[11],b=r[12],y=r[13],g=r[14],M=r[15];return n[0].setComponents(l-o,f-u,x-p,M-b).normalize(),n[1].setComponents(l+o,f+u,x+p,M+b).normalize(),n[2].setComponents(l+a,f+h,x+m,M+y).normalize(),n[3].setComponents(l-a,f-h,x-m,M-y).normalize(),n[4].setComponents(l-c,f-d,x-v,M-g).normalize(),n[5].setComponents(l+c,f+d,x+v,M+g).normalize(),this}intersectsObject(e){let n=e.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),Gc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Gc)}intersectsSprite(e){return Gc.center.set(0,0,0),Gc.radius=.7071067811865476,Gc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gc)}intersectsSphere(e){let n=this.planes,r=e.center,o=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<o)return!1;return!0}intersectsBox(e){let n=this.planes;for(let r=0;r<6;r++){let o=n[r];if(Ld.x=o.normal.x>0?e.max.x:e.min.x,Ld.y=o.normal.y>0?e.max.y:e.min.y,Ld.z=o.normal.z>0?e.max.z:e.min.z,o.distanceToPoint(Ld)<0)return!1}return!0}containsPoint(e){let n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}};function Fd(){let t=null,e=!1,n=null,r=null;function o(a,c){n(a,c),r=t.requestAnimationFrame(o)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(o),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function Ww(t,e){let n=e.isWebGL2,r=new WeakMap;function o(h,d){let f=h.array,p=h.usage,m=t.createBuffer();t.bindBuffer(d,m),t.bufferData(d,f,p),h.onUploadCallback();let v=t.FLOAT;return f instanceof Float32Array?v=t.FLOAT:f instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):f instanceof Uint16Array?v=t.UNSIGNED_SHORT:f instanceof Int16Array?v=t.SHORT:f instanceof Uint32Array?v=t.UNSIGNED_INT:f instanceof Int32Array?v=t.INT:f instanceof Int8Array?v=t.BYTE:f instanceof Uint8Array&&(v=t.UNSIGNED_BYTE),{buffer:m,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:h.version}}function a(h,d,f){let p=d.array,m=d.updateRange;t.bindBuffer(f,h),m.count===-1?t.bufferSubData(f,0,p):(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1)}function c(h){return h.isInterleavedBufferAttribute&&(h=h.data),r.get(h)}function l(h){h.isInterleavedBufferAttribute&&(h=h.data);let d=r.get(h);d&&(t.deleteBuffer(d.buffer),r.delete(h))}function u(h,d){if(h.isGLBufferAttribute){var f=r.get(h);(!f||f.version<h.version)&&r.set(h,{buffer:h.buffer,type:h.type,bytesPerElement:h.elementSize,version:h.version});return}h.isInterleavedBufferAttribute&&(h=h.data);let p=r.get(h);p===void 0?r.set(h,o(h,d)):p.version<h.version&&(a(p.buffer,h,d),p.version=h.version)}return{get:c,remove:l,update:u}}var kc=class extends qe{constructor(e,n,r,o){super(),this.type="PlaneBufferGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:o},e=e||1,n=n||1;let a=e/2,c=n/2,l=Math.floor(r)||1,u=Math.floor(o)||1,h=l+1,d=u+1,f=e/l,p=n/u,m=[],v=[],x=[],b=[];for(let y=0;y<d;y++){let g=y*p-c;for(let M=0;M<h;M++){let C=M*f-a;v.push(C,-g,0),x.push(0,0,1),b.push(M/l),b.push(1-y/u)}}for(let y=0;y<u;y++)for(let g=0;g<l;g++){let M=g+h*y,C=g+h*(y+1),E=g+1+h*(y+1),w=g+1+h*y;m.push(M,C,w),m.push(C,E,w)}this.setIndex(m),this.setAttribute("position",new Ke(v,3)),this.setAttribute("normal",new Ke(x,3)),this.setAttribute("uv",new Ke(b,2))}};var jw=`
#ifdef USE_ALPHAMAP

	diffuseColor.a *= texture2D( alphaMap, vUv ).g;

#endif
`;var qw=`
#ifdef USE_ALPHAMAP

	uniform sampler2D alphaMap;

#endif
`;var Xw=`
#ifdef ALPHATEST

	if ( diffuseColor.a < ALPHATEST ) discard;

#endif
`;var Yw=`
#ifdef USE_AOMAP

	// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
	float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;

	reflectedLight.indirectDiffuse *= ambientOcclusion;

	#if defined( USE_ENVMAP ) && defined( STANDARD )

		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );

		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );

	#endif

#endif
`;var $w=`
#ifdef USE_AOMAP

	uniform sampler2D aoMap;
	uniform float aoMapIntensity;

#endif
`;var Zw=`
vec3 transformed = vec3( position );
`;var Jw=`
vec3 objectNormal = vec3( normal );

#ifdef USE_TANGENT

	vec3 objectTangent = vec3( tangent.xyz );

#endif
`;var Qw=`

// Analytical approximation of the DFG LUT, one half of the
// split-sum approximation used in indirect specular lighting.
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile
vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );

	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );

	vec4 r = roughness * c0 + c1;

	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;

	return vec2( -1.04, 1.04 ) * a004 + r.zw;

}

float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {

#if defined ( PHYSICALLY_CORRECT_LIGHTS )

	// based upon Frostbite 3 Moving to Physically-based Rendering
	// page 32, equation 26: E[window1]
	// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
	// this is intended to be used on spot and point lights who are represented as luminous intensity
	// but who must be converted to luminous irradiance for surface lighting calculation
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );

	if( cutoffDistance > 0.0 ) {

		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );

	}

	return distanceFalloff;

#else

	if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {

		return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );

	}

	return 1.0;

#endif

}

vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {

	return RECIPROCAL_PI * diffuseColor;

} // validated

vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {

	// Original approximation by Christophe Schlick '94
	// float fresnel = pow( 1.0 - dotLH, 5.0 );

	// Optimized variant (presented by Epic at SIGGRAPH '13)
	// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
	float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );

	return ( 1.0 - specularColor ) * fresnel + specularColor;

} // validated

vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {

	// See F_Schlick
	float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
	vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;

	return Fr * fresnel + F0;

}


// Microfacet Models for Refraction through Rough Surfaces - equation (34)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney\u2019s reparameterization
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {

	// geometry term (normalized) = G(l)\u22C5G(v) / 4(n\u22C5l)(n\u22C5v)
	// also see #12151

	float a2 = pow2( alpha );

	float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );

	return 1.0 / ( gl * gv );

} // validated

// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {

	float a2 = pow2( alpha );

	// dotNL and dotNV are explicitly swapped. This is not a mistake.
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );

	return 0.5 / max( gv + gl, EPSILON );

}

// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney\u2019s reparameterization
float D_GGX( const in float alpha, const in float dotNH ) {

	float a2 = pow2( alpha );

	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1

	return RECIPROCAL_PI * a2 / pow2( denom );

}

// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {

	float alpha = pow2( roughness ); // UE4's roughness

	vec3 halfDir = normalize( incidentLight.direction + viewDir );

	float dotNL = saturate( dot( normal, incidentLight.direction ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );

	vec3 F = F_Schlick( specularColor, dotLH );

	float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );

	float D = D_GGX( alpha, dotNH );

	return F * ( G * D );

} // validated

// Rect Area Light

// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt
// code: https://github.com/selfshadow/ltc_code/

vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {

	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;

	float dotNV = saturate( dot( N, V ) );

	// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );

	uv = uv * LUT_SCALE + LUT_BIAS;

	return uv;

}

float LTC_ClippedSphereFormFactor( const in vec3 f ) {

	// Real-Time Area Lighting: a Journey from Research to Production (p.102)
	// An approximation of the form factor of a horizon-clipped rectangle.

	float l = length( f );

	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );

}

vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {

	float x = dot( v1, v2 );

	float y = abs( x );

	// rational polynomial approximation to theta / sin( theta ) / 2PI
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;

	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;

	return cross( v1, v2 ) * theta_sintheta;

}

vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {

	// bail if point is on back side of plane of light
	// assumes ccw winding order of light vertices
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );

	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );

	// construct orthonormal basis around N
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system

	// compute transform
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );

	// transform rect
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );

	// project rect onto sphere
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );

	// calculate vector form factor
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );

	// adjust for horizon clipping
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );

/*
	// alternate method of adjusting for horizon clipping (see referece)
	// refactoring required
	float len = length( vectorFormFactor );
	float z = vectorFormFactor.z / len;

	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;

	// tabulated horizon-clipped sphere, apparently...
	vec2 uv = vec2( z * 0.5 + 0.5, len );
	uv = uv * LUT_SCALE + LUT_BIAS;

	float scale = texture2D( ltc_2, uv ).w;

	float result = len * scale;
*/

	return vec3( result );

}

// End Rect Area Light

// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile
vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {

	float dotNV = saturate( dot( normal, viewDir ) );

	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );

	return specularColor * brdf.x + brdf.y;

} // validated

// Fdez-Ag\xFCera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
// Approximates multiscattering in order to preserve energy.
// http://www.jcgt.org/published/0008/01/03/
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {

	float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );

	vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
	vec3 FssEss = F * brdf.x + brdf.y;

	float Ess = brdf.x + brdf.y;
	float Ems = 1.0 - Ess;

	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21
	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );

	singleScatter += FssEss;
	multiScatter += Fms * Ems;

}

float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {

	// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
	return 0.25;

}

float D_BlinnPhong( const in float shininess, const in float dotNH ) {

	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );

}

vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {

	vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );

	//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );
	//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
	float dotNH = saturate( dot( geometry.normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );

	vec3 F = F_Schlick( specularColor, dotLH );

	float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );

	float D = D_BlinnPhong( shininess, dotNH );

	return F * ( G * D );

} // validated

// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
	return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
}

float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
	return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
}

#if defined( USE_SHEEN )

// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94
float D_Charlie(float roughness, float NoH) {
	// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"
	float invAlpha = 1.0 / roughness;
	float cos2h = NoH * NoH;
	float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16
	return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
}

// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136
float V_Neubelt(float NoV, float NoL) {
	// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
	return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
}

vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {

	vec3 N = geometry.normal;
	vec3 V = geometry.viewDir;

	vec3 H = normalize( V + L );
	float dotNH = saturate( dot( N, H ) );

	return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );

}

#endif
`;var Kw=`
#ifdef USE_BUMPMAP

	uniform sampler2D bumpMap;
	uniform float bumpScale;

	// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
	// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf

	// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)

	vec2 dHdxy_fwd() {

		vec2 dSTdx = dFdx( vUv );
		vec2 dSTdy = dFdy( vUv );

		float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;

		return vec2( dBx, dBy );

	}

	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {

		// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988

		vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
		vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
		vec3 vN = surf_norm;		// normalized

		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );

		float fDet = dot( vSigmaX, R1 );

		fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );

		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );

	}

#endif
`;var eM=`
#if NUM_CLIPPING_PLANES > 0

	vec4 plane;

	#pragma unroll_loop_start
	for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {

		plane = clippingPlanes[ i ];
		if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;

	}
	#pragma unroll_loop_end

	#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES

		bool clipped = true;

		#pragma unroll_loop_start
		for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {

			plane = clippingPlanes[ i ];
			clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;

		}
		#pragma unroll_loop_end

		if ( clipped ) discard;

	#endif

#endif
`;var tM=`
#if NUM_CLIPPING_PLANES > 0

	varying vec3 vClipPosition;

	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];

#endif
`;var nM=`
#if NUM_CLIPPING_PLANES > 0

	varying vec3 vClipPosition;

#endif
`;var rM=`
#if NUM_CLIPPING_PLANES > 0

	vClipPosition = - mvPosition.xyz;

#endif
`;var iM=`
#ifdef USE_COLOR

	diffuseColor.rgb *= vColor;

#endif
`;var oM=`
#ifdef USE_COLOR

	varying vec3 vColor;

#endif
`;var sM=`
#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )

	varying vec3 vColor;

#endif
`;var aM=`
#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )

	vColor = vec3( 1.0 );

#endif

#ifdef USE_COLOR

	vColor.xyz *= color.xyz;

#endif

#ifdef USE_INSTANCING_COLOR

	vColor.xyz *= instanceColor.xyz;

#endif
`;var cM=`
#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6

#ifndef saturate
// <tonemapping_pars_fragment> may have defined saturate() already
#define saturate(a) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement(a) ( 1.0 - saturate( a ) )

float pow2( const in float x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.
// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract(sin(sn) * c);
}

#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif

struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};

struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};

struct GeometricContext {
	vec3 position;
	vec3 normal;
	vec3 viewDir;
#ifdef CLEARCOAT
	vec3 clearcoatNormal;
#endif
};

vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

}

vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {

	// dir can be either a direction vector or a normal vector
	// upper-left 3x3 of matrix is assumed to be orthogonal

	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );

}

vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {

	float distance = dot( planeNormal, point - pointOnPlane );

	return - distance * planeNormal + point;

}

float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {

	return sign( dot( point - pointOnPlane, planeNormal ) );

}

vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {

	return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;

}

mat3 transposeMat3( const in mat3 m ) {

	mat3 tmp;

	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );

	return tmp;

}

// https://en.wikipedia.org/wiki/Relative_luminance
float linearToRelativeLuminance( const in vec3 color ) {

	vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );

	return dot( weights, color.rgb );

}

bool isPerspectiveMatrix( mat4 m ) {

	return m[ 2 ][ 3 ] == - 1.0;

}

vec2 equirectUv( in vec3 dir ) {

	// dir is assumed to be unit length

	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;

	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;

	return vec2( u, v );

}
`;var lM=`
#ifdef ENVMAP_TYPE_CUBE_UV

	#define cubeUV_maxMipLevel 8.0
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_maxTileSize 256.0
	#define cubeUV_minTileSize 16.0

	// These shader functions convert between the UV coordinates of a single face of
	// a cubemap, the 0-5 integer index of a cube face, and the direction vector for
	// sampling a textureCube (not generally normalized ).

	float getFace( vec3 direction ) {

		vec3 absDirection = abs( direction );

		float face = - 1.0;

		if ( absDirection.x > absDirection.z ) {

			if ( absDirection.x > absDirection.y )

				face = direction.x > 0.0 ? 0.0 : 3.0;

			else

				face = direction.y > 0.0 ? 1.0 : 4.0;

		} else {

			if ( absDirection.z > absDirection.y )

				face = direction.z > 0.0 ? 2.0 : 5.0;

			else

				face = direction.y > 0.0 ? 1.0 : 4.0;

		}

		return face;

	}

	// RH coordinate system; PMREM face-indexing convention
	vec2 getUV( vec3 direction, float face ) {

		vec2 uv;

		if ( face == 0.0 ) {

			uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x

		} else if ( face == 1.0 ) {

			uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y

		} else if ( face == 2.0 ) {

			uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z

		} else if ( face == 3.0 ) {

			uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x

		} else if ( face == 4.0 ) {

			uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y

		} else {

			uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z

		}

		return 0.5 * ( uv + 1.0 );

	}

	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {

		float face = getFace( direction );

		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );

		mipInt = max( mipInt, cubeUV_minMipLevel );

		float faceSize = exp2( mipInt );

		float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );

		vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );

		vec2 f = fract( uv );

		uv += 0.5 - f;

		if ( face > 2.0 ) {

			uv.y += faceSize;

			face -= 3.0;

		}

		uv.x += face * faceSize;

		if ( mipInt < cubeUV_maxMipLevel ) {

			uv.y += 2.0 * cubeUV_maxTileSize;

		}

		uv.y += filterInt * 2.0 * cubeUV_minTileSize;

		uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );

		uv *= texelSize;

		vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;

		uv.x += texelSize;

		vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;

		uv.y += texelSize;

		vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;

		uv.x -= texelSize;

		vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;

		vec3 tm = mix( tl, tr, f.x );

		vec3 bm = mix( bl, br, f.x );

		return mix( tm, bm, f.y );

	}

	// These defines must match with PMREMGenerator

	#define r0 1.0
	#define v0 0.339
	#define m0 - 2.0
	#define r1 0.8
	#define v1 0.276
	#define m1 - 1.0
	#define r4 0.4
	#define v4 0.046
	#define m4 2.0
	#define r5 0.305
	#define v5 0.016
	#define m5 3.0
	#define r6 0.21
	#define v6 0.0038
	#define m6 4.0

	float roughnessToMip( float roughness ) {

		float mip = 0.0;

		if ( roughness >= r1 ) {

			mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;

		} else if ( roughness >= r4 ) {

			mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;

		} else if ( roughness >= r5 ) {

			mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;

		} else if ( roughness >= r6 ) {

			mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;

		} else {

			mip = - 2.0 * log2( 1.16 * roughness ); // 1.16 = 1.79^0.25
		}

		return mip;

	}

	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {

		float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );

		float mipF = fract( mip );

		float mipInt = floor( mip );

		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );

		if ( mipF == 0.0 ) {

			return vec4( color0, 1.0 );

		} else {

			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );

			return vec4( mix( color0, color1, mipF ), 1.0 );

		}

	}

#endif
`;var uM=`
vec3 transformedNormal = objectNormal;

#ifdef USE_INSTANCING

	// this is in lieu of a per-instance normal-matrix
	// shear transforms in the instance matrix are not supported

	mat3 m = mat3( instanceMatrix );

	transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );

	transformedNormal = m * transformedNormal;

#endif

transformedNormal = normalMatrix * transformedNormal;

#ifdef FLIP_SIDED

	transformedNormal = - transformedNormal;

#endif

#ifdef USE_TANGENT

	vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;

	#ifdef FLIP_SIDED

		transformedTangent = - transformedTangent;

	#endif

#endif
`;var hM=`
#ifdef USE_DISPLACEMENTMAP

	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;

#endif
`;var fM=`
#ifdef USE_DISPLACEMENTMAP

	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );

#endif
`;var dM=`
#ifdef USE_EMISSIVEMAP

	vec4 emissiveColor = texture2D( emissiveMap, vUv );

	emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;

	totalEmissiveRadiance *= emissiveColor.rgb;

#endif
`;var pM=`
#ifdef USE_EMISSIVEMAP

	uniform sampler2D emissiveMap;

#endif
`;var mM=`
gl_FragColor = linearToOutputTexel( gl_FragColor );
`;var gM=`
// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/

vec4 LinearToLinear( in vec4 value ) {
	return value;
}

vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
}

vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
}

vec4 sRGBToLinear( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}

vec4 LinearTosRGB( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}

vec4 RGBEToLinear( in vec4 value ) {
	return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
}

vec4 LinearToRGBE( in vec4 value ) {
	float maxComponent = max( max( value.r, value.g ), value.b );
	float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
	return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
	// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );
}

// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * value.a * maxRange, 1.0 );
}

vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
	M = ceil( M * 255.0 ) / 255.0;
	return vec4( value.rgb / ( M * maxRange ), M );
}

// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
}

vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float D = max( maxRange / maxRGB, 1.0 );
	// NOTE: The implementation with min causes the shader to not compile on
	// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests 
	// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.
	// D = min( floor( D ) / 255.0, 1.0 );
	D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
	return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
}

// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html

// M matrix, for encoding
const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
vec4 LinearToLogLuv( in vec4 value ) {
	vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
	Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
	vec4 vResult;
	vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
	float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
	vResult.w = fract( Le );
	vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
	return vResult;
}

// Inverse M matrix, for decoding
const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
vec4 LogLuvToLinear( in vec4 value ) {
	float Le = value.z * 255.0 + value.w;
	vec3 Xp_Y_XYZp;
	Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
	Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
	Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
	vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
	return vec4( max( vRGB, 0.0 ), 1.0 );
}
`;var vM=`
#ifdef USE_ENVMAP

	#ifdef ENV_WORLDPOS

		vec3 cameraToFrag;

		if ( isOrthographic ) {

			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );

		} else {

			cameraToFrag = normalize( vWorldPosition - cameraPosition );

		}

		// Transforming Normal Vectors with the Inverse Transformation
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );

		#ifdef ENVMAP_MODE_REFLECTION

			vec3 reflectVec = reflect( cameraToFrag, worldNormal );

		#else

			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );

		#endif

	#else

		vec3 reflectVec = vReflect;

	#endif

	#ifdef ENVMAP_TYPE_CUBE

		vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );

	#elif defined( ENVMAP_TYPE_CUBE_UV )

		vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );

	#else

		vec4 envColor = vec4( 0.0 );

	#endif

	#ifndef ENVMAP_TYPE_CUBE_UV

		envColor = envMapTexelToLinear( envColor );

	#endif

	#ifdef ENVMAP_BLENDING_MULTIPLY

		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );

	#elif defined( ENVMAP_BLENDING_MIX )

		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );

	#elif defined( ENVMAP_BLENDING_ADD )

		outgoingLight += envColor.xyz * specularStrength * reflectivity;

	#endif

#endif
`;var yM=`
#ifdef USE_ENVMAP

	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform int maxMipLevel;

	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif
`;var xM=`
#ifdef USE_ENVMAP

	uniform float reflectivity;

	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )

		#define ENV_WORLDPOS

	#endif

	#ifdef ENV_WORLDPOS

		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif

#endif
`;var _M=`
#ifdef USE_ENVMAP

	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )

		#define ENV_WORLDPOS

	#endif

	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;

	#else

		varying vec3 vReflect;
		uniform float refractionRatio;

	#endif

#endif
`;var bM=`
#ifdef USE_ENVMAP

	#ifdef ENV_WORLDPOS

		vWorldPosition = worldPosition.xyz;

	#else

		vec3 cameraToVertex;

		if ( isOrthographic ) {

			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );

		} else {

			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );

		}

		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );

		#ifdef ENVMAP_MODE_REFLECTION

			vReflect = reflect( cameraToVertex, worldNormal );

		#else

			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );

		#endif

	#endif

#endif
`;var wM=`
#ifdef USE_FOG

	fogDepth = - mvPosition.z;

#endif
`;var MM=`
#ifdef USE_FOG

	varying float fogDepth;

#endif
`;var EM=`
#ifdef USE_FOG

	#ifdef FOG_EXP2

		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );

	#else

		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );

	#endif

	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );

#endif
`;var SM=`
#ifdef USE_FOG

	uniform vec3 fogColor;
	varying float fogDepth;

	#ifdef FOG_EXP2

		uniform float fogDensity;

	#else

		uniform float fogNear;
		uniform float fogFar;

	#endif

#endif
`;var TM=`

#ifdef USE_GRADIENTMAP

	uniform sampler2D gradientMap;

#endif

vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {

	// dotNL will be from -1.0 to 1.0
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );

	#ifdef USE_GRADIENTMAP

		return texture2D( gradientMap, coord ).rgb;

	#else

		return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );

	#endif

}
`;var AM=`
#ifdef USE_LIGHTMAP

	vec4 lightMapTexel= texture2D( lightMap, vUv2 );
	reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage

#endif
`;var CM=`
#ifdef USE_LIGHTMAP

	uniform sampler2D lightMap;
	uniform float lightMapIntensity;

#endif
`;var RM=`
vec3 diffuse = vec3( 1.0 );

GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );

GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;

vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
	vLightBack = vec3( 0.0 );
	vIndirectBack = vec3( 0.0 );
#endif

IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;

vIndirectFront += getAmbientLightIrradiance( ambientLightColor );

vIndirectFront += getLightProbeIrradiance( lightProbe, geometry );

#ifdef DOUBLE_SIDED

	vIndirectBack += getAmbientLightIrradiance( ambientLightColor );

	vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );

#endif

#if NUM_POINT_LIGHTS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {

		getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );

		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;

		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;

		#ifdef DOUBLE_SIDED

			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;

		#endif

	}
	#pragma unroll_loop_end

#endif

#if NUM_SPOT_LIGHTS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {

		getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );

		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;

		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;

		#ifdef DOUBLE_SIDED

			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;

		#endif
	}
	#pragma unroll_loop_end

#endif

/*
#if NUM_RECT_AREA_LIGHTS > 0

	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {

		// TODO (abelnation): implement

	}

#endif
*/

#if NUM_DIR_LIGHTS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {

		getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );

		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;

		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;

		#ifdef DOUBLE_SIDED

			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;

		#endif

	}
	#pragma unroll_loop_end

#endif

#if NUM_HEMI_LIGHTS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {

		vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );

		#ifdef DOUBLE_SIDED

			vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );

		#endif

	}
	#pragma unroll_loop_end

#endif
`;var PM=`
uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];

// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {

	// normal is assumed to have unit length

	float x = normal.x, y = normal.y, z = normal.z;

	// band 0
	vec3 result = shCoefficients[ 0 ] * 0.886227;

	// band 1
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;

	// band 2
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );

	return result;

}

vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {

	vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );

	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );

	return irradiance;

}

vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {

	vec3 irradiance = ambientLightColor;

	#ifndef PHYSICALLY_CORRECT_LIGHTS

		irradiance *= PI;

	#endif

	return irradiance;

}

#if NUM_DIR_LIGHTS > 0

	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};

	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];

	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {

		directLight.color = directionalLight.color;
		directLight.direction = directionalLight.direction;
		directLight.visible = true;

	}

#endif


#if NUM_POINT_LIGHTS > 0

	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};

	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];

	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
	void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {

		vec3 lVector = pointLight.position - geometry.position;
		directLight.direction = normalize( lVector );

		float lightDistance = length( lVector );

		directLight.color = pointLight.color;
		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
		directLight.visible = ( directLight.color != vec3( 0.0 ) );

	}

#endif


#if NUM_SPOT_LIGHTS > 0

	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};

	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];

	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
	void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {

		vec3 lVector = spotLight.position - geometry.position;
		directLight.direction = normalize( lVector );

		float lightDistance = length( lVector );
		float angleCos = dot( directLight.direction, spotLight.direction );

		if ( angleCos > spotLight.coneCos ) {

			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );

			directLight.color = spotLight.color;
			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
			directLight.visible = true;

		} else {

			directLight.color = vec3( 0.0 );
			directLight.visible = false;

		}
	}

#endif


#if NUM_RECT_AREA_LIGHTS > 0

	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};

	// Pre-computed values of LinearTransformedCosine approximation of BRDF
	// BRDF approximation Texture is 64x64
	uniform sampler2D ltc_1; // RGBA Float
	uniform sampler2D ltc_2; // RGBA Float

	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];

#endif


#if NUM_HEMI_LIGHTS > 0

	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};

	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];

	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {

		float dotNL = dot( geometry.normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;

		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );

		#ifndef PHYSICALLY_CORRECT_LIGHTS

			irradiance *= PI;

		#endif

		return irradiance;

	}

#endif
`;var LM=`
#if defined( USE_ENVMAP )

	#ifdef ENVMAP_MODE_REFRACTION
		uniform float refractionRatio;
	#endif

	vec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {

		vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );

		#ifdef ENVMAP_TYPE_CUBE

			vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );

			// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level
			// of a specular cubemap, or just the default level of a specially created irradiance cubemap.

			#ifdef TEXTURE_LOD_EXT

				vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );

			#else

				// force the bias high to get the last LOD level as it is the most blurred.
				vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );

			#endif

			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;

		#elif defined( ENVMAP_TYPE_CUBE_UV )

			vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );

		#else

			vec4 envMapColor = vec4( 0.0 );

		#endif

		return PI * envMapColor.rgb * envMapIntensity;

	}

	// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
	float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {

		float maxMIPLevelScalar = float( maxMIPLevel );

		float sigma = PI * roughness * roughness / ( 1.0 + roughness );
		float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );

		// clamp to allowable LOD ranges.
		return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );

	}

	vec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {

		#ifdef ENVMAP_MODE_REFLECTION

			vec3 reflectVec = reflect( -viewDir, normal );

			// Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );

		#else

			vec3 reflectVec = refract( -viewDir, normal, refractionRatio );

		#endif

		reflectVec = inverseTransformDirection( reflectVec, viewMatrix );

		float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );

		#ifdef ENVMAP_TYPE_CUBE

			vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );

			#ifdef TEXTURE_LOD_EXT

				vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );

			#else

				vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );

			#endif

			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;

		#elif defined( ENVMAP_TYPE_CUBE_UV )

			vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );

		#endif

		return envMapColor.rgb * envMapIntensity;

	}

#endif
`;var FM=`
ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;
`;var IM=`
varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif


struct ToonMaterial {

	vec3 diffuseColor;

};

void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {

	vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;

	#ifndef PHYSICALLY_CORRECT_LIGHTS

		irradiance *= PI; // punctual light

	#endif

	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );

}

void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {

	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );

}

#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon

#define Material_LightProbeLOD( material )	(0)
`;var DM=`
BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;
`;var BM=`
varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif


struct BlinnPhongMaterial {

	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;

};

void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {

	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;

	#ifndef PHYSICALLY_CORRECT_LIGHTS

		irradiance *= PI; // punctual light

	#endif

	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );

	reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;

}

void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {

	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );

}

#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong

#define Material_LightProbeLOD( material )	(0)
`;var OM=`
PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );

vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );

material.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
material.specularRoughness += geometryRoughness;
material.specularRoughness = min( material.specularRoughness, 1.0 );

#ifdef REFLECTIVITY

	material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );

#else

	material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );

#endif

#ifdef CLEARCOAT

	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;

	#ifdef USE_CLEARCOATMAP

		material.clearcoat *= texture2D( clearcoatMap, vUv ).x;

	#endif

	#ifdef USE_CLEARCOAT_ROUGHNESSMAP

		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;

	#endif

	material.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model
	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );

#endif

#ifdef USE_SHEEN

	material.sheenColor = sheen;

#endif
`;var UM=`
struct PhysicalMaterial {

	vec3 diffuseColor;
	float specularRoughness;
	vec3 specularColor;

#ifdef CLEARCOAT
	float clearcoat;
	float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
	vec3 sheenColor;
#endif

};

#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
#define DEFAULT_SPECULAR_COEFFICIENT 0.04

// Clear coat directional hemishperical reflectance (this approximation should be improved)
float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {

	return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );

}

#if NUM_RECT_AREA_LIGHTS > 0

	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {

		vec3 normal = geometry.normal;
		vec3 viewDir = geometry.viewDir;
		vec3 position = geometry.position;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.specularRoughness;

		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction
		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;

		vec2 uv = LTC_Uv( normal, viewDir, roughness );

		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );

		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);

		// LTC Fresnel Approximation by Stephen Hill
		// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );

		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );

		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );

	}

#endif

void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {

	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );

	vec3 irradiance = dotNL * directLight.color;

	#ifndef PHYSICALLY_CORRECT_LIGHTS

		irradiance *= PI; // punctual light

	#endif

	#ifdef CLEARCOAT

		float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );

		vec3 ccIrradiance = ccDotNL * directLight.color;

		#ifndef PHYSICALLY_CORRECT_LIGHTS

			ccIrradiance *= PI; // punctual light

		#endif

		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );

		reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );

	#else

		float clearcoatDHR = 0.0;

	#endif

	#ifdef USE_SHEEN
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
			material.specularRoughness,
			directLight.direction,
			geometry,
			material.sheenColor
		);
	#else
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
	#endif

	reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}

void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {

	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );

}

void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {

	#ifdef CLEARCOAT

		float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );

		reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );

		float ccDotNL = ccDotNV;
		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );

	#else

		float clearcoatDHR = 0.0;

	#endif

	float clearcoatInv = 1.0 - clearcoatDHR;

	// Both indirect specular and indirect diffuse light accumulate here

	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;

	BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );

	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );

	reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;

	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;

}

#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical

// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {

	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );

}
`;var NM=`
/**
 * This is a template that can be used to light a material, it uses pluggable
 * RenderEquations (RE)for specific lighting scenarios.
 *
 * Instructions for use:
 * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined
 * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???
 * - Create a material parameter that is to be passed as the third parameter to your lighting functions.
 *
 * TODO:
 * - Add area light support.
 * - Add sphere light support.
 * - Add diffuse light probe (irradiance cubemap) support.
 */

GeometricContext geometry;

geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );

#ifdef CLEARCOAT

	geometry.clearcoatNormal = clearcoatNormal;

#endif

IncidentLight directLight;

#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )

	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {

		pointLight = pointLights[ i ];

		getPointDirectLightIrradiance( pointLight, geometry, directLight );

		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif

		RE_Direct( directLight, geometry, material, reflectedLight );

	}
	#pragma unroll_loop_end

#endif

#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )

	SpotLight spotLight;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {

		spotLight = spotLights[ i ];

		getSpotDirectLightIrradiance( spotLight, geometry, directLight );

		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
		#endif

		RE_Direct( directLight, geometry, material, reflectedLight );

	}
	#pragma unroll_loop_end

#endif

#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )

	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {

		directionalLight = directionalLights[ i ];

		getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );

		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif

		RE_Direct( directLight, geometry, material, reflectedLight );

	}
	#pragma unroll_loop_end

#endif

#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )

	RectAreaLight rectAreaLight;

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {

		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );

	}
	#pragma unroll_loop_end

#endif

#if defined( RE_IndirectDiffuse )

	vec3 iblIrradiance = vec3( 0.0 );

	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );

	irradiance += getLightProbeIrradiance( lightProbe, geometry );

	#if ( NUM_HEMI_LIGHTS > 0 )

		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {

			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );

		}
		#pragma unroll_loop_end

	#endif

#endif

#if defined( RE_IndirectSpecular )

	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );

#endif
`;var GM=`
#if defined( RE_IndirectDiffuse )

	#ifdef USE_LIGHTMAP

		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;

		#ifndef PHYSICALLY_CORRECT_LIGHTS

			lightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage

		#endif

		irradiance += lightMapIrradiance;

	#endif

	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )

		iblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );

	#endif

#endif

#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )

	radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );

	#ifdef CLEARCOAT

		clearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );

	#endif

#endif
`;var kM=`
#if defined( RE_IndirectDiffuse )

	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );

#endif

#if defined( RE_IndirectSpecular )

	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );

#endif
`;var HM=`
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )

	// Doing a strict comparison with == 1.0 can cause noise artifacts
	// on some platforms. See issue #17623.
	gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;

#endif
`;var zM=`
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )

	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;

#endif
`;var VM=`
#ifdef USE_LOGDEPTHBUF

	#ifdef USE_LOGDEPTHBUF_EXT

		varying float vFragDepth;
		varying float vIsPerspective;

	#else

		uniform float logDepthBufFC;

	#endif

#endif
`;var WM=`
#ifdef USE_LOGDEPTHBUF

	#ifdef USE_LOGDEPTHBUF_EXT

		vFragDepth = 1.0 + gl_Position.w;
		vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );

	#else

		if ( isPerspectiveMatrix( projectionMatrix ) ) {

			gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;

			gl_Position.z *= gl_Position.w;

		}

	#endif

#endif
`;var jM=`
#ifdef USE_MAP

	vec4 texelColor = texture2D( map, vUv );

	texelColor = mapTexelToLinear( texelColor );
	diffuseColor *= texelColor;

#endif
`;var qM=`
#ifdef USE_MAP

	uniform sampler2D map;

#endif
`;var XM=`
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )

	vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;

#endif

#ifdef USE_MAP

	vec4 mapTexel = texture2D( map, uv );
	diffuseColor *= mapTexelToLinear( mapTexel );

#endif

#ifdef USE_ALPHAMAP

	diffuseColor.a *= texture2D( alphaMap, uv ).g;

#endif
`;var YM=`
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )

	uniform mat3 uvTransform;

#endif

#ifdef USE_MAP

	uniform sampler2D map;

#endif

#ifdef USE_ALPHAMAP

	uniform sampler2D alphaMap;

#endif
`;var $M=`
float metalnessFactor = metalness;

#ifdef USE_METALNESSMAP

	vec4 texelMetalness = texture2D( metalnessMap, vUv );

	// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
	metalnessFactor *= texelMetalness.b;

#endif
`;var ZM=`
#ifdef USE_METALNESSMAP

	uniform sampler2D metalnessMap;

#endif
`;var JM=`
#ifdef USE_MORPHNORMALS

	// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
	// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)
	// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
	objectNormal *= morphTargetBaseInfluence;
	objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
	objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
	objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
	objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];

#endif
`;var QM=`
#ifdef USE_MORPHTARGETS

	uniform float morphTargetBaseInfluence;

	#ifndef USE_MORPHNORMALS

		uniform float morphTargetInfluences[ 8 ];

	#else

		uniform float morphTargetInfluences[ 4 ];

	#endif

#endif
`;var KM=`
#ifdef USE_MORPHTARGETS

	// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
	// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)
	// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
	transformed *= morphTargetBaseInfluence;
	transformed += morphTarget0 * morphTargetInfluences[ 0 ];
	transformed += morphTarget1 * morphTargetInfluences[ 1 ];
	transformed += morphTarget2 * morphTargetInfluences[ 2 ];
	transformed += morphTarget3 * morphTargetInfluences[ 3 ];

	#ifndef USE_MORPHNORMALS

		transformed += morphTarget4 * morphTargetInfluences[ 4 ];
		transformed += morphTarget5 * morphTargetInfluences[ 5 ];
		transformed += morphTarget6 * morphTargetInfluences[ 6 ];
		transformed += morphTarget7 * morphTargetInfluences[ 7 ];

	#endif

#endif
`;var eE=`
#ifdef FLAT_SHADED

	// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...

	vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
	vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
	vec3 normal = normalize( cross( fdx, fdy ) );

#else

	vec3 normal = normalize( vNormal );

	#ifdef DOUBLE_SIDED

		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );

	#endif

	#ifdef USE_TANGENT

		vec3 tangent = normalize( vTangent );
		vec3 bitangent = normalize( vBitangent );

		#ifdef DOUBLE_SIDED

			tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
			bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );

		#endif

		#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )

			mat3 vTBN = mat3( tangent, bitangent, normal );

		#endif

	#endif

#endif

// non perturbed normal for clearcoat among others

vec3 geometryNormal = normal;

`;var tE=`

#ifdef OBJECTSPACE_NORMALMAP

	normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals

	#ifdef FLIP_SIDED

		normal = - normal;

	#endif

	#ifdef DOUBLE_SIDED

		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );

	#endif

	normal = normalize( normalMatrix * normal );

#elif defined( TANGENTSPACE_NORMALMAP )

	vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;

	#ifdef USE_TANGENT

		normal = normalize( vTBN * mapN );

	#else

		normal = perturbNormal2Arb( -vViewPosition, normal, mapN );

	#endif

#elif defined( USE_BUMPMAP )

	normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );

#endif
`;var nE=`
#ifdef USE_NORMALMAP

	uniform sampler2D normalMap;
	uniform vec2 normalScale;

#endif

#ifdef OBJECTSPACE_NORMALMAP

	uniform mat3 normalMatrix;

#endif

#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )

	// Per-Pixel Tangent Space Normal Mapping
	// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html

	vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {

		// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988

		vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
		vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
		vec2 st0 = dFdx( vUv.st );
		vec2 st1 = dFdy( vUv.st );

		float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude

		vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
		vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
		vec3 N = normalize( surf_norm );

		mat3 tsn = mat3( S, T, N );

		mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );

		return normalize( tsn * mapN );

	}

#endif
`;var rE=`
#ifdef CLEARCOAT

	vec3 clearcoatNormal = geometryNormal;

#endif
`;var iE=`
#ifdef USE_CLEARCOAT_NORMALMAP

	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;

	#ifdef USE_TANGENT

		clearcoatNormal = normalize( vTBN * clearcoatMapN );

	#else

		clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );

	#endif

#endif
`;var oE=`

#ifdef USE_CLEARCOATMAP

	uniform sampler2D clearcoatMap;

#endif

#ifdef USE_CLEARCOAT_ROUGHNESSMAP

	uniform sampler2D clearcoatRoughnessMap;

#endif

#ifdef USE_CLEARCOAT_NORMALMAP

	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;

#endif
`;var sE=`
vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}

vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}

const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)
const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)

const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );

const float ShiftRight8 = 1. / 256.;

vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8; // tidy overflow
	return r * PackUpscale;
}

float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}

vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}

// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions

float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
	return linearClipZ * ( near - far ) - near;
}

float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * invClipZ - far );
}
`;var aE=`
#ifdef PREMULTIPLIED_ALPHA

	// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
	gl_FragColor.rgb *= gl_FragColor.a;

#endif
`;var cE=`
vec4 mvPosition = vec4( transformed, 1.0 );

#ifdef USE_INSTANCING

	mvPosition = instanceMatrix * mvPosition;

#endif

mvPosition = modelViewMatrix * mvPosition;

gl_Position = projectionMatrix * mvPosition;
`;var lE=`
#ifdef DITHERING

	gl_FragColor.rgb = dithering( gl_FragColor.rgb );

#endif
`;var uE=`
#ifdef DITHERING

	// based on https://www.shadertoy.com/view/MslGR8
	vec3 dithering( vec3 color ) {
		//Calculate grid position
		float grid_position = rand( gl_FragCoord.xy );

		//Shift the individual colors differently, thus making it even harder to see the dithering pattern
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );

		//modify shift acording to grid position.
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );

		//shift the color by dither_shift
		return color + dither_shift_RGB;
	}

#endif
`;var hE=`
float roughnessFactor = roughness;

#ifdef USE_ROUGHNESSMAP

	vec4 texelRoughness = texture2D( roughnessMap, vUv );

	// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
	roughnessFactor *= texelRoughness.g;

#endif
`;var fE=`
#ifdef USE_ROUGHNESSMAP

	uniform sampler2D roughnessMap;

#endif
`;var dE=`
#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHT_SHADOWS > 0

		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];

		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};

		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];

	#endif

	#if NUM_SPOT_LIGHT_SHADOWS > 0

		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];

		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};

		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];

	#endif

	#if NUM_POINT_LIGHT_SHADOWS > 0

		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];

		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};

		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];

	#endif

	/*
	#if NUM_RECT_AREA_LIGHTS > 0

		// TODO (abelnation): create uniforms for area light shadows

	#endif
	*/

	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {

		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );

	}

	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {

		return unpackRGBATo2Half( texture2D( shadow, uv ) );

	}

	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){

		float occlusion = 1.0;

		vec2 distribution = texture2DDistribution( shadow, uv );

		float hard_shadow = step( compare , distribution.x ); // Hard Shadow

		if (hard_shadow != 1.0 ) {

			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );

		}
		return occlusion;

	}

	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {

		float shadow = 1.0;

		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;

		// if ( something && something ) breaks ATI OpenGL shader compiler
		// if ( all( something, something ) ) using this instead

		bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
		bool inFrustum = all( inFrustumVec );

		bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );

		bool frustumTest = all( frustumTestVec );

		if ( frustumTest ) {

		#if defined( SHADOWMAP_TYPE_PCF )

			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;

			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;

			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );

		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )

			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;

			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;

			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );

		#elif defined( SHADOWMAP_TYPE_VSM )

			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );

		#else // no percentage-closer filtering:

			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );

		#endif

		}

		return shadow;

	}

	// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
	// vector suitable for 2D texture mapping. This code uses the following layout for the
	// 2D texture:
	//
	// xzXZ
	//  y Y
	//
	// Y - Positive y direction
	// y - Negative y direction
	// X - Positive x direction
	// x - Negative x direction
	// Z - Positive z direction
	// z - Negative z direction
	//
	// Source and test bed:
	// https://gist.github.com/tschw/da10c43c467ce8afd0c4

	vec2 cubeToUV( vec3 v, float texelSizeY ) {

		// Number of texels to avoid at the edge of each square

		vec3 absV = abs( v );

		// Intersect unit cube

		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;

		// Apply scale to avoid seams

		// two texels less per square (one texel will do for NEAREST)
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );

		// Unwrap

		// space: -1 ... 1 range for each square
		//
		// #X##		dim    := ( 4 , 2 )
		//  # #		center := ( 1 , 1 )

		vec2 planar = v.xy;

		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;

		if ( absV.z >= almostOne ) {

			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;

		} else if ( absV.x >= almostOne ) {

			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;

		} else if ( absV.y >= almostOne ) {

			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;

		}

		// Transform to UV space

		// scale := 0.5 / dim
		// translate := ( center + 0.5 ) / dim
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );

	}

	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {

		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );

		// for point lights, the uniform @vShadowCoord is re-purposed to hold
		// the vector from the light to the world-space position of the fragment.
		vec3 lightToPosition = shadowCoord.xyz;

		// dp = normalized distance from light to fragment position
		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
		dp += shadowBias;

		// bd3D = base direction 3D
		vec3 bd3D = normalize( lightToPosition );

		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )

			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;

			return (
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
			) * ( 1.0 / 9.0 );

		#else // no percentage-closer filtering

			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );

		#endif

	}

#endif
`;var pE=`
#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHT_SHADOWS > 0

		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];

		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};

		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];

	#endif

	#if NUM_SPOT_LIGHT_SHADOWS > 0

		uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];

		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};

		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];

	#endif

	#if NUM_POINT_LIGHT_SHADOWS > 0

		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];

		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};

		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];

	#endif

	/*
	#if NUM_RECT_AREA_LIGHTS > 0

		// TODO (abelnation): uniforms for area light shadows

	#endif
	*/

#endif
`;var mE=`
#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0

		// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
		vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		vec4 shadowWorldPosition;

	#endif

	#if NUM_DIR_LIGHT_SHADOWS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {

		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
		vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;

	}
	#pragma unroll_loop_end

	#endif

	#if NUM_SPOT_LIGHT_SHADOWS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {

		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
		vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;

	}
	#pragma unroll_loop_end

	#endif

	#if NUM_POINT_LIGHT_SHADOWS > 0

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {

		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
		vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;

	}
	#pragma unroll_loop_end

	#endif

	/*
	#if NUM_RECT_AREA_LIGHTS > 0

		// TODO (abelnation): update vAreaShadowCoord with area light info

	#endif
	*/

#endif
`;var gE=`
float getShadowMask() {

	float shadow = 1.0;

	#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHT_SHADOWS > 0

	DirectionalLightShadow directionalLight;

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {

		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;

	}
	#pragma unroll_loop_end

	#endif

	#if NUM_SPOT_LIGHT_SHADOWS > 0

	SpotLightShadow spotLight;

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {

		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;

	}
	#pragma unroll_loop_end

	#endif

	#if NUM_POINT_LIGHT_SHADOWS > 0

	PointLightShadow pointLight;

	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {

		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;

	}
	#pragma unroll_loop_end

	#endif

	/*
	#if NUM_RECT_AREA_LIGHTS > 0

		// TODO (abelnation): update shadow for Area light

	#endif
	*/

	#endif

	return shadow;

}
`;var vE=`
#ifdef USE_SKINNING

	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );

#endif
`;var yE=`
#ifdef USE_SKINNING

	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;

	#ifdef BONE_TEXTURE

		uniform highp sampler2D boneTexture;
		uniform int boneTextureSize;

		mat4 getBoneMatrix( const in float i ) {

			float j = i * 4.0;
			float x = mod( j, float( boneTextureSize ) );
			float y = floor( j / float( boneTextureSize ) );

			float dx = 1.0 / float( boneTextureSize );
			float dy = 1.0 / float( boneTextureSize );

			y = dy * ( y + 0.5 );

			vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
			vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
			vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
			vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );

			mat4 bone = mat4( v1, v2, v3, v4 );

			return bone;

		}

	#else

		uniform mat4 boneMatrices[ MAX_BONES ];

		mat4 getBoneMatrix( const in float i ) {

			mat4 bone = boneMatrices[ int(i) ];
			return bone;

		}

	#endif

#endif
`;var xE=`
#ifdef USE_SKINNING

	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );

	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;

	transformed = ( bindMatrixInverse * skinned ).xyz;

#endif
`;var _E=`
#ifdef USE_SKINNING

	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;

	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;

	#ifdef USE_TANGENT

		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;

	#endif

#endif
`;var bE=`
float specularStrength;

#ifdef USE_SPECULARMAP

	vec4 texelSpecular = texture2D( specularMap, vUv );
	specularStrength = texelSpecular.r;

#else

	specularStrength = 1.0;

#endif
`;var wE=`
#ifdef USE_SPECULARMAP

	uniform sampler2D specularMap;

#endif
`;var ME=`
#if defined( TONE_MAPPING )

	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );

#endif
`;var EE=`
#ifndef saturate
// <common> may have defined saturate() already
#define saturate(a) clamp( a, 0.0, 1.0 )
#endif

uniform float toneMappingExposure;

// exposure only
vec3 LinearToneMapping( vec3 color ) {

	return toneMappingExposure * color;

}

// source: https://www.cs.utah.edu/~reinhard/cdrom/
vec3 ReinhardToneMapping( vec3 color ) {

	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );

}

// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/
vec3 OptimizedCineonToneMapping( vec3 color ) {

	// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );

}

// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
vec3 RRTAndODTFit( vec3 v ) {

	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;

}

// this implementation of ACES is modified to accommodate a brighter viewing environment.
// the scale factor of 1/0.6 is subjective. see discussion in #19621.

vec3 ACESFilmicToneMapping( vec3 color ) {

	// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);

	// ODT_SAT => XYZ => D60_2_D65 => sRGB
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ), // transposed from source
		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);

	color *= toneMappingExposure / 0.6;

	color = ACESInputMat * color;

	// Apply RRT and ODT
	color = RRTAndODTFit( color );

	color = ACESOutputMat * color;

	// Clamp to [0, 1]
	return saturate( color );

}

vec3 CustomToneMapping( vec3 color ) { return color; }
`;var SE=`
#ifdef USE_TRANSMISSIONMAP

	totalTransmission *= texture2D( transmissionMap, vUv ).r;

#endif
`;var TE=`
#ifdef USE_TRANSMISSIONMAP

	uniform sampler2D transmissionMap;

#endif
`;var AE=`
#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )

	varying vec2 vUv;

#endif
`;var CE=`
#ifdef USE_UV

	#ifdef UVS_VERTEX_ONLY

		vec2 vUv;

	#else

		varying vec2 vUv;

	#endif

	uniform mat3 uvTransform;

#endif
`;var RE=`
#ifdef USE_UV

	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;

#endif
`;var PE=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )

	varying vec2 vUv2;

#endif
`;var LE=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )

	attribute vec2 uv2;
	varying vec2 vUv2;

	uniform mat3 uv2Transform;

#endif
`;var FE=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )

	vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;

#endif
`;var IE=`
#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )

	vec4 worldPosition = vec4( transformed, 1.0 );

	#ifdef USE_INSTANCING

		worldPosition = instanceMatrix * worldPosition;

	#endif

	worldPosition = modelMatrix * worldPosition;

#endif
`;var DE=`
uniform sampler2D t2D;

varying vec2 vUv;

void main() {

	vec4 texColor = texture2D( t2D, vUv );

	gl_FragColor = mapTexelToLinear( texColor );

	#include <tonemapping_fragment>
	#include <encodings_fragment>

}
`;var BE=`
varying vec2 vUv;
uniform mat3 uvTransform;

void main() {

	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;

	gl_Position = vec4( position.xy, 1.0, 1.0 );

}
`;var OE=`
#include <envmap_common_pars_fragment>
uniform float opacity;

varying vec3 vWorldDirection;

#include <cube_uv_reflection_fragment>

void main() {

	vec3 vReflect = vWorldDirection;
	#include <envmap_fragment>

	gl_FragColor = envColor;
	gl_FragColor.a *= opacity;

	#include <tonemapping_fragment>
	#include <encodings_fragment>

}
`;var UE=`
varying vec3 vWorldDirection;

#include <common>

void main() {

	vWorldDirection = transformDirection( position, modelMatrix );

	#include <begin_vertex>
	#include <project_vertex>

	gl_Position.z = gl_Position.w; // set z to camera.far

}
`;var NE=`
#if DEPTH_PACKING == 3200

	uniform float opacity;

#endif

#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

varying vec2 vHighPrecisionZW;

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( 1.0 );

	#if DEPTH_PACKING == 3200

		diffuseColor.a = opacity;

	#endif

	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>

	#include <logdepthbuf_fragment>

	// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;

	#if DEPTH_PACKING == 3200

		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );

	#elif DEPTH_PACKING == 3201

		gl_FragColor = packDepthToRGBA( fragCoordZ );

	#endif

}
`;var GE=`
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.
// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for
// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.
varying vec2 vHighPrecisionZW;

void main() {

	#include <uv_vertex>

	#include <skinbase_vertex>

	#ifdef USE_DISPLACEMENTMAP

		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>

	#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

	vHighPrecisionZW = gl_Position.zw;

}
`;var kE=`
#define DISTANCE

uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;

#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <clipping_planes_pars_fragment>

void main () {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( 1.0 );

	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>

	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist ); // clamp to [ 0, 1 ]

	gl_FragColor = packDepthToRGBA( dist );

}
`;var HE=`
#define DISTANCE

varying vec3 vWorldPosition;

#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>

	#include <skinbase_vertex>

	#ifdef USE_DISPLACEMENTMAP

		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>

	#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>

	vWorldPosition = worldPosition.xyz;

}
`;var zE=`
uniform sampler2D tEquirect;

varying vec3 vWorldDirection;

#include <common>

void main() {

	vec3 direction = normalize( vWorldDirection );

	vec2 sampleUV = equirectUv( direction );

	vec4 texColor = texture2D( tEquirect, sampleUV );

	gl_FragColor = mapTexelToLinear( texColor );

	#include <tonemapping_fragment>
	#include <encodings_fragment>

}
`;var VE=`
varying vec3 vWorldDirection;

#include <common>

void main() {

	vWorldDirection = transformDirection( position, modelMatrix );

	#include <begin_vertex>
	#include <project_vertex>

}
`;var WE=`
uniform vec3 diffuse;
uniform float opacity;

uniform float dashSize;
uniform float totalSize;

varying float vLineDistance;

#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	if ( mod( vLineDistance, totalSize ) > dashSize ) {

		discard;

	}

	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );

	#include <logdepthbuf_fragment>
	#include <color_fragment>

	outgoingLight = diffuseColor.rgb; // simple shader

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>

}
`;var jE=`
uniform float scale;
attribute float lineDistance;

varying float vLineDistance;

#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	vLineDistance = scale * lineDistance;

	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>

}
`;var qE=`
uniform vec3 diffuse;
uniform float opacity;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>

	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );

	// accumulation (baked indirect lighting only)
	#ifdef USE_LIGHTMAP
	
		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;

	#else

		reflectedLight.indirectDiffuse += vec3( 1.0 );

	#endif

	// modulation
	#include <aomap_fragment>

	reflectedLight.indirectDiffuse *= diffuseColor.rgb;

	vec3 outgoingLight = reflectedLight.indirectDiffuse;

	#include <envmap_fragment>

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>

}
`;var XE=`
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <skinbase_vertex>

	#ifdef USE_ENVMAP

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

	#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>

	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>

}
`;var YE=`
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;

varying vec3 vLightFront;
varying vec3 vIndirectFront;

#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif


#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <emissivemap_fragment>

	// accumulation

	#ifdef DOUBLE_SIDED

		reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;

	#else

		reflectedLight.indirectDiffuse += vIndirectFront;

	#endif

	#include <lightmap_fragment>

	reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );

	#ifdef DOUBLE_SIDED

		reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;

	#else

		reflectedLight.directDiffuse = vLightFront;

	#endif

	reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();

	// modulation

	#include <aomap_fragment>

	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;

	#include <envmap_fragment>

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}
`;var $E=`
#define LAMBERT

varying vec3 vLightFront;
varying vec3 vIndirectFront;

#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <lights_lambert_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}
`;var ZE=`
#define MATCAP

uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>

#include <fog_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>

	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks

	#ifdef USE_MATCAP

		vec4 matcapColor = texture2D( matcap, uv );
		matcapColor = matcapTexelToLinear( matcapColor );

	#else

		vec4 matcapColor = vec4( 1.0 );

	#endif

	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>

}
`;var JE=`
#define MATCAP

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif

#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>

#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

	#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

		vNormal = normalize( transformedNormal );

	#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>

	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>

	vViewPosition = - mvPosition.xyz;

}
`;var QE=`
#define TOON

uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;

#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>

	// accumulation
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>

	// modulation
	#include <aomap_fragment>

	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>

}
`;var KE=`
#define TOON

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

	vNormal = normalize( transformedNormal );

#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

	vViewPosition = - mvPosition.xyz;

	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>

}
`;var eS=`
#define PHONG

uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;

#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>

	// accumulation
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>

	// modulation
	#include <aomap_fragment>

	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;

	#include <envmap_fragment>

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>

}
`;var tS=`
#define PHONG

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

	vNormal = normalize( transformedNormal );

#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

	vViewPosition = - mvPosition.xyz;

	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>

}
`;var nS=`
#define STANDARD

#ifdef PHYSICAL
	#define REFLECTIVITY
	#define CLEARCOAT
	#define TRANSMISSION
#endif

uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;

#ifdef TRANSMISSION
	uniform float transmission;
#endif

#ifdef REFLECTIVITY
	uniform float reflectivity;
#endif

#ifdef CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif

#ifdef USE_SHEEN
	uniform vec3 sheen;
#endif

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

	#ifdef USE_TANGENT

		varying vec3 vTangent;
		varying vec3 vBitangent;

	#endif

#endif

#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <transmissionmap_pars_fragment>
#include <bsdfs>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <lights_physical_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;

	#ifdef TRANSMISSION
		float totalTransmission = transmission;
	#endif

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <transmissionmap_fragment>

	// accumulation
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>

	// modulation
	#include <aomap_fragment>

	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;

	// this is a stub for the transmission model
	#ifdef TRANSMISSION
		diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );
	#endif

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>

}
`;var rS=`
#define STANDARD

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

	varying vec3 vNormal;

	#ifdef USE_TANGENT

		varying vec3 vTangent;
		varying vec3 vBitangent;

	#endif

#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

	vNormal = normalize( transformedNormal );

	#ifdef USE_TANGENT

		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );

	#endif

#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

	vViewPosition = - mvPosition.xyz;

	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>

}
`;var iS=`
#define NORMAL

uniform float opacity;

#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )

	varying vec3 vViewPosition;

#endif

#ifndef FLAT_SHADED

	varying vec3 vNormal;

	#ifdef USE_TANGENT

		varying vec3 vTangent;
		varying vec3 vBitangent;

	#endif

#endif

#include <packing>
#include <uv_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>

	gl_FragColor = vec4( packNormalToRGB( normal ), opacity );

}
`;var oS=`
#define NORMAL

#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )

	varying vec3 vViewPosition;

#endif

#ifndef FLAT_SHADED

	varying vec3 vNormal;

	#ifdef USE_TANGENT

		varying vec3 vTangent;
		varying vec3 vBitangent;

	#endif

#endif

#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

	vNormal = normalize( transformedNormal );

	#ifdef USE_TANGENT

		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );

	#endif

#endif

	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>

#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )

	vViewPosition = - mvPosition.xyz;

#endif

}
`;var sS=`
uniform vec3 diffuse;
uniform float opacity;

#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );

	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>

	outgoingLight = diffuseColor.rgb;

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>

}
`;var aS=`
uniform float size;
uniform float scale;

#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>

	gl_PointSize = size;

	#ifdef USE_SIZEATTENUATION

		bool isPerspective = isPerspectiveMatrix( projectionMatrix );

		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );

	#endif

	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>

}
`;var cS=`
uniform vec3 color;
uniform float opacity;

#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>

void main() {

	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>

}
`;var lS=`
#include <common>
#include <fog_pars_vertex>
#include <shadowmap_pars_vertex>

void main() {

	#include <begin_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>

	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>

	#include <shadowmap_vertex>
	#include <fog_vertex>

}
`;var uS=`
uniform vec3 diffuse;
uniform float opacity;

#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

void main() {

	#include <clipping_planes_fragment>

	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );

	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>

	outgoingLight = diffuseColor.rgb;

	gl_FragColor = vec4( outgoingLight, diffuseColor.a );

	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>

}
`;var hS=`
uniform float rotation;
uniform vec2 center;

#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

void main() {

	#include <uv_vertex>

	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );

	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );

	#ifndef USE_SIZEATTENUATION

		bool isPerspective = isPerspectiveMatrix( projectionMatrix );

		if ( isPerspective ) scale *= - mvPosition.z;

	#endif

	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;

	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;

	mvPosition.xy += rotatedPosition;

	gl_Position = projectionMatrix * mvPosition;

	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>

}
`;var gt={alphamap_fragment:jw,alphamap_pars_fragment:qw,alphatest_fragment:Xw,aomap_fragment:Yw,aomap_pars_fragment:$w,begin_vertex:Zw,beginnormal_vertex:Jw,bsdfs:Qw,bumpmap_pars_fragment:Kw,clipping_planes_fragment:eM,clipping_planes_pars_fragment:tM,clipping_planes_pars_vertex:nM,clipping_planes_vertex:rM,color_fragment:iM,color_pars_fragment:oM,color_pars_vertex:sM,color_vertex:aM,common:cM,cube_uv_reflection_fragment:lM,defaultnormal_vertex:uM,displacementmap_pars_vertex:hM,displacementmap_vertex:fM,emissivemap_fragment:dM,emissivemap_pars_fragment:pM,encodings_fragment:mM,encodings_pars_fragment:gM,envmap_fragment:vM,envmap_common_pars_fragment:yM,envmap_pars_fragment:xM,envmap_pars_vertex:_M,envmap_physical_pars_fragment:LM,envmap_vertex:bM,fog_vertex:wM,fog_pars_vertex:MM,fog_fragment:EM,fog_pars_fragment:SM,gradientmap_pars_fragment:TM,lightmap_fragment:AM,lightmap_pars_fragment:CM,lights_lambert_vertex:RM,lights_pars_begin:PM,lights_toon_fragment:FM,lights_toon_pars_fragment:IM,lights_phong_fragment:DM,lights_phong_pars_fragment:BM,lights_physical_fragment:OM,lights_physical_pars_fragment:UM,lights_fragment_begin:NM,lights_fragment_maps:GM,lights_fragment_end:kM,logdepthbuf_fragment:HM,logdepthbuf_pars_fragment:zM,logdepthbuf_pars_vertex:VM,logdepthbuf_vertex:WM,map_fragment:jM,map_pars_fragment:qM,map_particle_fragment:XM,map_particle_pars_fragment:YM,metalnessmap_fragment:$M,metalnessmap_pars_fragment:ZM,morphnormal_vertex:JM,morphtarget_pars_vertex:QM,morphtarget_vertex:KM,normal_fragment_begin:eE,normal_fragment_maps:tE,normalmap_pars_fragment:nE,clearcoat_normal_fragment_begin:rE,clearcoat_normal_fragment_maps:iE,clearcoat_pars_fragment:oE,packing:sE,premultiplied_alpha_fragment:aE,project_vertex:cE,dithering_fragment:lE,dithering_pars_fragment:uE,roughnessmap_fragment:hE,roughnessmap_pars_fragment:fE,shadowmap_pars_fragment:dE,shadowmap_pars_vertex:pE,shadowmap_vertex:mE,shadowmask_pars_fragment:gE,skinbase_vertex:vE,skinning_pars_vertex:yE,skinning_vertex:xE,skinnormal_vertex:_E,specularmap_fragment:bE,specularmap_pars_fragment:wE,tonemapping_fragment:ME,tonemapping_pars_fragment:EE,transmissionmap_fragment:SE,transmissionmap_pars_fragment:TE,uv_pars_fragment:AE,uv_pars_vertex:CE,uv_vertex:RE,uv2_pars_fragment:PE,uv2_pars_vertex:LE,uv2_vertex:FE,worldpos_vertex:IE,background_frag:DE,background_vert:BE,cube_frag:OE,cube_vert:UE,depth_frag:NE,depth_vert:GE,distanceRGBA_frag:kE,distanceRGBA_vert:HE,equirect_frag:zE,equirect_vert:VE,linedashed_frag:WE,linedashed_vert:jE,meshbasic_frag:qE,meshbasic_vert:XE,meshlambert_frag:YE,meshlambert_vert:$E,meshmatcap_frag:ZE,meshmatcap_vert:JE,meshtoon_frag:QE,meshtoon_vert:KE,meshphong_frag:eS,meshphong_vert:tS,meshphysical_frag:nS,meshphysical_vert:rS,normal_frag:iS,normal_vert:oS,points_frag:sS,points_vert:aS,shadow_frag:cS,shadow_vert:lS,sprite_frag:uS,sprite_vert:hS};var Ne={common:{diffuse:{value:new Ae(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ft},uv2Transform:{value:new Ft},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ae(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ae(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}},sprite:{diffuse:{value:new Ae(15658734)},opacity:{value:1},center:{value:new ue(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}}};var vr={basic:{uniforms:An([Ne.common,Ne.specularmap,Ne.envmap,Ne.aomap,Ne.lightmap,Ne.fog]),vertexShader:gt.meshbasic_vert,fragmentShader:gt.meshbasic_frag},lambert:{uniforms:An([Ne.common,Ne.specularmap,Ne.envmap,Ne.aomap,Ne.lightmap,Ne.emissivemap,Ne.fog,Ne.lights,{emissive:{value:new Ae(0)}}]),vertexShader:gt.meshlambert_vert,fragmentShader:gt.meshlambert_frag},phong:{uniforms:An([Ne.common,Ne.specularmap,Ne.envmap,Ne.aomap,Ne.lightmap,Ne.emissivemap,Ne.bumpmap,Ne.normalmap,Ne.displacementmap,Ne.fog,Ne.lights,{emissive:{value:new Ae(0)},specular:{value:new Ae(1118481)},shininess:{value:30}}]),vertexShader:gt.meshphong_vert,fragmentShader:gt.meshphong_frag},standard:{uniforms:An([Ne.common,Ne.envmap,Ne.aomap,Ne.lightmap,Ne.emissivemap,Ne.bumpmap,Ne.normalmap,Ne.displacementmap,Ne.roughnessmap,Ne.metalnessmap,Ne.fog,Ne.lights,{emissive:{value:new Ae(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gt.meshphysical_vert,fragmentShader:gt.meshphysical_frag},toon:{uniforms:An([Ne.common,Ne.aomap,Ne.lightmap,Ne.emissivemap,Ne.bumpmap,Ne.normalmap,Ne.displacementmap,Ne.gradientmap,Ne.fog,Ne.lights,{emissive:{value:new Ae(0)}}]),vertexShader:gt.meshtoon_vert,fragmentShader:gt.meshtoon_frag},matcap:{uniforms:An([Ne.common,Ne.bumpmap,Ne.normalmap,Ne.displacementmap,Ne.fog,{matcap:{value:null}}]),vertexShader:gt.meshmatcap_vert,fragmentShader:gt.meshmatcap_frag},points:{uniforms:An([Ne.points,Ne.fog]),vertexShader:gt.points_vert,fragmentShader:gt.points_frag},dashed:{uniforms:An([Ne.common,Ne.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gt.linedashed_vert,fragmentShader:gt.linedashed_frag},depth:{uniforms:An([Ne.common,Ne.displacementmap]),vertexShader:gt.depth_vert,fragmentShader:gt.depth_frag},normal:{uniforms:An([Ne.common,Ne.bumpmap,Ne.normalmap,Ne.displacementmap,{opacity:{value:1}}]),vertexShader:gt.normal_vert,fragmentShader:gt.normal_frag},sprite:{uniforms:An([Ne.sprite,Ne.fog]),vertexShader:gt.sprite_vert,fragmentShader:gt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ft},t2D:{value:null}},vertexShader:gt.background_vert,fragmentShader:gt.background_frag},cube:{uniforms:An([Ne.envmap,{opacity:{value:1}}]),vertexShader:gt.cube_vert,fragmentShader:gt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gt.equirect_vert,fragmentShader:gt.equirect_frag},distanceRGBA:{uniforms:An([Ne.common,Ne.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gt.distanceRGBA_vert,fragmentShader:gt.distanceRGBA_frag},shadow:{uniforms:An([Ne.lights,Ne.fog,{color:{value:new Ae(0)},opacity:{value:1}}]),vertexShader:gt.shadow_vert,fragmentShader:gt.shadow_frag}};vr.physical={uniforms:An([vr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ue(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Ae(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:gt.meshphysical_vert,fragmentShader:gt.meshphysical_frag};function fS(t,e,n,r,o){let a=new Ae(0),c=0,l,u,h=null,d=0,f=null;function p(v,x,b,y){let g=x.isScene===!0?x.background:null;g&&g.isTexture&&(g=e.get(g));let M=t.xr,C=M.getSession&&M.getSession();C&&C.environmentBlendMode==="additive"&&(g=null),g===null?m(a,c):g&&g.isColor&&(m(g,1),y=!0),(t.autoClear||y)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),g&&(g.isCubeTexture||g.isWebGLCubeRenderTarget||g.mapping===Xo)?(u===void 0&&(u=new Pt(new as(1,1,1),new en({name:"BackgroundCubeMaterial",uniforms:lo(vr.cube.uniforms),vertexShader:vr.cube.vertexShader,fragmentShader:vr.cube.fragmentShader,side:kt,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,w,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),g.isWebGLCubeRenderTarget&&(g=g.texture),u.material.uniforms.envMap.value=g,u.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g._needsFlipEnvMap?-1:1,(h!==g||d!==g.version||f!==t.toneMapping)&&(u.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),v.unshift(u,u.geometry,u.material,0,0,null)):g&&g.isTexture&&(l===void 0&&(l=new Pt(new kc(2,2),new en({name:"BackgroundMaterial",uniforms:lo(vr.background.uniforms),vertexShader:vr.background.vertexShader,fragmentShader:vr.background.fragmentShader,side:Vo,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=g,g.matrixAutoUpdate===!0&&g.updateMatrix(),l.material.uniforms.uvTransform.value.copy(g.matrix),(h!==g||d!==g.version||f!==t.toneMapping)&&(l.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),v.unshift(l,l.geometry,l.material,0,0,null))}function m(v,x){n.buffers.color.setClear(v.r,v.g,v.b,x,o)}return{getClearColor:function(){return a},setClearColor:function(v,x){a.set(v),c=x!==void 0?x:1,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,m(a,c)},render:p}}function dS(t,e,n,r){let o=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),c=r.isWebGL2||a!==null,l={},u=x(null),h=u;function d(G,z,D,B,q){let $=!1;if(c){let ce=v(B,D,z);h!==ce&&(h=ce,p(h.object)),$=b(B,q),$&&y(B,q)}else{let ce=z.wireframe===!0;(h.geometry!==B.id||h.program!==D.id||h.wireframe!==ce)&&(h.geometry=B.id,h.program=D.id,h.wireframe=ce,$=!0)}G.isInstancedMesh===!0&&($=!0),q!==null&&n.update(q,t.ELEMENT_ARRAY_BUFFER),$&&(F(G,z,D,B),q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(q).buffer))}function f(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(G){return r.isWebGL2?t.bindVertexArray(G):a.bindVertexArrayOES(G)}function m(G){return r.isWebGL2?t.deleteVertexArray(G):a.deleteVertexArrayOES(G)}function v(G,z,D){let B=D.wireframe===!0,q=l[G.id];q===void 0&&(q={},l[G.id]=q);let $=q[z.id];$===void 0&&($={},q[z.id]=$);let ce=$[B];return ce===void 0&&(ce=x(f()),$[B]=ce),ce}function x(G){let z=[],D=[],B=[];for(let q=0;q<o;q++)z[q]=0,D[q]=0,B[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:D,attributeDivisors:B,object:G,attributes:{},index:null}}function b(G,z){let D=h.attributes,B=G.attributes;if(Object.keys(D).length!==Object.keys(B).length)return!0;for(let q in B){let $=D[q],ce=B[q];if($===void 0||$.attribute!==ce||$.data!==ce.data)return!0}return h.index!==z}function y(G,z){let D={},B=G.attributes;for(let q in B){let $=B[q],ce={};ce.attribute=$,$.data&&(ce.data=$.data),D[q]=ce}h.attributes=D,h.index=z}function g(){let G=h.newAttributes;for(let z=0,D=G.length;z<D;z++)G[z]=0}function M(G){C(G,0)}function C(G,z){let D=h.newAttributes,B=h.enabledAttributes,q=h.attributeDivisors;D[G]=1,B[G]===0&&(t.enableVertexAttribArray(G),B[G]=1),q[G]!==z&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](G,z),q[G]=z)}function E(){let G=h.newAttributes,z=h.enabledAttributes;for(let D=0,B=z.length;D<B;D++)z[D]!==G[D]&&(t.disableVertexAttribArray(D),z[D]=0)}function w(G,z,D,B,q,$){r.isWebGL2===!0&&(D===t.INT||D===t.UNSIGNED_INT)?t.vertexAttribIPointer(G,z,D,q,$):t.vertexAttribPointer(G,z,D,B,q,$)}function F(G,z,D,B){if(r.isWebGL2===!1&&(G.isInstancedMesh||B.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;g();let q=B.attributes,$=D.getAttributes(),ce=z.defaultAttributeValues;for(let ge in $){let he=$[ge];if(he>=0){let Pe=q[ge];if(Pe!==void 0){let Fe=Pe.normalized,st=Pe.itemSize,V=n.get(Pe);if(V===void 0)continue;let _t=V.buffer,we=V.type,Ve=V.bytesPerElement;if(Pe.isInterleavedBufferAttribute){let Ce=Pe.data,$e=Ce.stride,Ie=Pe.offset;Ce&&Ce.isInstancedInterleavedBuffer?(C(he,Ce.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=Ce.meshPerAttribute*Ce.count)):M(he),t.bindBuffer(t.ARRAY_BUFFER,_t),w(he,st,we,Fe,$e*Ve,Ie*Ve)}else Pe.isInstancedBufferAttribute?(C(he,Pe.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=Pe.meshPerAttribute*Pe.count)):M(he),t.bindBuffer(t.ARRAY_BUFFER,_t),w(he,st,we,Fe,0,0)}else if(ge==="instanceMatrix"){let Fe=n.get(G.instanceMatrix);if(Fe===void 0)continue;let st=Fe.buffer,V=Fe.type;C(he+0,1),C(he+1,1),C(he+2,1),C(he+3,1),t.bindBuffer(t.ARRAY_BUFFER,st),t.vertexAttribPointer(he+0,4,V,!1,64,0),t.vertexAttribPointer(he+1,4,V,!1,64,16),t.vertexAttribPointer(he+2,4,V,!1,64,32),t.vertexAttribPointer(he+3,4,V,!1,64,48)}else if(ge==="instanceColor"){let Fe=n.get(G.instanceColor);if(Fe===void 0)continue;let st=Fe.buffer,V=Fe.type;C(he,1),t.bindBuffer(t.ARRAY_BUFFER,st),t.vertexAttribPointer(he,3,V,!1,12,0)}else if(ce!==void 0){let Fe=ce[ge];if(Fe!==void 0)switch(Fe.length){case 2:t.vertexAttrib2fv(he,Fe);break;case 3:t.vertexAttrib3fv(he,Fe);break;case 4:t.vertexAttrib4fv(he,Fe);break;default:t.vertexAttrib1fv(he,Fe)}}}}E()}function H(){L();for(let G in l){let z=l[G];for(let D in z){let B=z[D];for(let q in B)m(B[q].object),delete B[q];delete z[D]}delete l[G]}}function ne(G){if(l[G.id]===void 0)return;let z=l[G.id];for(let D in z){let B=z[D];for(let q in B)m(B[q].object),delete B[q];delete z[D]}delete l[G.id]}function Y(G){for(let z in l){let D=l[z];if(D[G.id]===void 0)continue;let B=D[G.id];for(let q in B)m(B[q].object),delete B[q];delete D[G.id]}}function L(){N(),h!==u&&(h=u,p(h.object))}function N(){u.geometry=null,u.program=null,u.wireframe=!1}return{setup:d,reset:L,resetDefaultState:N,dispose:H,releaseStatesOfGeometry:ne,releaseStatesOfProgram:Y,initAttributes:g,enableAttribute:M,disableUnusedAttributes:E}}function pS(t,e,n,r){let o=r.isWebGL2,a;function c(h){a=h}function l(h,d){t.drawArrays(a,h,d),n.update(d,a,1)}function u(h,d,f){if(f===0)return;let p,m;if(o)p=t,m="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[m](a,h,d,f),n.update(d,a,f)}this.setMode=c,this.render=l,this.renderInstances=u}function mS(t,e,n){let r;function o(){if(r!==void 0)return r;let w=e.get("EXT_texture_filter_anisotropic");return w!==null?r=t.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT):r=0,r}function a(w){if(w==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=typeof WebGL2RenderingContext!="undefined"&&t instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&t instanceof WebGL2ComputeRenderingContext,l=n.precision!==void 0?n.precision:"highp",u=a(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=n.logarithmicDepthBuffer===!0,d=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),f=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),m=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),y=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=f>0,M=c||!!e.get("OES_texture_float"),C=g&&M,E=c?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:c,getMaxAnisotropy:o,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:v,maxVertexUniforms:x,maxVaryings:b,maxFragmentUniforms:y,vertexTextures:g,floatFragmentTextures:M,floatVertexTextures:C,maxSamples:E}}function gS(t){let e=this,n=null,r=0,o=!1,a=!1,c=new Un,l=new Ft,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p,m){let v=f.length!==0||p||r!==0||o;return o=p,n=d(f,m,0),r=f.length,v},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1,h()},this.setState=function(f,p,m){let v=f.clippingPlanes,x=f.clipIntersection,b=f.clipShadows,y=t.get(f);if(!o||v===null||v.length===0||a&&!b)a?d(null):h();else{let g=a?0:r,M=g*4,C=y.clippingState||null;u.value=C,C=d(v,p,M,m);for(let E=0;E!==M;++E)C[E]=n[E];y.clippingState=C,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=g}};function h(){u.value!==n&&(u.value=n,u.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,m,v){let x=f!==null?f.length:0,b=null;if(x!==0){if(b=u.value,v!==!0||b===null){let y=m+x*4,g=p.matrixWorldInverse;l.getNormalMatrix(g),(b===null||b.length<y)&&(b=new Float32Array(y));for(let M=0,C=m;M!==x;++M,C+=4)c.copy(f[M]).applyMatrix4(g,l),c.normal.toArray(b,C),b[C+3]=c.constant}u.value=b,u.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,b}}function vS(t){let e=new WeakMap;function n(c,l){return l===Jf?c.mapping=Us:l===Qf&&(c.mapping=mc),c}function r(c){if(c&&c.isTexture){let l=c.mapping;if(l===Jf||l===Qf)if(e.has(c)){let u=e.get(c).texture;return n(u,c.mapping)}else{let u=c.image;if(u&&u.height>0){let h=t.getRenderList(),d=t.getRenderTarget(),f=t.getRenderState(),p=new Ai(u.height/2);return p.fromEquirectangularTexture(t,c),e.set(c,p),t.setRenderTarget(d),t.setRenderList(h),t.setRenderState(f),c.addEventListener("dispose",o),n(p.texture,c.mapping)}else return null}}return c}function o(c){let l=c.target;l.removeEventListener("dispose",o);let u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}function yS(t){let e={};return{has:function(n){if(e[n]!==void 0)return e[n]!==null;let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r!==null},get:function(n){return this.has(n)||console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),e[n]}}}function xS(t,e,n,r){let o=new WeakMap,a=new WeakMap;function c(f){let p=f.target,m=o.get(p);m.index!==null&&e.remove(m.index);for(let x in m.attributes)e.remove(m.attributes[x]);p.removeEventListener("dispose",c),o.delete(p);let v=a.get(m);v&&(e.remove(v),a.delete(m)),r.releaseStatesOfGeometry(m),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){let m=o.get(p);return m||(p.addEventListener("dispose",c),p.isBufferGeometry?m=p:p.isGeometry&&(p._bufferGeometry===void 0&&(p._bufferGeometry=new qe().setFromObject(f)),m=p._bufferGeometry),o.set(p,m),n.memory.geometries++,m)}function u(f){let p=f.attributes;for(let v in p)e.update(p[v],t.ARRAY_BUFFER);let m=f.morphAttributes;for(let v in m){let x=m[v];for(let b=0,y=x.length;b<y;b++)e.update(x[b],t.ARRAY_BUFFER)}}function h(f){let p=[],m=f.index,v=f.attributes.position,x=0;if(m!==null){let g=m.array;x=m.version;for(let M=0,C=g.length;M<C;M+=3){let E=g[M+0],w=g[M+1],F=g[M+2];p.push(E,w,w,F,F,E)}}else{let g=v.array;x=v.version;for(let M=0,C=g.length/3-1;M<C;M+=3){let E=M+0,w=M+1,F=M+2;p.push(E,w,w,F,F,E)}}let b=new(Sd(p)>65535?rs:ns)(p,1);b.version=x;let y=a.get(f);y&&e.remove(y),a.set(f,b)}function d(f){let p=a.get(f);if(p){let m=f.index;m!==null&&p.version<m.version&&h(f)}else h(f);return a.get(f)}return{get:l,update:u,getWireframeAttribute:d}}function _S(t,e,n,r){let o=r.isWebGL2,a;function c(p){a=p}let l,u;function h(p){l=p.type,u=p.bytesPerElement}function d(p,m){t.drawElements(a,m,l,p*u),n.update(m,a,1)}function f(p,m,v){if(v===0)return;let x,b;if(o)x=t,b="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[b](a,m,l,p*u,v),n.update(m,a,v)}this.setMode=c,this.setIndex=h,this.render=d,this.renderInstances=f}function bS(t){let e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,c,l){switch(n.calls++,c){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",c);break}}function o(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:o,update:r}}function HF(t,e){return t[0]-e[0]}function zF(t,e){return Math.abs(e[1])-Math.abs(t[1])}function wS(t){let e={},n=new Float32Array(8),r=[];for(let a=0;a<8;a++)r[a]=[a,0];function o(a,c,l,u){let h=a.morphTargetInfluences,d=h===void 0?0:h.length,f=e[c.id];if(f===void 0){f=[];for(let b=0;b<d;b++)f[b]=[b,0];e[c.id]=f}for(let b=0;b<d;b++){let y=f[b];y[0]=b,y[1]=h[b]}f.sort(zF);for(let b=0;b<8;b++)b<d&&f[b][1]?(r[b][0]=f[b][0],r[b][1]=f[b][1]):(r[b][0]=Number.MAX_SAFE_INTEGER,r[b][1]=0);r.sort(HF);let p=l.morphTargets&&c.morphAttributes.position,m=l.morphNormals&&c.morphAttributes.normal,v=0;for(let b=0;b<8;b++){let y=r[b],g=y[0],M=y[1];g!==Number.MAX_SAFE_INTEGER&&M?(p&&c.getAttribute("morphTarget"+b)!==p[g]&&c.setAttribute("morphTarget"+b,p[g]),m&&c.getAttribute("morphNormal"+b)!==m[g]&&c.setAttribute("morphNormal"+b,m[g]),n[b]=M,v+=M):(p&&c.getAttribute("morphTarget"+b)!==void 0&&c.deleteAttribute("morphTarget"+b),m&&c.getAttribute("morphNormal"+b)!==void 0&&c.deleteAttribute("morphNormal"+b),n[b]=0)}let x=c.morphTargetsRelative?1:1-v;u.getUniforms().setValue(t,"morphTargetBaseInfluence",x),u.getUniforms().setValue(t,"morphTargetInfluences",n)}return{update:o}}function MS(t,e,n,r){let o=new WeakMap;function a(l){let u=r.render.frame,h=l.geometry,d=e.get(l,h);return o.get(d)!==u&&(h.isGeometry&&d.updateFromObject(l),e.update(d),o.set(d,u)),l.isInstancedMesh&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER)),d}function c(){o=new WeakMap}return{update:a,dispose:c}}function Ys(t,e,n,r){yt.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Ys.prototype=Object.create(yt.prototype);Ys.prototype.constructor=Ys;Ys.prototype.isDataTexture2DArray=!0;function $s(t,e,n,r){yt.call(this,null),this.image={data:t||null,width:e||1,height:n||1,depth:r||1},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}$s.prototype=Object.create(yt.prototype);$s.prototype.constructor=$s;$s.prototype.isDataTexture3D=!0;var PS=new yt,VF=new Ys,WF=new $s,LS=new gr,ES=[],SS=[],TS=new Float32Array(16),AS=new Float32Array(9),CS=new Float32Array(4);function Hc(t,e,n){let r=t[0];if(r<=0||r>0)return t;let o=e*n,a=ES[o];if(a===void 0&&(a=new Float32Array(o),ES[o]=a),e!==0){r.toArray(a,0);for(let c=1,l=0;c!==e;++c)l+=n,t[c].toArray(a,l)}return a}function Br(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function yr(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function IS(t,e){let n=SS[e];n===void 0&&(n=new Int32Array(e),SS[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function jF(t,e){let n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function qF(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Br(n,e))return;t.uniform2fv(this.addr,e),yr(n,e)}}function XF(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Br(n,e))return;t.uniform3fv(this.addr,e),yr(n,e)}}function YF(t,e){let n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Br(n,e))return;t.uniform4fv(this.addr,e),yr(n,e)}}function $F(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Br(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),yr(n,e)}else{if(Br(n,r))return;CS.set(r),t.uniformMatrix2fv(this.addr,!1,CS),yr(n,r)}}function ZF(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Br(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),yr(n,e)}else{if(Br(n,r))return;AS.set(r),t.uniformMatrix3fv(this.addr,!1,AS),yr(n,r)}}function JF(t,e){let n=this.cache,r=e.elements;if(r===void 0){if(Br(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),yr(n,e)}else{if(Br(n,r))return;TS.set(r),t.uniformMatrix4fv(this.addr,!1,TS),yr(n,r)}}function QF(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.safeSetTexture2D(e||PS,o)}function KF(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.setTexture2DArray(e||VF,o)}function eI(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.setTexture3D(e||WF,o)}function tI(t,e,n){let r=this.cache,o=n.allocateTextureUnit();r[0]!==o&&(t.uniform1i(this.addr,o),r[0]=o),n.safeSetTextureCube(e||LS,o)}function nI(t,e){let n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function rI(t,e){let n=this.cache;Br(n,e)||(t.uniform2iv(this.addr,e),yr(n,e))}function iI(t,e){let n=this.cache;Br(n,e)||(t.uniform3iv(this.addr,e),yr(n,e))}function oI(t,e){let n=this.cache;Br(n,e)||(t.uniform4iv(this.addr,e),yr(n,e))}function sI(t,e){let n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function aI(t){switch(t){case 5126:return jF;case 35664:return qF;case 35665:return XF;case 35666:return YF;case 35674:return $F;case 35675:return ZF;case 35676:return JF;case 5124:case 35670:return nI;case 35667:case 35671:return rI;case 35668:case 35672:return iI;case 35669:case 35673:return oI;case 5125:return sI;case 35678:case 36198:case 36298:case 36306:case 35682:return QF;case 35679:case 36299:case 36307:return eI;case 35680:case 36300:case 36308:case 36293:return tI;case 36289:case 36303:case 36311:case 36292:return KF}}function cI(t,e){t.uniform1fv(this.addr,e)}function lI(t,e){t.uniform1iv(this.addr,e)}function uI(t,e){t.uniform2iv(this.addr,e)}function hI(t,e){t.uniform3iv(this.addr,e)}function fI(t,e){t.uniform4iv(this.addr,e)}function dI(t,e){let n=Hc(e,this.size,2);t.uniform2fv(this.addr,n)}function pI(t,e){let n=Hc(e,this.size,3);t.uniform3fv(this.addr,n)}function mI(t,e){let n=Hc(e,this.size,4);t.uniform4fv(this.addr,n)}function gI(t,e){let n=Hc(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function vI(t,e){let n=Hc(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function yI(t,e){let n=Hc(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function xI(t,e,n){let r=e.length,o=IS(n,r);t.uniform1iv(this.addr,o);for(let a=0;a!==r;++a)n.safeSetTexture2D(e[a]||PS,o[a])}function _I(t,e,n){let r=e.length,o=IS(n,r);t.uniform1iv(this.addr,o);for(let a=0;a!==r;++a)n.safeSetTextureCube(e[a]||LS,o[a])}function bI(t){switch(t){case 5126:return cI;case 35664:return dI;case 35665:return pI;case 35666:return mI;case 35674:return gI;case 35675:return vI;case 35676:return yI;case 5124:case 35670:return lI;case 35667:case 35671:return uI;case 35668:case 35672:return hI;case 35669:case 35673:return fI;case 35678:case 36198:case 36298:case 36306:case 35682:return xI;case 35680:case 36300:case 36308:case 36293:return _I}}function wI(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=aI(e.type)}function DS(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=bI(e.type)}DS.prototype.updateCache=function(t){let e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),yr(e,t)};function BS(t){this.id=t,this.seq=[],this.map={}}BS.prototype.setValue=function(t,e,n){let r=this.seq;for(let o=0,a=r.length;o!==a;++o){let c=r[o];c.setValue(t,e[c.id],n)}};var Pv=/([\w\d_]+)(\])?(\[|\.)?/g;function RS(t,e){t.seq.push(e),t.map[e.id]=e}function MI(t,e,n){let r=t.name,o=r.length;for(Pv.lastIndex=0;;){let a=Pv.exec(r),c=Pv.lastIndex,l=a[1],u=a[2]==="]",h=a[3];if(u&&(l=l|0),h===void 0||h==="["&&c+2===o){RS(n,h===void 0?new wI(l,t,e):new DS(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new BS(l),RS(n,f)),n=f}}}function Ci(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let o=t.getActiveUniform(e,r),a=t.getUniformLocation(e,o.name);MI(o,a,this)}}Ci.prototype.setValue=function(t,e,n,r){let o=this.map[e];o!==void 0&&o.setValue(t,n,r)};Ci.prototype.setOptional=function(t,e,n){let r=e[n];r!==void 0&&this.setValue(t,n,r)};Ci.upload=function(t,e,n,r){for(let o=0,a=e.length;o!==a;++o){let c=e[o],l=n[c.id];l.needsUpdate!==!1&&c.setValue(t,l.value,r)}};Ci.seqWithValue=function(t,e){let n=[];for(let r=0,o=t.length;r!==o;++r){let a=t[r];a.id in e&&n.push(a)}return n};function Lv(t,e,n){let r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}var EI=0;function SI(t){let e=t.split(`
`);for(let n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join(`
`)}function HS(t){switch(t){case Fr:return["Linear","( value )"];case Mc:return["sRGB","( value )"];case id:return["RGBE","( value )"];case od:return["RGBM","( value, 7.0 )"];case sd:return["RGBM","( value, 16.0 )"];case ad:return["RGBD","( value, 256.0 )"];case rd:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case Sw:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function OS(t,e,n){let r=t.getShaderParameter(e,t.COMPILE_STATUS),o=t.getShaderInfoLog(e).trim();if(r&&o==="")return"";let a=t.getShaderSource(e);return"THREE.WebGLShader: gl.getShaderInfoLog() "+n+`
`+o+SI(a)}function au(t,e){let n=HS(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function TI(t,e){let n=HS(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function AI(t,e){let n;switch(e){case Sb:n="Linear";break;case Tb:n="Reinhard";break;case Ab:n="OptimizedCineon";break;case Cb:n="ACESFilmic";break;case Rb:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function CI(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(cu).join(`
`)}function RI(t){let e=[];for(let n in t){let r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
`)}function PI(t,e){let n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let o=0;o<r;o++){let c=t.getActiveAttrib(e,o).name;n[c]=t.getAttribLocation(e,c)}return n}function cu(t){return t!==""}function US(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function NS(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var LI=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fv(t){return t.replace(LI,FI)}function FI(t,e){let n=gt[e];if(n===void 0)throw new Error("Can not resolve #include <"+e+">");return Fv(n)}var II=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,DI=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function GS(t){return t.replace(DI,zS).replace(II,BI)}function BI(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),zS(t,e,n,r)}function zS(t,e,n,r){let o="";for(let a=parseInt(e);a<parseInt(n);a++)o+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return o}function kS(t){let e="precision "+t.precision+` float;
precision `+t.precision+" int;";return t.precision==="highp"?e+=`
#define HIGH_PRECISION`:t.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function OI(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===qf?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===rb?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Bs&&(e="SHADOWMAP_TYPE_VSM"),e}function UI(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Us:case mc:e="ENVMAP_TYPE_CUBE";break;case Xo:case gc:e="ENVMAP_TYPE_CUBE_UV";break}return e}function NI(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case mc:case gc:e="ENVMAP_MODE_REFRACTION";break}return e}function GI(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case qo:e="ENVMAP_BLENDING_MULTIPLY";break;case Mb:e="ENVMAP_BLENDING_MIX";break;case Eb:e="ENVMAP_BLENDING_ADD";break}return e}function VS(t,e,n,r){let o=t.getContext(),a=n.defines,c=n.vertexShader,l=n.fragmentShader,u=OI(n),h=UI(n),d=NI(n),f=GI(n),p=t.gammaFactor>0?t.gammaFactor:1,m=n.isWebGL2?"":CI(n),v=RI(a),x=o.createProgram(),b,y,g=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(b=[v].filter(cu).join(`
`),b.length>0&&(b+=`
`),y=[m,v].filter(cu).join(`
`),y.length>0&&(y+=`
`)):(b=[kS(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+p,"#define MAX_BONES "+n.maxBones,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 "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+u:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#ifdef USE_COLOR","	attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","	attribute vec3 morphTarget0;","	attribute vec3 morphTarget1;","	attribute vec3 morphTarget2;","	attribute vec3 morphTarget3;","	#ifdef USE_MORPHNORMALS","		attribute vec3 morphNormal0;","		attribute vec3 morphNormal1;","		attribute vec3 morphNormal2;","		attribute vec3 morphNormal3;","	#else","		attribute vec3 morphTarget4;","		attribute vec3 morphTarget5;","		attribute vec3 morphTarget6;","		attribute vec3 morphTarget7;","	#endif","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(cu).join(`
`),y=[m,kS(n),"#define SHADER_NAME "+n.shaderName,v,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+u:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==eo?"#define TONE_MAPPING":"",n.toneMapping!==eo?gt.tonemapping_pars_fragment:"",n.toneMapping!==eo?AI("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",gt.encodings_pars_fragment,n.map?au("mapTexelToLinear",n.mapEncoding):"",n.matcap?au("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?au("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?au("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?au("lightMapTexelToLinear",n.lightMapEncoding):"",TI("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(cu).join(`
`)),c=Fv(c),c=US(c,n),c=NS(c,n),l=Fv(l),l=US(l,n),l=NS(l,n),c=GS(c),l=GS(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(g=`#version 300 es
`,b=["#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+b,y=["#define varying in",n.glslVersion===cv?"":"out highp vec4 pc_fragColor;",n.glslVersion===cv?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+y);let M=g+b+c,C=g+y+l,E=Lv(o,o.VERTEX_SHADER,M),w=Lv(o,o.FRAGMENT_SHADER,C);if(o.attachShader(x,E),o.attachShader(x,w),n.index0AttributeName!==void 0?o.bindAttribLocation(x,0,n.index0AttributeName):n.morphTargets===!0&&o.bindAttribLocation(x,0,"position"),o.linkProgram(x),t.debug.checkShaderErrors){let ne=o.getProgramInfoLog(x).trim(),Y=o.getShaderInfoLog(E).trim(),L=o.getShaderInfoLog(w).trim(),N=!0,G=!0;if(o.getProgramParameter(x,o.LINK_STATUS)===!1){N=!1;let z=OS(o,E,"vertex"),D=OS(o,w,"fragment");console.error("THREE.WebGLProgram: shader error: ",o.getError(),"gl.VALIDATE_STATUS",o.getProgramParameter(x,o.VALIDATE_STATUS),"gl.getProgramInfoLog",ne,z,D)}else ne!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ne):(Y===""||L==="")&&(G=!1);G&&(this.diagnostics={runnable:N,programLog:ne,vertexShader:{log:Y,prefix:b},fragmentShader:{log:L,prefix:y}})}o.deleteShader(E),o.deleteShader(w);let F;this.getUniforms=function(){return F===void 0&&(F=new Ci(o,x)),F};let H;return this.getAttributes=function(){return H===void 0&&(H=PI(o,x)),H},this.destroy=function(){r.releaseStatesOfProgram(this),o.deleteProgram(x),this.program=void 0},this.name=n.shaderName,this.id=EI++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=E,this.fragmentShader=w,this}function WS(t,e,n,r,o,a){let c=[],l=r.isWebGL2,u=r.logarithmicDepthBuffer,h=r.floatVertexTextures,d=r.maxVertexUniforms,f=r.vertexTextures,p=r.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},v=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function x(w){let H=w.skeleton.bones;if(h)return 1024;{let Y=Math.floor((d-20)/4),L=Math.min(Y,H.length);return L<H.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+H.length+" bones. This GPU supports "+L+"."),0):L}}function b(w){let F;return w?w.isTexture?F=w.encoding:w.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),F=w.texture.encoding):F=Fr,F}function y(w,F,H,ne,Y){let L=ne.fog,N=w.isMeshStandardMaterial?ne.environment:null,G=e.get(w.envMap||N),z=m[w.type],D=Y.isSkinnedMesh?x(Y):0;w.precision!==null&&(p=r.getMaxPrecision(w.precision),p!==w.precision&&console.warn("THREE.WebGLProgram.getParameters:",w.precision,"not supported, using",p,"instead."));let B,q;if(z){let ge=vr[z];B=ge.vertexShader,q=ge.fragmentShader}else B=w.vertexShader,q=w.fragmentShader;let $=t.getRenderTarget();return{isWebGL2:l,shaderID:z,shaderName:w.type,vertexShader:B,fragmentShader:q,defines:w.defines,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:p,instancing:Y.isInstancedMesh===!0,instancingColor:Y.isInstancedMesh===!0&&Y.instanceColor!==null,supportsVertexTextures:f,outputEncoding:$!==null?b($.texture):t.outputEncoding,map:!!w.map,mapEncoding:b(w.map),matcap:!!w.matcap,matcapEncoding:b(w.matcap),envMap:!!G,envMapMode:G&&G.mapping,envMapEncoding:b(G),envMapCubeUV:!!G&&(G.mapping===Xo||G.mapping===gc),lightMap:!!w.lightMap,lightMapEncoding:b(w.lightMap),aoMap:!!w.aoMap,emissiveMap:!!w.emissiveMap,emissiveMapEncoding:b(w.emissiveMap),bumpMap:!!w.bumpMap,normalMap:!!w.normalMap,objectSpaceNormalMap:w.normalMapType===Cw,tangentSpaceNormalMap:w.normalMapType===Ir,clearcoatMap:!!w.clearcoatMap,clearcoatRoughnessMap:!!w.clearcoatRoughnessMap,clearcoatNormalMap:!!w.clearcoatNormalMap,displacementMap:!!w.displacementMap,roughnessMap:!!w.roughnessMap,metalnessMap:!!w.metalnessMap,specularMap:!!w.specularMap,alphaMap:!!w.alphaMap,gradientMap:!!w.gradientMap,sheen:!!w.sheen,transmissionMap:!!w.transmissionMap,combine:w.combine,vertexTangents:w.normalMap&&w.vertexTangents,vertexColors:w.vertexColors,vertexUvs:!!w.map||!!w.bumpMap||!!w.normalMap||!!w.specularMap||!!w.alphaMap||!!w.emissiveMap||!!w.roughnessMap||!!w.metalnessMap||!!w.clearcoatMap||!!w.clearcoatRoughnessMap||!!w.clearcoatNormalMap||!!w.displacementMap||!!w.transmissionMap,uvsVertexOnly:!(w.map||w.bumpMap||w.normalMap||w.specularMap||w.alphaMap||w.emissiveMap||w.roughnessMap||w.metalnessMap||w.clearcoatNormalMap||w.transmissionMap)&&!!w.displacementMap,fog:!!L,useFog:w.fog,fogExp2:L&&L.isFogExp2,flatShading:w.flatShading,sizeAttenuation:w.sizeAttenuation,logarithmicDepthBuffer:u,skinning:w.skinning&&D>0,maxBones:D,useVertexTexture:h,morphTargets:w.morphTargets,morphNormals:w.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:F.directional.length,numPointLights:F.point.length,numSpotLights:F.spot.length,numRectAreaLights:F.rectArea.length,numHemiLights:F.hemi.length,numDirLightShadows:F.directionalShadowMap.length,numPointLightShadows:F.pointShadowMap.length,numSpotLightShadows:F.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:t.shadowMap.enabled&&H.length>0,shadowMapType:t.shadowMap.type,toneMapping:w.toneMapped?t.toneMapping:eo,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:w.premultipliedAlpha,alphaTest:w.alphaTest,doubleSided:w.side===Wo,flipSided:w.side===kt,depthPacking:w.depthPacking!==void 0?w.depthPacking:!1,index0AttributeName:w.index0AttributeName,extensionDerivatives:w.extensions&&w.extensions.derivatives,extensionFragDepth:w.extensions&&w.extensions.fragDepth,extensionDrawBuffers:w.extensions&&w.extensions.drawBuffers,extensionShaderTextureLOD:w.extensions&&w.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:w.customProgramCacheKey()}}function g(w){let F=[];if(w.shaderID?F.push(w.shaderID):(F.push(w.fragmentShader),F.push(w.vertexShader)),w.defines!==void 0)for(let H in w.defines)F.push(H),F.push(w.defines[H]);if(w.isRawShaderMaterial===!1){for(let H=0;H<v.length;H++)F.push(w[v[H]]);F.push(t.outputEncoding),F.push(t.gammaFactor)}return F.push(w.customProgramCacheKey),F.join()}function M(w){let F=m[w.type],H;if(F){let ne=vr[F];H=Rv.clone(ne.uniforms)}else H=w.uniforms;return H}function C(w,F){let H;for(let ne=0,Y=c.length;ne<Y;ne++){let L=c[ne];if(L.cacheKey===F){H=L,++H.usedTimes;break}}return H===void 0&&(H=new VS(t,F,w,o),c.push(H)),H}function E(w){if(--w.usedTimes===0){let F=c.indexOf(w);c[F]=c[c.length-1],c.pop(),w.destroy()}}return{getParameters:y,getProgramCacheKey:g,getUniforms:M,acquireProgram:C,releaseProgram:E,programs:c}}function jS(){let t=new WeakMap;function e(a){let c=t.get(a);return c===void 0&&(c={},t.set(a,c)),c}function n(a){t.delete(a)}function r(a,c,l){t.get(a)[c]=l}function o(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:o}}function kI(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function HI(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function qS(t){let e=[],n=0,r=[],o=[],a={id:-1};function c(){n=0,r.length=0,o.length=0}function l(p,m,v,x,b,y){let g=e[n],M=t.get(v);return g===void 0?(g={id:p.id,object:p,geometry:m,material:v,program:M.program||a,groupOrder:x,renderOrder:p.renderOrder,z:b,group:y},e[n]=g):(g.id=p.id,g.object=p,g.geometry=m,g.material=v,g.program=M.program||a,g.groupOrder=x,g.renderOrder=p.renderOrder,g.z=b,g.group=y),n++,g}function u(p,m,v,x,b,y){let g=l(p,m,v,x,b,y);(v.transparent===!0?o:r).push(g)}function h(p,m,v,x,b,y){let g=l(p,m,v,x,b,y);(v.transparent===!0?o:r).unshift(g)}function d(p,m){r.length>1&&r.sort(p||kI),o.length>1&&o.sort(m||HI)}function f(){for(let p=n,m=e.length;p<m;p++){let v=e[p];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.program=null,v.group=null}}return{opaque:r,transparent:o,init:c,push:u,unshift:h,finish:f,sort:d}}function XS(t){let e=new WeakMap;function n(o,a){let c=e.get(o),l;return c===void 0?(l=new qS(t),e.set(o,new WeakMap),e.get(o).set(a,l)):(l=c.get(a),l===void 0&&(l=new qS(t),c.set(a,l))),l}function r(){e=new WeakMap}return{get:n,dispose:r}}function zI(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new O,color:new Ae};break;case"SpotLight":n={position:new O,direction:new O,color:new Ae,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Ae,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Ae,groundColor:new Ae};break;case"RectAreaLight":n={color:new Ae,position:new O,halfWidth:new O,halfHeight:new O};break}return t[e.id]=n,n}}}function VI(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ue};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ue};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}var WI=0;function jI(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function YS(t,e){let n=new zI,r=VI(),o={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)o.probe.push(new O);let a=new O,c=new Qe,l=new Qe;function u(h,d,f){let p=0,m=0,v=0;for(let ne=0;ne<9;ne++)o.probe[ne].set(0,0,0);let x=0,b=0,y=0,g=0,M=0,C=0,E=0,w=0,F=f.matrixWorldInverse;h.sort(jI);for(let ne=0,Y=h.length;ne<Y;ne++){let L=h[ne],N=L.color,G=L.intensity,z=L.distance,D=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)p+=N.r*G,m+=N.g*G,v+=N.b*G;else if(L.isLightProbe)for(let B=0;B<9;B++)o.probe[B].addScaledVector(L.sh.coefficients[B],G);else if(L.isDirectionalLight){let B=n.get(L);if(B.color.copy(L.color).multiplyScalar(L.intensity),B.direction.setFromMatrixPosition(L.matrixWorld),a.setFromMatrixPosition(L.target.matrixWorld),B.direction.sub(a),B.direction.transformDirection(F),L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,o.directionalShadow[x]=$,o.directionalShadowMap[x]=D,o.directionalShadowMatrix[x]=L.shadow.matrix,C++}o.directional[x]=B,x++}else if(L.isSpotLight){let B=n.get(L);if(B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),B.color.copy(N).multiplyScalar(G),B.distance=z,B.direction.setFromMatrixPosition(L.matrixWorld),a.setFromMatrixPosition(L.target.matrixWorld),B.direction.sub(a),B.direction.transformDirection(F),B.coneCos=Math.cos(L.angle),B.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),B.decay=L.decay,L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,o.spotShadow[y]=$,o.spotShadowMap[y]=D,o.spotShadowMatrix[y]=L.shadow.matrix,w++}o.spot[y]=B,y++}else if(L.isRectAreaLight){let B=n.get(L);B.color.copy(N).multiplyScalar(G),B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),l.identity(),c.copy(L.matrixWorld),c.premultiply(F),l.extractRotation(c),B.halfWidth.set(L.width*.5,0,0),B.halfHeight.set(0,L.height*.5,0),B.halfWidth.applyMatrix4(l),B.halfHeight.applyMatrix4(l),o.rectArea[g]=B,g++}else if(L.isPointLight){let B=n.get(L);if(B.position.setFromMatrixPosition(L.matrixWorld),B.position.applyMatrix4(F),B.color.copy(L.color).multiplyScalar(L.intensity),B.distance=L.distance,B.decay=L.decay,L.castShadow){let q=L.shadow,$=r.get(L);$.shadowBias=q.bias,$.shadowNormalBias=q.normalBias,$.shadowRadius=q.radius,$.shadowMapSize=q.mapSize,$.shadowCameraNear=q.camera.near,$.shadowCameraFar=q.camera.far,o.pointShadow[b]=$,o.pointShadowMap[b]=D,o.pointShadowMatrix[b]=L.shadow.matrix,E++}o.point[b]=B,b++}else if(L.isHemisphereLight){let B=n.get(L);B.direction.setFromMatrixPosition(L.matrixWorld),B.direction.transformDirection(F),B.direction.normalize(),B.skyColor.copy(L.color).multiplyScalar(G),B.groundColor.copy(L.groundColor).multiplyScalar(G),o.hemi[M]=B,M++}}g>0&&(e.isWebGL2?(o.rectAreaLTC1=Ne.LTC_FLOAT_1,o.rectAreaLTC2=Ne.LTC_FLOAT_2):t.has("OES_texture_float_linear")===!0?(o.rectAreaLTC1=Ne.LTC_FLOAT_1,o.rectAreaLTC2=Ne.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(o.rectAreaLTC1=Ne.LTC_HALF_1,o.rectAreaLTC2=Ne.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),o.ambient[0]=p,o.ambient[1]=m,o.ambient[2]=v;let H=o.hash;(H.directionalLength!==x||H.pointLength!==b||H.spotLength!==y||H.rectAreaLength!==g||H.hemiLength!==M||H.numDirectionalShadows!==C||H.numPointShadows!==E||H.numSpotShadows!==w)&&(o.directional.length=x,o.spot.length=y,o.rectArea.length=g,o.point.length=b,o.hemi.length=M,o.directionalShadow.length=C,o.directionalShadowMap.length=C,o.pointShadow.length=E,o.pointShadowMap.length=E,o.spotShadow.length=w,o.spotShadowMap.length=w,o.directionalShadowMatrix.length=C,o.pointShadowMatrix.length=E,o.spotShadowMatrix.length=w,H.directionalLength=x,H.pointLength=b,H.spotLength=y,H.rectAreaLength=g,H.hemiLength=M,H.numDirectionalShadows=C,H.numPointShadows=E,H.numSpotShadows=w,o.version=WI++)}return{setup:u,state:o}}function $S(t,e){let n=new YS(t,e),r=[],o=[];function a(){r.length=0,o.length=0}function c(d){r.push(d)}function l(d){o.push(d)}function u(d){n.setup(r,o,d)}return{init:a,state:{lightsArray:r,shadowsArray:o,lights:n},setupLights:u,pushLight:c,pushShadow:l}}function ZS(t,e){let n=new WeakMap;function r(a,c){let l;return n.has(a)===!1?(l=new $S(t,e),n.set(a,new WeakMap),n.get(a).set(c,l)):n.get(a).has(c)===!1?(l=new $S(t,e),n.get(a).set(c,l)):l=n.get(a).get(c),l}function o(){n=new WeakMap}return{get:r,dispose:o}}function fo(t){Ye.call(this),this.type="MeshDepthMaterial",this.depthPacking=Tw,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}fo.prototype=Object.create(Ye.prototype);fo.prototype.constructor=fo;fo.prototype.isMeshDepthMaterial=!0;fo.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this};function po(t){Ye.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new O,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}po.prototype=Object.create(Ye.prototype);po.prototype.constructor=po;po.prototype.isMeshDistanceMaterial=!0;po.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};var JS=`
uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;

#include <packing>

void main() {

	float mean = 0.0;
	float squared_mean = 0.0;

	// This seems totally useless but it's a crazy work around for a Adreno compiler bug
	float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );

	for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {

		#ifdef HORIZONAL_PASS

			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;

		#else

			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;

		#endif

	}

	mean = mean * HALF_SAMPLE_RATE;
	squared_mean = squared_mean * HALF_SAMPLE_RATE;

	float std_dev = sqrt( squared_mean - mean * mean );

	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );

}
`;var QS=`
void main() {

	gl_Position = vec4( position, 1.0 );

}
`;function Id(t,e,n){let r=new ei,o=new ue,a=new ue,c=new mt,l=[],u=[],h={},d={0:kt,1:Vo,2:Wo},f=new en({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new ue},radius:{value:4}},vertexShader:QS,fragmentShader:JS}),p=f.clone();p.defines.HORIZONAL_PASS=1;let m=new qe;m.setAttribute("position",new tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Pt(m,f),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qf,this.render=function(E,w,F){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||E.length===0)return;let H=t.getRenderTarget(),ne=t.getActiveCubeFace(),Y=t.getActiveMipmapLevel(),L=t.state;L.setBlending(Ki),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let N=0,G=E.length;N<G;N++){let z=E[N],D=z.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;o.copy(D.mapSize);let B=D.getFrameExtents();if(o.multiply(B),a.copy(D.mapSize),(o.x>n||o.y>n)&&(o.x>n&&(a.x=Math.floor(n/B.x),o.x=a.x*B.x,D.mapSize.x=a.x),o.y>n&&(a.y=Math.floor(n/B.y),o.y=a.y*B.y,D.mapSize.y=a.y)),D.map===null&&!D.isPointLightShadow&&this.type===Bs){let $={minFilter:Ht,magFilter:Ht,format:mn};D.map=new Sn(o.x,o.y,$),D.map.texture.name=z.name+".shadowMap",D.mapPass=new Sn(o.x,o.y,$),D.camera.updateProjectionMatrix()}if(D.map===null){let $={minFilter:Xt,magFilter:Xt,format:mn};D.map=new Sn(o.x,o.y,$),D.map.texture.name=z.name+".shadowMap",D.camera.updateProjectionMatrix()}t.setRenderTarget(D.map),t.clear();let q=D.getViewportCount();for(let $=0;$<q;$++){let ce=D.getViewport($);c.set(a.x*ce.x,a.y*ce.y,a.x*ce.z,a.y*ce.w),L.viewport(c),D.updateMatrices(z,$),r=D.getFrustum(),C(w,F,D.camera,z,this.type)}!D.isPointLightShadow&&this.type===Bs&&b(D,F),D.needsUpdate=!1}x.needsUpdate=!1,t.setRenderTarget(H,ne,Y)};function b(E,w){let F=e.update(v);f.uniforms.shadow_pass.value=E.map.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(w,null,F,f,v,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(w,null,F,p,v,null)}function y(E,w,F){let H=E<<0|w<<1|F<<2,ne=l[H];return ne===void 0&&(ne=new fo({depthPacking:Aw,morphTargets:E,skinning:w}),l[H]=ne),ne}function g(E,w,F){let H=E<<0|w<<1|F<<2,ne=u[H];return ne===void 0&&(ne=new po({morphTargets:E,skinning:w}),u[H]=ne),ne}function M(E,w,F,H,ne,Y,L){let N=null,G=y,z=E.customDepthMaterial;if(H.isPointLight===!0&&(G=g,z=E.customDistanceMaterial),z===void 0){let D=!1;F.morphTargets===!0&&(D=w.morphAttributes&&w.morphAttributes.position&&w.morphAttributes.position.length>0);let B=!1;E.isSkinnedMesh===!0&&(F.skinning===!0?B=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",E));let q=E.isInstancedMesh===!0;N=G(D,B,q)}else N=z;if(t.localClippingEnabled&&F.clipShadows===!0&&F.clippingPlanes.length!==0){let D=N.uuid,B=F.uuid,q=h[D];q===void 0&&(q={},h[D]=q);let $=q[B];$===void 0&&($=N.clone(),q[B]=$),N=$}return N.visible=F.visible,N.wireframe=F.wireframe,L===Bs?N.side=F.shadowSide!==null?F.shadowSide:F.side:N.side=F.shadowSide!==null?F.shadowSide:d[F.side],N.clipShadows=F.clipShadows,N.clippingPlanes=F.clippingPlanes,N.clipIntersection=F.clipIntersection,N.wireframeLinewidth=F.wireframeLinewidth,N.linewidth=F.linewidth,H.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(H.matrixWorld),N.nearDistance=ne,N.farDistance=Y),N}function C(E,w,F,H,ne){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&ne===Bs)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,E.matrixWorld);let N=e.update(E),G=E.material;if(Array.isArray(G)){let z=N.groups;for(let D=0,B=z.length;D<B;D++){let q=z[D],$=G[q.materialIndex];if($&&$.visible){let ce=M(E,N,$,H,F.near,F.far,ne);t.renderBufferDirect(F,null,N,ce,E,q)}}}else if(G.visible){let z=M(E,N,G,H,F.near,F.far,ne);t.renderBufferDirect(F,null,N,z,E,null)}}let L=E.children;for(let N=0,G=L.length;N<G;N++)C(L[N],w,F,H,ne)}}function KS(t,e,n){let r=n.isWebGL2;function o(){let I=!1,ee=new mt,ae=null,ve=new mt(0,0,0,0);return{setMask:function(oe){ae!==oe&&!I&&(t.colorMask(oe,oe,oe,oe),ae=oe)},setLocked:function(oe){I=oe},setClear:function(oe,pe,be,Te,de){de===!0&&(oe*=Te,pe*=Te,be*=Te),ee.set(oe,pe,be,Te),ve.equals(ee)===!1&&(t.clearColor(oe,pe,be,Te),ve.copy(ee))},reset:function(){I=!1,ae=null,ve.set(-1,0,0,0)}}}function a(){let I=!1,ee=null,ae=null,ve=null;return{setTest:function(oe){oe?ge(t.DEPTH_TEST):he(t.DEPTH_TEST)},setMask:function(oe){ee!==oe&&!I&&(t.depthMask(oe),ee=oe)},setFunc:function(oe){if(ae!==oe){if(oe)switch(oe){case gb:t.depthFunc(t.NEVER);break;case vb:t.depthFunc(t.ALWAYS);break;case yb:t.depthFunc(t.LESS);break;case tu:t.depthFunc(t.LEQUAL);break;case xb:t.depthFunc(t.EQUAL);break;case _b:t.depthFunc(t.GEQUAL);break;case bb:t.depthFunc(t.GREATER);break;case wb:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);ae=oe}},setLocked:function(oe){I=oe},setClear:function(oe){ve!==oe&&(t.clearDepth(oe),ve=oe)},reset:function(){I=!1,ee=null,ae=null,ve=null}}}function c(){let I=!1,ee=null,ae=null,ve=null,oe=null,pe=null,be=null,Te=null,de=null;return{setTest:function(Me){I||(Me?ge(t.STENCIL_TEST):he(t.STENCIL_TEST))},setMask:function(Me){ee!==Me&&!I&&(t.stencilMask(Me),ee=Me)},setFunc:function(Me,ot,Mt){(ae!==Me||ve!==ot||oe!==Mt)&&(t.stencilFunc(Me,ot,Mt),ae=Me,ve=ot,oe=Mt)},setOp:function(Me,ot,Mt){(pe!==Me||be!==ot||Te!==Mt)&&(t.stencilOp(Me,ot,Mt),pe=Me,be=ot,Te=Mt)},setLocked:function(Me){I=Me},setClear:function(Me){de!==Me&&(t.clearStencil(Me),de=Me)},reset:function(){I=!1,ee=null,ae=null,ve=null,oe=null,pe=null,be=null,Te=null,de=null}}}let l=new o,u=new a,h=new c,d={},f=null,p=null,m=null,v=null,x=null,b=null,y=null,g=null,M=null,C=!1,E=null,w=null,F=null,H=null,ne=null,Y=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),L=!1,N=0,G=t.getParameter(t.VERSION);G.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL\ ([0-9])/.exec(G)[1]),L=N>=1):G.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(G)[1]),L=N>=2);let z=null,D={},B=new mt,q=new mt;function $(I,ee,ae){let ve=new Uint8Array(4),oe=t.createTexture();t.bindTexture(I,oe),t.texParameteri(I,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(I,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let pe=0;pe<ae;pe++)t.texImage2D(ee+pe,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ve);return oe}let ce={};ce[t.TEXTURE_2D]=$(t.TEXTURE_2D,t.TEXTURE_2D,1),ce[t.TEXTURE_CUBE_MAP]=$(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),l.setClear(0,0,0,1),u.setClear(1),h.setClear(0),ge(t.DEPTH_TEST),u.setFunc(tu),we(!1),Ve(jg),ge(t.CULL_FACE),V(Ki);function ge(I){d[I]!==!0&&(t.enable(I),d[I]=!0)}function he(I){d[I]!==!1&&(t.disable(I),d[I]=!1)}function Pe(I){return f!==I?(t.useProgram(I),f=I,!0):!1}let Fe={[jo]:t.FUNC_ADD,[ob]:t.FUNC_SUBTRACT,[sb]:t.FUNC_REVERSE_SUBTRACT};if(r)Fe[$g]=t.MIN,Fe[Zg]=t.MAX;else{let I=e.get("EXT_blend_minmax");I!==null&&(Fe[$g]=I.MIN_EXT,Fe[Zg]=I.MAX_EXT)}let st={[ab]:t.ZERO,[cb]:t.ONE,[lb]:t.SRC_COLOR,[Yf]:t.SRC_ALPHA,[mb]:t.SRC_ALPHA_SATURATE,[db]:t.DST_COLOR,[hb]:t.DST_ALPHA,[ub]:t.ONE_MINUS_SRC_COLOR,[$f]:t.ONE_MINUS_SRC_ALPHA,[pb]:t.ONE_MINUS_DST_COLOR,[fb]:t.ONE_MINUS_DST_ALPHA};function V(I,ee,ae,ve,oe,pe,be,Te){if(I===Ki){p&&(he(t.BLEND),p=!1);return}if(p||(ge(t.BLEND),p=!0),I!==ib){if(I!==m||Te!==C){if((v!==jo||y!==jo)&&(t.blendEquation(t.FUNC_ADD),v=jo,y=jo),Te)switch(I){case Os:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case qg:t.blendFunc(t.ONE,t.ONE);break;case Xg:t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA);break;case Yg:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}else switch(I){case Os:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case qg:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case Xg:t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR);break;case Yg:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}x=null,b=null,g=null,M=null,m=I,C=Te}return}oe=oe||ee,pe=pe||ae,be=be||ve,(ee!==v||oe!==y)&&(t.blendEquationSeparate(Fe[ee],Fe[oe]),v=ee,y=oe),(ae!==x||ve!==b||pe!==g||be!==M)&&(t.blendFuncSeparate(st[ae],st[ve],st[pe],st[be]),x=ae,b=ve,g=pe,M=be),m=I,C=null}function _t(I,ee){I.side===Wo?he(t.CULL_FACE):ge(t.CULL_FACE);let ae=I.side===kt;ee&&(ae=!ae),we(ae),I.blending===Os&&I.transparent===!1?V(Ki):V(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.premultipliedAlpha),u.setFunc(I.depthFunc),u.setTest(I.depthTest),u.setMask(I.depthWrite),l.setMask(I.colorWrite);let ve=I.stencilWrite;h.setTest(ve),ve&&(h.setMask(I.stencilWriteMask),h.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),h.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),$e(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits)}function we(I){E!==I&&(I?t.frontFace(t.CW):t.frontFace(t.CCW),E=I)}function Ve(I){I!==tb?(ge(t.CULL_FACE),I!==w&&(I===jg?t.cullFace(t.BACK):I===nb?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):he(t.CULL_FACE),w=I}function Ce(I){I!==F&&(L&&t.lineWidth(I),F=I)}function $e(I,ee,ae){I?(ge(t.POLYGON_OFFSET_FILL),(H!==ee||ne!==ae)&&(t.polygonOffset(ee,ae),H=ee,ne=ae)):he(t.POLYGON_OFFSET_FILL)}function Ie(I){I?ge(t.SCISSOR_TEST):he(t.SCISSOR_TEST)}function Q(I){I===void 0&&(I=t.TEXTURE0+Y-1),z!==I&&(t.activeTexture(I),z=I)}function re(I,ee){z===null&&Q();let ae=D[z];ae===void 0&&(ae={type:void 0,texture:void 0},D[z]=ae),(ae.type!==I||ae.texture!==ee)&&(t.bindTexture(I,ee||ce[I]),ae.type=I,ae.texture=ee)}function ie(){let I=D[z];I!==void 0&&I.type!==void 0&&(t.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function _e(){try{t.compressedTexImage2D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function le(){try{t.texImage2D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function A(){try{t.texImage3D.apply(t,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function S(I){B.equals(I)===!1&&(t.scissor(I.x,I.y,I.z,I.w),B.copy(I))}function K(I){q.equals(I)===!1&&(t.viewport(I.x,I.y,I.z,I.w),q.copy(I))}function Z(){d={},z=null,D={},f=null,m=null,E=null,w=null,l.reset(),u.reset(),h.reset()}return{buffers:{color:l,depth:u,stencil:h},enable:ge,disable:he,useProgram:Pe,setBlending:V,setMaterial:_t,setFlipSided:we,setCullFace:Ve,setLineWidth:Ce,setPolygonOffset:$e,setScissorTest:Ie,activeTexture:Q,bindTexture:re,unbindTexture:ie,compressedTexImage2D:_e,texImage2D:le,texImage3D:A,scissor:S,viewport:K,reset:Z}}function eT(t,e,n,r,o,a,c){let l=o.isWebGL2,u=o.maxTextures,h=o.maxCubemapSize,d=o.maxTextureSize,f=o.maxSamples,p=new WeakMap,m,v=!1;try{v=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function x(A,S){return v?new OffscreenCanvas(A,S):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function b(A,S,K,Z){let I=1;if((A.width>Z||A.height>Z)&&(I=Z/Math.max(A.width,A.height)),I<1||S===!0)if(typeof HTMLImageElement!="undefined"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&A instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&A instanceof ImageBitmap){let ee=S?je.floorPowerOfTwo:Math.floor,ae=ee(I*A.width),ve=ee(I*A.height);m===void 0&&(m=x(ae,ve));let oe=K?x(ae,ve):m;return oe.width=ae,oe.height=ve,oe.getContext("2d").drawImage(A,0,0,ae,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+A.width+"x"+A.height+") to ("+ae+"x"+ve+")."),oe}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+A.width+"x"+A.height+")."),A;return A}function y(A){return je.isPowerOfTwo(A.width)&&je.isPowerOfTwo(A.height)}function g(A){return l?!1:A.wrapS!==ln||A.wrapT!==ln||A.minFilter!==Xt&&A.minFilter!==Ht}function M(A,S){return A.generateMipmaps&&S&&A.minFilter!==Xt&&A.minFilter!==Ht}function C(A,S,K,Z){t.generateMipmap(A);let I=r.get(S);I.__maxMipLevel=Math.log(Math.max(K,Z))*Math.LOG2E}function E(A,S,K){if(l===!1)return S;if(A!==null){if(t[A]!==void 0)return t[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let Z=S;return S===t.RED&&(K===t.FLOAT&&(Z=t.R32F),K===t.HALF_FLOAT&&(Z=t.R16F),K===t.UNSIGNED_BYTE&&(Z=t.R8)),S===t.RGB&&(K===t.FLOAT&&(Z=t.RGB32F),K===t.HALF_FLOAT&&(Z=t.RGB16F),K===t.UNSIGNED_BYTE&&(Z=t.RGB8)),S===t.RGBA&&(K===t.FLOAT&&(Z=t.RGBA32F),K===t.HALF_FLOAT&&(Z=t.RGBA16F),K===t.UNSIGNED_BYTE&&(Z=t.RGBA8)),(Z===t.R16F||Z===t.R32F||Z===t.RGBA16F||Z===t.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function w(A){return A===Xt||A===Kf||A===ed?t.NEAREST:t.LINEAR}function F(A){let S=A.target;S.removeEventListener("dispose",F),ne(S),S.isVideoTexture&&p.delete(S),c.memory.textures--}function H(A){let S=A.target;S.removeEventListener("dispose",H),Y(S),c.memory.textures--}function ne(A){let S=r.get(A);S.__webglInit!==void 0&&(t.deleteTexture(S.__webglTexture),r.remove(A))}function Y(A){let S=r.get(A),K=r.get(A.texture);if(A){if(K.__webglTexture!==void 0&&t.deleteTexture(K.__webglTexture),A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++)t.deleteFramebuffer(S.__webglFramebuffer[Z]),S.__webglDepthbuffer&&t.deleteRenderbuffer(S.__webglDepthbuffer[Z]);else t.deleteFramebuffer(S.__webglFramebuffer),S.__webglDepthbuffer&&t.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&t.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer&&t.deleteRenderbuffer(S.__webglColorRenderbuffer),S.__webglDepthRenderbuffer&&t.deleteRenderbuffer(S.__webglDepthRenderbuffer);r.remove(A.texture),r.remove(A)}}let L=0;function N(){L=0}function G(){let A=L;return A>=u&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+u),L+=1,A}function z(A,S){let K=r.get(A);if(A.isVideoTexture&&Q(A),A.version>0&&K.__version!==A.version){let Z=A.image;if(Z===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(K,A,S);return}}n.activeTexture(t.TEXTURE0+S),n.bindTexture(t.TEXTURE_2D,K.__webglTexture)}function D(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Pe(K,A,S);return}n.activeTexture(t.TEXTURE0+S),n.bindTexture(t.TEXTURE_2D_ARRAY,K.__webglTexture)}function B(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Pe(K,A,S);return}n.activeTexture(t.TEXTURE0+S),n.bindTexture(t.TEXTURE_3D,K.__webglTexture)}function q(A,S){let K=r.get(A);if(A.version>0&&K.__version!==A.version){Fe(K,A,S);return}n.activeTexture(t.TEXTURE0+S),n.bindTexture(t.TEXTURE_CUBE_MAP,K.__webglTexture)}let $={[vc]:t.REPEAT,[ln]:t.CLAMP_TO_EDGE,[yc]:t.MIRRORED_REPEAT},ce={[Xt]:t.NEAREST,[Kf]:t.NEAREST_MIPMAP_NEAREST,[ed]:t.NEAREST_MIPMAP_LINEAR,[Ht]:t.LINEAR,[Jg]:t.LINEAR_MIPMAP_NEAREST,[to]:t.LINEAR_MIPMAP_LINEAR};function ge(A,S,K){K?(t.texParameteri(A,t.TEXTURE_WRAP_S,$[S.wrapS]),t.texParameteri(A,t.TEXTURE_WRAP_T,$[S.wrapT]),(A===t.TEXTURE_3D||A===t.TEXTURE_2D_ARRAY)&&t.texParameteri(A,t.TEXTURE_WRAP_R,$[S.wrapR]),t.texParameteri(A,t.TEXTURE_MAG_FILTER,ce[S.magFilter]),t.texParameteri(A,t.TEXTURE_MIN_FILTER,ce[S.minFilter])):(t.texParameteri(A,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(A,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(A===t.TEXTURE_3D||A===t.TEXTURE_2D_ARRAY)&&t.texParameteri(A,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(S.wrapS!==ln||S.wrapT!==ln)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(A,t.TEXTURE_MAG_FILTER,w(S.magFilter)),t.texParameteri(A,t.TEXTURE_MIN_FILTER,w(S.minFilter)),S.minFilter!==Xt&&S.minFilter!==Ht&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));let Z=e.get("EXT_texture_filter_anisotropic");if(Z){if(S.type===Zr&&e.get("OES_texture_float_linear")===null||S.type===ks&&(l||e.get("OES_texture_half_float_linear"))===null)return;(S.anisotropy>1||r.get(S).__currentAnisotropy)&&(t.texParameterf(A,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,o.getMaxAnisotropy())),r.get(S).__currentAnisotropy=S.anisotropy)}}function he(A,S){A.__webglInit===void 0&&(A.__webglInit=!0,S.addEventListener("dispose",F),A.__webglTexture=t.createTexture(),c.memory.textures++)}function Pe(A,S,K){let Z=t.TEXTURE_2D;S.isDataTexture2DArray&&(Z=t.TEXTURE_2D_ARRAY),S.isDataTexture3D&&(Z=t.TEXTURE_3D),he(A,S),n.activeTexture(t.TEXTURE0+K),n.bindTexture(Z,A.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,S.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,S.unpackAlignment);let I=g(S)&&y(S.image)===!1,ee=b(S.image,I,!1,d),ae=y(ee)||l,ve=a.convert(S.format),oe=a.convert(S.type),pe=E(S.internalFormat,ve,oe);ge(Z,S,ae);let be,Te=S.mipmaps;if(S.isDepthTexture)pe=t.DEPTH_COMPONENT,l?S.type===Zr?pe=t.DEPTH_COMPONENT32F:S.type===xc?pe=t.DEPTH_COMPONENT24:S.type===Yo?pe=t.DEPTH24_STENCIL8:pe=t.DEPTH_COMPONENT16:S.type===Zr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===no&&pe===t.DEPTH_COMPONENT&&S.type!==Gs&&S.type!==xc&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=Gs,oe=a.convert(S.type)),S.format===$o&&pe===t.DEPTH_COMPONENT&&(pe=t.DEPTH_STENCIL,S.type!==Yo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Yo,oe=a.convert(S.type))),n.texImage2D(t.TEXTURE_2D,0,pe,ee.width,ee.height,0,ve,oe,null);else if(S.isDataTexture)if(Te.length>0&&ae){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],n.texImage2D(t.TEXTURE_2D,de,pe,be.width,be.height,0,ve,oe,be.data);S.generateMipmaps=!1,A.__maxMipLevel=Te.length-1}else n.texImage2D(t.TEXTURE_2D,0,pe,ee.width,ee.height,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(S.isCompressedTexture){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],S.format!==mn&&S.format!==Lr?ve!==null?n.compressedTexImage2D(t.TEXTURE_2D,de,pe,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,de,pe,be.width,be.height,0,ve,oe,be.data);A.__maxMipLevel=Te.length-1}else if(S.isDataTexture2DArray)n.texImage3D(t.TEXTURE_2D_ARRAY,0,pe,ee.width,ee.height,ee.depth,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(S.isDataTexture3D)n.texImage3D(t.TEXTURE_3D,0,pe,ee.width,ee.height,ee.depth,0,ve,oe,ee.data),A.__maxMipLevel=0;else if(Te.length>0&&ae){for(let de=0,Me=Te.length;de<Me;de++)be=Te[de],n.texImage2D(t.TEXTURE_2D,de,pe,ve,oe,be);S.generateMipmaps=!1,A.__maxMipLevel=Te.length-1}else n.texImage2D(t.TEXTURE_2D,0,pe,ve,oe,ee),A.__maxMipLevel=0;M(S,ae)&&C(Z,S,ee.width,ee.height),A.__version=S.version,S.onUpdate&&S.onUpdate(S)}function Fe(A,S,K){if(S.image.length!==6)return;he(A,S),n.activeTexture(t.TEXTURE0+K),n.bindTexture(t.TEXTURE_CUBE_MAP,A.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,S.flipY);let Z=S&&(S.isCompressedTexture||S.image[0].isCompressedTexture),I=S.image[0]&&S.image[0].isDataTexture,ee=[];for(let de=0;de<6;de++)!Z&&!I?ee[de]=b(S.image[de],!1,!0,h):ee[de]=I?S.image[de].image:S.image[de];let ae=ee[0],ve=y(ae)||l,oe=a.convert(S.format),pe=a.convert(S.type),be=E(S.internalFormat,oe,pe);ge(t.TEXTURE_CUBE_MAP,S,ve);let Te;if(Z){for(let de=0;de<6;de++){Te=ee[de].mipmaps;for(let Me=0;Me<Te.length;Me++){let ot=Te[Me];S.format!==mn&&S.format!==Lr?oe!==null?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,Me,be,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,Me,be,ot.width,ot.height,0,oe,pe,ot.data)}}A.__maxMipLevel=Te.length-1}else{Te=S.mipmaps;for(let de=0;de<6;de++)if(I){n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,be,ee[de].width,ee[de].height,0,oe,pe,ee[de].data);for(let Me=0;Me<Te.length;Me++){let Mt=Te[Me].image[de].image;n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,Me+1,be,Mt.width,Mt.height,0,oe,pe,Mt.data)}}else{n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,be,oe,pe,ee[de]);for(let Me=0;Me<Te.length;Me++){let ot=Te[Me];n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+de,Me+1,be,oe,pe,ot.image[de])}}A.__maxMipLevel=Te.length}M(S,ve)&&C(t.TEXTURE_CUBE_MAP,S,ae.width,ae.height),A.__version=S.version,S.onUpdate&&S.onUpdate(S)}function st(A,S,K,Z){let I=a.convert(S.texture.format),ee=a.convert(S.texture.type),ae=E(S.texture.internalFormat,I,ee);n.texImage2D(Z,0,ae,S.width,S.height,0,I,ee,null),t.bindFramebuffer(t.FRAMEBUFFER,A),t.framebufferTexture2D(t.FRAMEBUFFER,K,Z,r.get(S.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function V(A,S,K){if(t.bindRenderbuffer(t.RENDERBUFFER,A),S.depthBuffer&&!S.stencilBuffer){let Z=t.DEPTH_COMPONENT16;if(K){let I=S.depthTexture;I&&I.isDepthTexture&&(I.type===Zr?Z=t.DEPTH_COMPONENT32F:I.type===xc&&(Z=t.DEPTH_COMPONENT24));let ee=Ie(S);t.renderbufferStorageMultisample(t.RENDERBUFFER,ee,Z,S.width,S.height)}else t.renderbufferStorage(t.RENDERBUFFER,Z,S.width,S.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,A)}else if(S.depthBuffer&&S.stencilBuffer){if(K){let Z=Ie(S);t.renderbufferStorageMultisample(t.RENDERBUFFER,Z,t.DEPTH24_STENCIL8,S.width,S.height)}else t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,S.width,S.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,A)}else{let Z=a.convert(S.texture.format),I=a.convert(S.texture.type),ee=E(S.texture.internalFormat,Z,I);if(K){let ae=Ie(S);t.renderbufferStorageMultisample(t.RENDERBUFFER,ae,ee,S.width,S.height)}else t.renderbufferStorage(t.RENDERBUFFER,ee,S.width,S.height)}t.bindRenderbuffer(t.RENDERBUFFER,null)}function _t(A,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,A),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),z(S.depthTexture,0);let Z=r.get(S.depthTexture).__webglTexture;if(S.depthTexture.format===no)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Z,0);else if(S.depthTexture.format===$o)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function we(A){let S=r.get(A),K=A.isWebGLCubeRenderTarget===!0;if(A.depthTexture){if(K)throw new Error("target.depthTexture not supported in Cube render targets");_t(S.__webglFramebuffer,A)}else if(K){S.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)t.bindFramebuffer(t.FRAMEBUFFER,S.__webglFramebuffer[Z]),S.__webglDepthbuffer[Z]=t.createRenderbuffer(),V(S.__webglDepthbuffer[Z],A,!1)}else t.bindFramebuffer(t.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=t.createRenderbuffer(),V(S.__webglDepthbuffer,A,!1);t.bindFramebuffer(t.FRAMEBUFFER,null)}function Ve(A){let S=r.get(A),K=r.get(A.texture);A.addEventListener("dispose",H),K.__webglTexture=t.createTexture(),c.memory.textures++;let Z=A.isWebGLCubeRenderTarget===!0,I=A.isWebGLMultisampleRenderTarget===!0,ee=y(A)||l;if(l&&A.texture.format===Lr&&(A.texture.type===Zr||A.texture.type===ks)&&(A.texture.format=mn,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),Z){S.__webglFramebuffer=[];for(let ae=0;ae<6;ae++)S.__webglFramebuffer[ae]=t.createFramebuffer()}else if(S.__webglFramebuffer=t.createFramebuffer(),I)if(l){S.__webglMultisampledFramebuffer=t.createFramebuffer(),S.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,S.__webglColorRenderbuffer);let ae=a.convert(A.texture.format),ve=a.convert(A.texture.type),oe=E(A.texture.internalFormat,ae,ve),pe=Ie(A);t.renderbufferStorageMultisample(t.RENDERBUFFER,pe,oe,A.width,A.height),t.bindFramebuffer(t.FRAMEBUFFER,S.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,S.__webglColorRenderbuffer),t.bindRenderbuffer(t.RENDERBUFFER,null),A.depthBuffer&&(S.__webglDepthRenderbuffer=t.createRenderbuffer(),V(S.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(t.FRAMEBUFFER,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(Z){n.bindTexture(t.TEXTURE_CUBE_MAP,K.__webglTexture),ge(t.TEXTURE_CUBE_MAP,A.texture,ee);for(let ae=0;ae<6;ae++)st(S.__webglFramebuffer[ae],A,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ae);M(A.texture,ee)&&C(t.TEXTURE_CUBE_MAP,A.texture,A.width,A.height),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,K.__webglTexture),ge(t.TEXTURE_2D,A.texture,ee),st(S.__webglFramebuffer,A,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),M(A.texture,ee)&&C(t.TEXTURE_2D,A.texture,A.width,A.height),n.bindTexture(t.TEXTURE_2D,null);A.depthBuffer&&we(A)}function Ce(A){let S=A.texture,K=y(A)||l;if(M(S,K)){let Z=A.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,I=r.get(S).__webglTexture;n.bindTexture(Z,I),C(Z,S,A.width,A.height),n.bindTexture(Z,null)}}function $e(A){if(A.isWebGLMultisampleRenderTarget)if(l){let S=r.get(A);t.bindFramebuffer(t.READ_FRAMEBUFFER,S.__webglMultisampledFramebuffer),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,S.__webglFramebuffer);let K=A.width,Z=A.height,I=t.COLOR_BUFFER_BIT;A.depthBuffer&&(I|=t.DEPTH_BUFFER_BIT),A.stencilBuffer&&(I|=t.STENCIL_BUFFER_BIT),t.blitFramebuffer(0,0,K,Z,0,0,K,Z,I,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,S.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function Ie(A){return l&&A.isWebGLMultisampleRenderTarget?Math.min(f,A.samples):0}function Q(A){let S=c.render.frame;p.get(A)!==S&&(p.set(A,S),A.update())}let re=!1,ie=!1;function _e(A,S){A&&A.isWebGLRenderTarget&&(re===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),re=!0),A=A.texture),z(A,S)}function le(A,S){A&&A.isWebGLCubeRenderTarget&&(ie===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ie=!0),A=A.texture),q(A,S)}this.allocateTextureUnit=G,this.resetTextureUnits=N,this.setTexture2D=z,this.setTexture2DArray=D,this.setTexture3D=B,this.setTextureCube=q,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=Ce,this.updateMultisampleRenderTarget=$e,this.safeSetTexture2D=_e,this.safeSetTextureCube=le}function Iv(t,e,n){let r=n.isWebGL2;function o(a){let c;if(a===Ns)return t.UNSIGNED_BYTE;if(a===Ib)return t.UNSIGNED_SHORT_4_4_4_4;if(a===Db)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Bb)return t.UNSIGNED_SHORT_5_6_5;if(a===Pb)return t.BYTE;if(a===Lb)return t.SHORT;if(a===Gs)return t.UNSIGNED_SHORT;if(a===Fb)return t.INT;if(a===xc)return t.UNSIGNED_INT;if(a===Zr)return t.FLOAT;if(a===ks)return r?t.HALF_FLOAT:(c=e.get("OES_texture_half_float"),c!==null?c.HALF_FLOAT_OES:null);if(a===Ob)return t.ALPHA;if(a===Lr)return t.RGB;if(a===mn)return t.RGBA;if(a===Ub)return t.LUMINANCE;if(a===Nb)return t.LUMINANCE_ALPHA;if(a===no)return t.DEPTH_COMPONENT;if(a===$o)return t.DEPTH_STENCIL;if(a===Gb)return t.RED;if(a===kb)return t.RED_INTEGER;if(a===Hb)return t.RG;if(a===zb)return t.RG_INTEGER;if(a===Vb)return t.RGB_INTEGER;if(a===Wb)return t.RGBA_INTEGER;if(a===Qg||a===Kg||a===ev||a===tv)if(c=e.get("WEBGL_compressed_texture_s3tc"),c!==null){if(a===Qg)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Kg)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ev)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===tv)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===nv||a===rv||a===iv||a===ov)if(c=e.get("WEBGL_compressed_texture_pvrtc"),c!==null){if(a===nv)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===rv)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===iv)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===ov)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===jb)return c=e.get("WEBGL_compressed_texture_etc1"),c!==null?c.COMPRESSED_RGB_ETC1_WEBGL:null;if((a===sv||a===av)&&(c=e.get("WEBGL_compressed_texture_etc"),c!==null)){if(a===sv)return c.COMPRESSED_RGB8_ETC2;if(a===av)return c.COMPRESSED_RGBA8_ETC2_EAC}if(a===qb||a===Xb||a===Yb||a===$b||a===Zb||a===Jb||a===Qb||a===Kb||a===ew||a===tw||a===nw||a===rw||a===iw||a===ow||a===aw||a===cw||a===lw||a===uw||a===hw||a===fw||a===dw||a===pw||a===mw||a===gw||a===vw||a===yw||a===xw||a===_w)return c=e.get("WEBGL_compressed_texture_astc"),c!==null?a:null;if(a===sw)return c=e.get("EXT_texture_compression_bptc"),c!==null?a:null;if(a===Yo)return r?t.UNSIGNED_INT_24_8:(c=e.get("WEBGL_depth_texture"),c!==null?c.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:o}}function lu(t){It.call(this),this.cameras=t||[]}lu.prototype=Object.assign(Object.create(It.prototype),{constructor:lu,isArrayCamera:!0});function mo(){Ue.call(this),this.type="Group"}mo.prototype=Object.assign(Object.create(Ue.prototype),{constructor:mo,isGroup:!0});function zc(){this._targetRay=null,this._grip=null,this._hand=null}Object.assign(zc.prototype,{constructor:zc,getHandSpace:function(){if(this._hand===null&&(this._hand=new mo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(let t=0;t<=window.XRHand.LITTLE_PHALANX_TIP;t++){let e=new mo;e.matrixAutoUpdate=!1,e.visible=!1,this._hand.joints.push(e),this._hand.add(e)}return this._hand},getTargetRaySpace:function(){return this._targetRay===null&&(this._targetRay=new mo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return this._grip===null&&(this._grip=new mo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},update:function(t,e,n){let r=null,o=null,a=null,c=this._targetRay,l=this._grip,u=this._hand;if(t)if(u&&t.hand){a=!0;for(let h=0;h<=window.XRHand.LITTLE_PHALANX_TIP;h++)if(t.hand[h]){let d=e.getJointPose(t.hand[h],n),f=u.joints[h];d!==null&&(f.matrix.fromArray(d.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.jointRadius=d.radius),f.visible=d!==null;let p=u.joints[window.XRHand.INDEX_PHALANX_TIP],m=u.joints[window.XRHand.THUMB_PHALANX_TIP],v=p.position.distanceTo(m.position),x=.02,b=.005;u.inputState.pinching&&v>x+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&v<=x-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}}else c!==null&&(r=e.getPose(t.targetRaySpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale))),l!==null&&t.gripSpace&&(o=e.getPose(t.gripSpace,n),o!==null&&(l.matrix.fromArray(o.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale)));return c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),u!==null&&(u.visible=a!==null),this}});function Dv(t,e){let n=this,r=null,o=1,a=null,c="local-floor",l=null,u=[],h=new Map,d=new It;d.layers.enable(1),d.viewport=new mt;let f=new It;f.layers.enable(2),f.viewport=new mt;let p=[d,f],m=new lu;m.layers.enable(1),m.layers.enable(2);let v=null,x=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let N=u[L];return N===void 0&&(N=new zc,u[L]=N),N.getTargetRaySpace()},this.getControllerGrip=function(L){let N=u[L];return N===void 0&&(N=new zc,u[L]=N),N.getGripSpace()},this.getHand=function(L){let N=u[L];return N===void 0&&(N=new zc,u[L]=N),N.getHandSpace()};function b(L){let N=h.get(L.inputSource);N&&N.dispatchEvent({type:L.type,data:L.inputSource})}function y(){h.forEach(function(L,N){L.disconnect(N)}),h.clear(),t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function g(L){a=L,Y.setContext(r),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}this.setFramebufferScaleFactor=function(L){o=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){c=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getSession=function(){return r},this.setSession=function(L){if(r=L,r!==null){r.addEventListener("select",b),r.addEventListener("selectstart",b),r.addEventListener("selectend",b),r.addEventListener("squeeze",b),r.addEventListener("squeezestart",b),r.addEventListener("squeezeend",b),r.addEventListener("end",y);let N=e.getContextAttributes();N.xrCompatible!==!0&&e.makeXRCompatible();let G={antialias:N.antialias,alpha:N.alpha,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:o},z=new XRWebGLLayer(r,e,G);r.updateRenderState({baseLayer:z}),r.requestReferenceSpace(c).then(g),r.addEventListener("inputsourceschange",M)}};function M(L){let N=r.inputSources;for(let G=0;G<u.length;G++)h.set(N[G],u[G]);for(let G=0;G<L.removed.length;G++){let z=L.removed[G],D=h.get(z);D&&(D.dispatchEvent({type:"disconnected",data:z}),h.delete(z))}for(let G=0;G<L.added.length;G++){let z=L.added[G],D=h.get(z);D&&D.dispatchEvent({type:"connected",data:z})}}let C=new O,E=new O;function w(L,N,G){C.setFromMatrixPosition(N.matrixWorld),E.setFromMatrixPosition(G.matrixWorld);let z=C.distanceTo(E),D=N.projectionMatrix.elements,B=G.projectionMatrix.elements,q=D[14]/(D[10]-1),$=D[14]/(D[10]+1),ce=(D[9]+1)/D[5],ge=(D[9]-1)/D[5],he=(D[8]-1)/D[0],Pe=(B[8]+1)/B[0],Fe=q*he,st=q*Pe,V=z/(-he+Pe),_t=V*-he;N.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(_t),L.translateZ(V),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.getInverse(L.matrixWorld);let we=q+V,Ve=$+V,Ce=Fe-_t,$e=st+(z-_t),Ie=ce*$/Ve*we,Q=ge*$/Ve*we;L.projectionMatrix.makePerspective(Ce,$e,Ie,Q,we,Ve)}function F(L,N){N===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(N.matrixWorld,L.matrix),L.matrixWorldInverse.getInverse(L.matrixWorld)}this.getCamera=function(L){m.near=f.near=d.near=L.near,m.far=f.far=d.far=L.far,(v!==m.near||x!==m.far)&&(r.updateRenderState({depthNear:m.near,depthFar:m.far}),v=m.near,x=m.far);let N=L.parent,G=m.cameras;F(m,N);for(let D=0;D<G.length;D++)F(G[D],N);L.matrixWorld.copy(m.matrixWorld);let z=L.children;for(let D=0,B=z.length;D<B;D++)z[D].updateMatrixWorld(!0);return G.length===2?w(m,d,f):m.projectionMatrix.copy(d.projectionMatrix),m};let H=null;function ne(L,N){if(l=N.getViewerPose(a),l!==null){let z=l.views,D=r.renderState.baseLayer;t.setFramebuffer(D.framebuffer);let B=!1;z.length!==m.cameras.length&&(m.cameras.length=0,B=!0);for(let q=0;q<z.length;q++){let $=z[q],ce=D.getViewport($),ge=p[q];ge.matrix.fromArray($.transform.matrix),ge.projectionMatrix.fromArray($.projectionMatrix),ge.viewport.set(ce.x,ce.y,ce.width,ce.height),q===0&&m.matrix.copy(ge.matrix),B===!0&&m.cameras.push(ge)}}let G=r.inputSources;for(let z=0;z<u.length;z++){let D=u[z],B=G[z];D.update(B,N,a)}H&&H(L,N)}let Y=new Fd;Y.setAnimationLoop(ne),this.setAnimationLoop=function(L){H=L},this.dispose=function(){}}Object.assign(Dv.prototype,gn.prototype);function tT(t){function e(y,g){y.fogColor.value.copy(g.color),g.isFog?(y.fogNear.value=g.near,y.fogFar.value=g.far):g.isFogExp2&&(y.fogDensity.value=g.density)}function n(y,g,M,C){g.isMeshBasicMaterial?r(y,g):g.isMeshLambertMaterial?(r(y,g),u(y,g)):g.isMeshToonMaterial?(r(y,g),d(y,g)):g.isMeshPhongMaterial?(r(y,g),h(y,g)):g.isMeshStandardMaterial?(r(y,g),g.isMeshPhysicalMaterial?p(y,g):f(y,g)):g.isMeshMatcapMaterial?(r(y,g),m(y,g)):g.isMeshDepthMaterial?(r(y,g),v(y,g)):g.isMeshDistanceMaterial?(r(y,g),x(y,g)):g.isMeshNormalMaterial?(r(y,g),b(y,g)):g.isLineBasicMaterial?(o(y,g),g.isLineDashedMaterial&&a(y,g)):g.isPointsMaterial?c(y,g,M,C):g.isSpriteMaterial?l(y,g):g.isShadowMaterial?(y.color.value.copy(g.color),y.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(y,g){y.opacity.value=g.opacity,g.color&&y.diffuse.value.copy(g.color),g.emissive&&y.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap),g.specularMap&&(y.specularMap.value=g.specularMap);let M=t.get(g).envMap;if(M){y.envMap.value=M,y.flipEnvMap.value=M.isCubeTexture&&M._needsFlipEnvMap?-1:1,y.reflectivity.value=g.reflectivity,y.refractionRatio.value=g.refractionRatio;let w=t.get(M).__maxMipLevel;w!==void 0&&(y.maxMipLevel.value=w)}g.lightMap&&(y.lightMap.value=g.lightMap,y.lightMapIntensity.value=g.lightMapIntensity),g.aoMap&&(y.aoMap.value=g.aoMap,y.aoMapIntensity.value=g.aoMapIntensity);let C;g.map?C=g.map:g.specularMap?C=g.specularMap:g.displacementMap?C=g.displacementMap:g.normalMap?C=g.normalMap:g.bumpMap?C=g.bumpMap:g.roughnessMap?C=g.roughnessMap:g.metalnessMap?C=g.metalnessMap:g.alphaMap?C=g.alphaMap:g.emissiveMap?C=g.emissiveMap:g.clearcoatMap?C=g.clearcoatMap:g.clearcoatNormalMap?C=g.clearcoatNormalMap:g.clearcoatRoughnessMap&&(C=g.clearcoatRoughnessMap),C!==void 0&&(C.isWebGLRenderTarget&&(C=C.texture),C.matrixAutoUpdate===!0&&C.updateMatrix(),y.uvTransform.value.copy(C.matrix));let E;g.aoMap?E=g.aoMap:g.lightMap&&(E=g.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),y.uv2Transform.value.copy(E.matrix))}function o(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity}function a(y,g){y.dashSize.value=g.dashSize,y.totalSize.value=g.dashSize+g.gapSize,y.scale.value=g.scale}function c(y,g,M,C){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.size.value=g.size*M,y.scale.value=C*.5,g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap);let E;g.map?E=g.map:g.alphaMap&&(E=g.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),y.uvTransform.value.copy(E.matrix))}function l(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.rotation.value=g.rotation,g.map&&(y.map.value=g.map),g.alphaMap&&(y.alphaMap.value=g.alphaMap);let M;g.map?M=g.map:g.alphaMap&&(M=g.alphaMap),M!==void 0&&(M.matrixAutoUpdate===!0&&M.updateMatrix(),y.uvTransform.value.copy(M.matrix))}function u(y,g){g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap)}function h(y,g){y.specular.value.copy(g.specular),y.shininess.value=Math.max(g.shininess,1e-4),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===kt&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===kt&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function d(y,g){g.gradientMap&&(y.gradientMap.value=g.gradientMap),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===kt&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===kt&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function f(y,g){y.roughness.value=g.roughness,y.metalness.value=g.metalness,g.roughnessMap&&(y.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(y.metalnessMap.value=g.metalnessMap),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===kt&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===kt&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias),t.get(g).envMap&&(y.envMapIntensity.value=g.envMapIntensity)}function p(y,g){f(y,g),y.reflectivity.value=g.reflectivity,y.clearcoat.value=g.clearcoat,y.clearcoatRoughness.value=g.clearcoatRoughness,g.sheen&&y.sheen.value.copy(g.sheen),g.clearcoatMap&&(y.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(y.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),y.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===kt&&y.clearcoatNormalScale.value.negate()),y.transmission.value=g.transmission,g.transmissionMap&&(y.transmissionMap.value=g.transmissionMap)}function m(y,g){g.matcap&&(y.matcap.value=g.matcap),g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===kt&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===kt&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function v(y,g){g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}function x(y,g){g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias),y.referencePosition.value.copy(g.referencePosition),y.nearDistance.value=g.nearDistance,y.farDistance.value=g.farDistance}function b(y,g){g.bumpMap&&(y.bumpMap.value=g.bumpMap,y.bumpScale.value=g.bumpScale,g.side===kt&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,y.normalScale.value.copy(g.normalScale),g.side===kt&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function Zs(t){t=t||{};let e=t.canvas!==void 0?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=t.context!==void 0?t.context:null,r=t.alpha!==void 0?t.alpha:!1,o=t.depth!==void 0?t.depth:!0,a=t.stencil!==void 0?t.stencil:!0,c=t.antialias!==void 0?t.antialias:!1,l=t.premultipliedAlpha!==void 0?t.premultipliedAlpha:!0,u=t.preserveDrawingBuffer!==void 0?t.preserveDrawingBuffer:!1,h=t.powerPreference!==void 0?t.powerPreference:"default",d=t.failIfMajorPerformanceCaveat!==void 0?t.failIfMajorPerformanceCaveat:!1,f=null,p=null;this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Fr,this.physicallyCorrectLights=!1,this.toneMapping=eo,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;let m=this,v=!1,x=null,b=0,y=0,g=null,M=null,C=-1,E=null,w=null,F=new mt,H=new mt,ne=null,Y=e.width,L=e.height,N=1,G=null,z=null,D=new mt(0,0,Y,L),B=new mt(0,0,Y,L),q=!1,$=new ei,ce=!1,ge=!1,he=new Qe,Pe=new O,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function st(){return g===null?N:1}let V=n;function _t(T,k){for(let U=0;U<T.length;U++){let X=T[U],se=e.getContext(X,k);if(se!==null)return se}return null}try{let T={alpha:r,depth:o,stencil:a,antialias:c,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:h,failIfMajorPerformanceCaveat:d};if(e.addEventListener("webglcontextlost",ot,!1),e.addEventListener("webglcontextrestored",Mt,!1),V===null){let k=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&k.shift(),V=_t(k,T),V===null)throw _t(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(T){throw console.error("THREE.WebGLRenderer: "+T.message),T}let we,Ve,Ce,$e,Ie,Q,re,ie,_e,le,A,S,K,Z,I,ee,ae,ve,oe,pe,be;function Te(){we=new yS(V),Ve=new mS(V,we,t),Ve.isWebGL2===!1&&(we.get("WEBGL_depth_texture"),we.get("OES_texture_float"),we.get("OES_texture_half_float"),we.get("OES_texture_half_float_linear"),we.get("OES_standard_derivatives"),we.get("OES_element_index_uint"),we.get("OES_vertex_array_object"),we.get("ANGLE_instanced_arrays")),we.get("OES_texture_float_linear"),pe=new Iv(V,we,Ve),Ce=new KS(V,we,Ve),Ce.scissor(H.copy(B).multiplyScalar(N).floor()),Ce.viewport(F.copy(D).multiplyScalar(N).floor()),$e=new bS(V),Ie=new jS,Q=new eT(V,we,Ce,Ie,Ve,pe,$e),re=new vS(m),ie=new Ww(V,Ve),be=new dS(V,we,ie,Ve),_e=new xS(V,ie,$e,be),le=new MS(V,_e,ie,$e),ae=new wS(V),I=new gS(Ie),A=new WS(m,re,we,Ve,be,I),S=new tT(Ie),K=new XS(Ie),Z=new ZS(we,Ve),ee=new fS(m,re,Ce,le,l),ve=new pS(V,we,$e,Ve),oe=new _S(V,we,$e,Ve),$e.programs=A.programs,m.capabilities=Ve,m.extensions=we,m.properties=Ie,m.renderLists=K,m.state=Ce,m.info=$e}Te();let de=new Dv(m,V);this.xr=de;let Me=new Id(m,le,Ve.maxTextureSize);this.shadowMap=Me,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let T=we.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){let T=we.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(T){T!==void 0&&(N=T,this.setSize(Y,L,!1))},this.getSize=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),T=new ue),T.set(Y,L)},this.setSize=function(T,k,U){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=T,L=k,e.width=Math.floor(T*N),e.height=Math.floor(k*N),U!==!1&&(e.style.width=T+"px",e.style.height=k+"px"),this.setViewport(0,0,T,k)},this.getDrawingBufferSize=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),T=new ue),T.set(Y*N,L*N).floor()},this.setDrawingBufferSize=function(T,k,U){Y=T,L=k,N=U,e.width=Math.floor(T*U),e.height=Math.floor(k*U),this.setViewport(0,0,T,k)},this.getCurrentViewport=function(T){return T===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),T=new mt),T.copy(F)},this.getViewport=function(T){return T.copy(D)},this.setViewport=function(T,k,U,X){T.isVector4?D.set(T.x,T.y,T.z,T.w):D.set(T,k,U,X),Ce.viewport(F.copy(D).multiplyScalar(N).floor())},this.getScissor=function(T){return T.copy(B)},this.setScissor=function(T,k,U,X){T.isVector4?B.set(T.x,T.y,T.z,T.w):B.set(T,k,U,X),Ce.scissor(H.copy(B).multiplyScalar(N).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(T){Ce.setScissorTest(q=T)},this.setOpaqueSort=function(T){G=T},this.setTransparentSort=function(T){z=T},this.getClearColor=function(){return ee.getClearColor()},this.setClearColor=function(){ee.setClearColor.apply(ee,arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha.apply(ee,arguments)},this.clear=function(T,k,U){let X=0;(T===void 0||T)&&(X|=V.COLOR_BUFFER_BIT),(k===void 0||k)&&(X|=V.DEPTH_BUFFER_BIT),(U===void 0||U)&&(X|=V.STENCIL_BUFFER_BIT),V.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ot,!1),e.removeEventListener("webglcontextrestored",Mt,!1),K.dispose(),Z.dispose(),Ie.dispose(),re.dispose(),le.dispose(),be.dispose(),de.dispose(),fn.stop()};function ot(T){T.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Mt(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1,Te()}function ms(T){let k=T.target;k.removeEventListener("dispose",ms),sl(k)}function sl(T){gs(T),Ie.remove(T)}function gs(T){let k=Ie.get(T).program;k!==void 0&&A.releaseProgram(k)}function al(T,k){T.render(function(U){m.renderBufferImmediate(U,k)})}this.renderBufferImmediate=function(T,k){be.initAttributes();let U=Ie.get(T);T.hasPositions&&!U.position&&(U.position=V.createBuffer()),T.hasNormals&&!U.normal&&(U.normal=V.createBuffer()),T.hasUvs&&!U.uv&&(U.uv=V.createBuffer()),T.hasColors&&!U.color&&(U.color=V.createBuffer());let X=k.getAttributes();T.hasPositions&&(V.bindBuffer(V.ARRAY_BUFFER,U.position),V.bufferData(V.ARRAY_BUFFER,T.positionArray,V.DYNAMIC_DRAW),be.enableAttribute(X.position),V.vertexAttribPointer(X.position,3,V.FLOAT,!1,0,0)),T.hasNormals&&(V.bindBuffer(V.ARRAY_BUFFER,U.normal),V.bufferData(V.ARRAY_BUFFER,T.normalArray,V.DYNAMIC_DRAW),be.enableAttribute(X.normal),V.vertexAttribPointer(X.normal,3,V.FLOAT,!1,0,0)),T.hasUvs&&(V.bindBuffer(V.ARRAY_BUFFER,U.uv),V.bufferData(V.ARRAY_BUFFER,T.uvArray,V.DYNAMIC_DRAW),be.enableAttribute(X.uv),V.vertexAttribPointer(X.uv,2,V.FLOAT,!1,0,0)),T.hasColors&&(V.bindBuffer(V.ARRAY_BUFFER,U.color),V.bufferData(V.ARRAY_BUFFER,T.colorArray,V.DYNAMIC_DRAW),be.enableAttribute(X.color),V.vertexAttribPointer(X.color,3,V.FLOAT,!1,0,0)),be.disableUnusedAttributes(),V.drawArrays(V.TRIANGLES,0,T.count),T.count=0},this.renderBufferDirect=function(T,k,U,X,se,Ge){k===null&&(k=Fe);let De=se.isMesh&&se.matrixWorld.determinant()<0,ze=Eo(T,k,X,se);Ce.setMaterial(X,De);let Be=U.index,lt=U.attributes.position;if(Be===null){if(lt===void 0||lt.count===0)return}else if(Be.count===0)return;let ct=1;X.wireframe===!0&&(Be=_e.getWireframeAttribute(U),ct=2),(X.morphTargets||X.morphNormals)&&ae.update(se,U,X,ze),be.setup(se,X,ze,U,Be);let Re,nt=ve;Be!==null&&(Re=ie.get(Be),nt=oe,nt.setIndex(Re));let Qt=Be!==null?Be.count:lt.count,et=U.drawRange.start*ct,tn=U.drawRange.count*ct,ht=Ge!==null?Ge.start*ct:0,Gi=Ge!==null?Ge.count*ct:1/0,Et=Math.max(et,ht),wn=Math.min(Qt,et+tn,ht+Gi)-1,Gn=Math.max(0,wn-Et+1);if(Gn!==0){if(se.isMesh)X.wireframe===!0?(Ce.setLineWidth(X.wireframeLinewidth*st()),nt.setMode(V.LINES)):nt.setMode(V.TRIANGLES);else if(se.isLine){let rr=X.linewidth;rr===void 0&&(rr=1),Ce.setLineWidth(rr*st()),se.isLineSegments?nt.setMode(V.LINES):se.isLineLoop?nt.setMode(V.LINE_LOOP):nt.setMode(V.LINE_STRIP)}else se.isPoints?nt.setMode(V.POINTS):se.isSprite&&nt.setMode(V.TRIANGLES);if(se.isInstancedMesh)nt.renderInstances(Et,Gn,se.count);else if(U.isInstancedBufferGeometry){let rr=Math.min(U.instanceCount,U._maxInstanceCount);nt.renderInstances(Et,Gn,rr)}else nt.render(Et,Gn)}},this.compile=function(T,k){p=Z.get(T,k),p.init(),T.traverseVisible(function(X){X.isLight&&X.layers.test(k.layers)&&(p.pushLight(X),X.castShadow&&p.pushShadow(X))}),p.setupLights(k);let U=new WeakMap;T.traverse(function(X){let se=X.material;if(se)if(Array.isArray(se))for(let Ge=0;Ge<se.length;Ge++){let De=se[Ge];U.has(De)===!1&&(it(De,T,X),U.set(De))}else U.has(se)===!1&&(it(se,T,X),U.set(se))})};let si=null;function bn(T){de.isPresenting||si&&si(T)}let fn=new Fd;fn.setAnimationLoop(bn),typeof window!="undefined"&&fn.setContext(window),this.setAnimationLoop=function(T){si=T,de.setAnimationLoop(T),T===null?fn.stop():fn.start()},this.render=function(T,k){let U,X;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),U=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),X=arguments[3]),k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;be.resetDefaultState(),C=-1,E=null,T.autoUpdate===!0&&T.updateMatrixWorld(),k.parent===null&&k.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(k=de.getCamera(k)),T.isScene===!0&&T.onBeforeRender(m,T,k,U||g),p=Z.get(T,k),p.init(),he.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),$.setFromProjectionMatrix(he),ge=this.localClippingEnabled,ce=I.init(this.clippingPlanes,ge,k),f=K.get(T,k),f.init(),nr(T,k,0,m.sortObjects),f.finish(),m.sortObjects===!0&&f.sort(G,z),ce===!0&&I.beginShadows();let se=p.state.shadowsArray;Me.render(se,T,k),p.setupLights(k),ce===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),U!==void 0&&this.setRenderTarget(U),ee.render(f,T,k,X);let Ge=f.opaque,De=f.transparent;Ge.length>0&&ai(Ge,T,k),De.length>0&&ai(De,T,k),T.isScene===!0&&T.onAfterRender(m,T,k),g!==null&&(Q.updateRenderTargetMipmap(g),Q.updateMultisampleRenderTarget(g)),Ce.buffers.depth.setTest(!0),Ce.buffers.depth.setMask(!0),Ce.buffers.color.setMask(!0),Ce.setPolygonOffset(!1),f=null,p=null};function nr(T,k,U,X){if(T.visible===!1)return;if(T.layers.test(k.layers)){if(T.isGroup)U=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(k);else if(T.isLight)p.pushLight(T),T.castShadow&&p.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||$.intersectsSprite(T)){X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he);let De=le.update(T),ze=T.material;ze.visible&&f.push(T,De,ze,U,Pe.z,null)}}else if(T.isImmediateRenderObject)X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he),f.push(T,null,T.material,U,Pe.z,null);else if((T.isMesh||T.isLine||T.isPoints)&&(T.isSkinnedMesh&&T.skeleton.frame!==$e.render.frame&&(T.skeleton.update(),T.skeleton.frame=$e.render.frame),!T.frustumCulled||$.intersectsObject(T))){X&&Pe.setFromMatrixPosition(T.matrixWorld).applyMatrix4(he);let De=le.update(T),ze=T.material;if(Array.isArray(ze)){let Be=De.groups;for(let lt=0,ct=Be.length;lt<ct;lt++){let Re=Be[lt],nt=ze[Re.materialIndex];nt&&nt.visible&&f.push(T,De,nt,U,Pe.z,Re)}}else ze.visible&&f.push(T,De,ze,U,Pe.z,null)}}let Ge=T.children;for(let De=0,ze=Ge.length;De<ze;De++)nr(Ge[De],k,U,X)}function ai(T,k,U){let X=k.isScene===!0?k.overrideMaterial:null;for(let se=0,Ge=T.length;se<Ge;se++){let De=T[se],ze=De.object,Be=De.geometry,lt=X===null?De.material:X,ct=De.group;if(U.isArrayCamera){w=U;let Re=U.cameras;for(let nt=0,Qt=Re.length;nt<Qt;nt++){let et=Re[nt];ze.layers.test(et.layers)&&(Ce.viewport(F.copy(et.viewport)),p.setupLights(et),br(ze,k,et,Be,lt,ct))}}else w=null,br(ze,k,U,Be,lt,ct)}}function br(T,k,U,X,se,Ge){if(T.onBeforeRender(m,k,U,X,se,Ge),p=Z.get(k,w||U),T.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix),T.isImmediateRenderObject){let De=Eo(U,k,se,T);Ce.setMaterial(se),be.reset(),al(T,De)}else m.renderBufferDirect(U,k,X,se,T,Ge);T.onAfterRender(m,k,U,X,se,Ge),p=Z.get(k,w||U)}function it(T,k,U){k.isScene!==!0&&(k=Fe);let X=Ie.get(T),se=p.state.lights,Ge=p.state.shadowsArray,De=se.state.version,ze=A.getParameters(T,se.state,Ge,k,U),Be=A.getProgramCacheKey(ze),lt=X.program,ct=!0;if(lt===void 0)T.addEventListener("dispose",ms);else if(lt.cacheKey!==Be)gs(T);else if(X.lightsStateVersion!==De)ct=!1;else if(ze.shaderID!==void 0){let et=T.isMeshStandardMaterial?k.environment:null;X.envMap=re.get(T.envMap||et);return}else ct=!1;ct&&(ze.uniforms=A.getUniforms(T),T.onBeforeCompile(ze,m),lt=A.acquireProgram(ze,Be),X.program=lt,X.uniforms=ze.uniforms,X.outputEncoding=ze.outputEncoding);let Re=X.uniforms;(!T.isShaderMaterial&&!T.isRawShaderMaterial||T.clipping===!0)&&(X.numClippingPlanes=I.numPlanes,X.numIntersection=I.numIntersection,Re.clippingPlanes=I.uniform),X.environment=T.isMeshStandardMaterial?k.environment:null,X.fog=k.fog,X.envMap=re.get(T.envMap||X.environment),X.needsLights=ci(T),X.lightsStateVersion=De,X.needsLights&&(Re.ambientLightColor.value=se.state.ambient,Re.lightProbe.value=se.state.probe,Re.directionalLights.value=se.state.directional,Re.directionalLightShadows.value=se.state.directionalShadow,Re.spotLights.value=se.state.spot,Re.spotLightShadows.value=se.state.spotShadow,Re.rectAreaLights.value=se.state.rectArea,Re.ltc_1.value=se.state.rectAreaLTC1,Re.ltc_2.value=se.state.rectAreaLTC2,Re.pointLights.value=se.state.point,Re.pointLightShadows.value=se.state.pointShadow,Re.hemisphereLights.value=se.state.hemi,Re.directionalShadowMap.value=se.state.directionalShadowMap,Re.directionalShadowMatrix.value=se.state.directionalShadowMatrix,Re.spotShadowMap.value=se.state.spotShadowMap,Re.spotShadowMatrix.value=se.state.spotShadowMatrix,Re.pointShadowMap.value=se.state.pointShadowMap,Re.pointShadowMatrix.value=se.state.pointShadowMatrix);let nt=X.program.getUniforms(),Qt=Ci.seqWithValue(nt.seq,Re);X.uniformsList=Qt}function Eo(T,k,U,X){k.isScene!==!0&&(k=Fe),Q.resetTextureUnits();let se=k.fog,Ge=U.isMeshStandardMaterial?k.environment:null,De=g===null?m.outputEncoding:g.texture.encoding,ze=re.get(U.envMap||Ge),Be=Ie.get(U),lt=p.state.lights;if(ce===!0&&(ge===!0||T!==E)){let ht=T===E&&U.id===C;I.setState(U,T,ht)}U.version===Be.__version?(U.fog&&Be.fog!==se||Be.environment!==Ge||Be.needsLights&&Be.lightsStateVersion!==lt.state.version||Be.numClippingPlanes!==void 0&&(Be.numClippingPlanes!==I.numPlanes||Be.numIntersection!==I.numIntersection)||Be.outputEncoding!==De||Be.envMap!==ze)&&it(U,k,X):(it(U,k,X),Be.__version=U.version);let ct=!1,Re=!1,nt=!1,Qt=Be.program,et=Qt.getUniforms(),tn=Be.uniforms;if(Ce.useProgram(Qt.program)&&(ct=!0,Re=!0,nt=!0),U.id!==C&&(C=U.id,Re=!0),ct||E!==T){if(et.setValue(V,"projectionMatrix",T.projectionMatrix),Ve.logarithmicDepthBuffer&&et.setValue(V,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),E!==T&&(E=T,Re=!0,nt=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let ht=et.map.cameraPosition;ht!==void 0&&ht.setValue(V,Pe.setFromMatrixPosition(T.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&et.setValue(V,"isOrthographic",T.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||U.skinning)&&et.setValue(V,"viewMatrix",T.matrixWorldInverse)}if(U.skinning){et.setOptional(V,X,"bindMatrix"),et.setOptional(V,X,"bindMatrixInverse");let ht=X.skeleton;if(ht){let Gi=ht.bones;if(Ve.floatVertexTextures){if(ht.boneTexture===void 0){let Et=Math.sqrt(Gi.length*4);Et=je.ceilPowerOfTwo(Et),Et=Math.max(Et,4);let wn=new Float32Array(Et*Et*4);wn.set(ht.boneMatrices);let Gn=new ho(wn,Et,Et,mn,Zr);ht.boneMatrices=wn,ht.boneTexture=Gn,ht.boneTextureSize=Et}et.setValue(V,"boneTexture",ht.boneTexture,Q),et.setValue(V,"boneTextureSize",ht.boneTextureSize)}else et.setOptional(V,ht,"boneMatrices")}}return(Re||Be.receiveShadow!==X.receiveShadow)&&(Be.receiveShadow=X.receiveShadow,et.setValue(V,"receiveShadow",X.receiveShadow)),Re&&(et.setValue(V,"toneMappingExposure",m.toneMappingExposure),Be.needsLights&&So(tn,nt),se&&U.fog&&S.refreshFogUniforms(tn,se),S.refreshMaterialUniforms(tn,U,N,L),Ci.upload(V,Be.uniformsList,tn,Q)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(Ci.upload(V,Be.uniformsList,tn,Q),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&et.setValue(V,"center",X.center),et.setValue(V,"modelViewMatrix",X.modelViewMatrix),et.setValue(V,"normalMatrix",X.normalMatrix),et.setValue(V,"modelMatrix",X.matrixWorld),Qt}function So(T,k){T.ambientLightColor.needsUpdate=k,T.lightProbe.needsUpdate=k,T.directionalLights.needsUpdate=k,T.directionalLightShadows.needsUpdate=k,T.pointLights.needsUpdate=k,T.pointLightShadows.needsUpdate=k,T.spotLights.needsUpdate=k,T.spotLightShadows.needsUpdate=k,T.rectAreaLights.needsUpdate=k,T.hemisphereLights.needsUpdate=k}function ci(T){return T.isMeshLambertMaterial||T.isMeshToonMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isShadowMaterial||T.isShaderMaterial&&T.lights===!0}this.setFramebuffer=function(T){x!==T&&g===null&&V.bindFramebuffer(V.FRAMEBUFFER,T),x=T},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return y},this.getRenderList=function(){return f},this.setRenderList=function(T){f=T},this.getRenderState=function(){return p},this.setRenderState=function(T){p=T},this.getRenderTarget=function(){return g},this.setRenderTarget=function(T,k=0,U=0){g=T,b=k,y=U,T&&Ie.get(T).__webglFramebuffer===void 0&&Q.setupRenderTarget(T);let X=x,se=!1;if(T){let Ge=Ie.get(T).__webglFramebuffer;T.isWebGLCubeRenderTarget?(X=Ge[k],se=!0):T.isWebGLMultisampleRenderTarget?X=Ie.get(T).__webglMultisampledFramebuffer:X=Ge,F.copy(T.viewport),H.copy(T.scissor),ne=T.scissorTest}else F.copy(D).multiplyScalar(N).floor(),H.copy(B).multiplyScalar(N).floor(),ne=q;if(M!==X&&(V.bindFramebuffer(V.FRAMEBUFFER,X),M=X),Ce.viewport(F),Ce.scissor(H),Ce.setScissorTest(ne),se){let Ge=Ie.get(T.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+k,Ge.__webglTexture,U)}},this.readRenderTargetPixels=function(T,k,U,X,se,Ge,De){if(!(T&&T.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=Ie.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&De!==void 0&&(ze=ze[De]),ze){let Be=!1;ze!==M&&(V.bindFramebuffer(V.FRAMEBUFFER,ze),Be=!0);try{let lt=T.texture,ct=lt.format,Re=lt.type;if(ct!==mn&&pe.convert(ct)!==V.getParameter(V.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re!==Ns&&pe.convert(Re)!==V.getParameter(V.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Re===Zr&&(Ve.isWebGL2||we.get("OES_texture_float")||we.get("WEBGL_color_buffer_float")))&&!(Re===ks&&(Ve.isWebGL2?we.get("EXT_color_buffer_float"):we.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V.checkFramebufferStatus(V.FRAMEBUFFER)===V.FRAMEBUFFER_COMPLETE?k>=0&&k<=T.width-X&&U>=0&&U<=T.height-se&&V.readPixels(k,U,X,se,pe.convert(ct),pe.convert(Re),Ge):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Be&&V.bindFramebuffer(V.FRAMEBUFFER,M)}}},this.copyFramebufferToTexture=function(T,k,U){U===void 0&&(U=0);let X=Math.pow(2,-U),se=Math.floor(k.image.width*X),Ge=Math.floor(k.image.height*X),De=pe.convert(k.format);Q.setTexture2D(k,0),V.copyTexImage2D(V.TEXTURE_2D,U,De,T.x,T.y,se,Ge,0),Ce.unbindTexture()},this.copyTextureToTexture=function(T,k,U,X){X===void 0&&(X=0);let se=k.image.width,Ge=k.image.height,De=pe.convert(U.format),ze=pe.convert(U.type);Q.setTexture2D(U,0),V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,U.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,U.unpackAlignment),k.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,X,T.x,T.y,se,Ge,De,ze,k.image.data):k.isCompressedTexture?V.compressedTexSubImage2D(V.TEXTURE_2D,X,T.x,T.y,k.mipmaps[0].width,k.mipmaps[0].height,De,k.mipmaps[0].data):V.texSubImage2D(V.TEXTURE_2D,X,T.x,T.y,De,ze,k.image),X===0&&U.generateMipmaps&&V.generateMipmap(V.TEXTURE_2D),Ce.unbindTexture()},this.initTexture=function(T){Q.setTexture2D(T,0),Ce.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Bv(t){Zs.call(this,t)}Bv.prototype=Object.assign(Object.create(Zs.prototype),{constructor:Bv,isWebGL1Renderer:!0});var Vc=class extends Ue{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let n=super.toJSON(e);return this.background!==null&&(n.object.background=this.background.toJSON(e)),this.environment!==null&&(n.object.environment=this.environment.toJSON(e)),this.fog!==null&&(n.object.fog=this.fog.toJSON()),n}};function Cn(t,e){this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=zs,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=je.generateUUID()}Object.defineProperty(Cn.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(Cn.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,o=this.stride;r<o;r++)this.array[t+r]=e.array[n+r];return this},set:function(t,e){return e===void 0&&(e=0),this.array.set(t,e),this},clone:function(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=je.generateUUID()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new Cn(e,this.stride);return n.setUsage(this.usage),n},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=je.generateUUID()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});var Js=new O;function Ri(t,e,n,r){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r===!0}Object.defineProperties(Ri.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}});Object.assign(Ri.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,n=this.data.count;e<n;e++)Js.x=this.getX(e),Js.y=this.getY(e),Js.z=this.getZ(e),Js.applyMatrix4(t),this.setXYZ(e,Js.x,Js.y,Js.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this},setXYZ:function(t,e,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this},setXYZW:function(t,e,n,r,o){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=o,this},clone:function(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)e.push(this.data.array[r+o])}return new tt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ri(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)e.push(this.data.array[r+o])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});function go(t){Ye.call(this),this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}go.prototype=Object.create(Ye.prototype);go.prototype.constructor=go;go.prototype.isSpriteMaterial=!0;go.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var Wc,uu=new O,jc=new O,qc=new O,Xc=new ue,hu=new ue,iT=new Qe,Dd=new O,fu=new O,Bd=new O,nT=new ue,Ov=new ue,rT=new ue;function du(t){if(Ue.call(this),this.type="Sprite",Wc===void 0){Wc=new qe;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Cn(e,5);Wc.setIndex([0,1,2,0,2,3]),Wc.setAttribute("position",new Ri(n,3,0,!1)),Wc.setAttribute("uv",new Ri(n,2,3,!1))}this.geometry=Wc,this.material=t!==void 0?t:new go,this.center=new ue(.5,.5)}du.prototype=Object.assign(Object.create(Ue.prototype),{constructor:du,isSprite:!0,raycast:function(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),jc.setFromMatrixScale(this.matrixWorld),iT.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),qc.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&jc.multiplyScalar(-qc.z);let n=this.material.rotation,r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));let a=this.center;Od(Dd.set(-.5,-.5,0),qc,a,jc,r,o),Od(fu.set(.5,-.5,0),qc,a,jc,r,o),Od(Bd.set(.5,.5,0),qc,a,jc,r,o),nT.set(0,0),Ov.set(1,0),rT.set(1,1);let c=t.ray.intersectTriangle(Dd,fu,Bd,!1,uu);if(c===null&&(Od(fu.set(-.5,.5,0),qc,a,jc,r,o),Ov.set(0,1),c=t.ray.intersectTriangle(Dd,Bd,fu,!1,uu),c===null))return;let l=t.ray.origin.distanceTo(uu);l<t.near||l>t.far||e.push({distance:l,point:uu.clone(),uv:Tn.getUV(uu,Dd,fu,Bd,nT,Ov,rT,new ue),face:null,object:this})},copy:function(t){return Ue.prototype.copy.call(this,t),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}});function Od(t,e,n,r,o,a){Xc.subVectors(t,n).addScalar(.5).multiply(r),o!==void 0?(hu.x=a*Xc.x-o*Xc.y,hu.y=o*Xc.x+a*Xc.y):hu.copy(Xc),t.copy(e),t.x+=hu.x,t.y+=hu.y,t.applyMatrix4(iT)}var Ud=new O,oT=new O;function Yc(){Ue.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Yc.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Yc,isLOD:!0,copy:function(t){Ue.prototype.copy.call(this,t,!1);let e=t.levels;for(let n=0,r=e.length;n<r;n++){let o=e[n];this.addLevel(o.object.clone(),o.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e){e===void 0&&(e=0),e=Math.abs(e);let n=this.levels,r;for(r=0;r<n.length&&!(e<n[r].distance);r++);return n.splice(r,0,{distance:e,object:t}),this.add(t),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(t){let e=this.levels;if(e.length>0){let n,r;for(n=1,r=e.length;n<r&&!(t<e[n].distance);n++);return e[n-1].object}return null},raycast:function(t,e){if(this.levels.length>0){Ud.setFromMatrixPosition(this.matrixWorld);let r=t.ray.origin.distanceTo(Ud);this.getObjectForDistance(r).raycast(t,e)}},update:function(t){let e=this.levels;if(e.length>1){Ud.setFromMatrixPosition(t.matrixWorld),oT.setFromMatrixPosition(this.matrixWorld);let n=Ud.distanceTo(oT)/t.zoom;e[0].object.visible=!0;let r,o;for(r=1,o=e.length;r<o&&n>=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(this._currentLevel=r-1;r<o;r++)e[r].object.visible=!1}},toJSON:function(t){let e=Ue.prototype.toJSON.call(this,t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];let n=this.levels;for(let r=0,o=n.length;r<o;r++){let a=n[r];e.object.levels.push({object:a.object.uuid,distance:a.distance})}return e}});function pu(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Pt.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe}pu.prototype=Object.assign(Object.create(Pt.prototype),{constructor:pu,isSkinnedMesh:!0,copy:function(t){return Pt.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){let t=new mt,e=this.geometry.attributes.skinWeight;for(let n=0,r=e.count;n<r;n++){t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.w=e.getW(n);let o=1/t.manhattanLength();o!==1/0?t.multiplyScalar(o):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){Pt.prototype.updateMatrixWorld.call(this,t),this.bindMode==="attached"?this.bindMatrixInverse.getInverse(this.matrixWorld):this.bindMode==="detached"?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(){let t=new O,e=new mt,n=new mt,r=new O,o=new Qe;return function(a,c){let l=this.skeleton,u=this.geometry;e.fromBufferAttribute(u.attributes.skinIndex,a),n.fromBufferAttribute(u.attributes.skinWeight,a),t.fromBufferAttribute(u.attributes.position,a).applyMatrix4(this.bindMatrix),c.set(0,0,0);for(let h=0;h<4;h++){let d=n.getComponent(h);if(d!==0){let f=e.getComponent(h);o.multiplyMatrices(l.bones[f].matrixWorld,l.boneInverses[f]),c.addScaledVector(r.copy(t).applyMatrix4(o),d)}}return c.applyMatrix4(this.bindMatrixInverse)}}()});var sT=new Qe,qI=new Qe;function mu(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(this.bones.length*16),this.frame=-1,e===void 0)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Qe)}}Object.assign(mu.prototype,{calculateInverses:function(){this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++){let n=new Qe;this.bones[t]&&n.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(n)}},pose:function(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.getInverse(this.boneInverses[t])}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.getInverse(n.parent.matrixWorld),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}},update:function(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let o=0,a=t.length;o<a;o++){let c=t[o]?t[o].matrixWorld:qI;sT.multiplyMatrices(c,e[o]),sT.toArray(n,o*16)}r!==void 0&&(r.needsUpdate=!0)},clone:function(){return new mu(this.bones,this.boneInverses)},getBoneByName:function(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}});function Uv(){Ue.call(this),this.type="Bone"}Uv.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Uv,isBone:!0});var aT=new Qe,cT=new Qe,Nd=[],gu=new Pt;function Gd(t,e,n){Pt.call(this,t,e),this.instanceMatrix=new tt(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}Gd.prototype=Object.assign(Object.create(Pt.prototype),{constructor:Gd,isInstancedMesh:!0,copy:function(t){return Pt.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),this.count=t.count,this},setColorAt:function(t,e){this.instanceColor===null&&(this.instanceColor=new tt(new Float32Array(this.count*3),3)),e.toArray(this.instanceColor.array,t*3)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,t*16)},raycast:function(t,e){let n=this.matrixWorld,r=this.count;if(gu.geometry=this.geometry,gu.material=this.material,gu.material!==void 0)for(let o=0;o<r;o++){this.getMatrixAt(o,aT),cT.multiplyMatrices(n,aT),gu.matrixWorld=cT,gu.raycast(t,Nd);for(let a=0,c=Nd.length;a<c;a++){let l=Nd[a];l.instanceId=o,l.object=this,e.push(l)}Nd.length=0}},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,t*16)},updateMorphTargets:function(){}});function Dt(t){Ye.call(this),this.type="LineBasicMaterial",this.color=new Ae(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}Dt.prototype=Object.create(Ye.prototype);Dt.prototype.constructor=Dt;Dt.prototype.isLineBasicMaterial=!0;Dt.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this};var lT=new O,uT=new O,hT=new Qe,kd=new fr,Hd=new un;function xr(t,e,n){n===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),Ue.call(this),this.type="Line",this.geometry=t!==void 0?t:new qe,this.material=e!==void 0?e:new Dt,this.updateMorphTargets()}xr.prototype=Object.assign(Object.create(Ue.prototype),{constructor:xr,isLine:!0,copy:function(t){return Ue.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){let t=this.geometry;if(t.isBufferGeometry)if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,o=e.count;r<o;r++)lT.fromBufferAttribute(e,r-1),uT.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=lT.distanceTo(uT);t.setAttribute("lineDistance",new Ke(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){let e=t.vertices,n=t.lineDistances;n[0]=0;for(let r=1,o=e.length;r<o;r++)n[r]=n[r-1],n[r]+=e[r-1].distanceTo(e[r])}return this},raycast:function(t,e){let n=this.geometry,r=this.matrixWorld,o=t.params.Line.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),Hd.copy(n.boundingSphere),Hd.applyMatrix4(r),Hd.radius+=o,t.ray.intersectsSphere(Hd)===!1)return;hT.getInverse(r),kd.copy(t.ray).applyMatrix4(hT);let a=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new O,u=new O,h=new O,d=new O,f=this.isLineSegments?2:1;if(n.isBufferGeometry){let p=n.index,v=n.attributes.position;if(p!==null){let x=p.array;for(let b=0,y=x.length-1;b<y;b+=f){let g=x[b],M=x[b+1];if(l.fromBufferAttribute(v,g),u.fromBufferAttribute(v,M),kd.distanceSqToSegment(l,u,d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(d);E<t.near||E>t.far||e.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else for(let x=0,b=v.count-1;x<b;x+=f){if(l.fromBufferAttribute(v,x),u.fromBufferAttribute(v,x+1),kd.distanceSqToSegment(l,u,d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let g=t.ray.origin.distanceTo(d);g<t.near||g>t.far||e.push({distance:g,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else if(n.isGeometry){let p=n.vertices,m=p.length;for(let v=0;v<m-1;v+=f){if(kd.distanceSqToSegment(p[v],p[v+1],d,h)>c)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});var zd=new O,Vd=new O;function Yn(t,e){xr.call(this,t,e),this.type="LineSegments"}Yn.prototype=Object.assign(Object.create(xr.prototype),{constructor:Yn,isLineSegments:!0,computeLineDistances:function(){let t=this.geometry;if(t.isBufferGeometry)if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,o=e.count;r<o;r+=2)zd.fromBufferAttribute(e,r),Vd.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+zd.distanceTo(Vd);t.setAttribute("lineDistance",new Ke(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){let e=t.vertices,n=t.lineDistances;for(let r=0,o=e.length;r<o;r+=2)zd.copy(e[r]),Vd.copy(e[r+1]),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+zd.distanceTo(Vd)}return this}});function Wd(t,e){xr.call(this,t,e),this.type="LineLoop"}Wd.prototype=Object.assign(Object.create(xr.prototype),{constructor:Wd,isLineLoop:!0});function Pi(t){Ye.call(this),this.type="PointsMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}Pi.prototype=Object.create(Ye.prototype);Pi.prototype.constructor=Pi;Pi.prototype.isPointsMaterial=!0;Pi.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};var fT=new Qe,Gv=new fr,jd=new un,qd=new O;function vu(t,e){Ue.call(this),this.type="Points",this.geometry=t!==void 0?t:new qe,this.material=e!==void 0?e:new Pi,this.updateMorphTargets()}vu.prototype=Object.assign(Object.create(Ue.prototype),{constructor:vu,isPoints:!0,copy:function(t){return Ue.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){let n=this.geometry,r=this.matrixWorld,o=t.params.Points.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),jd.copy(n.boundingSphere),jd.applyMatrix4(r),jd.radius+=o,t.ray.intersectsSphere(jd)===!1)return;fT.getInverse(r),Gv.copy(t.ray).applyMatrix4(fT);let a=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a;if(n.isBufferGeometry){let l=n.index,h=n.attributes.position;if(l!==null){let d=l.array;for(let f=0,p=d.length;f<p;f++){let m=d[f];qd.fromBufferAttribute(h,m),Nv(qd,m,c,r,t,e,this)}}else for(let d=0,f=h.count;d<f;d++)qd.fromBufferAttribute(h,d),Nv(qd,d,c,r,t,e,this)}else{let l=n.vertices;for(let u=0,h=l.length;u<h;u++)Nv(l[u],u,c,r,t,e,this)}},updateMorphTargets:function(){let t=this.geometry;if(t.isBufferGeometry){let e=t.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){let c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}else{let e=t.morphTargets;e!==void 0&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});function Nv(t,e,n,r,o,a,c){let l=Gv.distanceSqToPoint(t);if(l<n){let u=new O;Gv.closestPointToPoint(t,u),u.applyMatrix4(r);let h=o.ray.origin.distanceTo(u);if(h<o.near||h>o.far)return;a.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:c})}}function kv(t,e,n,r,o,a,c,l,u){yt.call(this,t,e,n,r,o,a,c,l,u),this.format=c!==void 0?c:Lr,this.minFilter=a!==void 0?a:Ht,this.magFilter=o!==void 0?o:Ht,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}kv.prototype=Object.assign(Object.create(yt.prototype),{constructor:kv,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Qs(t,e,n,r,o,a,c,l,u,h,d,f){yt.call(this,null,a,c,l,u,h,r,o,d,f),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}Qs.prototype=Object.create(yt.prototype);Qs.prototype.constructor=Qs;Qs.prototype.isCompressedTexture=!0;function yu(t,e,n,r,o,a,c,l,u){yt.call(this,t,e,n,r,o,a,c,l,u),this.needsUpdate=!0}yu.prototype=Object.create(yt.prototype);yu.prototype.constructor=yu;yu.prototype.isCanvasTexture=!0;function xu(t,e,n,r,o,a,c,l,u,h){if(h=h!==void 0?h:no,h!==no&&h!==$o)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===no&&(n=Gs),n===void 0&&h===$o&&(n=Yo),yt.call(this,null,r,o,a,c,l,h,n,u),this.image={width:t,height:e},this.magFilter=c!==void 0?c:Xt,this.minFilter=l!==void 0?l:Xt,this.flipY=!1,this.generateMipmaps=!1}xu.prototype=Object.create(yt.prototype);xu.prototype.constructor=xu;xu.prototype.isDepthTexture=!0;var XI=0,Li=new Qe,Hv=new Ue,Xd=new O;function wt(){Object.defineProperty(this,"id",{value:XI+=2}),this.uuid=je.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}wt.prototype=Object.assign(Object.create(gn.prototype),{constructor:wt,isGeometry:!0,applyMatrix4:function(t){let e=new Ft().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n];o.normal.applyMatrix3(e).normalize();for(let a=0,c=o.vertexNormals.length;a<c;a++)o.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return Li.makeRotationX(t),this.applyMatrix4(Li),this},rotateY:function(t){return Li.makeRotationY(t),this.applyMatrix4(Li),this},rotateZ:function(t){return Li.makeRotationZ(t),this.applyMatrix4(Li),this},translate:function(t,e,n){return Li.makeTranslation(t,e,n),this.applyMatrix4(Li),this},scale:function(t,e,n){return Li.makeScale(t,e,n),this.applyMatrix4(Li),this},lookAt:function(t){return Hv.lookAt(t),Hv.updateMatrix(),this.applyMatrix4(Hv.matrix),this},fromBufferGeometry:function(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let o=r.position,a=r.normal,c=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let f=0;f<o.count;f++)e.vertices.push(new O().fromBufferAttribute(o,f)),c!==void 0&&e.colors.push(new Ae().fromBufferAttribute(c,f));function h(f,p,m,v){let x=c===void 0?[]:[e.colors[f].clone(),e.colors[p].clone(),e.colors[m].clone()],b=a===void 0?[]:[new O().fromBufferAttribute(a,f),new O().fromBufferAttribute(a,p),new O().fromBufferAttribute(a,m)],y=new co(f,p,m,b,x,v);e.faces.push(y),l!==void 0&&e.faceVertexUvs[0].push([new ue().fromBufferAttribute(l,f),new ue().fromBufferAttribute(l,p),new ue().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new ue().fromBufferAttribute(u,f),new ue().fromBufferAttribute(u,p),new ue().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let f=0;f<d.length;f++){let p=d[f],m=p.start,v=p.count;for(let x=m,b=m+v;x<b;x+=3)n!==void 0?h(n.getX(x),n.getX(x+1),n.getX(x+2),p.materialIndex):h(x,x+1,x+2,p.materialIndex)}else if(n!==void 0)for(let f=0;f<n.count;f+=3)h(n.getX(f),n.getX(f+1),n.getX(f+2));else for(let f=0;f<o.count;f+=3)h(f,f+1,f+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xd).negate(),this.translate(Xd.x,Xd.y,Xd.z),this},normalize:function(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new Qe;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){let t=new O,e=new O;for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n],a=this.vertices[o.a],c=this.vertices[o.b],l=this.vertices[o.c];t.subVectors(l,c),e.subVectors(a,c),t.cross(e),t.normalize(),o.normal.copy(t)}},computeVertexNormals:function(t){t===void 0&&(t=!0);let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new O;if(t){let n=new O,r=new O;for(let o=0,a=this.faces.length;o<a;o++){let c=this.faces[o],l=this.vertices[c.a],u=this.vertices[c.b],h=this.vertices[c.c];n.subVectors(h,u),r.subVectors(l,u),n.cross(r),e[c.a].add(n),e[c.b].add(n),e[c.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n];e[o.a].add(o.normal),e[o.b].add(o.normal),e[o.c].add(o.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let o=this.faces[n],a=o.vertexNormals;a.length===3?(a[0].copy(e[o.a]),a[1].copy(e[o.b]),a[2].copy(e[o.c])):(a[0]=e[o.a].clone(),a[1]=e[o.b].clone(),a[2]=e[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let o=0,a=r.vertexNormals.length;o<a;o++)r.__originalVertexNormals[o]?r.__originalVertexNormals[o].copy(r.vertexNormals[o]):r.__originalVertexNormals[o]=r.vertexNormals[o].clone()}let t=new wt;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let o=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let c=0,l=this.faces.length;c<l;c++){let u=new O,h={a:new O,b:new O,c:new O};o.push(u),a.push(h)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let o=0,a=this.faces.length;o<a;o++){let c=this.faces[o],l=r.faceNormals[o],u=r.vertexNormals[o];l.copy(c.normal),u.a.copy(c.vertexNormals[0]),u.b.copy(c.vertexNormals[1]),u.c.copy(c.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new On),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new un),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,n){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,o=this.vertices.length,a=this.vertices,c=t.vertices,l=this.faces,u=t.faces,h=this.colors,d=t.colors;n===void 0&&(n=0),e!==void 0&&(r=new Ft().getNormalMatrix(e));for(let f=0,p=c.length;f<p;f++){let v=c[f].clone();e!==void 0&&v.applyMatrix4(e),a.push(v)}for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone());for(let f=0,p=u.length;f<p;f++){let m=u[f],v,x,b=m.vertexNormals,y=m.vertexColors,g=new co(m.a+o,m.b+o,m.c+o);g.normal.copy(m.normal),r!==void 0&&g.normal.applyMatrix3(r).normalize();for(let M=0,C=b.length;M<C;M++)v=b[M].clone(),r!==void 0&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(m.color);for(let M=0,C=y.length;M<C;M++)x=y[M],g.vertexColors.push(x.clone());g.materialIndex=m.materialIndex+n,l.push(g)}for(let f=0,p=t.faceVertexUvs.length;f<p;f++){let m=t.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let v=0,x=m.length;v<x;v++){let b=m[v],y=[];for(let g=0,M=b.length;g<M;g++)y.push(b[g].clone());this.faceVertexUvs[f].push(y)}}},mergeMesh:function(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)},mergeVertices:function(){let t={},e=[],n=[],o=Math.pow(10,4);for(let l=0,u=this.vertices.length;l<u;l++){let h=this.vertices[l],d=Math.round(h.x*o)+"_"+Math.round(h.y*o)+"_"+Math.round(h.z*o);t[d]===void 0?(t[d]=l,e.push(this.vertices[l]),n[l]=e.length-1):n[l]=n[t[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let h=this.faces[l];h.a=n[h.a],h.b=n[h.b],h.c=n[h.c];let d=[h.a,h.b,h.c];for(let f=0;f<3;f++)if(d[f]===d[(f+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(u,1)}let c=this.vertices.length-e.length;return this.vertices=e,c},setFromPoints:function(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new O(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],o=this.faceVertexUvs[1],a,c;r&&r.length===e&&(a=[]),o&&o.length===e&&(c=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(r[u]),c&&c.push(o[u])}a&&(this.faceVertexUvs[0]=a),c&&(this.faceVertexUvs[1]=c)},toJSON:function(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let v in m)m[v]!==void 0&&(t[v]=m[v]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let v=this.vertices[m];e.push(v.x,v.y,v.z)}let n=[],r=[],o={},a=[],c={},l=[],u={};for(let m=0;m<this.faces.length;m++){let v=this.faces[m],x=!0,b=!1,y=this.faceVertexUvs[0][m]!==void 0,g=v.normal.length()>0,M=v.vertexNormals.length>0,C=v.color.r!==1||v.color.g!==1||v.color.b!==1,E=v.vertexColors.length>0,w=0;if(w=h(w,0,0),w=h(w,1,x),w=h(w,2,b),w=h(w,3,y),w=h(w,4,g),w=h(w,5,M),w=h(w,6,C),w=h(w,7,E),n.push(w),n.push(v.a,v.b,v.c),n.push(v.materialIndex),y){let F=this.faceVertexUvs[0][m];n.push(p(F[0]),p(F[1]),p(F[2]))}if(g&&n.push(d(v.normal)),M){let F=v.vertexNormals;n.push(d(F[0]),d(F[1]),d(F[2]))}if(C&&n.push(f(v.color)),E){let F=v.vertexColors;n.push(f(F[0]),f(F[1]),f(F[2]))}}function h(m,v,x){return x?m|1<<v:m&~(1<<v)}function d(m){let v=m.x.toString()+m.y.toString()+m.z.toString();return o[v]!==void 0||(o[v]=r.length/3,r.push(m.x,m.y,m.z)),o[v]}function f(m){let v=m.r.toString()+m.g.toString()+m.b.toString();return c[v]!==void 0||(c[v]=a.length,a.push(m.getHex())),c[v]}function p(m){let v=m.x.toString()+m.y.toString();return u[v]!==void 0||(u[v]=l.length/2,l.push(m.x,m.y)),u[v]}return t.data={},t.data.vertices=e,t.data.normals=r,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t},clone:function(){return new wt().copy(this)},copy:function(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let f=0,p=e.length;f<p;f++)this.vertices.push(e[f].clone());let n=t.colors;for(let f=0,p=n.length;f<p;f++)this.colors.push(n[f].clone());let r=t.faces;for(let f=0,p=r.length;f<p;f++)this.faces.push(r[f].clone());for(let f=0,p=t.faceVertexUvs.length;f<p;f++){let m=t.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let v=0,x=m.length;v<x;v++){let b=m[v],y=[];for(let g=0,M=b.length;g<M;g++){let C=b[g];y.push(C.clone())}this.faceVertexUvs[f].push(y)}}let o=t.morphTargets;for(let f=0,p=o.length;f<p;f++){let m={};if(m.name=o[f].name,o[f].vertices!==void 0){m.vertices=[];for(let v=0,x=o[f].vertices.length;v<x;v++)m.vertices.push(o[f].vertices[v].clone())}if(o[f].normals!==void 0){m.normals=[];for(let v=0,x=o[f].normals.length;v<x;v++)m.normals.push(o[f].normals[v].clone())}this.morphTargets.push(m)}let a=t.morphNormals;for(let f=0,p=a.length;f<p;f++){let m={};if(a[f].vertexNormals!==void 0){m.vertexNormals=[];for(let v=0,x=a[f].vertexNormals.length;v<x;v++){let b=a[f].vertexNormals[v],y={};y.a=b.a.clone(),y.b=b.b.clone(),y.c=b.c.clone(),m.vertexNormals.push(y)}}if(a[f].faceNormals!==void 0){m.faceNormals=[];for(let v=0,x=a[f].faceNormals.length;v<x;v++)m.faceNormals.push(a[f].faceNormals[v].clone())}this.morphNormals.push(m)}let c=t.skinWeights;for(let f=0,p=c.length;f<p;f++)this.skinWeights.push(c[f].clone());let l=t.skinIndices;for(let f=0,p=l.length;f<p;f++)this.skinIndices.push(l[f].clone());let u=t.lineDistances;for(let f=0,p=u.length;f<p;f++)this.lineDistances.push(u[f]);let h=t.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Q9=new O,K9=new O,e7=new O,t7=new Tn;var pT={triangulate:function(t,e,n){n=n||2;let r=e&&e.length,o=r?e[0]*n:t.length,a=mT(t,0,o,n,!0),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,f,p,m;if(r&&(a=tD(t,e,a,n)),t.length>80*n){l=h=t[0],u=d=t[1];for(let v=n;v<o;v+=n)f=t[v],p=t[v+1],f<l&&(l=f),p<u&&(u=p),f>h&&(h=f),p>d&&(d=p);m=Math.max(h-l,d-u),m=m!==0?1/m:0}return bu(a,c,n,l,u,m),c}};function mT(t,e,n,r,o){let a,c;if(o===fD(t,e,n,r)>0)for(a=e;a<n;a+=r)c=dT(a,t[a],t[a+1],c);else for(a=n-r;a>=e;a-=r)c=dT(a,t[a],t[a+1],c);return c&&Zd(c,c.next)&&(Mu(c),c=c.next),c}function cs(t,e){if(!t)return t;e||(e=t);let n=t,r;do if(r=!1,!n.steiner&&(Zd(n,n.next)||Yt(n.prev,n,n.next)===0)){if(Mu(n),n=e=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==e);return e}function bu(t,e,n,r,o,a,c){if(!t)return;!c&&a&&sD(t,r,o,a);let l=t,u,h;for(;t.prev!==t.next;){if(u=t.prev,h=t.next,a?QI(t,r,o,a):JI(t)){e.push(u.i/n),e.push(t.i/n),e.push(h.i/n),Mu(t),t=h.next,l=h.next;continue}if(t=h,t===l){c?c===1?(t=KI(cs(t),e,n),bu(t,e,n,r,o,a,2)):c===2&&eD(t,e,n,r,o,a):bu(cs(t),e,n,r,o,a,1);break}}}function JI(t){let e=t.prev,n=t,r=t.next;if(Yt(e,n,r)>=0)return!1;let o=t.next.next;for(;o!==t.prev;){if($c(e.x,e.y,n.x,n.y,r.x,r.y,o.x,o.y)&&Yt(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function QI(t,e,n,r){let o=t.prev,a=t,c=t.next;if(Yt(o,a,c)>=0)return!1;let l=o.x<a.x?o.x<c.x?o.x:c.x:a.x<c.x?a.x:c.x,u=o.y<a.y?o.y<c.y?o.y:c.y:a.y<c.y?a.y:c.y,h=o.x>a.x?o.x>c.x?o.x:c.x:a.x>c.x?a.x:c.x,d=o.y>a.y?o.y>c.y?o.y:c.y:a.y>c.y?a.y:c.y,f=Vv(l,u,e,n,r),p=Vv(h,d,e,n,r),m=t.prevZ,v=t.nextZ;for(;m&&m.z>=f&&v&&v.z<=p;){if(m!==t.prev&&m!==t.next&&$c(o.x,o.y,a.x,a.y,c.x,c.y,m.x,m.y)&&Yt(m.prev,m,m.next)>=0||(m=m.prevZ,v!==t.prev&&v!==t.next&&$c(o.x,o.y,a.x,a.y,c.x,c.y,v.x,v.y)&&Yt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;m&&m.z>=f;){if(m!==t.prev&&m!==t.next&&$c(o.x,o.y,a.x,a.y,c.x,c.y,m.x,m.y)&&Yt(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;v&&v.z<=p;){if(v!==t.prev&&v!==t.next&&$c(o.x,o.y,a.x,a.y,c.x,c.y,v.x,v.y)&&Yt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function KI(t,e,n){let r=t;do{let o=r.prev,a=r.next.next;!Zd(o,a)&&gT(o,r,r.next,a)&&wu(o,a)&&wu(a,o)&&(e.push(o.i/n),e.push(r.i/n),e.push(a.i/n),Mu(r),Mu(r.next),r=t=a),r=r.next}while(r!==t);return cs(r)}function eD(t,e,n,r,o,a){let c=t;do{let l=c.next.next;for(;l!==c.prev;){if(c.i!==l.i&&lD(c,l)){let u=vT(c,l);c=cs(c,c.next),u=cs(u,u.next),bu(c,e,n,r,o,a),bu(u,e,n,r,o,a);return}l=l.next}c=c.next}while(c!==t)}function tD(t,e,n,r){let o=[],a,c,l,u,h;for(a=0,c=e.length;a<c;a++)l=e[a]*r,u=a<c-1?e[a+1]*r:t.length,h=mT(t,l,u,r,!1),h===h.next&&(h.steiner=!0),o.push(cD(h));for(o.sort(nD),a=0;a<o.length;a++)rD(o[a],n),n=cs(n,n.next);return n}function nD(t,e){return t.x-e.x}function rD(t,e){if(e=iD(t,e),e){let n=vT(e,t);cs(e,e.next),cs(n,n.next)}}function iD(t,e){let n=e,r=t.x,o=t.y,a=-1/0,c;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let p=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=r&&p>a){if(a=p,p===r){if(o===n.y)return n;if(o===n.next.y)return n.next}c=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!c)return null;if(r===a)return c;let l=c,u=c.x,h=c.y,d=1/0,f;n=c;do r>=n.x&&n.x>=u&&r!==n.x&&$c(o<h?r:a,o,u,h,o<h?a:r,o,n.x,n.y)&&(f=Math.abs(o-n.y)/(r-n.x),wu(n,t)&&(f<d||f===d&&(n.x>c.x||n.x===c.x&&oD(c,n)))&&(c=n,d=f)),n=n.next;while(n!==l);return c}function oD(t,e){return Yt(t.prev,t,e.prev)<0&&Yt(e.next,t,t.next)<0}function sD(t,e,n,r){let o=t;do o.z===null&&(o.z=Vv(o.x,o.y,e,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,aD(o)}function aD(t){let e,n,r,o,a,c,l,u,h=1;do{for(n=t,t=null,a=null,c=0;n;){for(c++,r=n,l=0,e=0;e<h&&(l++,r=r.nextZ,!!r);e++);for(u=h;l>0||u>0&&r;)l!==0&&(u===0||!r||n.z<=r.z)?(o=n,n=n.nextZ,l--):(o=r,r=r.nextZ,u--),a?a.nextZ=o:t=o,o.prevZ=a,a=o;n=r}a.nextZ=null,h*=2}while(c>1);return t}function Vv(t,e,n,r,o){return t=32767*(t-n)*o,e=32767*(e-r)*o,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function cD(t){let e=t,n=t;do(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next;while(e!==t);return n}function $c(t,e,n,r,o,a,c,l){return(o-c)*(e-l)-(t-c)*(a-l)>=0&&(t-c)*(r-l)-(n-c)*(e-l)>=0&&(n-c)*(a-l)-(o-c)*(r-l)>=0}function lD(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!uD(t,e)&&(wu(t,e)&&wu(e,t)&&hD(t,e)&&(Yt(t.prev,t,e.prev)||Yt(t,e.prev,e))||Zd(t,e)&&Yt(t.prev,t,t.next)>0&&Yt(e.prev,e,e.next)>0)}function Yt(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Zd(t,e){return t.x===e.x&&t.y===e.y}function gT(t,e,n,r){let o=$d(Yt(t,e,n)),a=$d(Yt(t,e,r)),c=$d(Yt(n,r,t)),l=$d(Yt(n,r,e));return!!(o!==a&&c!==l||o===0&&Yd(t,n,e)||a===0&&Yd(t,r,e)||c===0&&Yd(n,t,r)||l===0&&Yd(n,e,r))}function Yd(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function $d(t){return t>0?1:t<0?-1:0}function uD(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&gT(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function wu(t,e){return Yt(t.prev,t,t.next)<0?Yt(t,e,t.next)>=0&&Yt(t,t.prev,e)>=0:Yt(t,e,t.prev)<0||Yt(t,t.next,e)<0}function hD(t,e){let n=t,r=!1,o=(t.x+e.x)/2,a=(t.y+e.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&o<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==t);return r}function vT(t,e){let n=new Wv(t.i,t.x,t.y),r=new Wv(e.i,e.x,e.y),o=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function dT(t,e,n,r){let o=new Wv(t,e,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Mu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Wv(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function fD(t,e,n,r){let o=0;for(let a=e,c=n-r;a<n;a+=r)o+=(t[c]-t[a])*(t[a+1]+t[c+1]),c=a;return o}var Or={area:function(t){let e=t.length,n=0;for(let r=e-1,o=0;o<e;r=o++)n+=t[r].x*t[o].y-t[o].x*t[r].y;return n*.5},isClockWise:function(t){return Or.area(t)<0},triangulateShape:function(t,e){let n=[],r=[],o=[];yT(t),xT(n,t);let a=t.length;e.forEach(yT);for(let l=0;l<e.length;l++)r.push(a),a+=e[l].length,xT(n,e[l]);let c=pT.triangulate(n,r);for(let l=0;l<c.length;l+=3)o.push(c.slice(l,l+3));return o}};function yT(t){let e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function xT(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}var ls=class extends qe{constructor(e,n){super(),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:n},e=Array.isArray(e)?e:[e];let r=this,o=[],a=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];c(h)}this.setAttribute("position",new Ke(o,3)),this.setAttribute("uv",new Ke(a,2)),this.computeVertexNormals();function c(l){let u=[],h=n.curveSegments!==void 0?n.curveSegments:12,d=n.steps!==void 0?n.steps:1,f=n.depth!==void 0?n.depth:100,p=n.bevelEnabled!==void 0?n.bevelEnabled:!0,m=n.bevelThickness!==void 0?n.bevelThickness:6,v=n.bevelSize!==void 0?n.bevelSize:m-2,x=n.bevelOffset!==void 0?n.bevelOffset:0,b=n.bevelSegments!==void 0?n.bevelSegments:3,y=n.extrudePath,g=n.UVGenerator!==void 0?n.UVGenerator:dD;n.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),f=n.amount);let M,C=!1,E,w,F,H;y&&(M=y.getSpacedPoints(d),C=!0,p=!1,E=y.computeFrenetFrames(d,!1),w=new O,F=new O,H=new O),p||(b=0,m=0,v=0,x=0);let ne=l.extractPoints(h),Y=ne.shape,L=ne.holes;if(!Or.isClockWise(Y)){Y=Y.reverse();for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];Or.isClockWise(ie)&&(L[Q]=ie.reverse())}}let G=Or.triangulateShape(Y,L),z=Y;for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];Y=Y.concat(ie)}function D(Q,re,ie){return re||console.error("THREE.ExtrudeGeometry: vec does not exist"),re.clone().multiplyScalar(ie).add(Q)}let B=Y.length,q=G.length;function $(Q,re,ie){let _e,le,A,S=Q.x-re.x,K=Q.y-re.y,Z=ie.x-Q.x,I=ie.y-Q.y,ee=S*S+K*K,ae=S*I-K*Z;if(Math.abs(ae)>Number.EPSILON){let ve=Math.sqrt(ee),oe=Math.sqrt(Z*Z+I*I),pe=re.x-K/ve,be=re.y+S/ve,Te=ie.x-I/oe,de=ie.y+Z/oe,Me=((Te-pe)*I-(de-be)*Z)/(S*I-K*Z);_e=pe+S*Me-Q.x,le=be+K*Me-Q.y;let ot=_e*_e+le*le;if(ot<=2)return new ue(_e,le);A=Math.sqrt(ot/2)}else{let ve=!1;S>Number.EPSILON?Z>Number.EPSILON&&(ve=!0):S<-Number.EPSILON?Z<-Number.EPSILON&&(ve=!0):Math.sign(K)===Math.sign(I)&&(ve=!0),ve?(_e=-K,le=S,A=Math.sqrt(ee)):(_e=S,le=K,A=Math.sqrt(ee/2))}return new ue(_e/A,le/A)}let ce=[];for(let Q=0,re=z.length,ie=re-1,_e=Q+1;Q<re;Q++,ie++,_e++)ie===re&&(ie=0),_e===re&&(_e=0),ce[Q]=$(z[Q],z[ie],z[_e]);let ge=[],he,Pe=ce.concat();for(let Q=0,re=L.length;Q<re;Q++){let ie=L[Q];he=[];for(let _e=0,le=ie.length,A=le-1,S=_e+1;_e<le;_e++,A++,S++)A===le&&(A=0),S===le&&(S=0),he[_e]=$(ie[_e],ie[A],ie[S]);ge.push(he),Pe=Pe.concat(he)}for(let Q=0;Q<b;Q++){let re=Q/b,ie=m*Math.cos(re*Math.PI/2),_e=v*Math.sin(re*Math.PI/2)+x;for(let le=0,A=z.length;le<A;le++){let S=D(z[le],ce[le],_e);we(S.x,S.y,-ie)}for(let le=0,A=L.length;le<A;le++){let S=L[le];he=ge[le];for(let K=0,Z=S.length;K<Z;K++){let I=D(S[K],he[K],_e);we(I.x,I.y,-ie)}}}let Fe=v+x;for(let Q=0;Q<B;Q++){let re=p?D(Y[Q],Pe[Q],Fe):Y[Q];C?(F.copy(E.normals[0]).multiplyScalar(re.x),w.copy(E.binormals[0]).multiplyScalar(re.y),H.copy(M[0]).add(F).add(w),we(H.x,H.y,H.z)):we(re.x,re.y,0)}for(let Q=1;Q<=d;Q++)for(let re=0;re<B;re++){let ie=p?D(Y[re],Pe[re],Fe):Y[re];C?(F.copy(E.normals[Q]).multiplyScalar(ie.x),w.copy(E.binormals[Q]).multiplyScalar(ie.y),H.copy(M[Q]).add(F).add(w),we(H.x,H.y,H.z)):we(ie.x,ie.y,f/d*Q)}for(let Q=b-1;Q>=0;Q--){let re=Q/b,ie=m*Math.cos(re*Math.PI/2),_e=v*Math.sin(re*Math.PI/2)+x;for(let le=0,A=z.length;le<A;le++){let S=D(z[le],ce[le],_e);we(S.x,S.y,f+ie)}for(let le=0,A=L.length;le<A;le++){let S=L[le];he=ge[le];for(let K=0,Z=S.length;K<Z;K++){let I=D(S[K],he[K],_e);C?we(I.x,I.y+M[d-1].y,M[d-1].x+ie):we(I.x,I.y,f+ie)}}}st(),V();function st(){let Q=o.length/3;if(p){let re=0,ie=B*re;for(let _e=0;_e<q;_e++){let le=G[_e];Ve(le[2]+ie,le[1]+ie,le[0]+ie)}re=d+b*2,ie=B*re;for(let _e=0;_e<q;_e++){let le=G[_e];Ve(le[0]+ie,le[1]+ie,le[2]+ie)}}else{for(let re=0;re<q;re++){let ie=G[re];Ve(ie[2],ie[1],ie[0])}for(let re=0;re<q;re++){let ie=G[re];Ve(ie[0]+B*d,ie[1]+B*d,ie[2]+B*d)}}r.addGroup(Q,o.length/3-Q,0)}function V(){let Q=o.length/3,re=0;_t(z,re),re+=z.length;for(let ie=0,_e=L.length;ie<_e;ie++){let le=L[ie];_t(le,re),re+=le.length}r.addGroup(Q,o.length/3-Q,1)}function _t(Q,re){let ie=Q.length;for(;--ie>=0;){let _e=ie,le=ie-1;le<0&&(le=Q.length-1);for(let A=0,S=d+b*2;A<S;A++){let K=B*A,Z=B*(A+1),I=re+_e+K,ee=re+le+K,ae=re+le+Z,ve=re+_e+Z;Ce(I,ee,ae,ve)}}}function we(Q,re,ie){u.push(Q),u.push(re),u.push(ie)}function Ve(Q,re,ie){$e(Q),$e(re),$e(ie);let _e=o.length/3,le=g.generateTopUV(r,o,_e-3,_e-2,_e-1);Ie(le[0]),Ie(le[1]),Ie(le[2])}function Ce(Q,re,ie,_e){$e(Q),$e(re),$e(_e),$e(re),$e(ie),$e(_e);let le=o.length/3,A=g.generateSideWallUV(r,o,le-6,le-3,le-2,le-1);Ie(A[0]),Ie(A[1]),Ie(A[3]),Ie(A[1]),Ie(A[2]),Ie(A[3])}function $e(Q){o.push(u[Q*3+0]),o.push(u[Q*3+1]),o.push(u[Q*3+2])}function Ie(Q){a.push(Q.x),a.push(Q.y)}}}toJSON(){let e=qe.prototype.toJSON.call(this),n=this.parameters.shapes,r=this.parameters.options;return pD(n,r,e)}},dD={generateTopUV:function(t,e,n,r,o){let a=e[n*3],c=e[n*3+1],l=e[r*3],u=e[r*3+1],h=e[o*3],d=e[o*3+1];return[new ue(a,c),new ue(l,u),new ue(h,d)]},generateSideWallUV:function(t,e,n,r,o,a){let c=e[n*3],l=e[n*3+1],u=e[n*3+2],h=e[r*3],d=e[r*3+1],f=e[r*3+2],p=e[o*3],m=e[o*3+1],v=e[o*3+2],x=e[a*3],b=e[a*3+1],y=e[a*3+2];return Math.abs(l-d)<.01?[new ue(c,1-u),new ue(h,1-f),new ue(p,1-v),new ue(x,1-y)]:[new ue(l,1-u),new ue(d,1-f),new ue(m,1-v),new ue(b,1-y)]}};function pD(t,e,n){if(n.shapes=[],Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);return e.extrudePath!==void 0&&(n.options.extrudePath=e.extrudePath.toJSON()),n}var Eu=class extends wt{constructor(e,n){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:n},this.fromBufferGeometry(new ls(e,n)),this.mergeVertices()}toJSON(){let e=super.toJSON(),n=this.parameters.shapes,r=this.parameters.options;return mD(n,r,e)}};function mD(t,e,n){if(n.shapes=[],Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];n.shapes.push(a.uuid)}else n.shapes.push(t.uuid);return e.extrudePath!==void 0&&(n.options.extrudePath=e.extrudePath.toJSON()),n}function Zc(t,e,n){qe.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:n};let r=[],o=[],a=[],c=[],l=1e-5,u=new O,h=new O,d=new O,f=new O,p=new O;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");let m=e+1;for(let v=0;v<=n;v++){let x=v/n;for(let b=0;b<=e;b++){let y=b/e;t(y,x,h),o.push(h.x,h.y,h.z),y-l>=0?(t(y-l,x,d),f.subVectors(h,d)):(t(y+l,x,d),f.subVectors(d,h)),x-l>=0?(t(y,x-l,d),p.subVectors(h,d)):(t(y,x+l,d),p.subVectors(d,h)),u.crossVectors(f,p).normalize(),a.push(u.x,u.y,u.z),c.push(y,x)}}for(let v=0;v<n;v++)for(let x=0;x<e;x++){let b=v*m+x,y=v*m+x+1,g=(v+1)*m+x+1,M=(v+1)*m+x;r.push(b,y,M),r.push(y,g,M)}this.setIndex(r),this.setAttribute("position",new Ke(o,3)),this.setAttribute("normal",new Ke(a,3)),this.setAttribute("uv",new Ke(c,2))}Zc.prototype=Object.create(qe.prototype);Zc.prototype.constructor=Zc;function Jd(t,e,n){wt.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n},this.fromBufferGeometry(new Zc(t,e,n)),this.mergeVertices()}Jd.prototype=Object.create(wt.prototype);Jd.prototype.constructor=Jd;var Su=class extends qe{constructor(e,n){super(),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:n},n=n||12;let r=[],o=[],a=[],c=[],l=0,u=0;if(Array.isArray(e)===!1)h(e);else for(let d=0;d<e.length;d++)h(e[d]),this.addGroup(l,u,d),l+=u,u=0;this.setIndex(r),this.setAttribute("position",new Ke(o,3)),this.setAttribute("normal",new Ke(a,3)),this.setAttribute("uv",new Ke(c,2));function h(d){let f=o.length/3,p=d.extractPoints(n),m=p.shape,v=p.holes;Or.isClockWise(m)===!1&&(m=m.reverse());for(let b=0,y=v.length;b<y;b++){let g=v[b];Or.isClockWise(g)===!0&&(v[b]=g.reverse())}let x=Or.triangulateShape(m,v);for(let b=0,y=v.length;b<y;b++){let g=v[b];m=m.concat(g)}for(let b=0,y=m.length;b<y;b++){let g=m[b];o.push(g.x,g.y,0),a.push(0,0,1),c.push(g.x,g.y)}for(let b=0,y=x.length;b<y;b++){let g=x[b],M=g[0]+f,C=g[1]+f,E=g[2]+f;r.push(M,C,E),u+=3}}}toJSON(){let e=qe.prototype.toJSON.call(this),n=this.parameters.shapes;return xD(n,e)}};function xD(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,r=t.length;n<r;n++){let o=t[n];e.shapes.push(o.uuid)}else e.shapes.push(t.uuid);return e}var Tu=class extends wt{constructor(e,n){super(),this.type="ShapeGeometry",typeof n=="object"&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),n=n.curveSegments),this.parameters={shapes:e,curveSegments:n},this.fromBufferGeometry(new Su(e,n)),this.mergeVertices()}toJSON(){let e=wt.prototype.toJSON.call(this),n=this.parameters.shapes;return _D(n,e)}};function _D(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,r=t.length;n<r;n++){let o=t[n];e.shapes.push(o.uuid)}else e.shapes.push(t.uuid);return e}var jv={};xh(jv,{LineBasicMaterial:()=>Dt,LineDashedMaterial:()=>oa,Material:()=>Ye,MeshBasicMaterial:()=>pr,MeshDepthMaterial:()=>fo,MeshDistanceMaterial:()=>po,MeshLambertMaterial:()=>ra,MeshMatcapMaterial:()=>ia,MeshNormalMaterial:()=>na,MeshPhongMaterial:()=>yo,MeshPhysicalMaterial:()=>vo,MeshStandardMaterial:()=>ti,MeshToonMaterial:()=>ta,PointsMaterial:()=>Pi,RawShaderMaterial:()=>ea,ShaderMaterial:()=>en,ShadowMaterial:()=>Ks,SpriteMaterial:()=>go});function Ks(t){Ye.call(this),this.type="ShadowMaterial",this.color=new Ae(0),this.transparent=!0,this.setValues(t)}Ks.prototype=Object.create(Ye.prototype);Ks.prototype.constructor=Ks;Ks.prototype.isShadowMaterial=!0;Ks.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this};function ea(t){en.call(this,t),this.type="RawShaderMaterial"}ea.prototype=Object.create(en.prototype);ea.prototype.constructor=ea;ea.prototype.isRawShaderMaterial=!0;function ti(t){Ye.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}ti.prototype=Object.create(Ye.prototype);ti.prototype.constructor=ti;ti.prototype.isMeshStandardMaterial=!0;ti.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this};function vo(t){ti.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ue(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(e){this.reflectivity=je.clamp(2.5*(e-1)/(e+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}vo.prototype=Object.create(ti.prototype);vo.prototype.constructor=vo;vo.prototype.isMeshPhysicalMaterial=!0;vo.prototype.copy=function(t){return ti.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new Ae).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this};function yo(t){Ye.call(this),this.type="MeshPhongMaterial",this.color=new Ae(16777215),this.specular=new Ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}yo.prototype=Object.create(Ye.prototype);yo.prototype.constructor=yo;yo.prototype.isMeshPhongMaterial=!0;yo.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function ta(t){Ye.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}ta.prototype=Object.create(Ye.prototype);ta.prototype.constructor=ta;ta.prototype.isMeshToonMaterial=!0;ta.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function na(t){Ye.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}na.prototype=Object.create(Ye.prototype);na.prototype.constructor=na;na.prototype.isMeshNormalMaterial=!0;na.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function ra(t){Ye.call(this),this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}ra.prototype=Object.create(Ye.prototype);ra.prototype.constructor=ra;ra.prototype.isMeshLambertMaterial=!0;ra.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function ia(t){Ye.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}ia.prototype=Object.create(Ye.prototype);ia.prototype.constructor=ia;ia.prototype.isMeshMatcapMaterial=!0;ia.prototype.copy=function(t){return Ye.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};function oa(t){Dt.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}oa.prototype=Object.create(Dt.prototype);oa.prototype.constructor=oa;oa.prototype.isLineDashedMaterial=!0;oa.prototype.copy=function(t){return Dt.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Bt={arraySlice:function(t,e,n){return Bt.isTypedArray(t)?new t.constructor(t.subarray(e,n!==void 0?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:typeof e.BYTES_PER_ELEMENT=="number"?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(o,a){return t[o]-t[a]}let n=t.length,r=new Array(n);for(let o=0;o!==n;++o)r[o]=o;return r.sort(e),r},sortedArray:function(t,e,n){let r=t.length,o=new t.constructor(r);for(let a=0,c=0;c!==r;++a){let l=n[a]*e;for(let u=0;u!==e;++u)o[c++]=t[l+u]}return o},flattenJSON:function(t,e,n,r){let o=1,a=t[0];for(;a!==void 0&&a[r]===void 0;)a=t[o++];if(a===void 0)return;let c=a[r];if(c!==void 0)if(Array.isArray(c))do c=a[r],c!==void 0&&(e.push(a.time),n.push.apply(n,c)),a=t[o++];while(a!==void 0);else if(c.toArray!==void 0)do c=a[r],c!==void 0&&(e.push(a.time),c.toArray(n,n.length)),a=t[o++];while(a!==void 0);else do c=a[r],c!==void 0&&(e.push(a.time),n.push(c)),a=t[o++];while(a!==void 0)},subclip:function(t,e,n,r,o){o=o||30;let a=t.clone();a.name=e;let c=[];for(let u=0;u<a.tracks.length;++u){let h=a.tracks[u],d=h.getValueSize(),f=[],p=[];for(let m=0;m<h.times.length;++m){let v=h.times[m]*o;if(!(v<n||v>=r)){f.push(h.times[m]);for(let x=0;x<d;++x)p.push(h.values[m*d+x])}}f.length!==0&&(h.times=Bt.convertArray(f,h.times.constructor),h.values=Bt.convertArray(p,h.values.constructor),c.push(h))}a.tracks=c;let l=1/0;for(let u=0;u<a.tracks.length;++u)l>a.tracks[u].times[0]&&(l=a.tracks[u].times[0]);for(let u=0;u<a.tracks.length;++u)a.tracks[u].shift(-1*l);return a.resetDuration(),a},makeClipAdditive:function(t,e,n,r){e===void 0&&(e=0),n===void 0&&(n=t),(r===void 0||r<=0)&&(r=30);let o=n.tracks.length,a=e/r;for(let c=0;c<o;++c){let l=n.tracks[c],u=l.ValueTypeName;if(u==="bool"||u==="string")continue;let h=t.tracks.find(function(y){return y.name===l.name&&y.ValueTypeName===u});if(h===void 0)continue;let d=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let p=0,m=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);let v=l.times.length-1,x;if(a<=l.times[0]){let y=d,g=f-d;x=Bt.arraySlice(l.values,y,g)}else if(a>=l.times[v]){let y=v*f+d,g=y+f-d;x=Bt.arraySlice(l.values,y,g)}else{let y=l.createInterpolant(),g=d,M=f-d;y.evaluate(a),x=Bt.arraySlice(y.resultBuffer,g,M)}u==="quaternion"&&new zt().fromArray(x).normalize().conjugate().toArray(x);let b=h.times.length;for(let y=0;y<b;++y){let g=y*m+p;if(u==="quaternion")zt.multiplyQuaternionsFlat(h.values,g,x,0,h.values,g);else{let M=m-p*2;for(let C=0;C<M;++C)h.values[g+C]-=x[C]}}}return t.blendMode=nd,t}};function Rn(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n}Object.assign(Rn.prototype,{evaluate:function(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],o=e[n-1];e:{t:{let a;n:{r:if(!(t<r)){for(let c=n+2;;){if(r===void 0){if(t<o)break r;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,o)}if(n===c)break;if(o=r,r=e[++n],t<r)break t}a=e.length;break n}if(!(t>=o)){let c=e[1];t<c&&(n=2,o=c);for(let l=n-2;;){if(o===void 0)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(n===l)break;if(r=o,o=e[--n-1],t>=o)break t}a=n,n=0;break n}break e}for(;n<a;){let c=n+a>>>1;t<e[c]?a=c:n=c+1}if(r=e[n],o=e[n-1],o===void 0)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(r===void 0)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,o,t)}this._cachedIndex=n,this.intervalChanged_(n,o,r)}return this.interpolate_(n,o,t,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=t*r;for(let a=0;a!==r;++a)e[a]=n[o+a];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}});Object.assign(Rn.prototype,{beforeStart_:Rn.prototype.copySampleValue_,afterEnd_:Rn.prototype.copySampleValue_});function Au(t,e,n,r){Rn.call(this,t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}Au.prototype=Object.assign(Object.create(Rn.prototype),{constructor:Au,DefaultSettings_:{endingStart:Zo,endingEnd:Zo},intervalChanged_:function(t,e,n){let r=this.parameterPositions,o=t-2,a=t+1,c=r[o],l=r[a];if(c===void 0)switch(this.getSettings_().endingStart){case Jo:o=t,c=2*e-n;break;case bc:o=r.length-2,c=e+r[o]-r[o+1];break;default:o=t,c=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Jo:a=t,l=2*n-e;break;case bc:a=1,l=n+r[1]-r[0];break;default:a=t-1,l=e}let u=(n-e)*.5,h=this.valueSize;this._weightPrev=u/(e-c),this._weightNext=u/(l-n),this._offsetPrev=o*h,this._offsetNext=a*h},interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=t*c,u=l-c,h=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,m=(n-e)/(r-e),v=m*m,x=v*m,b=-f*x+2*f*v-f*m,y=(1+f)*x+(-1.5-2*f)*v+(-.5+f)*m+1,g=(-1-p)*x+(1.5+p)*v+.5*m,M=p*x-p*v;for(let C=0;C!==c;++C)o[C]=b*a[h+C]+y*a[u+C]+g*a[l+C]+M*a[d+C];return o}});function sa(t,e,n,r){Rn.call(this,t,e,n,r)}sa.prototype=Object.assign(Object.create(Rn.prototype),{constructor:sa,interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=t*c,u=l-c,h=(n-e)/(r-e),d=1-h;for(let f=0;f!==c;++f)o[f]=a[u+f]*d+a[l+f]*h;return o}});function Cu(t,e,n,r){Rn.call(this,t,e,n,r)}Cu.prototype=Object.assign(Object.create(Rn.prototype),{constructor:Cu,interpolate_:function(t){return this.copySampleValue_(t-1)}});function jt(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Bt.convertArray(e,this.TimeBufferType),this.values=Bt.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}Object.assign(jt,{toJSON:function(t){let e=t.constructor,n;if(e.toJSON!==void 0)n=e.toJSON(t);else{n={name:t.name,times:Bt.convertArray(t.times,Array),values:Bt.convertArray(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}});Object.assign(jt.prototype,{constructor:jt,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:_c,InterpolantFactoryMethodDiscrete:function(t){return new Cu(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new sa(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Au(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){let e;switch(t){case Hs:e=this.InterpolantFactoryMethodDiscrete;break;case _c:e=this.InterpolantFactoryMethodLinear;break;case td:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Hs;case this.InterpolantFactoryMethodLinear:return _c;case this.InterpolantFactoryMethodSmooth:return td}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this},scale:function(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this},trim:function(t,e){let n=this.times,r=n.length,o=0,a=r-1;for(;o!==r&&n[o]<t;)++o;for(;a!==-1&&n[a]>e;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);let c=this.getValueSize();this.times=Bt.arraySlice(n,o,a),this.values=Bt.arraySlice(this.values,o*c,a*c)}return this},validate:function(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let c=0;c!==o;c++){let l=n[c];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,l,a),t=!1;break}a=l}if(r!==void 0&&Bt.isTypedArray(r))for(let c=0,l=r.length;c!==l;++c){let u=r[c];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,u),t=!1;break}}return t},optimize:function(){let t=Bt.arraySlice(this.times),e=Bt.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===td,o=t.length-1,a=1;for(let c=1;c<o;++c){let l=!1,u=t[c],h=t[c+1];if(u!==h&&(c!==1||u!==u[0]))if(r)l=!0;else{let d=c*n,f=d-n,p=d+n;for(let m=0;m!==n;++m){let v=e[d+m];if(v!==e[f+m]||v!==e[p+m]){l=!0;break}}}if(l){if(c!==a){t[a]=t[c];let d=c*n,f=a*n;for(let p=0;p!==n;++p)e[f+p]=e[d+p]}++a}}if(o>0){t[a]=t[o];for(let c=o*n,l=a*n,u=0;u!==n;++u)e[l+u]=e[c+u];++a}return a!==t.length?(this.times=Bt.arraySlice(t,0,a),this.values=Bt.arraySlice(e,0,a*n)):(this.times=t,this.values=e),this},clone:function(){let t=Bt.arraySlice(this.times,0),e=Bt.arraySlice(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}});function Ru(t,e,n){jt.call(this,t,e,n)}Ru.prototype=Object.assign(Object.create(jt.prototype),{constructor:Ru,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Hs,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Pu(t,e,n,r){jt.call(this,t,e,n,r)}Pu.prototype=Object.assign(Object.create(jt.prototype),{constructor:Pu,ValueTypeName:"color"});function aa(t,e,n,r){jt.call(this,t,e,n,r)}aa.prototype=Object.assign(Object.create(jt.prototype),{constructor:aa,ValueTypeName:"number"});function Lu(t,e,n,r){Rn.call(this,t,e,n,r)}Lu.prototype=Object.assign(Object.create(Rn.prototype),{constructor:Lu,interpolate_:function(t,e,n,r){let o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,l=(n-e)/(r-e),u=t*c;for(let h=u+c;u!==h;u+=4)zt.slerpFlat(o,0,a,u-c,a,u,l);return o}});function Jc(t,e,n,r){jt.call(this,t,e,n,r)}Jc.prototype=Object.assign(Object.create(jt.prototype),{constructor:Jc,ValueTypeName:"quaternion",DefaultInterpolation:_c,InterpolantFactoryMethodLinear:function(t){return new Lu(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0});function Fu(t,e,n,r){jt.call(this,t,e,n,r)}Fu.prototype=Object.assign(Object.create(jt.prototype),{constructor:Fu,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Hs,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function ca(t,e,n,r){jt.call(this,t,e,n,r)}ca.prototype=Object.assign(Object.create(jt.prototype),{constructor:ca,ValueTypeName:"vector"});function Kn(t,e,n,r){this.name=t,this.tracks=n,this.duration=e!==void 0?e:-1,this.blendMode=r!==void 0?r:wc,this.uuid=je.generateUUID(),this.duration<0&&this.resetDuration()}function PD(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return aa;case"vector":case"vector2":case"vector3":case"vector4":return ca;case"color":return Pu;case"quaternion":return Jc;case"bool":case"boolean":return Ru;case"string":return Fu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function LD(t){if(t.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=PD(t.type);if(t.times===void 0){let n=[],r=[];Bt.flattenJSON(t.keys,n,r,"value"),t.times=n,t.values=r}return e.parse!==void 0?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(Kn,{parse:function(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(LD(n[o]).scale(r));return new Kn(t.name,t.duration,e,t.blendMode)},toJSON:function(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let o=0,a=n.length;o!==a;++o)e.push(jt.toJSON(n[o]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){let o=e.length,a=[];for(let c=0;c<o;c++){let l=[],u=[];l.push((c+o-1)%o,c,(c+1)%o),u.push(0,1,0);let h=Bt.getKeyframeOrder(l);l=Bt.sortedArray(l,1,h),u=Bt.sortedArray(u,1,h),!r&&l[0]===0&&(l.push(o),u.push(u[0])),a.push(new aa(".morphTargetInfluences["+e[c].name+"]",l,u).scale(1/n))}return new Kn(t,-1,a)},findByName:function(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null},CreateClipsFromMorphTargetSequences:function(t,e,n){let r={},o=/^([\w-]*?)([\d]+)$/;for(let c=0,l=t.length;c<l;c++){let u=t[c],h=u.name.match(o);if(h&&h.length>1){let d=h[1],f=r[d];f||(r[d]=f=[]),f.push(u)}}let a=[];for(let c in r)a.push(Kn.CreateFromMorphTargetSequence(c,r[c],e,n));return a},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,f,p,m,v){if(p.length!==0){let x=[],b=[];Bt.flattenJSON(p,x,b,m),x.length!==0&&v.push(new d(f,x,b))}},r=[],o=t.name||"default",a=t.fps||30,c=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let f=u[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let v=0;v<f[m].morphTargets.length;v++)p[f[m].morphTargets[v]]=-1;for(let v in p){let x=[],b=[];for(let y=0;y!==f[m].morphTargets.length;++y){let g=f[m];x.push(g.time),b.push(g.morphTarget===v?1:0)}r.push(new aa(".morphTargetInfluence["+v+"]",x,b))}l=p.length*(a||1)}else{let p=".bones["+e[d].name+"]";n(ca,p+".position",f,"pos",r),n(Jc,p+".quaternion",f,"rot",r),n(ca,p+".scale",f,"scl",r)}}return r.length===0?null:new Kn(o,l,r,c)}});Object.assign(Kn.prototype,{resetDuration:function(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let o=this.tracks[n];e=Math.max(e,o.times[o.times.length-1])}return this.duration=e,this},trim:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new Kn(this.name,this.duration,t,this.blendMode)}});var Fi={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function qv(t,e,n){let r=this,o=!1,a=0,c=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){c++,o===!1&&r.onStart!==void 0&&r.onStart(h,a,c),o=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,c),a===c&&(o=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return u.push(h,d),this},this.removeHandler=function(h){let d=u.indexOf(h);return d!==-1&&u.splice(d,2),this},this.getHandler=function(h){for(let d=0,f=u.length;d<f;d+=2){let p=u[d],m=u[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null}}var Xv=new qv;function pt(t){this.manager=t!==void 0?t:Xv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(pt.prototype,{load:function(){},loadAsync:function(t,e){let n=this;return new Promise(function(r,o){n.load(t,r,e,o)})},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});var ni={};function hn(t){pt.call(this,t)}hn.prototype=Object.assign(Object.create(pt.prototype),{constructor:hn,load:function(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=Fi.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;if(ni[t]!==void 0){ni[t].push({onLoad:e,onProgress:n,onError:r});return}let c=/^data:(.*?)(;base64)?,(.*)$/,l=t.match(c),u;if(l){let h=l[1],d=!!l[2],f=l[3];f=decodeURIComponent(f),d&&(f=atob(f));try{let p,m=(this.responseType||"").toLowerCase();switch(m){case"arraybuffer":case"blob":let v=new Uint8Array(f.length);for(let b=0;b<f.length;b++)v[b]=f.charCodeAt(b);m==="blob"?p=new Blob([v.buffer],{type:h}):p=v.buffer;break;case"document":p=new DOMParser().parseFromString(f,h);break;case"json":p=JSON.parse(f);break;default:p=f;break}setTimeout(function(){e&&e(p),o.manager.itemEnd(t)},0)}catch(p){setTimeout(function(){r&&r(p),o.manager.itemError(t),o.manager.itemEnd(t)},0)}}else{ni[t]=[],ni[t].push({onLoad:e,onProgress:n,onError:r}),u=new XMLHttpRequest,u.open("GET",t,!0),u.addEventListener("load",function(h){let d=this.response,f=ni[t];if(delete ni[t],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Fi.add(t,d);for(let p=0,m=f.length;p<m;p++){let v=f[p];v.onLoad&&v.onLoad(d)}o.manager.itemEnd(t)}else{for(let p=0,m=f.length;p<m;p++){let v=f[p];v.onError&&v.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)}},!1),u.addEventListener("progress",function(h){let d=ni[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onProgress&&m.onProgress(h)}},!1),u.addEventListener("error",function(h){let d=ni[t];delete ni[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onError&&m.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)},!1),u.addEventListener("abort",function(h){let d=ni[t];delete ni[t];for(let f=0,p=d.length;f<p;f++){let m=d[f];m.onError&&m.onError(h)}o.manager.itemError(t),o.manager.itemEnd(t)},!1),this.responseType!==void 0&&(u.responseType=this.responseType),this.withCredentials!==void 0&&(u.withCredentials=this.withCredentials),u.overrideMimeType&&u.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(let h in this.requestHeader)u.setRequestHeader(h,this.requestHeader[h]);u.send(null)}return o.manager.itemStart(t),u},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}});function Yv(t){pt.call(this,t)}Yv.prototype=Object.assign(Object.create(pt.prototype),{constructor:Yv,load:function(t,e,n,r){let o=this,a=new hn(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e=[];for(let n=0;n<t.length;n++){let r=Kn.parse(t[n]);e.push(r)}return e}});function $v(t){pt.call(this,t)}$v.prototype=Object.assign(Object.create(pt.prototype),{constructor:$v,load:function(t,e,n,r){let o=this,a=[],c=new Qs;c.image=a;let l=new hn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(o.withCredentials);let u=0;function h(d){l.load(t[d],function(f){let p=o.parse(f,!0);a[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},u+=1,u===6&&(p.mipmapCount===1&&(c.minFilter=Ht),c.format=p.format,c.needsUpdate=!0,e&&e(c))},n,r)}if(Array.isArray(t))for(let d=0,f=t.length;d<f;++d)h(d);else l.load(t,function(d){let f=o.parse(d,!0);if(f.isCubemap){let p=f.mipmaps.length/f.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)a[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+v]),a[m].format=f.format,a[m].width=f.width,a[m].height=f.height}}else c.image.width=f.width,c.image.height=f.height,c.mipmaps=f.mipmaps;f.mipmapCount===1&&(c.minFilter=Ht),c.format=f.format,c.needsUpdate=!0,e&&e(c)},n,r);return c}});function us(t){pt.call(this,t)}us.prototype=Object.assign(Object.create(pt.prototype),{constructor:us,load:function(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=Fi.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;let c=document.createElementNS("http://www.w3.org/1999/xhtml","img");function l(){c.removeEventListener("load",l,!1),c.removeEventListener("error",u,!1),Fi.add(t,this),e&&e(this),o.manager.itemEnd(t)}function u(h){c.removeEventListener("load",l,!1),c.removeEventListener("error",u,!1),r&&r(h),o.manager.itemError(t),o.manager.itemEnd(t)}return c.addEventListener("load",l,!1),c.addEventListener("error",u,!1),t.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),o.manager.itemStart(t),c.src=t,c}});function Iu(t){pt.call(this,t)}Iu.prototype=Object.assign(Object.create(pt.prototype),{constructor:Iu,load:function(t,e,n,r){let o=new gr,a=new us(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function l(u){a.load(t[u],function(h){o.images[u]=h,c++,c===6&&(o.needsUpdate=!0,e&&e(o))},void 0,r)}for(let u=0;u<t.length;++u)l(u);return o}});function Qd(t){pt.call(this,t)}Qd.prototype=Object.assign(Object.create(pt.prototype),{constructor:Qd,load:function(t,e,n,r){let o=this,a=new ho,c=new hn(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(o.withCredentials),c.load(t,function(l){let u=o.parse(l);u&&(u.image!==void 0?a.image=u.image:u.data!==void 0&&(a.image.width=u.width,a.image.height=u.height,a.image.data=u.data),a.wrapS=u.wrapS!==void 0?u.wrapS:ln,a.wrapT=u.wrapT!==void 0?u.wrapT:ln,a.magFilter=u.magFilter!==void 0?u.magFilter:Ht,a.minFilter=u.minFilter!==void 0?u.minFilter:Ht,a.anisotropy=u.anisotropy!==void 0?u.anisotropy:1,u.format!==void 0&&(a.format=u.format),u.type!==void 0&&(a.type=u.type),u.mipmaps!==void 0&&(a.mipmaps=u.mipmaps,a.minFilter=to),u.mipmapCount===1&&(a.minFilter=Ht),a.needsUpdate=!0,e&&e(a,u))},n,r),a}});function Du(t){pt.call(this,t)}Du.prototype=Object.assign(Object.create(pt.prototype),{constructor:Du,load:function(t,e,n,r){let o=new yt,a=new us(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(c){o.image=c;let l=t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0;o.format=l?Lr:mn,o.needsUpdate=!0,e!==void 0&&e(o)},n,r),o}});function Xe(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(Xe.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){t===void 0&&(t=5);let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){t===void 0&&(t=5);let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){let t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(t===void 0&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),o=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),o+=n.distanceTo(r),e.push(o),r=n;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){let n=this.getLengths(),r=0,o=n.length,a;e?a=e:a=t*n[o-1];let c=0,l=o-1,u;for(;c<=l;)if(r=Math.floor(c+(l-c)/2),u=n[r]-a,u<0)c=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(o-1);let h=n[r],f=n[r+1]-h,p=(a-h)/f;return(r+p)/(o-1)},getTangent:function(t,e){let r=t-1e-4,o=t+1e-4;r<0&&(r=0),o>1&&(o=1);let a=this.getPoint(r),c=this.getPoint(o),l=e||(a.isVector2?new ue:new O);return l.copy(c).sub(a).normalize(),l},getTangentAt:function(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)},computeFrenetFrames:function(t,e){let n=new O,r=[],o=[],a=[],c=new O,l=new Qe;for(let p=0;p<=t;p++){let m=p/t;r[p]=this.getTangentAt(m,new O),r[p].normalize()}o[0]=new O,a[0]=new O;let u=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),f=Math.abs(r[0].z);h<=u&&(u=h,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),f<=u&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],c),a[0].crossVectors(r[0],o[0]);for(let p=1;p<=t;p++){if(o[p]=o[p-1].clone(),a[p]=a[p-1].clone(),c.crossVectors(r[p-1],r[p]),c.length()>Number.EPSILON){c.normalize();let m=Math.acos(je.clamp(r[p-1].dot(r[p]),-1,1));o[p].applyMatrix4(l.makeRotationAxis(c,m))}a[p].crossVectors(r[p],o[p])}if(e===!0){let p=Math.acos(je.clamp(o[0].dot(o[t]),-1,1));p/=t,r[0].dot(c.crossVectors(o[0],o[t]))>0&&(p=-p);for(let m=1;m<=t;m++)o[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],o[m])}return{tangents:r,normals:o,binormals:a}},clone:function(){return new this.constructor().copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}});var ep={};xh(ep,{ArcCurve:()=>Qc,CatmullRomCurve3:()=>Pn,CubicBezierCurve:()=>Ur,CubicBezierCurve3:()=>Ii,EllipseCurve:()=>$n,LineCurve:()=>Nn,LineCurve3:()=>ri,QuadraticBezierCurve:()=>Nr,QuadraticBezierCurve3:()=>Di,SplineCurve:()=>Gr});function $n(t,e,n,r,o,a,c,l){Xe.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=n||1,this.yRadius=r||1,this.aStartAngle=o||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=c||!1,this.aRotation=l||0}$n.prototype=Object.create(Xe.prototype);$n.prototype.constructor=$n;$n.prototype.isEllipseCurve=!0;$n.prototype.getPoint=function(t,e){let n=e||new ue,r=Math.PI*2,o=this.aEndAngle-this.aStartAngle,a=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=r;for(;o>r;)o-=r;o<Number.EPSILON&&(a?o=0:o=r),this.aClockwise===!0&&!a&&(o===r?o=-r:o=o-r);let c=this.aStartAngle+t*o,l=this.aX+this.xRadius*Math.cos(c),u=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),f=l-this.aX,p=u-this.aY;l=f*h-p*d+this.aX,u=f*d+p*h+this.aY}return n.set(l,u)};$n.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this};$n.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t};$n.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this};function Qc(t,e,n,r,o,a){$n.call(this,t,e,n,n,r,o,a),this.type="ArcCurve"}Qc.prototype=Object.create($n.prototype);Qc.prototype.constructor=Qc;Qc.prototype.isArcCurve=!0;function Kv(){let t=0,e=0,n=0,r=0;function o(a,c,l,u){t=a,e=l,n=-3*a+3*c-2*l-u,r=2*a-2*c+l+u}return{initCatmullRom:function(a,c,l,u,h){o(c,l,h*(l-a),h*(u-c))},initNonuniformCatmullRom:function(a,c,l,u,h,d,f){let p=(c-a)/h-(l-a)/(h+d)+(l-c)/d,m=(l-c)/d-(u-c)/(d+f)+(u-l)/f;p*=d,m*=d,o(c,l,p,m)},calc:function(a){let c=a*a,l=c*a;return t+e*a+n*c+r*l}}}var Kd=new O,Zv=new Kv,Jv=new Kv,Qv=new Kv;function Pn(t,e,n,r){Xe.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=n||"centripetal",this.tension=r!==void 0?r:.5}Pn.prototype=Object.create(Xe.prototype);Pn.prototype.constructor=Pn;Pn.prototype.isCatmullRomCurve3=!0;Pn.prototype.getPoint=function(t,e){let n=e||new O,r=this.points,o=r.length,a=(o-(this.closed?0:1))*t,c=Math.floor(a),l=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:l===0&&c===o-1&&(c=o-2,l=1);let u,h;this.closed||c>0?u=r[(c-1)%o]:(Kd.subVectors(r[0],r[1]).add(r[0]),u=Kd);let d=r[c%o],f=r[(c+1)%o];if(this.closed||c+2<o?h=r[(c+2)%o]:(Kd.subVectors(r[o-1],r[o-2]).add(r[o-1]),h=Kd),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),p),v=Math.pow(d.distanceToSquared(f),p),x=Math.pow(f.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),x<1e-4&&(x=v),Zv.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,m,v,x),Jv.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,m,v,x),Qv.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,m,v,x)}else this.curveType==="catmullrom"&&(Zv.initCatmullRom(u.x,d.x,f.x,h.x,this.tension),Jv.initCatmullRom(u.y,d.y,f.y,h.y,this.tension),Qv.initCatmullRom(u.z,d.z,f.z,h.z,this.tension));return n.set(Zv.calc(l),Jv.calc(l),Qv.calc(l)),n};Pn.prototype.copy=function(t){Xe.prototype.copy.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this};Pn.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t};Pn.prototype.fromJSON=function(t){Xe.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new O().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this};function ey(t,e,n,r,o){let a=(r-e)*.5,c=(o-n)*.5,l=t*t,u=t*l;return(2*n-2*r+a+c)*u+(-3*n+3*r-2*a-c)*l+a*t+n}function FD(t,e){let n=1-t;return n*n*e}function ID(t,e){return 2*(1-t)*t*e}function DD(t,e){return t*t*e}function la(t,e,n,r){return FD(t,e)+ID(t,n)+DD(t,r)}function BD(t,e){let n=1-t;return n*n*n*e}function OD(t,e){let n=1-t;return 3*n*n*t*e}function UD(t,e){return 3*(1-t)*t*t*e}function ND(t,e){return t*t*t*e}function ua(t,e,n,r,o){return BD(t,e)+OD(t,n)+UD(t,r)+ND(t,o)}function Ur(t,e,n,r){Xe.call(this),this.type="CubicBezierCurve",this.v0=t||new ue,this.v1=e||new ue,this.v2=n||new ue,this.v3=r||new ue}Ur.prototype=Object.create(Xe.prototype);Ur.prototype.constructor=Ur;Ur.prototype.isCubicBezierCurve=!0;Ur.prototype.getPoint=function(t,e){let n=e||new ue,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(ua(t,r.x,o.x,a.x,c.x),ua(t,r.y,o.y,a.y,c.y)),n};Ur.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this};Ur.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t};Ur.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this};function Ii(t,e,n,r){Xe.call(this),this.type="CubicBezierCurve3",this.v0=t||new O,this.v1=e||new O,this.v2=n||new O,this.v3=r||new O}Ii.prototype=Object.create(Xe.prototype);Ii.prototype.constructor=Ii;Ii.prototype.isCubicBezierCurve3=!0;Ii.prototype.getPoint=function(t,e){let n=e||new O,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(ua(t,r.x,o.x,a.x,c.x),ua(t,r.y,o.y,a.y,c.y),ua(t,r.z,o.z,a.z,c.z)),n};Ii.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this};Ii.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t};Ii.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this};function Nn(t,e){Xe.call(this),this.type="LineCurve",this.v1=t||new ue,this.v2=e||new ue}Nn.prototype=Object.create(Xe.prototype);Nn.prototype.constructor=Nn;Nn.prototype.isLineCurve=!0;Nn.prototype.getPoint=function(t,e){let n=e||new ue;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n};Nn.prototype.getPointAt=function(t,e){return this.getPoint(t,e)};Nn.prototype.getTangent=function(t,e){let n=e||new ue;return n.copy(this.v2).sub(this.v1).normalize(),n};Nn.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this};Nn.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};Nn.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function ri(t,e){Xe.call(this),this.type="LineCurve3",this.v1=t||new O,this.v2=e||new O}ri.prototype=Object.create(Xe.prototype);ri.prototype.constructor=ri;ri.prototype.isLineCurve3=!0;ri.prototype.getPoint=function(t,e){let n=e||new O;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n};ri.prototype.getPointAt=function(t,e){return this.getPoint(t,e)};ri.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this};ri.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};ri.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function Nr(t,e,n){Xe.call(this),this.type="QuadraticBezierCurve",this.v0=t||new ue,this.v1=e||new ue,this.v2=n||new ue}Nr.prototype=Object.create(Xe.prototype);Nr.prototype.constructor=Nr;Nr.prototype.isQuadraticBezierCurve=!0;Nr.prototype.getPoint=function(t,e){let n=e||new ue,r=this.v0,o=this.v1,a=this.v2;return n.set(la(t,r.x,o.x,a.x),la(t,r.y,o.y,a.y)),n};Nr.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this};Nr.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};Nr.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function Di(t,e,n){Xe.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new O,this.v1=e||new O,this.v2=n||new O}Di.prototype=Object.create(Xe.prototype);Di.prototype.constructor=Di;Di.prototype.isQuadraticBezierCurve3=!0;Di.prototype.getPoint=function(t,e){let n=e||new O,r=this.v0,o=this.v1,a=this.v2;return n.set(la(t,r.x,o.x,a.x),la(t,r.y,o.y,a.y),la(t,r.z,o.z,a.z)),n};Di.prototype.copy=function(t){return Xe.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this};Di.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t};Di.prototype.fromJSON=function(t){return Xe.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this};function Gr(t){Xe.call(this),this.type="SplineCurve",this.points=t||[]}Gr.prototype=Object.create(Xe.prototype);Gr.prototype.constructor=Gr;Gr.prototype.isSplineCurve=!0;Gr.prototype.getPoint=function(t,e){let n=e||new ue,r=this.points,o=(r.length-1)*t,a=Math.floor(o),c=o-a,l=r[a===0?a:a-1],u=r[a],h=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return n.set(ey(c,l.x,u.x,h.x,d.x),ey(c,l.y,u.y,h.y,d.y)),n};Gr.prototype.copy=function(t){Xe.prototype.copy.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this};Gr.prototype.toJSON=function(){let t=Xe.prototype.toJSON.call(this);t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t};Gr.prototype.fromJSON=function(t){Xe.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new ue().fromArray(r))}return this};function ii(){Xe.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}ii.prototype=Object.assign(Object.create(Xe.prototype),{constructor:ii,add:function(t){this.curves.push(t)},closePath:function(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Nn(e,t))},getPoint:function(t){let e=t*this.getLength(),n=this.getCurveLengths(),r=0;for(;r<n.length;){if(n[r]>=e){let o=n[r]-e,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l)}r++}return null},getLength:function(){let t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){t===void 0&&(t=40);let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;let e=[],n;for(let r=0,o=this.curves;r<o.length;r++){let a=o[r],c=a&&a.isEllipseCurve?t*2:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?t*a.points.length:t,l=a.getPoints(c);for(let u=0;u<l.length;u++){let h=l[u];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){Xe.prototype.copy.call(this,t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){let t=Xe.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t},fromJSON:function(t){Xe.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new ep[r.type]().fromJSON(r))}return this}});function er(t){ii.call(this),this.type="Path",this.currentPoint=new ue,t&&this.setFromPoints(t)}er.prototype=Object.assign(Object.create(ii.prototype),{constructor:er,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){let n=new Nn(this.currentPoint.clone(),new ue(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,n,r){let o=new Nr(this.currentPoint.clone(),new ue(t,e),new ue(n,r));return this.curves.push(o),this.currentPoint.set(n,r),this},bezierCurveTo:function(t,e,n,r,o,a){let c=new Ur(this.currentPoint.clone(),new ue(t,e),new ue(n,r),new ue(o,a));return this.curves.push(c),this.currentPoint.set(o,a),this},splineThru:function(t){let e=[this.currentPoint.clone()].concat(t),n=new Gr(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,n,r,o,a){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+c,e+l,n,r,o,a),this},absarc:function(t,e,n,r,o,a){return this.absellipse(t,e,n,n,r,o,a),this},ellipse:function(t,e,n,r,o,a,c,l){let u=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+u,e+h,n,r,o,a,c,l),this},absellipse:function(t,e,n,r,o,a,c,l){let u=new $n(t,e,n,r,o,a,c,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let h=u.getPoint(1);return this.currentPoint.copy(h),this},copy:function(t){return ii.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){let t=ii.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return ii.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}});function Bi(t){er.call(this,t),this.uuid=je.generateUUID(),this.type="Shape",this.holes=[]}Bi.prototype=Object.assign(Object.create(er.prototype),{constructor:Bi,getPointsHoles:function(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){er.prototype.copy.call(this,t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this},toJSON:function(){let t=er.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t},fromJSON:function(t){er.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new er().fromJSON(r))}return this}});function bt(t,e){Ue.call(this),this.type="Light",this.color=new Ae(t),this.intensity=e!==void 0?e:1}bt.prototype=Object.assign(Object.create(Ue.prototype),{constructor:bt,isLight:!0,copy:function(t){return Ue.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){let e=Ue.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}});function tp(t,e,n){bt.call(this,t,n),this.type="HemisphereLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.groundColor=new Ae(e)}tp.prototype=Object.assign(Object.create(bt.prototype),{constructor:tp,isHemisphereLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}});function kr(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new ue(512,512),this.map=null,this.mapPass=null,this.matrix=new Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ei,this._frameExtents=new ue(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}Object.assign(kr.prototype,{_projScreenMatrix:new Qe,_lightPositionWorld:new O,_lookTarget:new O,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){let e=this.camera,n=this.matrix,r=this._projScreenMatrix,o=this._lookTarget,a=this._lightPositionWorld;a.setFromMatrixPosition(t.matrixWorld),e.position.copy(a),o.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(o),e.updateMatrixWorld(),r.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(e.projectionMatrix),n.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}});function np(){kr.call(this,new It(50,1,.5,500)),this.focus=1}np.prototype=Object.assign(Object.create(kr.prototype),{constructor:np,isSpotLightShadow:!0,updateMatrices:function(t){let e=this.camera,n=je.RAD2DEG*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=t.distance||e.far;(n!==e.fov||r!==e.aspect||o!==e.far)&&(e.fov=n,e.aspect=r,e.far=o,e.updateProjectionMatrix()),kr.prototype.updateMatrices.call(this,t)}});function rp(t,e,n,r,o,a){bt.call(this,t,e),this.type="SpotLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.target=new Ue,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(c){this.intensity=c/Math.PI}}),this.distance=n!==void 0?n:0,this.angle=r!==void 0?r:Math.PI/3,this.penumbra=o!==void 0?o:0,this.decay=a!==void 0?a:1,this.shadow=new np}rp.prototype=Object.assign(Object.create(bt.prototype),{constructor:rp,isSpotLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}});function ip(){kr.call(this,new It(90,1,.5,500)),this._frameExtents=new ue(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}ip.prototype=Object.assign(Object.create(kr.prototype),{constructor:ip,isPointLightShadow:!0,updateMatrices:function(t,e){e===void 0&&(e=0);let n=this.camera,r=this.matrix,o=this._lightPositionWorld,a=this._lookTarget,c=this._projScreenMatrix;o.setFromMatrixPosition(t.matrixWorld),n.position.copy(o),a.copy(n.position),a.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(a),n.updateMatrixWorld(),r.makeTranslation(-o.x,-o.y,-o.z),c.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(c)}});function op(t,e,n,r){bt.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(o){this.intensity=o/(4*Math.PI)}}),this.distance=n!==void 0?n:0,this.decay=r!==void 0?r:1,this.shadow=new ip}op.prototype=Object.assign(Object.create(bt.prototype),{constructor:op,isPointLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}});function ha(t,e,n,r,o,a){Dr.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t!==void 0?t:-1,this.right=e!==void 0?e:1,this.top=n!==void 0?n:1,this.bottom=r!==void 0?r:-1,this.near=o!==void 0?o:.1,this.far=a!==void 0?a:2e3,this.updateProjectionMatrix()}ha.prototype=Object.assign(Object.create(Dr.prototype),{constructor:ha,isOrthographicCamera:!0,copy:function(t,e){return Dr.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this},setViewOffset:function(t,e,n,r,o,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,o=n-t,a=n+t,c=r+e,l=r-e;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=u*this.view.offsetX,a=o+u*this.view.width,c-=h*this.view.offsetY,l=c-h*this.view.height}this.projectionMatrix.makeOrthographic(o,a,c,l,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){let e=Ue.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}});function sp(){kr.call(this,new ha(-5,5,5,-5,.5,500))}sp.prototype=Object.assign(Object.create(kr.prototype),{constructor:sp,isDirectionalLightShadow:!0,updateMatrices:function(t){kr.prototype.updateMatrices.call(this,t)}});function ap(t,e){bt.call(this,t,e),this.type="DirectionalLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.target=new Ue,this.shadow=new sp}ap.prototype=Object.assign(Object.create(bt.prototype),{constructor:ap,isDirectionalLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}});function cp(t,e){bt.call(this,t,e),this.type="AmbientLight"}cp.prototype=Object.assign(Object.create(bt.prototype),{constructor:cp,isAmbientLight:!0});function lp(t,e,n,r){bt.call(this,t,e),this.type="RectAreaLight",this.width=n!==void 0?n:10,this.height=r!==void 0?r:10}lp.prototype=Object.assign(Object.create(bt.prototype),{constructor:lp,isRectAreaLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){let e=bt.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var Bu=class{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new O)}set(e){for(let n=0;n<9;n++)this.coefficients[n].copy(e[n]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,n){let r=e.x,o=e.y,a=e.z,c=this.coefficients;return n.copy(c[0]).multiplyScalar(.282095),n.addScaledVector(c[1],.488603*o),n.addScaledVector(c[2],.488603*a),n.addScaledVector(c[3],.488603*r),n.addScaledVector(c[4],1.092548*(r*o)),n.addScaledVector(c[5],1.092548*(o*a)),n.addScaledVector(c[6],.315392*(3*a*a-1)),n.addScaledVector(c[7],1.092548*(r*a)),n.addScaledVector(c[8],.546274*(r*r-o*o)),n}getIrradianceAt(e,n){let r=e.x,o=e.y,a=e.z,c=this.coefficients;return n.copy(c[0]).multiplyScalar(.886227),n.addScaledVector(c[1],2*.511664*o),n.addScaledVector(c[2],2*.511664*a),n.addScaledVector(c[3],2*.511664*r),n.addScaledVector(c[4],2*.429043*r*o),n.addScaledVector(c[5],2*.429043*o*a),n.addScaledVector(c[6],.743125*a*a-.247708),n.addScaledVector(c[7],2*.429043*r*a),n.addScaledVector(c[8],.429043*(r*r-o*o)),n}add(e){for(let n=0;n<9;n++)this.coefficients[n].add(e.coefficients[n]);return this}addScaledSH(e,n){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],n);return this}scale(e){for(let n=0;n<9;n++)this.coefficients[n].multiplyScalar(e);return this}lerp(e,n){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],n);return this}equals(e){for(let n=0;n<9;n++)if(!this.coefficients[n].equals(e.coefficients[n]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,n=0){let r=this.coefficients;for(let o=0;o<9;o++)r[o].fromArray(e,n+o*3);return this}toArray(e=[],n=0){let r=this.coefficients;for(let o=0;o<9;o++)r[o].toArray(e,n+o*3);return e}static getBasisAt(e,n){let r=e.x,o=e.y,a=e.z;n[0]=.282095,n[1]=.488603*o,n[2]=.488603*a,n[3]=.488603*r,n[4]=1.092548*r*o,n[5]=1.092548*o*a,n[6]=.315392*(3*a*a-1),n[7]=1.092548*r*a,n[8]=.546274*(r*r-o*o)}};function tr(t,e){bt.call(this,void 0,e),this.type="LightProbe",this.sh=t!==void 0?t:new Bu}tr.prototype=Object.assign(Object.create(bt.prototype),{constructor:tr,isLightProbe:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.sh.copy(t.sh),this},fromJSON:function(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this},toJSON:function(t){let e=bt.prototype.toJSON.call(this,t);return e.object.sh=this.sh.toArray(),e}});function up(t){pt.call(this,t),this.textures={}}up.prototype=Object.assign(Object.create(pt.prototype),{constructor:up,load:function(t,e,n,r){let o=this,a=new hn(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e=this.textures;function n(o){return e[o]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",o),e[o]}let r=new jv[t.type];if(t.uuid!==void 0&&(r.uuid=t.uuid),t.name!==void 0&&(r.name=t.name),t.color!==void 0&&r.color!==void 0&&r.color.setHex(t.color),t.roughness!==void 0&&(r.roughness=t.roughness),t.metalness!==void 0&&(r.metalness=t.metalness),t.sheen!==void 0&&(r.sheen=new Ae().setHex(t.sheen)),t.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(t.emissive),t.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(t.specular),t.shininess!==void 0&&(r.shininess=t.shininess),t.clearcoat!==void 0&&(r.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=t.clearcoatRoughness),t.fog!==void 0&&(r.fog=t.fog),t.flatShading!==void 0&&(r.flatShading=t.flatShading),t.blending!==void 0&&(r.blending=t.blending),t.combine!==void 0&&(r.combine=t.combine),t.side!==void 0&&(r.side=t.side),t.opacity!==void 0&&(r.opacity=t.opacity),t.transparent!==void 0&&(r.transparent=t.transparent),t.alphaTest!==void 0&&(r.alphaTest=t.alphaTest),t.depthTest!==void 0&&(r.depthTest=t.depthTest),t.depthWrite!==void 0&&(r.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(r.colorWrite=t.colorWrite),t.stencilWrite!==void 0&&(r.stencilWrite=t.stencilWrite),t.stencilWriteMask!==void 0&&(r.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(r.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(r.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(r.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(r.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(r.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(r.stencilZPass=t.stencilZPass),t.wireframe!==void 0&&(r.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(r.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(r.rotation=t.rotation),t.linewidth!==1&&(r.linewidth=t.linewidth),t.dashSize!==void 0&&(r.dashSize=t.dashSize),t.gapSize!==void 0&&(r.gapSize=t.gapSize),t.scale!==void 0&&(r.scale=t.scale),t.polygonOffset!==void 0&&(r.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=t.polygonOffsetUnits),t.skinning!==void 0&&(r.skinning=t.skinning),t.morphTargets!==void 0&&(r.morphTargets=t.morphTargets),t.morphNormals!==void 0&&(r.morphNormals=t.morphNormals),t.dithering!==void 0&&(r.dithering=t.dithering),t.vertexTangents!==void 0&&(r.vertexTangents=t.vertexTangents),t.visible!==void 0&&(r.visible=t.visible),t.toneMapped!==void 0&&(r.toneMapped=t.toneMapped),t.userData!==void 0&&(r.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?r.vertexColors=t.vertexColors>0:r.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let o in t.uniforms){let a=t.uniforms[o];switch(r.uniforms[o]={},a.type){case"t":r.uniforms[o].value=n(a.value);break;case"c":r.uniforms[o].value=new Ae().setHex(a.value);break;case"v2":r.uniforms[o].value=new ue().fromArray(a.value);break;case"v3":r.uniforms[o].value=new O().fromArray(a.value);break;case"v4":r.uniforms[o].value=new mt().fromArray(a.value);break;case"m3":r.uniforms[o].value=new Ft().fromArray(a.value);break;case"m4":r.uniforms[o].value=new Qe().fromArray(a.value);break;default:r.uniforms[o].value=a.value}}if(t.defines!==void 0&&(r.defines=t.defines),t.vertexShader!==void 0&&(r.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(r.fragmentShader=t.fragmentShader),t.extensions!==void 0)for(let o in t.extensions)r.extensions[o]=t.extensions[o];if(t.shading!==void 0&&(r.flatShading=t.shading===1),t.size!==void 0&&(r.size=t.size),t.sizeAttenuation!==void 0&&(r.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(r.map=n(t.map)),t.matcap!==void 0&&(r.matcap=n(t.matcap)),t.alphaMap!==void 0&&(r.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(r.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(r.bumpScale=t.bumpScale),t.normalMap!==void 0&&(r.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(r.normalMapType=t.normalMapType),t.normalScale!==void 0){let o=t.normalScale;Array.isArray(o)===!1&&(o=[o,o]),r.normalScale=new ue().fromArray(o)}return t.displacementMap!==void 0&&(r.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(r.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(r.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(r.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(r.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(r.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(r.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(r.specularMap=n(t.specularMap)),t.envMap!==void 0&&(r.envMap=n(t.envMap)),t.envMapIntensity!==void 0&&(r.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(r.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(r.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(r.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(r.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(r.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(r.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(r.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(r.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new ue().fromArray(t.clearcoatNormalScale)),t.transmission!==void 0&&(r.transmission=t.transmission),t.transmissionMap!==void 0&&(r.transmissionMap=n(t.transmissionMap)),r},setTextures:function(t){return this.textures=t,this}});var hp={decodeText:function(t){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(t);let e="";for(let n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(n){return e}},extractUrlBase:function(t){let e=t.lastIndexOf("/");return e===-1?"./":t.substr(0,e+1)}};function fa(){qe.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}fa.prototype=Object.assign(Object.create(qe.prototype),{constructor:fa,isInstancedBufferGeometry:!0,copy:function(t){return qe.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let t=qe.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}});function Ou(t,e,n,r){typeof n=="number"&&(r=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),tt.call(this,t,e,n),this.meshPerAttribute=r||1}Ou.prototype=Object.assign(Object.create(tt.prototype),{constructor:Ou,isInstancedBufferAttribute:!0,copy:function(t){return tt.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){let t=tt.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}});function dp(t){pt.call(this,t)}dp.prototype=Object.assign(Object.create(pt.prototype),{constructor:dp,load:function(t,e,n,r){let o=this,a=new hn(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{e(o.parse(JSON.parse(c)))}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)},parse:function(t){let e={},n={};function r(p,m){if(e[m]!==void 0)return e[m];let x=p.interleavedBuffers[m],b=o(p,x.buffer),y=new fp[x.type](b),g=new Cn(y,x.stride);return g.uuid=x.uuid,e[m]=g,g}function o(p,m){if(n[m]!==void 0)return n[m];let x=p.arrayBuffers[m],b=new Uint32Array(x).buffer;return n[m]=b,b}let a=t.isInstancedBufferGeometry?new fa:new qe,c=t.data.index;if(c!==void 0){let p=new fp[c.type](c.array);a.setIndex(new tt(p,1))}let l=t.data.attributes;for(let p in l){let m=l[p],v;if(m.isInterleavedBufferAttribute){let x=r(t.data,m.data);v=new Ri(x,m.itemSize,m.offset,m.normalized)}else{let x=new fp[m.type](m.array),b=m.isInstancedBufferAttribute?Ou:tt;v=new b(x,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),a.setAttribute(p,v)}let u=t.data.morphAttributes;if(u)for(let p in u){let m=u[p],v=[];for(let x=0,b=m.length;x<b;x++){let y=m[x],g;if(y.isInterleavedBufferAttribute){let M=r(t.data,y.data);g=new Ri(M,y.itemSize,y.offset,y.normalized)}else{let M=new fp[y.type](y.array);g=new tt(M,y.itemSize,y.normalized)}y.name!==void 0&&(g.name=y.name),v.push(g)}a.morphAttributes[p]=v}t.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){let v=d[p];a.addGroup(v.start,v.count,v.materialIndex)}let f=t.data.boundingSphere;if(f!==void 0){let p=new O;f.center!==void 0&&p.fromArray(f.center),a.boundingSphere=new un(p,f.radius)}return t.name&&(a.name=t.name),t.userData&&(a.userData=t.userData),a}});var fp={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray!="undefined"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ty(t){typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),pt.call(this,t),this.options={premultiplyAlpha:"none"}}ty.prototype=Object.assign(Object.create(pt.prototype),{constructor:ty,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let o=this,a=Fi.get(t);if(a!==void 0)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;let c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",fetch(t,c).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,o.options)}).then(function(l){Fi.add(t,l),e&&e(l),o.manager.itemEnd(t)}).catch(function(l){r&&r(l),o.manager.itemError(t),o.manager.itemEnd(t)}),o.manager.itemStart(t)}});function pp(){this.type="ShapePath",this.color=new Ae,this.subPaths=[],this.currentPath=null}Object.assign(pp.prototype,{moveTo:function(t,e){return this.currentPath=new er,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,n,r){return this.currentPath.quadraticCurveTo(t,e,n,r),this},bezierCurveTo:function(t,e,n,r,o,a){return this.currentPath.bezierCurveTo(t,e,n,r,o,a),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function n(y){let g=[];for(let M=0,C=y.length;M<C;M++){let E=y[M],w=new Bi;w.curves=E.curves,g.push(w)}return g}function r(y,g){let M=g.length,C=!1;for(let E=M-1,w=0;w<M;E=w++){let F=g[E],H=g[w],ne=H.x-F.x,Y=H.y-F.y;if(Math.abs(Y)>Number.EPSILON){if(Y<0&&(F=g[w],ne=-ne,H=g[E],Y=-Y),y.y<F.y||y.y>H.y)continue;if(y.y===F.y){if(y.x===F.x)return!0}else{let L=Y*(y.x-F.x)-ne*(y.y-F.y);if(L===0)return!0;if(L<0)continue;C=!C}}else{if(y.y!==F.y)continue;if(H.x<=y.x&&y.x<=F.x||F.x<=y.x&&y.x<=H.x)return!0}}return C}let o=Or.isClockWise,a=this.subPaths;if(a.length===0)return[];if(e===!0)return n(a);let c,l,u,h=[];if(a.length===1)return l=a[0],u=new Bi,u.curves=l.curves,h.push(u),h;let d=!o(a[0].getPoints());d=t?!d:d;let f=[],p=[],m=[],v=0,x;p[v]=void 0,m[v]=[];for(let y=0,g=a.length;y<g;y++)l=a[y],x=l.getPoints(),c=o(x),c=t?!c:c,c?(!d&&p[v]&&v++,p[v]={s:new Bi,p:x},p[v].s.curves=l.curves,d&&v++,m[v]=[]):m[v].push({h:l,p:x[0]});if(!p[0])return n(a);if(p.length>1){let y=!1,g=[];for(let M=0,C=p.length;M<C;M++)f[M]=[];for(let M=0,C=p.length;M<C;M++){let E=m[M];for(let w=0;w<E.length;w++){let F=E[w],H=!0;for(let ne=0;ne<p.length;ne++)r(F.p,p[ne].p)&&(M!==ne&&g.push({froms:M,tos:ne,hole:w}),H?(H=!1,f[ne].push(F)):y=!0);H&&f[M].push(F)}}g.length>0&&(y||(m=f))}let b;for(let y=0,g=p.length;y<g;y++){u=p[y].s,h.push(u),b=m[y];for(let M=0,C=b.length;M<C;M++)u.holes.push(b[M].h)}return h}});function mp(t){this.type="Font",this.data=t}Object.assign(mp.prototype,{isFont:!0,generateShapes:function(t,e){e===void 0&&(e=100);let n=[],r=HD(t,e,this.data);for(let o=0,a=r.length;o<a;o++)Array.prototype.push.apply(n,r[o].toShapes());return n}});function HD(t,e,n){let r=Array.from?Array.from(t):String(t).split(""),o=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,c=[],l=0,u=0;for(let h=0;h<r.length;h++){let d=r[h];if(d===`
`)l=0,u-=a;else{let f=zD(d,o,l,u,n);l+=f.offsetX,c.push(f.path)}}return c}function zD(t,e,n,r,o){let a=o.glyphs[t]||o.glyphs["?"];if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+o.familyName+".");return}let c=new pp,l,u,h,d,f,p,m,v;if(a.o){let x=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let b=0,y=x.length;b<y;)switch(x[b++]){case"m":l=x[b++]*e+n,u=x[b++]*e+r,c.moveTo(l,u);break;case"l":l=x[b++]*e+n,u=x[b++]*e+r,c.lineTo(l,u);break;case"q":h=x[b++]*e+n,d=x[b++]*e+r,f=x[b++]*e+n,p=x[b++]*e+r,c.quadraticCurveTo(f,p,h,d);break;case"b":h=x[b++]*e+n,d=x[b++]*e+r,f=x[b++]*e+n,p=x[b++]*e+r,m=x[b++]*e+n,v=x[b++]*e+r,c.bezierCurveTo(f,p,m,v,h,d);break}}return{offsetX:a.ha*e,path:c}}function ny(t){pt.call(this,t)}ny.prototype=Object.assign(Object.create(pt.prototype),{constructor:ny,load:function(t,e,n,r){let o=this,a=new hn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){let l;try{l=JSON.parse(c)}catch(h){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(c.substring(65,c.length-2))}let u=o.parse(l);e&&e(u)},n,r)},parse:function(t){return new mp(t)}});var gp,vp={getContext:function(){return gp===void 0&&(gp=new(window.AudioContext||window.webkitAudioContext)),gp},setContext:function(t){gp=t}};function Uu(t){pt.call(this,t)}Uu.prototype=Object.assign(Object.create(pt.prototype),{constructor:Uu,load:function(t,e,n,r){let o=this,a=new hn(o.manager);a.setResponseType("arraybuffer"),a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(t,function(c){try{let l=c.slice(0);vp.getContext().decodeAudioData(l,function(h){e(h)})}catch(l){r?r(l):console.error(l),o.manager.itemError(t)}},n,r)}});function ry(t,e,n){tr.call(this,void 0,n);let r=new Ae().set(t),o=new Ae().set(e),a=new O(r.r,r.g,r.b),c=new O(o.r,o.g,o.b),l=Math.sqrt(Math.PI),u=l*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(c).multiplyScalar(l),this.sh.coefficients[1].copy(a).sub(c).multiplyScalar(u)}ry.prototype=Object.assign(Object.create(tr.prototype),{constructor:ry,isHemisphereLightProbe:!0,copy:function(t){return tr.prototype.copy.call(this,t),this},toJSON:function(t){return tr.prototype.toJSON.call(this,t)}});function iy(t,e){tr.call(this,void 0,e);let n=new Ae().set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}iy.prototype=Object.assign(Object.create(tr.prototype),{constructor:iy,isAmbientLightProbe:!0,copy:function(t){return tr.prototype.copy.call(this,t),this},toJSON:function(t){return tr.prototype.toJSON.call(this,t)}});var wT=new Qe,MT=new Qe;function ET(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new It,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new It,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(ET.prototype,{update:function(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;let r=t.projectionMatrix.clone(),o=e.eyeSep/2,a=o*e.near/e.focus,c=e.near*Math.tan(je.DEG2RAD*e.fov*.5)/e.zoom,l,u;MT.elements[12]=-o,wT.elements[12]=o,l=-c*e.aspect+a,u=c*e.aspect+a,r.elements[0]=2*e.near/(u-l),r.elements[8]=(u+l)/(u-l),this.cameraL.projectionMatrix.copy(r),l=-c*e.aspect-a,u=c*e.aspect-a,r.elements[0]=2*e.near/(u-l),r.elements[8]=(u+l)/(u-l),this.cameraR.projectionMatrix.copy(r)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(MT),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(wT)}});var Kc=class extends Ue{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e){if(e===void 0&&(e=0),this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let n=this.context.createBufferSource();return n.buffer=this.buffer,n.loop=this.loop,n.loopStart=this.loopStart,n.loopEnd=this.loopEnd,n.onended=this.onEnded.bind(this),n.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=n,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}};var Nu=class{constructor(e,n){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=n!==void 0?n:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,n=this.getFrequencyData();for(let r=0;r<n.length;r++)e+=n[r];return e/n.length}};function yp(t,e,n){this.binding=t,this.valueSize=n;let r,o,a;switch(e){case"quaternion":r=this._slerp,o=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,o=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,o=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=o,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(yp.prototype,{accumulate:function(t,e){let n=this.buffer,r=this.valueSize,o=t*r+r,a=this.cumulativeWeight;if(a===0){for(let c=0;c!==r;++c)n[o+c]=n[c];a=e}else{a+=e;let c=e/a;this._mixBufferRegion(n,o,0,c,r)}this.cumulativeWeight=a},accumulateAdditive:function(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t},apply:function(t){let e=this.valueSize,n=this.buffer,r=t*e+e,o=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-o,e)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){c.setValue(n,r);break}},saveOriginalState:function(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let o=n,a=r;o!==a;++o)e[o]=e[r+o%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)},_setAdditiveIdentityNumeric:function(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]},_select:function(t,e,n,r,o){if(r>=.5)for(let a=0;a!==o;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){zt.slerpFlat(t,e,t,e,t,n,r)},_slerpAdditive:function(t,e,n,r,o){let a=this._workIndex*o;zt.multiplyQuaternionsFlat(t,a,t,e,t,n),zt.slerpFlat(t,e,t,e,t,a,r)},_lerp:function(t,e,n,r,o){let a=1-r;for(let c=0;c!==o;++c){let l=e+c;t[l]=t[l]*a+t[n+c]*r}},_lerpAdditive:function(t,e,n,r,o){for(let a=0;a!==o;++a){let c=e+a;t[c]=t[c]+t[n+a]*r}}});var oy="\\[\\]\\.:\\/",WD=new RegExp("["+oy+"]","g"),sy="[^"+oy+"]",jD="[^"+oy.replace("\\.","")+"]",qD=/((?:WC+[\/:])*)/.source.replace("WC",sy),XD=/(WCOD+)?/.source.replace("WCOD",jD),YD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",sy),$D=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",sy),ZD=new RegExp("^"+qD+XD+YD+$D+"$"),JD=["material","materials","bones"];function ST(t,e,n){let r=n||yn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}Object.assign(ST.prototype,{getValue:function(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)},setValue:function(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(t,e)},bind:function(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()},unbind:function(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}});function yn(t,e,n){this.path=e,this.parsedPath=n||yn.parseTrackName(e),this.node=yn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(yn,{Composite:ST,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new yn.Composite(t,e,n):new yn(t,e,n)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(WD,"")},parseTrackName:function(t){let e=ZD.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let o=n.nodeName.substring(r+1);JD.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n},findNode:function(t,e){if(!e||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(o){for(let a=0;a<o.length;a++){let c=o[a];if(c.name===e||c.uuid===e)return c;let l=n(c.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}});Object.assign(yn.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,n){e[n]=this.node[this.propertyName]},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)e[n++]=r[o]},function(e,n){e[n]=this.resolvedProperty[this.propertyIndex]},function(e,n){this.resolvedProperty.toArray(e,n)}],SetterByBindingTypeAndVersioning:[[function(e,n){this.targetObject[this.propertyName]=e[n]},function(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.needsUpdate=!0},function(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++]},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++];this.targetObject.needsUpdate=!0},function(e,n){let r=this.resolvedProperty;for(let o=0,a=r.length;o!==a;++o)r[o]=e[n++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){this.resolvedProperty[this.propertyIndex]=e[n]},function(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.needsUpdate=!0},function(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,n){this.resolvedProperty.fromArray(e,n)},function(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.needsUpdate=!0},function(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,n){this.bind(),this.getValue(e,n)},setValue:function(e,n){this.bind(),this.setValue(e,n)},bind:function(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,o=e.propertyIndex;if(t||(t=yn.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===u){u=h;break}break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let a=t[r];if(a===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let c=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?c=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(o!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[o]!==void 0&&(o=t.morphTargetDictionary[o])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][c]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}});Object.assign(yn.prototype,{_getValue_unbound:yn.prototype.getValue,_setValue_unbound:yn.prototype.setValue});function TT(){this.uuid=je.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let t={};this._indicesByUUID=t;for(let n=0,r=arguments.length;n!==r;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}Object.assign(TT.prototype,{isAnimationObjectGroup:!0,add:function(){let t=this._objects,e=this._indicesByUUID,n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length,c,l=t.length,u=this.nCachedObjects_;for(let h=0,d=arguments.length;h!==d;++h){let f=arguments[h],p=f.uuid,m=e[p];if(m===void 0){m=l++,e[p]=m,t.push(f);for(let v=0,x=a;v!==x;++v)o[v].push(new yn(f,n[v],r[v]))}else if(m<u){c=t[m];let v=--u,x=t[v];e[x.uuid]=m,t[m]=x,e[p]=v,t[v]=f;for(let b=0,y=a;b!==y;++b){let g=o[b],M=g[v],C=g[m];g[m]=M,C===void 0&&(C=new yn(f,n[b],r[b])),g[v]=C}}else t[m]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=u},remove:function(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,o=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=e[u];if(h!==void 0&&h>=o){let d=o++,f=t[d];e[f.uuid]=h,t[h]=f,e[u]=d,t[d]=l;for(let p=0,m=r;p!==m;++p){let v=n[p],x=v[d],b=v[h];v[h]=x,v[d]=b}}}this.nCachedObjects_=o},uncache:function(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length,o=this.nCachedObjects_,a=t.length;for(let c=0,l=arguments.length;c!==l;++c){let u=arguments[c],h=u.uuid,d=e[h];if(d!==void 0)if(delete e[h],d<o){let f=--o,p=t[f],m=--a,v=t[m];e[p.uuid]=d,t[d]=p,e[v.uuid]=f,t[f]=v,t.pop();for(let x=0,b=r;x!==b;++x){let y=n[x],g=y[f],M=y[m];y[d]=g,y[f]=M,y.pop()}}else{let f=--a,p=t[f];f>0&&(e[p.uuid]=d),t[d]=p,t.pop();for(let m=0,v=r;m!==v;++m){let x=n[m];x[d]=x[f],x.pop()}}}this.nCachedObjects_=o},subscribe_:function(t,e){let n=this._bindingsIndicesByPath,r=n[t],o=this._bindings;if(r!==void 0)return o[r];let a=this._paths,c=this._parsedPaths,l=this._objects,u=l.length,h=this.nCachedObjects_,d=new Array(u);r=o.length,n[t]=r,a.push(t),c.push(e),o.push(d);for(let f=h,p=l.length;f!==p;++f){let m=l[f];d[f]=new yn(m,t,e)}return d},unsubscribe_:function(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let r=this._paths,o=this._parsedPaths,a=this._bindings,c=a.length-1,l=a[c],u=t[c];e[u]=n,a[n]=l,a.pop(),o[n]=o[c],o.pop(),r[n]=r[c],r.pop()}}});var xp=class{constructor(e,n,r,o){this._mixer=e,this._clip=n,this._localRoot=r||null,this.blendMode=o||n.blendMode;let a=n.tracks,c=a.length,l=new Array(c),u={endingStart:Zo,endingEnd:Zo};for(let h=0;h!==c;++h){let d=a[h].createInterpolant(null);l[h]=d,d.settings=u}this._interpolantSettings=u,this._interpolants=l,this._propertyBindings=new Array(c),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ww,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,n){return this.loop=e,this.repetitions=n,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,n,r){if(e.fadeOut(n),this.fadeIn(n),r){let o=this._clip.duration,a=e._clip.duration,c=a/o,l=o/a;e.warp(1,c,n),this.warp(l,1,n)}return this}crossFadeTo(e,n,r){return e.crossFadeFrom(this,n,r)}stopFading(){let e=this._weightInterpolant;return e!==null&&(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,n,r){let o=this._mixer,a=o.time,c=this.timeScale,l=this._timeScaleInterpolant;l===null&&(l=o._lendControlInterpolant(),this._timeScaleInterpolant=l);let u=l.parameterPositions,h=l.sampleValues;return u[0]=a,u[1]=a+r,h[0]=e/c,h[1]=n/c,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(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,n,r,o){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let u=(e-a)*r;if(u<0||r===0)return;this._startTime=null,n=r*u}n*=this._updateTimeScale(e);let c=this._updateTime(n),l=this._updateWeight(e);if(l>0){let u=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case nd:for(let d=0,f=u.length;d!==f;++d)u[d].evaluate(c),h[d].accumulateAdditive(l);break;case wc:default:for(let d=0,f=u.length;d!==f;++d)u[d].evaluate(c),h[d].accumulate(o,l)}}}_updateWeight(e){let n=0;if(this.enabled){n=this.weight;let r=this._weightInterpolant;if(r!==null){let o=r.evaluate(e)[0];n*=o,e>r.parameterPositions[1]&&(this.stopFading(),o===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n}_updateTimeScale(e){let n=0;if(!this.paused){n=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let o=r.evaluate(e)[0];n*=o,e>r.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n}_updateTime(e){let n=this._clip.duration,r=this.loop,o=this.time+e,a=this._loopCount,c=r===Mw;if(e===0)return a===-1?o:c&&(a&1)===1?n-o:o;if(r===bw){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(o>=n)o=n;else if(o<0)o=0;else{this.time=o;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=o,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,c)):this._setEndings(this.repetitions===0,!0,c)),o>=n||o<0){let l=Math.floor(o/n);o-=n*l,a+=Math.abs(l);let u=this.repetitions-a;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o=e>0?n:0,this.time=o,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){let h=e<0;this._setEndings(h,!h,c)}else this._setEndings(!1,!1,c);this._loopCount=a,this.time=o,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}else this.time=o;if(c&&(a&1)===1)return n-o}return o}_setEndings(e,n,r){let o=this._interpolantSettings;r?(o.endingStart=Jo,o.endingEnd=Jo):(e?o.endingStart=this.zeroSlopeAtStart?Jo:Zo:o.endingStart=bc,n?o.endingEnd=this.zeroSlopeAtEnd?Jo:Zo:o.endingEnd=bc)}_scheduleFading(e,n,r){let o=this._mixer,a=o.time,c=this._weightInterpolant;c===null&&(c=o._lendControlInterpolant(),this._weightInterpolant=c);let l=c.parameterPositions,u=c.sampleValues;return l[0]=a,u[0]=n,l[1]=a+e,u[1]=r,this}};function ay(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}ay.prototype=Object.assign(Object.create(gn.prototype),{constructor:ay,_bindAction:function(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,o=r.length,a=t._propertyBindings,c=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,h=u[l];h===void 0&&(h={},u[l]=h);for(let d=0;d!==o;++d){let f=r[d],p=f.name,m=h[p];if(m!==void 0)a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}let v=e&&e._propertyBindings[d].binding.parsedPath;m=new yp(yn.create(n,p,v),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[d]=m}c[d].resultBuffer=m.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,o=this._actionsByClip[r];this._bindAction(t,o&&o.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions},_addInactiveAction:function(t,e,n){let r=this._actions,o=this._actionsByClip,a=o[e];if(a===void 0)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,o[e]=a;else{let c=a.knownActions;t._byClipCacheIndex=c.length,c.push(t)}t._cacheIndex=r.length,r.push(t),a.actionByRoot[n]=t},_removeInactiveAction:function(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let o=t._clip.uuid,a=this._actionsByClip,c=a[o],l=c.knownActions,u=l[l.length-1],h=t._byClipCacheIndex;u._byClipCacheIndex=h,l[h]=u,l.pop(),t._byClipCacheIndex=null;let d=c.actionByRoot,f=(t._localRoot||this._root).uuid;delete d[f],l.length===0&&delete a[o],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let o=e[n];--o.referenceCount===0&&this._removeInactiveBinding(o)}},_lendAction:function(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_takeBackAction:function(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_addInactiveBinding:function(t,e,n){let r=this._bindingsByRootAndName,o=this._bindings,a=r[e];a===void 0&&(a={},r[e]=a),a[n]=t,t._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,o=n.path,a=this._bindingsByRootAndName,c=a[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete c[o],Object.keys(c).length===0&&delete a[r]},_lendBinding:function(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_takeBackBinding:function(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,o=e[r];t._cacheIndex=r,e[r]=t,o._cacheIndex=n,e[n]=o},_lendControlInterpolant:function(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new sa(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=e,t[e]=n),n},_takeBackControlInterpolant:function(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,o=e[r];t.__cacheIndex=r,e[r]=t,o.__cacheIndex=n,e[n]=o},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e,n){let r=e||this._root,o=r.uuid,a=typeof t=="string"?Kn.findByName(r,t):t,c=a!==null?a.uuid:t,l=this._actionsByClip[c],u=null;if(n===void 0&&(a!==null?n=a.blendMode:n=wc),l!==void 0){let d=l.actionByRoot[o];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],a===null&&(a=u._clip)}if(a===null)return null;let h=new xp(this,a,e,n);return this._bindAction(h,u),this._addInactiveAction(h,c,o),h},existingAction:function(t,e){let n=e||this._root,r=n.uuid,o=typeof t=="string"?Kn.findByName(n,t):t,a=o?o.uuid:t,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[r]||null},stopAllAction:function(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this},update:function(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,o=Math.sign(t),a=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,o,a);let c=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)c[u].apply(a);return this},setTime:function(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,o=r[n];if(o!==void 0){let a=o.knownActions;for(let c=0,l=a.length;c!==l;++c){let u=a[c];this._deactivateAction(u);let h=u._cacheIndex,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=h,e[h]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}},uncacheRoot:function(t){let e=t.uuid,n=this._actionsByClip;for(let a in n){let c=n[a].actionByRoot,l=c[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,o=r[e];if(o!==void 0)for(let a in o){let c=o[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}},uncacheAction:function(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}});var Gu=class t{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new t(this.value.clone===void 0?this.value:this.value.clone())}};function cy(t,e,n){Cn.call(this,t,e),this.meshPerAttribute=n||1}cy.prototype=Object.assign(Object.create(Cn.prototype),{constructor:cy,isInstancedInterleavedBuffer:!0,copy:function(t){return Cn.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){let e=Cn.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){let e=Cn.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}});function ly(t,e,n,r,o){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=r,this.count=o,this.version=0}Object.defineProperty(ly.prototype,"needsUpdate",{set:function(t){t===!0&&this.version++}});Object.assign(ly.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}});function _p(t,e,n,r){this.ray=new fr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,this.layers=new qs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function AT(t,e){return t.distance-e.distance}function uy(t,e,n,r){if(t.layers.test(e.layers)&&t.raycast(e,n),r===!0){let o=t.children;for(let a=0,c=o.length;a<c;a++)uy(o[a],e,n,!0)}}Object.assign(_p.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e,n){let r=n||[];return uy(t,this,r,e),r.sort(AT),r},intersectObjects:function(t,e,n){let r=n||[];if(Array.isArray(t)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(let o=0,a=t.length;o<a;o++)uy(t[o],this,r,e);return r.sort(AT),r}});var CT=new ue,ku=class{constructor(e,n){Object.defineProperty(this,"isBox2",{value:!0}),this.min=e!==void 0?e:new ue(1/0,1/0),this.max=n!==void 0?n:new ue(-1/0,-1/0)}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){let r=CT.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return e===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new ue),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new ue),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.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,n){return n===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),n=new ue),n.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,n){return n===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),n=new ue),n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return CT.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)}};var RT=new O,bp=new O,Hu=class{constructor(e,n){this.start=e!==void 0?e:new O,this.end=n!==void 0?n:new O}set(e,n){return this.start.copy(e),this.end.copy(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e===void 0&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new O),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e===void 0&&(console.warn("THREE.Line3: .delta() target is now required"),e=new O),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return n===void 0&&(console.warn("THREE.Line3: .at() target is now required"),n=new O),this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){RT.subVectors(e,this.start),bp.subVectors(this.end,this.start);let r=bp.dot(bp),a=bp.dot(RT)/r;return n&&(a=je.clamp(a,0,1)),a}closestPointToPoint(e,n,r){let o=this.closestPointToPointParameter(e,n);return r===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),r=new O),this.delta(r).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)}};function zu(t){Ue.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}zu.prototype=Object.create(Ue.prototype);zu.prototype.constructor=zu;zu.prototype.isImmediateRenderObject=!0;var hs=new O,wp=new Qe,hy=new Qe,Vu=class extends Yn{constructor(e){let n=PT(e),r=new qe,o=[],a=[],c=new Ae(0,0,1),l=new Ae(0,1,0);for(let h=0;h<n.length;h++){let d=n[h];d.parent&&d.parent.isBone&&(o.push(0,0,0),o.push(0,0,0),a.push(c.r,c.g,c.b),a.push(l.r,l.g,l.b))}r.setAttribute("position",new Ke(o,3)),r.setAttribute("color",new Ke(a,3));let u=new Dt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(r,u),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=n,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let n=this.bones,r=this.geometry,o=r.getAttribute("position");hy.getInverse(this.root.matrixWorld);for(let a=0,c=0;a<n.length;a++){let l=n[a];l.parent&&l.parent.isBone&&(wp.multiplyMatrices(hy,l.matrixWorld),hs.setFromMatrixPosition(wp),o.setXYZ(c,hs.x,hs.y,hs.z),wp.multiplyMatrices(hy,l.parent.matrixWorld),hs.setFromMatrixPosition(wp),o.setXYZ(c+1,hs.x,hs.y,hs.z),c+=2)}r.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}};function PT(t){let e=[];t&&t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push.apply(e,PT(t.children[n]));return e}var Wu=class extends Yn{constructor(e,n,r,o){e=e||10,n=n||10,r=new Ae(r!==void 0?r:4473924),o=new Ae(o!==void 0?o:8947848);let a=n/2,c=e/n,l=e/2,u=[],h=[];for(let p=0,m=0,v=-l;p<=n;p++,v+=c){u.push(-l,0,v,l,0,v),u.push(v,0,-l,v,0,l);let x=p===a?r:o;x.toArray(h,m),m+=3,x.toArray(h,m),m+=3,x.toArray(h,m),m+=3,x.toArray(h,m),m+=3}let d=new qe;d.setAttribute("position",new Ke(u,3)),d.setAttribute("color",new Ke(h,3));let f=new Dt({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}};var Mp=4,ju=8,sre=Math.pow(2,ju),LT=[.125,.215,.35,.446,.526,.582],QD=ju-Mp+1+LT.length;var are={[Fr]:0,[Mc]:1,[id]:2,[od]:3,[sd]:4,[ad]:5,[rd]:6};var{_lodPlanes:cre,_sizeLods:lre,_sigmas:ure}=KD();var da=(1+Math.sqrt(5))/2,el=1/da,hre=[new O(1,1,1),new O(-1,1,1),new O(1,1,-1),new O(-1,1,-1),new O(0,da,el),new O(0,da,-el),new O(el,0,da),new O(-el,0,da),new O(da,el,0),new O(-da,el,0)];function KD(){let t=[],e=[],n=[],r=ju;for(let o=0;o<QD;o++){let a=Math.pow(2,r);e.push(a);let c=1/a;o>ju-Mp?c=LT[o-ju+Mp-1]:o==0&&(c=0),n.push(c);let l=1/(a-1),u=-l/2,h=1+l/2,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,p=6,m=3,v=2,x=1,b=new Float32Array(m*p*f),y=new Float32Array(v*p*f),g=new Float32Array(x*p*f);for(let C=0;C<f;C++){let E=C%3*2/3-1,w=C>2?0:-1,F=[E,w,0,E+2/3,w,0,E+2/3,w+1,0,E,w,0,E+2/3,w+1,0,E,w+1,0];b.set(F,m*p*C),y.set(d,v*p*C);let H=[C,C,C,C,C,C];g.set(H,x*p*C)}let M=new qe;M.setAttribute("position",new tt(b,m)),M.setAttribute("uv",new tt(y,v)),M.setAttribute("faceIndex",new tt(g,x)),t.push(M),r>Mp&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}Xe.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Xe.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t};Object.assign(ii.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let e=new wt;for(let n=0,r=t.length;n<r;n++){let o=t[n];e.vertices.push(new O(o.x,o.y,o.z||0))}return e}});Object.assign(er.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}});function nB(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Pn.call(this,t),this.type="catmullrom",this.closed=!0}nB.prototype=Object.create(Pn.prototype);function rB(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Pn.call(this,t),this.type="catmullrom"}rB.prototype=Object.create(Pn.prototype);function FT(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Pn.call(this,t),this.type="catmullrom"}FT.prototype=Object.create(Pn.prototype);Object.assign(FT.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});Wu.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Vu.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(pt.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),hp.extractUrlBase(t)}});pt.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};Object.assign(ku.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}});Object.assign(On.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}});Object.assign(un.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}});ei.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)};Hu.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)};Object.assign(je,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),je.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),je.ceilPowerOfTwo(t)}});Object.assign(Ft.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(Qe.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new O().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,n,r,o,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,n,o,a)}});Un.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)};zt.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)};Object.assign(fr.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}});Object.assign(Tn.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}});Object.assign(Tn,{barycoordFromPoint:function(t,e,n,r,o){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Tn.getBarycoord(t,e,n,r,o)},normal:function(t,e,n,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Tn.getNormal(t,e,n,r)}});Object.assign(Bi.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Eu(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Tu(this,t)}});Object.assign(ue.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(O.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(mt.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(wt.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.assign(Ue.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.defineProperties(Ue.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.assign(Pt.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}});Object.defineProperties(Pt.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Ew},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});Object.defineProperties(Yc.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}});Object.defineProperty(mu.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});pu.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Object.defineProperty(Xe.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}});It.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),e!==void 0&&(this.filmGauge=e),this.setFocalLength(t)};Object.defineProperties(bt.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}});Object.defineProperties(tt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Ec},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Ec)}}});Object.assign(tt.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(t===!0?Ec:zs),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(qe.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(e&&e.isBufferAttribute)&&!(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new tt(arguments[1],arguments[2]))):t==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e)},addDrawCall:function(t,e,n){n!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},applyMatrix:function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}});Object.defineProperties(qe.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}});Object.defineProperties(fa.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}});Object.defineProperties(_p.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}});Object.defineProperties(Cn.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===Ec},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}});Object.assign(Cn.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(t===!0?Ec:zs),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(ls.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.assign(Vc.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}});Object.defineProperties(Gu.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}});Object.defineProperties(Ye.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Ae}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=t===Xf}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}});Object.defineProperties(yo.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(vo.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}});Object.defineProperties(en.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}});Object.assign(Zs.prototype,{clearTarget:function(t,e,n,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,n,r)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}});Object.defineProperties(Zs.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=t===!0?Mc:Fr}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}});Object.defineProperties(Id.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(Sn.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}});Object.defineProperties(Kc.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");let e=this;return new Uu().load(t,function(r){e.setBuffer(r)}),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}});Nu.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};uo.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)};uo.prototype.clear=function(t,e,n,r){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,r)};Si.crossOrigin=void 0;Si.loadTexture=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");let o=new Du;o.setCrossOrigin(this.crossOrigin);let a=o.load(t,n,void 0,r);return e&&(a.mapping=e),a};Si.loadTextureCube=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");let o=new Iu;o.setCrossOrigin(this.crossOrigin);let a=o.load(t,n,void 0,r);return e&&(a.mapping=e),a};Si.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Si.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:eb}}));var xo=class{constructor(){te(this,"_id");this._id=je.generateUUID()}get id(){return this._id}};var oi=class extends xo{constructor(n,r,o,a){super();te(this,"filters",[]);te(this,"internalQueue");te(this,"_queue");te(this,"rootFilter");te(this,"isCropped",!1);te(this,"listenerManager",new hr);this.rootFilter=n,this.internalQueue=new cn(a,"Composite"),this._queue=o;let c=r[0],l=r[r.length-1];r.forEach(u=>{if(!u.gameObject)throw new Error("Composite's subfilter is missing an object.");u!==l&&(u.gameObject.parent=l.gameObject),u!==c&&a==="SHARED_TARGET"&&(u.gameObject.camera.clearFlagColor=!1,u.gameObject.camera.clearFlagDepth=!0),u.queue.Remove(u),this.internalQueue.Add(u),this.filters.push(u)}),o.Add(this)}get isIRenderPass(){return!0}get queue(){return this._queue}get target(){return this.internalQueue.target}set target(n){this.internalQueue.target=n}get inputRenderPasses(){let n=new Qn;for(let r of this.rootFilter.GetInputFilters())r.Accept(n);return n.renderPasses}get lastFilter(){return this.filters[this.filters.length-1]}AddOrReplaceInput(n,r){this.rootFilter.AddOrReplaceInput(n,r)}AttachListener(n,r){this.listenerManager.AddListener(n,r),this.lastFilter.AttachListener(this,r)}DetachListener(n){this.listenerManager.RemoveListener(n),this.lastFilter.DetachListener(this);let r=[];this.listenerManager.HasGpuListeners()&&r.push(2),this.listenerManager.HasCpuListeners()&&r.push(1);let o=r.reduce((a,c)=>a|c,0);this.lastFilter.AttachListener(this,o)}GetListeners(){return this.listenerManager.GetListeners()}get parameter(){return new Qi(this.internalQueue.target)}get depth(){return this.lastFilter.depth}Delete(){for(let n of this.filters)n.Delete();this.internalQueue.Destroy(),this._queue.Remove(this)}get gameObject(){if(!this.lastFilter.gameObject)throw new Error("Composite filter contains no objects and cannot return it.");return this.lastFilter.gameObject}Accept(n){n.Visit(this)}GetInput(n){return this.rootFilter.GetInput(n)}HasInput(n){return this.rootFilter.HasInput(n)}RemoveInput(n){this.rootFilter.RemoveInput(n)}GetInputFilters(){return this.rootFilter.GetInputFilters()}FilterInputPreparedHandler(n,r){this.listenerManager.NotifyListeners(this,r)}DepthChangedEventHandler(n,r){this.listenerManager.NotifyListeners(this,r)}Render(n){this.filters.forEach(r=>{r.Render(n),r.PostRender()}),this.PostRender()}PostRender(){}};var qu=class{constructor(e,n){this.pipelineManager=e;this.meshGeneratorManager=n;te(this,"effectObjects",[]);te(this,"effectPipes",{})}OnPipelineInitialized(e,n){return xe(this,null,function*(){let r=yield this.meshGeneratorManager.GetGenerator(e.type);for(let a of e.effect.children)a.feature=new uc(r,a.mesh),a.visible=!1;this.effectPipes[e.effect.uuid]=n;let o=this.pipelineManager.globalMasks.GetByType(zo(e.type));if(o!=null)for(let a of o.effect.children)a.feature=new uc(r,a.mesh),a.visible=!1})}Create(e,n,r){return xe(this,null,function*(){let o=new Je;o.name=e.type+"["+o.id+"]";let a={id:o.id,elements:[]};Object.defineProperty(a,"id",{value:o.id,writable:!1}),Object.defineProperty(a,"type",{value:e.type,writable:!1}),Object.defineProperty(a,"name",{value:e.name,writable:!1});let c=r?[...r]:[0,0,1,1];Object.defineProperty(a,"boundingBox",{value:c,writable:!0}),a.elements=[];let l={};for(let u=0;u<e.elements.length;u++){let h=e.elements[u],d={};Object.defineProperty(d,"name",{value:h.name,writable:!1}),d.area=h.area,d.color=h.color,d.useColor=h.useColor,d.texture=h.texture,d.useTexture=h.useTexture,a.elements.push(d);let f=this.CreateColorPipeParameters(o,d,h.pipeline.masks,e.type),p=this.ClonePipeTemplate(h.pipeline),m=yield this.pipelineManager.Build(p,f,c);yield this.OnPipelineInitialized(f,m),m.IsReady()&&(l[h.area]=m)}if(n!==null)for(let u in l){let h={};Object.defineProperty(h,"name",{value:n.name,writable:!1}),h.area=u,h.color={r:0,g:0,b:0,a:n.transparency},h.useColor=n.useColor,h.texture=n.texture,h.useTexture=n.useTexture,a.elements.push(h);let d=this.CreateCopyPipeParameters(o,h,l[u],n.pipeline.masks,e.type),f=this.ClonePipeTemplate(n.pipeline),p=yield this.pipelineManager.BuildOnTop(f,d,c);yield this.OnPipelineInitialized(d,p)}return o.visible=!1,this.effectObjects.push(o),a})}CreateColorPipeParameters(e,n,r,o){var u;let a=new Je;e.add(a),a.name=n.area+"_"+n.name;let c=new jn(n.color.r,n.color.g,n.color.b,1);if(typeof n.area!="string")throw new TypeError("Area should be of type 'string'.");return new Jl(n.area,c,n.texture,(u=n.color.a)!=null?u:1,r,a,o,n.useColor,n.useTexture)}CreateCopyPipeParameters(e,n,r,o,a){let c=new Je;e.add(c),c.name=n.area+"_"+n.name;let l=new jn(n.color.r,n.color.g,n.color.b,1);if(typeof n.area!="string")throw new TypeError("Area should be of type 'string'.");return new Of(n.area,r,l,n.texture,n.color.a,o,c,a,n.useColor,n.useTexture)}ClonePipeTemplate(e){return{filters:[...e.filters],masks:[...e.masks]}}FindEffectIdxById(e){return this.effectObjects.findIndex(n=>n.id===e)}getEffectObjectAndControllableChildren(e,n=null){let r=e.id,o=this.FindEffectIdxById(r);if(o===-1)return[null,[]];let a=this.effectObjects[o],l=(u=>[...u.children.flatMap(d=>{let f=this.effectPipes[d.uuid],p=Object.values(f.masks);n!=3&&(p=p.filter(b=>this.pipelineManager.globalMasks.GetByMask(b)==null));let m=b=>b instanceof oi?b.filters.map(y=>y.gameObject):[b.gameObject],v=f.colorCamera?m(f.colorCamera):[];return[d,...p.filter(b=>!!b.gameObject).flatMap(m),...v]})])(a);return[a,l]}Intersect(e,n,r){let o=this.pipelineManager.globalMasks.GetByType(zo(e.type));if(o!=null&&o.rendered){let a=new Lf,c=new fe(n,r),l=o.effect.children[0];a.setFromCamera(c,l.camera.camera);let u=a.intersectObject(l.mesh,!0);if(u.length>0)return{uv:{x:u[0].uv.x,y:u[0].uv.y}}}return{}}Display(e){let[n,r]=this.getEffectObjectAndControllableChildren(e,3),o=pc();if(n){for(let a of r.filter(c=>c.mesh!==o))Le.controllableObjects.Add(a);for(let a of n.children.map(c=>this.effectPipes[c.uuid]))a&&this.pipelineManager.Connect(a);n.visible=!0}}IsMakeupDisplayed(e){let n=e.id,r=this.FindEffectIdxById(n);return r===-1?!1:this.effectObjects[r].visible}Hide(e){let[n,r]=this.getEffectObjectAndControllableChildren(e,1),o=pc();if(n){r.filter(a=>a.mesh!==o).forEach(a=>{Le.controllableObjects.Remove(a)});for(let a of n.children.map(c=>this.effectPipes[c.uuid]))a&&this.pipelineManager.Disconnect(a);n.visible=!1}}Refresh(e){return xe(this,null,function*(){let n=this.FindEffectIdxById(e.id);if(n===-1)return;let r=this.effectObjects[n],o=r.children.map((a,c)=>[r.children[c],e.elements[c]]);for(let[a,c]of o.filter(l=>!!l[1])){a.name=c.area+"_"+c.name;let l=this.effectPipes[a.uuid],u=function(){let{r:v,g:x,b,a:y}=c.color;return new jn(v,x,b,y)}(),h=`${Le.pathToAssets}Assets/StreamingAssets/Textures/${c.texture}/${e.type}/${c.area}`,d=c.useTexture?Bn.loadTexture(h):Promise.resolve(void 0),f;if(c.area instanceof ImageData){let v=new xi(c.area.data,c.area.width,c.area.height,ar);v.minFilter=sn,v.magFilter=sn,f=Promise.resolve(v)}else{let v=`${Le.pathToAssets}Assets/StreamingAssets/Textures/Area/${e.type}/${c.area}`;f=Bn.loadTexture(v)}let[p,m]=yield Promise.allSettled([d,f]);l.SetColor({color:u,map:p.status=="fulfilled"?p.value:void 0}),m.status=="fulfilled"&&l.SetArea(m.value),l.SetBoundingBox(e.boundingBox)}})}Remove(e){let[n,r]=this.getEffectObjectAndControllableChildren(e,2),o=pc();if(n){let a=r.filter(l=>l.mesh!==o);for(let l of a)Le.controllableObjects.Remove(l);for(let l of n.children){let u=this.effectPipes[l.uuid];this.pipelineManager.Destroy(u),delete this.effectPipes[l.uuid]}n.visible=!1;let c=this.FindEffectIdxById(e.id);c>-1&&this.effectObjects.splice(c,1)}}Update(){this.effectObjects.flatMap(n=>n.children).flatMap(n=>n.children).forEach(n=>{var r;return(r=n.feature)==null?void 0:r.Update()}),this.pipelineManager.globalMasks.masks.forEach(n=>{n.effect.children.forEach(r=>{let o=r.feature;o==null||o.Update()})})}LateUpdate(){this.effectObjects.flatMap(n=>n.children).flatMap(n=>n.children).forEach(n=>{var r;return(r=n.feature)==null?void 0:r.LateUpdate()}),this.pipelineManager.globalMasks.masks.forEach(n=>{n.effect.children.forEach(r=>{let o=r.feature;o==null||o.LateUpdate()})})}};function iB(t){return t.fov!==void 0}var $t=class $t{constructor(){throw new Error("Cannot be constructed")}static Initialize(){Jt.Update(),$t.CreateMesh()}static AddCamera(e){$t.trackingCamera.push(e)}static RemoveCamera(e){$t.trackingCamera=$t.trackingCamera.filter(n=>n!==e)}static Update(e){$t.inputWidth=e.width,$t.inputHeight=e.height}static LateUpdate(){$t.Fill()}static Fill(){let[e,n]=[Jt.Width(),Jt.Height()],r=$t.inputWidth/$t.inputHeight,o=e/n,a=Math.min(o,r),[c,l]=[r/a,o/a];$t.ScaleMesh(c,l);let u=1;o>=1?c>l?u=1:u=Math.max(1,r)/o:r<1?u=Math.min(1/r,1/o):u=1;let h=dt.radToDeg(2*Math.atan(u/3));$t.UpdatePerspectiveCams(o,h)}static ScaleMesh(e,n){$t.videoPlane.scale.set(e,n,1),$t.videoPlane.updateWorldMatrix(!1,!1)}static UpdatePerspectiveCams(e,n){let r=$t.trackingCamera.filter(o=>iB(o));for(let o of r)o.aspect=e,o.fov=n,o.updateProjectionMatrix()}static CreateMesh(){let e=new Kt,n=1,r=1;e.vertices.push(new W(-n,-r,0)),e.vertices.push(new W(n,-r,0)),e.vertices.push(new W(-n,r,0)),e.vertices.push(new W(n,r,0)),e.faces.push(new Ar(0,3,1)),e.faces.push(new Ar(0,2,3)),e.computeVertexNormals(),e.computeFaceNormals(),e.verticesNeedUpdate=!0,e.normalsNeedUpdate=!0,e.faceVertexUvs[0]=[],e.faceVertexUvs[0].push([new fe(0,1),new fe(1,0),new fe(1,1)]),e.faceVertexUvs[0].push([new fe(0,1),new fe(0,0),new fe(1,0)]),e.uvsNeedUpdate=!0,$t.videoPlane.name="ScreenFiller mesh",$t.videoPlane.geometry=e,$t.videoPlane.position.z=1}};te($t,"trackingCamera",[]),te($t,"videoPlane",new Wt),te($t,"inputWidth",0),te($t,"inputHeight",0);var xn=$t;var Xu=class{constructor(e,n,r,o,a,c,l){this.frameProvider=e;this.renderer=n;this.pipelineManager=r;this.meshGeneratorManager=o;this.video=a;this.effectController=c;this.onScreen=l;te(this,"onIterationCompleteCallback",()=>{});this.frameProvider.SetCallback((u,h)=>{var d,f,p;(d=window.makeupsdkLogger)==null||d.Log({message:"track",id:u,isStarting:!1}),(f=window.makeupsdkLogger)==null||f.SetDefaultID("render",u),this.GameLoop(u,h),(p=window.makeupsdkLogger)==null||p.SetDefaultID("render",null)}),xn.Initialize()}onIterationComplete(e){this.onIterationCompleteCallback=e}GameLoop(e,n){n&&(this.Update(e,n),this.LateUpdate(),this.Render())}Update(e,n){var r;Jt.Update(),(r=Le.tracker)==null||r.Update(),xn.Update(n),this.video.Update(n),Le.lumGatherer.Update(n),this.meshGeneratorManager.Update(),Le.controllableObjects.Update(),this.pipelineManager.Update(),this.effectController.Update(),this.onScreen.Update()}LateUpdate(){var e;(e=Le.tracker)==null||e.LateUpdate(),xn.LateUpdate(),this.video.LateUpdate(),Le.lumGatherer.LateUpdate(),this.meshGeneratorManager.LateUpdate(),Le.controllableObjects.LateUpdate(),this.pipelineManager.LateUpdate(),this.effectController.LateUpdate(),this.onScreen.LateUpdate()}Render(){requestAnimationFrame(()=>{var n,r,o;(n=window.makeupsdkLogger)==null||n.Log({message:"render",isStarting:!0}),this.video.Render(this.renderer),this.pipelineManager.Render(this.renderer);let e=this.pipelineManager.attachedPipes.length?this.pipelineManager.attachedPipes[this.pipelineManager.attachedPipes.length-1].GetOutputPass():this.video.filter;e&&(this.onScreen.SetInputPass(e),this.onScreen.Render(this.renderer)),(r=window.makeupsdkLogger)==null||r.Log({message:"render",isStarting:!1}),(o=this.onIterationCompleteCallback)==null||o.call(this)})}RenderPlanePipeStep(e,n,r){var o,a;this.renderer.setRenderTarget((o=e.camera.target)!=null?o:null),n&&(this.renderer.setClearColor(e.camera.clearColor,1),this.renderer.clear()),e.children.forEach(c=>this.RenderPlanePipeStep(c,n,r)),this.renderer.setRenderTarget((a=e.camera.target)!=null?a:null),e.mesh.material=e.material,this.renderer.render(e.mesh,e.camera.camera)}};function Yu(t,e){var r,o;if(!t.gameObject)throw new Error("Filter object is not set.");let n=t.gameObject.camera;e.setRenderTarget(t.target),e.setClearColor(n.clearColor,1),(n.clearFlagColor||n.clearFlagDepth)&&e.clear(n.clearFlagColor,n.clearFlagDepth),((o=(r=t.gameObject)==null?void 0:r.feature)==null?void 0:o.generator)instanceof dc&&(t.gameObject.material.side=rn),t.gameObject.mesh.material=t.gameObject.material,t.gameObject.mesh.material.needsUpdate=!0,e.render(t.gameObject.mesh,n.camera)}var ds=class extends xo{constructor(n,r,o){super();this.meshManager=n;this.renderQueue=o;te(this,"cameraParameter");te(this,"inputs",{});te(this,"listenerManager",new hr);let a=n.GetRootObject().camera;this.cameraParameter=new Hf(a),o.Add(this);for(let[c,l]of Object.entries(r))this.AddOrReplaceInput(l,c);for(let c of Object.values(this.inputs))c.AttachListener(this,2)}get isIRenderPass(){return!0}GetListeners(){return this.listenerManager.GetListeners()}Accept(n){n.Visit(this)}set target(n){this.cameraParameter.target=n}get target(){return this.cameraParameter.target}get queue(){return this.renderQueue}get inputRenderPasses(){let n=new Qn;return Object.values(this.inputs).forEach(r=>r.Accept(n)),n.renderPasses}AddOrReplaceInput(n,r){var o;(o=this.inputs[r])==null||o.DetachListener(this),this.inputs[r]=n,n.AttachListener(this,2),this.UpdateDepth()}UpdateDepth(){let n=Object.values(this.inputs).reduce((r,o)=>Math.max(r,o.depth),0);this.cameraParameter.depth<n+1&&(this.cameraParameter.depth=n+1,this.listenerManager.NotifyListeners(this,n+1))}AttachListener(n,r){this.listenerManager.AddListener(n,r)}DetachListener(n){this.listenerManager.RemoveListener(n)}get parameter(){return new kf(this)}get depth(){return this.cameraParameter.depth}get gameObject(){return this.meshManager.GetRootObject()}GetInput(n){var r;return(r=this.inputs[n])!=null?r:null}HasInput(n){return Object.prototype.hasOwnProperty.call(this.inputs,n)}RemoveInput(n){let r=this.meshManager.GetInputManager(),o=Object.keys(this.inputs).filter(a=>this.inputs[a]===n);for(let a of o)delete this.inputs[a],r.RemoveParameter(a);n.DetachListener(this),this.UpdateDepth()}GetInputFilters(){return Object.values(this.inputs)}FilterInputPreparedHandler(n,r){r.parameterCropped||this.meshManager.Adjust(!0);let o=this.meshManager.GetInputManager();for(let[a,c]of Object.entries(this.inputs))c===n&&r.parameter&&o.AddParameter(new qn(a,r.parameter))}DepthChangedEventHandler(n,r){this.UpdateDepth()}Delete(){for(let r of Object.values(this.inputs))r.DetachListener(this);this.meshManager.Delete();let n=this.gameObject.camera.camera;xn.RemoveCamera(n),this.queue.Remove(this)}Render(n){this.gameObject.onPreRender(),Yu(this,n)}PostRender(){let n=null,r=null;if(this.listenerManager.HasCpuListeners())throw"Not implemented exception";this.listenerManager.HasGpuListeners()&&(n=this.parameter);let o=new ur(n,r,!0,!0);this.listenerManager.NotifyListeners(this,o)}};var _o=class extends ds{constructor(n,r,o,a,c,l,u){var d;super(n,li({_MainTex:r,_PreviousTex:o},a),u);this.inputFilter=r;this.previousInputFilter=o;this.grabPassFilters=a;let h=n.GetInputManager();for(let f of l)switch(f.type){case"int":{let p=+f.value;Number.isFinite(p)&&h.AddParameter(new qn(f.name,new Xn(p)));break}case"float":{let p=+f.value;Number.isFinite(p)&&h.AddParameter(new qn(f.name,new Xn(p)));break}case"texture":{if(!c)continue;let p=f.value,v=((d=c[p])!=null?d:c.CombineMask).parameter;if(!v)continue;h.AddParameter(new qn(f.name,v));break}}}};var pa=class extends _o{constructor(n,r,o,a,c){super(n,r,r,{},o,a,c);this.inputFilter=r}};var $u=class extends pa{constructor(e,n,r,o,a){super(e,n,r,o,a)}FilterInputPreparedHandler(e,n){n.parameterCropped||this.meshManager.Adjust(!0);let r=this.meshManager.GetInputManager();for(let[u,h]of Object.entries(this.inputs))h===e&&n.parameter&&r.AddParameter(new qn(u,n.parameter));let{Avg:o,Max:a}=Le.lumGatherer.Process(),c=new qn("AverageLuminance",new Xn(o)),l=new qn("MaxLuminance",new Xn(a));r.AddParameter(c),r.AddParameter(l)}};var _n=class extends Je{constructor(n,r,o,a,c){super();this.mesh=n;this.material=r;this.camera=o;this.children=a;this.feature=c;te(this,"renderPassInputManager")}onPreRender(){var n;(n=this.renderPassInputManager)==null||n.onPreRender()}onRender(){}};var ma=class{constructor(e){te(this,"parameters",[]);te(this,"material");this.material=e.material}RemoveParameter(e){Ds(this.material)||(this.parameters=this.parameters.filter(n=>n.GetName()!==e))}AddParameter(e){this.parameters.find(n=>n.GetName()===e.GetName())?this.parameters=this.parameters.map(n=>n.GetName()===e.GetName()?e:n):this.parameters.push(e)}ClearParameters(){this.parameters=[]}onPreRender(){for(let e of this.parameters)e.Apply(this.material)}};var bo=class{constructor(e,n,r=new We(0),o=!1,a=!1,c=0,l="",u=""){this.camera=e;this.target=n;this.clearColor=r;this.clearFlagDepth=o;this.clearFlagColor=a;this.depth=c;this.name=l;this.tag=u}};var fy=new Zl(-1,1,1,-1,.01,1e3);fy.position.z=-1;fy.lookAt(0,0,1);var Oi=class{static GetOrthographic(){return fy}};function oB(t){let e=new on;e.far=1e3,e.near=.001,e.lookAt(new W(0,0,1));let n=new bo(e);return n.clearFlagDepth=!0,n.clearFlagColor=!0,n.depth=t,n}var ga=class t{static GetFilterCamera(e,n,r){let o=Oi.GetOrthographic(),a=new bo(o);return a.clearFlagDepth=!0,a.clearFlagColor=!0,a.depth=r,e="Filter"+e+n,a.name=e+"Camera",a.tag=e,a}static FindReferenceMeshCamera(e,n,r){let o=oB(r);switch(e=e+n+"Depth"+r,o.name=e+"Camera",o.tag=e,n){case"Overlay":{o.clearColor=new We(.5,.5,.5);break}case"Screen":{o.clearColor=new We(0,0,0);break}case"Multiply":{o.clearColor=new We(1,1,1);break}case"ColorStabilizerOverlay":{o.clearColor=new We(.5,.5,.5);break}case"AlphaBlendUseMaskAlpha":case"ExposureMultiplyAndEffectExposureBlend":case"ExposureMultiplyAndEffectGrayscaleBlend":case"ExposureMultiplyBlend":case"CurvesBlend":case"CurvesDampenBlend":case"Mask":case"LuminanceMixBlend":case"ColorStabilizerAlphaBlend":break;default:throw"Camera not found exception"}return o}static GetMeshCamera(e,n,r){let o=t.FindReferenceMeshCamera(e,n,r);return xn.AddCamera(o.camera),o}static GetBlendCamera(e,n,r){let o=Oi.GetOrthographic(),a=new bo(o);return a.clearFlagDepth=!0,a.clearFlagColor=!0,a.depth=n,e="Blend"+e+r,a.name=e+"Camera",a.tag=e,a}};var sB=3,Ui=class{constructor(e,n,r,o){te(this,"cameraObject");te(this,"planeObject");this.cameraObject=ga.GetFilterCamera(e,n,o+1);let{mesh:a,material:c}=J_(r);this.planeObject=new _n(a,c,this.cameraObject,[]),this.planeObject.position.setZ(sB),this.planeObject.renderPassInputManager=new ma(this.planeObject)}Adjust(e){}GetRootObject(){return this.planeObject}GetRenderableObject(){return this.planeObject}GetInputManager(){return this.planeObject.renderPassInputManager}Delete(){}};function Zu(t,e,n,r,o,a){return xe(this,null,function*(){let c=`${t}${e.name}`,l=o+n.depth+1,u=`${Le.pathToAssets}Assets/Resources/Materials/Filter/${e.name}.json`,h=yield Bn.loadMaterial(u),d=[],f={};return h.forEach((p,m)=>{let v=new Ui(t,c,p,l+m);if(e.name=="BrightSpots"){if(m>0)throw Error("Expected only one ResourceMaterialFilterPass for BrightSpotsGPUFilter.");d.push(new $u(v,n,r,e.parameters,a))}else d.push(new _o(v,n,d.length===0?n:d[d.length-1],f,r,e.parameters,a)),p.grabPass!==void 0&&(f[p.grabPass]=d[d.length-1])}),d.length>1?new oi(n,d,a,"DEDICATED_TARGET"):d[0]})}var IT=Object.freeze({Lipstick:2,Lipliner:3,Concealer:2,Mascara:5,Eyeliner:4,Blush:3,Foundation:1,EyebrowLine:2,Eyeshadow:3,Highlighter:1});function cB(t){return t in IT}var Ju=class{static GetProperty(e){return cB(e)?IT[e]:2}};var Qu=class{constructor(e,n,r,o=!1,a="video"){this.blendCamera=e;this.preProcessCameras=n;this.postProcessCameras=r;this.switchLayers=o;this.origin=a}};var va=class extends ds{constructor(e,n,r,o,a){let c={"":n,_MainTex:o,_Color:r};super(e,c,a)}};var Ku=class{constructor(e,n,r,o,a,c,l,u){te(this,"gameObject");let h=ga.GetMeshCamera(e,n,u),d=new Xr({map:l!=null?l:null,opacity:a,color:c,transparent:!0}),f=new Wt(new Tt,d);this.gameObject=new _n(f,d,h,[]),this.gameObject.renderPassInputManager=new ma(this.gameObject),r.add(this.gameObject)}Adjust(e){}GetRootObject(){return this.gameObject}GetRenderableObject(){return this.gameObject}GetInputManager(){return this.gameObject.renderPassInputManager}Delete(){}};var wo=class{constructor(e,n){this.game_object=e;this.color=n;te(this,"listenerManager",new hr)}AttachListener(e,n){this.listenerManager.AddListener(e,n);let r=this.listenerManager.HasGpuListeners()?this.parameter:null,o=new ur(r,null,!1,!1);this.listenerManager.NotifyListeners(this,o)}DetachListener(e){this.listenerManager.RemoveListener(e)}GetListeners(){return this.listenerManager.GetListeners()}get parameter(){return new Xn([this.color.r,this.color.g,this.color.b,this.color.a])}get depth(){return 0}Delete(){}get gameObject(){return this.game_object}Accept(e){}};var ps=class{constructor(e,n){this._gameObject=e;this.texture=n;te(this,"listenerManager",new hr)}get gameObject(){return this._gameObject}get parameter(){return new Qi(this.texture)}get depth(){return 0}AttachListener(e,n){this.listenerManager.AddListener(e,n),this.listenerManager.HasCpuListeners();let r=this.listenerManager.HasGpuListeners()?new Qi(this.texture):null,o=new ur(r,null,!1,!1);this.listenerManager.NotifyListeners(this,o)}DetachListener(e){this.listenerManager.RemoveListener(e)}GetListeners(){return this.listenerManager.GetListeners()}Accept(e){e.Visit(this)}Delete(){var e;(e=this.texture)==null||e.dispose()}};var BT={lipstick:"LipstickMaskBlur.json",foundation:"MaskBlur.json",blush:"MaskBlur.json",highlighter:"MaskBlur.json"};function lB(t){return t in BT}var OT={blush:"HighlighterMaskBlur.json",foundation:"HighlighterMaskBlur.json",highlighter:"HighlighterMaskBlur.json"};function uB(t){return t in OT}function UT(t,e,n,r,o){return xe(this,null,function*(){let a=n.useColor||n.useTexture?1:0,c=new We(n.color.r,n.color.g,n.color.b),l=n.useTexture?yield Bn.loadTexture(n.texture):At.DEFAULT_IMAGE,u=r.depth+1,h=new Ku(t,e,n.effect,n.type,a,c,l,u),d=new ps(new _n(h.GetRenderableObject().mesh,h.GetRenderableObject().material,h.GetRenderableObject().camera,[]),l),f=new wo(new _n(h.GetRenderableObject().mesh,h.GetRenderableObject().material,h.GetRenderableObject().camera,[]),n.color);if(e==="AlphaBlendUseMaskAlpha"){let p="Copy",m={uniforms:{},vertexShader:"SimpleVertexShader",fragmentShader:"CopyShader"},v=new Ui("Color"+t,p,m,u),x=new pa(v,r,{},[],o),b=new va(h,x,f,d,o);return new oi(b,[x,b],o,"SHARED_TARGET")}else return new va(h,r,f,d,o)})}function NT(t,e,n,r,o,a,c){return xe(this,null,function*(){let l=a.depth+1,u=new We(n.a,n.a,n.a),h=new Ku("Mask"+t,"Mask",e,o,1,u,r,l),d=new ps(new _n(h.GetRenderableObject().mesh,h.GetRenderableObject().material,h.GetRenderableObject().camera,[]),r),f=new wo(new _n(h.GetRenderableObject().mesh,h.GetRenderableObject().material,h.GetRenderableObject().camera,[]),new jn(n.a,n.a,n.a,1)),p=new va(h,a,f,d,c),m=t.toLowerCase(),v=o.toLowerCase();return m.endsWith("binary")&&lB(v)?DT(t,p,`${Le.pathToAssets}Assets/Resources/Materials/Filter/`+BT[v],c):m.endsWith("combine")&&uB(v)?DT(t,p,`${Le.pathToAssets}Assets/Resources/Materials/Filter/`+OT[v],c):p})}function DT(t,e,n,r){return xe(this,null,function*(){let o=yield Bn.loadMaterial(n),a=[];o.forEach((u,h)=>{let d=new Ui(t,"AlphaBlendUseMaskAlpha",u,e.depth+h);a.push(new _o(d,e,a.length===0?e:a[a.length-1],{},{},[],r))});let c=new oi(e,a,r,"DEDICATED_TARGET");return new oi(e,[e,c],r,"SWITCH_TARGET")})}var Ep=class extends ds{constructor(n,r,o,a,c){super(n,{_MainTex:r,_OverlayTexture:o,_MaskTexture:a},c);this.bottomFilter=r;this.topFilter=o;this.maskFilter=a;this.meshManager.GetInputManager().AddParameter(new qn("_BoundingBox",new Xn([0,0,1,1])))}get Top(){return this.topFilter}get Bottom(){return this.bottomFilter}get Mask(){return this.maskFilter}Connect(n,r,o){this.RemoveInput(this.bottomFilter),this.RemoveInput(this.topFilter),this.RemoveInput(this.maskFilter),this.bottomFilter=n,this.topFilter=r,this.maskFilter=o,this.AddOrReplaceInput(this.bottomFilter,"_MainTex"),this.AddOrReplaceInput(this.topFilter,"_OverlayTexture"),this.AddOrReplaceInput(this.maskFilter,"_MaskTexture")}Delete(){super.Delete()}SetBoundingBox(n){this.meshManager.GetInputManager().AddParameter(new qn("_BoundingBox",n))}};var eh=class{static Create(e,n,r,o,a,c){return xe(this,null,function*(){let l=`${Le.pathToAssets}Assets/Resources/Materials/Blend/${n}.json`,u=yield Bn.loadMaterial(l);if(u.length>1)throw new Error("Creating blend having multiple passes is not implemented.");let h=Math.max(r.depth,o.depth,a.depth),d=new Ui(e,n,u[0],h);return new Ep(d,r,o,a,c)})}};function Sp(){return[0,0,1,1]}function GT(t){return new Xn(t!=null?t:Sp())}var Mo=class{constructor(e,n,r){this.manager=e;te(this,"tag","");te(this,"combineCamera",null);te(this,"colorCamera",null);te(this,"masks",{});te(this,"meshGeneratorType");te(this,"lastPass",null);te(this,"inputPass",null);te(this,"internalQueues",[]);te(this,"currentOffset",0);te(this,"startOffset",0);te(this,"depth",0);te(this,"boundingBox");te(this,"pipeSegments",[]);te(this,"globalFilters");te(this,"globalMasks");this.globalFilters=n,this.globalMasks=r}IsReady(){return!!this.colorCamera}Connect(e){var r,o;if(this.inputPass=e,!this.lastPass)throw new Error("Lastpass not defined");if(this.boundingBox||(this.boundingBox=GT(Sp())),this.combineCamera){let a=this.masks.CombineMask;this.combineCamera.Connect(this.inputPass,this.lastPass,a),this.combineCamera.SetBoundingBox(this.boundingBox)}let n=(o=(r=this.inputPass)==null?void 0:r.depth)!=null?o:0;this.UpdateFilterQueues(),this.UpdateDepth(n)}SetColor({color:e,map:n}){let r=this.colorCamera;if(!this.IsReady()||!this.masks.CombineMask||!r.gameObject)return;let o=new wo(new _n(r.gameObject.mesh,r.gameObject.material,r.gameObject.camera,[]),new jn(e.r,e.g,e.b,1));if(r.AddOrReplaceInput(o,"_Color"),n){let l=new ps(new _n(r.gameObject.mesh,r.gameObject.material,r.gameObject.camera,[]),n);r.AddOrReplaceInput(l,"_MainTex")}let a=this.masks.CombineMask,c=new wo(new _n(a.gameObject.mesh,a.gameObject.material,a.gameObject.camera,[]),new jn(e.a,e.a,e.a,1));a.AddOrReplaceInput(c,"_Color")}SetArea(e){let n=this.masks.CombineMask,r=new ps(new _n(n.gameObject.mesh,n.gameObject.material,n.gameObject.camera,[]),e);n.AddOrReplaceInput(r,"_MainTex")}GetBoundingBox(){var n;let e=(n=this.boundingBox)==null?void 0:n.Get();return e!=null?e:Sp()}SetBoundingBox(e){var n;this.boundingBox=new Xn(e),(n=this.combineCamera)==null||n.SetBoundingBox(this.boundingBox)}UpdateFilterQueues(){if(!this.inputPass)throw new Error("input pass should be defined");let e=this.inputPass;this.pipeSegments.forEach(n=>{if(n.origin=="previous")if(n.preProcessCameras.length==0){let r=n.blendCamera,o=n.switchLayers?e:r.Top,a=n.switchLayers?r.Bottom:e,c=r.Mask;r.Connect(a,o,c)}else n.preProcessCameras[0].AddOrReplaceInput(e,"_Maintex")})}UpdateDepth(e){var u,h,d,f,p;let n=e-this.startOffset+1;if(!this.colorCamera)return;Object.keys(this.masks).forEach(m=>{let v=this.masks[m];if(!v.gameObject)throw new Error("Mask object is not properly initialized.");this.globalMasks.GetByMask(v)||(v.gameObject.camera.depth=v.gameObject.camera.depth-this.currentOffset+n)}),this.pipeSegments.forEach(m=>{m.blendCamera.gameObject.camera.depth=m.blendCamera.gameObject.camera.depth-this.currentOffset+n,m.preProcessCameras.forEach(v=>{!this.globalFilters.Has(v)&&v.gameObject&&(v.gameObject.camera.depth=v.gameObject.camera.depth-this.currentOffset+n)}),m.postProcessCameras.forEach(v=>{!this.globalFilters.Has(v)&&v.gameObject&&(v.gameObject.camera.depth=v.gameObject.camera.depth-this.currentOffset+n)})});let r=this.masks.CombineMask,o=(h=(u=this.lastPass)==null?void 0:u.depth)!=null?h:0,a=(f=(d=this.inputPass)==null?void 0:d.depth)!=null?f:0,c=(p=r==null?void 0:r.depth)!=null?p:0,l=Math.max(o,Math.max(a,c))+1;this.combineCamera?this.combineCamera.gameObject.camera.depth=l:console.warn("Expected combineCamera of pipe, got falsy."),this.currentOffset=n}UpdateRenderQueues(){this.manager.UpdateQueues()}GetDepth(){return this.depth}GetOutputPass(){if(!this.combineCamera)throw new Error("Combine Camera is not created");return this.combineCamera}GetInputPass(){return this.inputPass}Destroy(){var e;this.IsReady()&&(this.manager.Remove(this),this.colorCamera&&(this.colorCamera.Delete(),this.colorCamera.gameObject&&xn.RemoveCamera(this.colorCamera.gameObject.camera.camera))),Object.entries(this.masks).forEach(([n,r])=>{n==="DefaultMask"?this.globalMasks.RemoveFromPipe(r,this):(r.gameObject&&xn.RemoveCamera(r.gameObject.camera.camera),r.Delete())}),this.masks={},this.internalQueues.forEach(n=>{n.Destroy()}),this.internalQueues=[],this.pipeSegments.forEach(n=>{n.blendCamera.Delete()}),this.pipeSegments=[],(e=this.combineCamera)==null||e.Delete(),this.combineCamera=null,this.currentOffset=0}static CreateColorPass(e,n,r,o,a){return xe(this,null,function*(){return UT(e,r,n,o,a)})}static CreateBlendPass(e,n,r,o,a,c){return xe(this,null,function*(){return eh.Create(e,n,r,o,a,c)})}static CreateFilterPass(e,n,r,o,a,c){return xe(this,null,function*(){var d;let l=[],u=r,h=0;for(let f of n){++h;let p=(d=a.Get(f,u))!=null?d:yield Zu(`[${h}]${e}]`,f,u,o,u.depth+1,c);u=p,l.push(p)}return l})}Render(e){if(this.colorCamera){for(let n of new Qn(this.colorCamera))n.Render(e),n.PostRender();if(this.RenderMasks(e),this.RenderFilters(e),!this.combineCamera)throw new Error("This should never happened");this.combineCamera.Render(e),this.combineCamera.PostRender()}}RenderMasks(e){if(!this.meshGeneratorType)throw new Error("Must request mesh generator type.");let n=this.globalMasks.GetByType(this.meshGeneratorType);if(!n)throw new Error("Invalid mesh generator type requested.");let r=new Qn;n.rendered||(r.Visit(n.mask),n.rendered=!0);for(let o in this.masks)o!=="DefaultMask"&&r.Visit(this.masks[o]);for(let o of r)o.Render(e),o.PostRender()}RenderFilters(e){let n=new Qn,r=this.pipeSegments.flatMap(o=>[...o.preProcessCameras,o.blendCamera,...o.postProcessCameras]);n.Visit(...r);for(let o of n)o.Render(e),o.PostRender()}},tl=class t extends Mo{constructor(e,n,r,o){super(e,n,r),this.boundingBox=GT(o)}Build(e,n,r){return xe(this,null,function*(){this.BuildCommon(n,r),yield this.BuildMasks(n,r);let o=e.filters.length>0?e.filters[0].blend:"AlphaBlendUseMaskAlpha";yield this.BuildColor(n,o,r),yield this.BuildSteps(e,r)})}BuildOnTop(e,n,r){return xe(this,null,function*(){this.BuildCommon(n,r),yield this.BuildMasks(n,r),e.filters.length>0&&(yield this.BuildColorFromPipe(n)),yield this.BuildSteps(e,r)})}BuildCommon(e,n){this.inputPass=n,this.depth=Ju.GetProperty(e.type),this.tag=`:Effect[${e.effect.id}]: `,this.startOffset=n.depth+1}static CreateMaskPass(e,n,r,o,a,c,l){return xe(this,null,function*(){let u=new jn(1,1,1,o);return yield NT(e,n,u,r,a,c,l)})}BuildMasks(e,n){return xe(this,null,function*(){this.meshGeneratorType=zo(e.type),this.masks.DefaultMask=yield this.globalMasks.CreateForPipe(this,`${this.tag}Binary`,At.DEFAULT_IMAGE,1,e.type,n),this.masks.CombineMask=yield t.CreateMaskPass(`${this.tag}Combine`,e.effect,yield Bn.loadTexture(e.area),e.transparency,e.type,n,this.manager.GetQueue("CombineMask"));for(let r of e.masks){let o=new cn("SWITCH_TARGET",`${this.tag}${r.name}InternalRenderQueue`);this.internalQueues.push(o);let a=yield t.CreateMaskPass(`${this.tag}${r.name}`,e.effect,yield Bn.loadTexture(r.path),1,e.type,n,o);this.masks[r.name]=a}})}BuildSteps(e,n){return xe(this,null,function*(){let r=n,o=this.colorCamera,a=this.masks.DefaultMask;for(let c=0;c<e.filters.length;c++){let l=e.filters[c],u=l.origin==="previous"?"previous":"video",h=yield Mo.CreateFilterPass(":Queue["+c.toString()+"]"+this.tag+":Preprocces",l.preprocess,n,this.masks,this.globalFilters,this.manager.GetQueue("Preprocess")),d=h[h.length-1],f=d!=null?d:n;if(o===null)throw new Error("Colorpass shouldn't be null");let p=l.switchLayers===void 0?!1:l.switchLayers,m=p?f:o,v=p?o:f,x=yield Mo.CreateBlendPass(`:Queue[${c}]${this.tag}`,l.blend,v,m,a,this.manager.GetQueue("Blend")),b=yield Mo.CreateFilterPass(":Queue["+c.toString()+"]"+this.tag+":PostProcess",l.postprocess,x,this.masks,this.globalFilters,this.manager.GetQueue("Postprocess")),y=b[b.length-1];r=y!=null?y:x;let g=new Qu(x,h,b,p,u);o=r,this.pipeSegments.push(g)}if(this.lastPass=r,"CombineMask"in this.masks){if(this.inputPass===null)throw new Error("Input pass shouldn't be null");this.combineCamera=yield Mo.CreateBlendPass("Output"+this.tag,"AlphaBlendUseMaskAlpha",this.inputPass,this.lastPass,this.masks.CombineMask,this.manager.GetQueue("Combine"))}})}BuildColor(e,n,r){return xe(this,null,function*(){this.colorCamera=yield Mo.CreateColorPass(this.tag,e,n,r,this.manager.GetQueue("Color"))})}BuildColorFromPipe(e){return xe(this,null,function*(){e.useColor===!1&&e.useTexture===!1?this.colorCamera=yield Zu(this.tag,{name:"Copy",parameters:[]},e.initialPipe.GetOutputPass(),this.masks,0,this.manager.GetQueue("Color")):this.colorCamera=yield Mo.CreateColorPass(this.tag,e,"AlphaBlendUseMaskAlpha",e.initialPipe.GetOutputPass(),this.manager.GetQueue("Color"))})}},th=class{constructor(e,n,r){this.manager=e;this.globalFilters=n;this.globalMasks=r;te(this,"bb",Sp())}withBoundingBox(e){return this.bb=e,this}build(...e){return xe(this,null,function*(){let n=new tl(this.manager,this.globalFilters,this.globalMasks,this.bb);return yield n.Build(...e),n})}buildOnTop(...e){return xe(this,null,function*(){let n=new tl(this.manager,this.globalFilters,this.globalMasks,this.bb);return yield n.BuildOnTop(...e),n})}};var Tp=class{constructor(e){te(this,"filters",[]);te(this,"queue");this.queue=e.GetQueue("Global")}Add(e,n){return xe(this,null,function*(){let r=yield Zu("Global",e,n,{},0,this.queue);this.filters.push({name:e.name,input:n,filter:r})})}Has(e){return this.filters.some(n=>n.filter==e)}Get(e,n){let r=this.filters.find(o=>o.name===e.name&&o.input===n);return r==null?void 0:r.filter}},dy=class{constructor(e,n,r){this.mask=e;this.rendered=n;this.effect=r;te(this,"pipes",new Set)}},Ap=class{constructor(e){te(this,"masks",new Map);te(this,"queue");this.queue=e.GetQueue("Global")}Has(e){return this.masks.has(e)}GetByType(e){return this.Has(e)?this.masks.get(e):null}GetByMask(e){for(let[,n]of this.masks)if(n.mask==e)return n;return null}CreateForPipe(e,n,r,o,a,c){return xe(this,null,function*(){let l=zo(a),u;if(this.Has(l))u=this.masks.get(l);else{let h=new Je,d=yield tl.CreateMaskPass(n,h,r,o,a,c,this.queue);u=new dy(d,!1,h),n=n.substring(1),this.masks.set(l,u)}return u.pipes.add(e),u.mask})}RemoveFromPipe(e,n){for(let[r,o]of this.masks.entries())if(o.mask==e){if(o.pipes.delete(n),o.pipes.size==0){let a=e.gameObject;if(a&&Le.controllableObjects.Remove(a),e.gameObject)xn.RemoveCamera(e.gameObject.camera.camera);else throw new Error("Cleanup impossible. GlobalMask doesn't exit.");o.mask.Delete(),this.masks.delete(r)}return}}};var nh=class{constructor(){te(this,"queues");let e={Video:new cn("SWITCH_TARGET","Video"),Blend:new cn("DEDICATED_TARGET","Blend"),Color:new cn("SWITCH_TARGET","Color"),Preprocess:new cn("SWITCH_TARGET","Preprocess"),Combine:new cn("DEDICATED_TARGET","Combine"),CombineMask:new cn("SWITCH_TARGET","CombineMask"),EmptyMask:new cn("SWITCH_TARGET","EmptyMask"),Display:new cn("SWITCH_TARGET","Display"),DefaultMask:new cn("DEDICATED_TARGET","DefaultMask"),Global:new cn("DEDICATED_TARGET","Global")};this.queues=_a(li({},e),{Postprocess:e.Blend})}GetQueue(e){return this.queues[e]}UpdateQueues(){for(let e of Object.values(this.queues))e.Update()}RemoveFilterIfExists(e,n){return r=>{for(let o of new Qn(r))e.globalFilters.Has(r)||this.queues[n].Remove(o)}}Remove(e){if(!e.colorCamera)throw new Error("Pipe ColorCamera is not inited.");let n=new Qn(e.colorCamera);for(let r of n)this.queues.Color.Remove(r);Object.keys(e.masks).forEach(r=>{let o=e.masks[r],a=this.queues[r];n.clear();for(let c of n.Visit(o))a==null||a.Remove(c)}),e.pipeSegments.forEach(r=>{this.queues.Blend.Remove(r.blendCamera),r.preProcessCameras.forEach(this.RemoveFilterIfExists(e,"Preprocess")),r.postProcessCameras.forEach(this.RemoveFilterIfExists(e,"Postprocess"))}),e.combineCamera&&this.queues.Combine.Remove(e.combineCamera)}};function ya(t,e){let n=t.indexOf(e);n>-1&&t.splice(n,1)}var rh=class{constructor(e,n){this.videoCamera=e;this.screenPass=n;te(this,"pipeline",[]);te(this,"attachedPipes",[]);te(this,"detachedPipes",[]);te(this,"connectQueue",[]);te(this,"disconnectQueue",[]);te(this,"destroyQueue",[]);te(this,"globalFilters");te(this,"globalFiltersInitialized",!1);te(this,"globalMasks");te(this,"manager");this.manager=new nh,this.globalFilters=new Tp(this.manager),this.globalMasks=new Ap(this.manager),this.ConnectToDisplay(this.videoCamera)}Update(){this.ConnectPipes(),this.DisconnectPipes(),this.DestroyPipes()}LateUpdate(){}ConnectPipes(){for(;this.connectQueue.length>0;){let e=this.connectQueue.shift();e&&this.PerformConnect(e)}}DisconnectPipes(){for(;this.disconnectQueue.length>0;){let e=this.disconnectQueue.shift();e&&this.PerformDisconnect(e)}}DestroyPipes(){for(;this.destroyQueue.length>0;){let e=this.destroyQueue.shift();e&&this.PerformDestroy(e)}}Build(e,n,r){return xe(this,null,function*(){return yield this.ensureGlobalFiltersInited(),this.asDetached(yield new th(this.manager,this.globalFilters,this.globalMasks).withBoundingBox(r).build(e,n,this.videoCamera))})}BuildOnTop(e,n,r){return xe(this,null,function*(){return yield this.ensureGlobalFiltersInited(),this.asDetached(yield new th(this.manager,this.globalFilters,this.globalMasks).withBoundingBox(r).buildOnTop(e,n,this.videoCamera))})}InitializeGlobalFilters(){return xe(this,null,function*(){let e={name:"Smoothing",parameters:[]};yield this.globalFilters.Add(e,this.videoCamera);let n={name:"Greyscale",parameters:[]};yield this.globalFilters.Add(n,this.videoCamera)})}ensureGlobalFiltersInited(){return xe(this,null,function*(){this.globalFiltersInitialized||(yield this.InitializeGlobalFilters(),this.globalFiltersInitialized=!0)})}asDetached(e){return this.detachedPipes.push(e),e}Connect(e){if(this.pipeline.includes(e)){ya(this.disconnectQueue,e);return}this.connectQueue.includes(e)||this.connectQueue.push(e)}PerformConnect(e){if(this.pipeline.includes(e)||!e.IsReady())return;let n=this.pipeline.length;for(let o=0;o<this.pipeline.length;o++)if(this.pipeline[o].GetDepth()>e.GetDepth()){n=o;break}this.pipeline.splice(n,0,e);let r=this.videoCamera;for(let o of this.pipeline)o.Connect(r),r=o.GetOutputPass();for(let o of this.pipeline)this.detachedPipes.includes(o)?(ya(this.detachedPipes,o),this.attachedPipes.push(o)):this.attachedPipes.includes(o)||this.attachedPipes.push(o);this.ConnectToDisplay(r)}Disconnect(e){if(!this.pipeline.includes(e)){this.connectQueue.includes(e)&&ya(this.connectQueue,e);return}!this.destroyQueue.includes(e)&&!this.disconnectQueue.includes(e)&&this.disconnectQueue.push(e)}PerformDisconnect(e){if(!this.pipeline.includes(e))return;this.detachedPipes.push(e),ya(this.attachedPipes,e),ya(this.pipeline,e);let n=this.videoCamera;for(let r of this.pipeline)r.Connect(n),n=r.GetOutputPass();this.ConnectToDisplay(n)}Destroy(e){this.destroyQueue.includes(e)||this.destroyQueue.push(e)}PerformDestroy(e){this.PerformDisconnect(e),e.Destroy(),ya(this.detachedPipes,e),ya(this.destroyQueue,e)}ConnectToDisplay(e){this.screenPass.SetInputPass(e)}Render(e){this.globalMasks.masks.forEach(n=>n.rendered=!1),this.attachedPipes.sort((n,r)=>n.GetDepth()-r.GetDepth()),this.attachedPipes.forEach(n=>{n.IsReady()&&n.Render(e)})}getManager(){return this.manager}};var Cp=class extends xo{constructor(n){super();te(this,"game_object");te(this,"listenerManager",new hr);te(this,"_queue",new cn("DEDICATED_TARGET","raw input"));let r=xn.videoPlane;this.game_object=new _n(r,r.material,n,[])}get queue(){return this._queue}get inputRenderPasses(){return[].values()}get isIRenderPass(){return!0}get gameObject(){return this.game_object}Render(n){Yu(this,n)}PostRender(){let n=new ur(this.parameter,null,!1,!1);this.listenerManager.NotifyListeners(this,n)}SetInputImage(n){var o;let r=this.gameObject.material;(o=r.map)==null||o.dispose(),r.map=new xi(n.data,n.width,n.height),r.needsUpdate=!0}set target(n){this.gameObject.camera.target=n}get target(){var n;return(n=this.gameObject.camera.target)!=null?n:null}AttachListener(n,r){this.listenerManager.AddListener(n,r)}DetachListener(n){this.listenerManager.RemoveListener(n)}GetListeners(){throw[].values()}get parameter(){return new Qi(this.target)}get depth(){return 0}Delete(){this.gameObject.material.dispose()}Accept(n){n.Visit(this)}};var ih=class{constructor(){te(this,"filter");let e=Oi.GetOrthographic(),n=new an(Jt.Width(),Jt.Height());n.texture.name="Video target";let r=new bo(e,n);this.filter=new Cp(r)}Update(e){this.filter.SetInputImage(e)}LateUpdate(){}Render(e){this.filter.Render(e),this.filter.PostRender()}};function hB(t){let e=new xf(2,2,1,1);t.geometry=e,t.position.set(0,0,1),t.lookAt(0,0,-1),t.updateWorldMatrix(!0,!1)}var oh=class{constructor(){te(this,"camera",Oi.GetOrthographic());te(this,"material",new Xr);te(this,"mesh");te(this,"inputPass",{target:null});this.mesh=pc(),this.mesh.material=this.material,hB(this.mesh)}Update(){var e,n,r;this.material.map=(r=(n=(e=this.inputPass)==null?void 0:e.target)==null?void 0:n.texture)!=null?r:null,this.material.color=new We(1,1,1),this.material.needsUpdate=!0}LateUpdate(){}SetInputPass(e){this.inputPass=e}Render(e){e.setRenderTarget(null),this.mesh.material=this.material,e.setClearColor(new We(.1,.1,.1)),e.clear(),e.render(this.mesh,this.camera)}};var Rp=class t{constructor(e,n){this.bscMeshGenerator=e;this.bsc=n;te(this,"isFirstTrack");te(this,"faceData",null);this.isFirstTrack=!0,this.faceData=null}static Create(e){if(Le.tracker)return;let n=e.modules.visage.module,r=n.GetMeshGenerator();r.StartAnalysis(),Le.tracker=new t(r,n)}get statuses(){return{OFF:this.bsc.TrackStatus.off,OK:this.bsc.TrackStatus.ok,RECOVERING:this.bsc.TrackStatus.recovering,INIT:this.bsc.TrackStatus.init}}Get(){var e;return this.isFirstTrack&&(this.Update(),((e=this.faceData)==null?void 0:e.status)===this.statuses.OK&&(Jn.Update("FirstTrack",1),this.isFirstTrack=!1)),this.faceData}Update(){var e;(e=this.faceData)==null||e.delete(),this.faceData=this.bscMeshGenerator.Get()}LateUpdate(){}Reset(){this.bscMeshGenerator.Reset()}};var sh=class{constructor(){te(this,"objects",[]);te(this,"startingPositions",[]);te(this,"tracker");if(!Le.tracker)throw new Error("Tracker not created");this.tracker=Le.tracker}LateUpdate(){let e=this.tracker.Get(),n=e.status;this.objects.forEach(r=>{if(n==this.tracker.statuses.OK&&r.mesh){r.mesh.visible=!0;let o=e.GetFaceRotation(),a=e.GetFaceTranslation();r.mesh.position.set(-a.x,a.y,a.z),r.mesh.rotation.set(o.x,-(o.y+3.14),-o.z),r.mesh.rotation.order="YXZ",r.mesh.scale.set(-1,1,1),r.mesh.updateWorldMatrix(!0,!0)}else r.mesh&&(r.mesh.visible=!1)})}Update(){}Add(e){this.objects.some(n=>n.id===e.id)||(this.objects.push(e),this.startingPositions.push(new W(0,0,1)))}Remove(e){let n=this.objects.findIndex(r=>r.id==e.id);n!==-1&&(this.objects.splice(n,1),this.startingPositions.splice(n,1))}};function fB(t,e,n){let r=new lc({antialias:!0,alpha:!0,preserveDrawingBuffer:n});return r.setSize(t,e),r.autoClear=!1,r}function dB(t,e,n){let r=new ih,o=new oh,a=new Ql(t),c=new rh(r.filter,o),l=new qu(c,a);return[new Xu(e,n,c,a,r,l,o),l]}var nl=class nl{constructor(e,n){this.effectController=e;this.loop=n}static Initialize(e,n,r){if(nl.instance)throw new Error("Already initialized.");Rp.Create(e.modulesManager),Le.controllableObjects=new sh;let o=fB(n.width,n.height,r);Jt.SetRenderer(o);let[a,c]=dB(e.modulesManager,e.frameProvider,o);nl.instance=new nl(c,a)}CreateMakeup(o,a){return xe(this,arguments,function*(e,n,r=[0,0,1,1]){return yield this.effectController.Create(e,n,r)})}UpdateMakeup(e){return this.effectController.Refresh(e)}IsMakeupDisplayed(e){return this.effectController.IsMakeupDisplayed(e)}DisplayMakeup(e){this.effectController.Display(e)}HideMakeup(e){this.effectController.Hide(e)}RemoveMakeup(e){this.effectController.Remove(e)}IntersectMakeup(e,n,r){let o={x:n,y:r};return pB(e,this.effectController,o)}onIterationComplete(e){this.loop.onIterationComplete(e)}};te(nl,"instance");var _r=nl;function pB(t,e,n){let{width:r,height:o}=Jt.size,a=2*n.x/r-1,c=1-2*n.y/o;return e.Intersect(t,a,c)}function rl(t,e){if(!t)throw new Error(e)}var Lp=class{constructor(e,n,r){rl(_r.instance,"Engine is not initialized."),this.globalEngine=_r.instance,this.features=e,this.finishes=n,this.makeupEngineAnalytics=r,this.finishNamesRecord=new Map,this.activeEffects=new Map}CreateMakeup(o,a){return xe(this,arguments,function*(e,n,r=[0,0,1,1]){let c=yield this.globalEngine.CreateMakeup(e,n,r);return this.finishNamesRecord.set(c.id,n==null?void 0:n.name),this.activeEffects.set(c.id,c),c})}DisplayMakeup(e){this.makeupEngineAnalytics&&!this.IsMakeupDisplayed(e)&&this.makeupEngineAnalytics.sendEffect("EFFECT_SIMULATED",Pp(e,this.finishNamesRecord)),this.globalEngine.DisplayMakeup(e)}UpdateMakeup(e,n={analyticsDebounceTime:300}){return this.makeupEngineAnalytics&&this.IsMakeupDisplayed(e)&&Df(e.id,()=>{var r;return(r=this.makeupEngineAnalytics)==null?void 0:r.sendEffect("EFFECT_SIMULATED",Pp(e,this.finishNamesRecord))},n.analyticsDebounceTime),this.globalEngine.UpdateMakeup(e)}IsMakeupDisplayed(e){return this.globalEngine.IsMakeupDisplayed(e)}HideMakeup(e){this.makeupEngineAnalytics&&this.IsMakeupDisplayed(e)&&this.makeupEngineAnalytics.sendEffect("EFFECT_DISABLED",Pp(e,this.finishNamesRecord)),this.globalEngine.HideMakeup(e)}RemoveMakeup(e){this.makeupEngineAnalytics&&this.IsMakeupDisplayed(e)&&this.makeupEngineAnalytics.sendEffect("EFFECT_DISABLED",Pp(e,this.finishNamesRecord)),this.globalEngine.RemoveMakeup(e),this.finishNamesRecord.delete(e.id),this.activeEffects.delete(e.id)}ClearMakeup(){for(let e of this.activeEffects.values())this.RemoveMakeup(e);this.finishNamesRecord.clear(),this.activeEffects.clear()}IntersectMakeup(e,n,r){return this.globalEngine.IntersectMakeup(e,n,r)}GetView(){return Jt.renderer.domElement}GetFeatures(){return this.features}GetFinishes(){return this.finishes}Reset(){var e;(e=Le.tracker)==null||e.Reset()}onFrameRendered(e){this.globalEngine.onIterationComplete(e)}};var py=t=>{if(typeof t!="number")throw Error(`Expected a number, got ${t}`);let e=Math.round(t*255);if(e<0||e>255)throw Error(`Expected RGB value in range [0, 255], got ${e}`);return("0"+e.toString(16)).slice(-2)},mB=t=>`0x${py(t.r)}${py(t.g)}${py(t.b)}`,kT=t=>{if(typeof t!="number")throw new Error(`opacity ${t} is invalid`);let e=Math.round(t*100);if(e<0||e>100)throw new Error(`Expected opacity in range [0, 100], got ${e}`);return e};function gB(t,e){var o,a;let n=e.elements.map(c=>c.name).lastIndexOf(t);if(n<0)throw Error("Finish element not found");let r=(a=(o=e.elements[n])==null?void 0:o.color)==null?void 0:a.a;return kT(r)}var Pp=(t,e)=>{var u,h;let n=t.name;if(!n)throw new Error("applicationArea is not defined in effect.name");let r=(h=(u=t==null?void 0:t.elements)==null?void 0:u.find(d=>{var f;return((f=d==null?void 0:d.name)==null?void 0:f.toLowerCase())==="color"}))==null?void 0:h.color;if(!r)throw new Error("renderingHex is not defined in effect");let o=mB(r),a=kT(r.a),c=e.get(t.id),l=c?gB(c,t):void 0;return{application_area_name:n,rendering_hex:o,finish_name:c!=null?c:"Satin",color_opacity:a,finish_opacity:l!=null?l:100,bounding_box:t.boundingBox,effect:t.id}};var jT=$y(HT(),1),qT=$y(WT(),1);var Fp=class{constructor(){te(this,"promise",null);te(this,"module");te(this,"inited",!1);te(this,"licenses")}lazy(e){return this.promise?this.promise:(this.promise=e(),this.promise.then(n=>(this.module=n,this.inited=!0,this.module)),this.promise)}},gy=class{constructor(e){te(this,"modules");te(this,"licenses");te(this,"locateFile");te(this,"statusCallback");this.modules={visage:new Fp,meshGenerator:new Fp},this.licenses=e,this.locateFile=n=>Le.pathToAssets+"Assets/Plugins/"+n,this.statusCallback=({progress:n,text:r})=>{console.info(r,(n*100).toFixed(2)+"%"),Jn.Update("Tracker",n),n===1&&Jn.StartFakeProgress("FirstTrack")}}LoadCoreModules(){return this.modules.visage.lazy(()=>(0,jT.default)(this.licenses,{locateFile:this.locateFile,statusCallback:this.statusCallback}))}LoadMeshGenerator(){return this.modules.meshGenerator.lazy(()=>(0,qT.default)({locateFile:this.locateFile}))}};function XT(t){return xe(this,null,function*(){let e=new gy(t);return yield e.LoadCoreModules(),e})}function Ni(t,e,n,r,o,a){return xe(this,null,function*(){var f,p,m;let c=yield fetch(n);if(!(c!=null&&c.body)||!c.headers)return!1;let l=a||+((p=(f=c.headers)==null?void 0:f.get("Content-Length"))!=null?p:0);if(!((m=c==null?void 0:c.body)!=null&&m.getReader)||!l){let v=yield c.arrayBuffer(),x=v instanceof ArrayBuffer?new Uint8Array(v):v;o({contentLength:x.byteLength});let b=t.open(e,"w");return t.write(b,x,0,x.byteLength),t.close(b),r({receivedLength:x.byteLength,contentLength:x.byteLength,progress:1,done:!0}),!0}let u=c.body.getReader();o({contentLength:l});let h=t.open(e,"w"),d=0;try{for(;;){let{done:v,value:x}=yield u.read();if(v)break;t.write(h,x,0,x.length),d+=x.length,r({receivedLength:d,contentLength:l,progress:d/l,done:!1})}}finally{t.close(h),r({receivedLength:d,contentLength:l,progress:d/l,done:!0})}return!0})}var Ip=null,Dp=class t{static Create(e,n,r){return xe(this,null,function*(){var l;let o=e.modules.visage.module,a=n==Bp.MORE_ACCURACY?o.SkinToneTargetQuality.MORE_ACCURACY:o.SkinToneTargetQuality.MORE_SPEED,c=o.GetSkinToneAnalysis(a);if(!Ip){let u=[];(a==null?void 0:a.value)==((l=o.SkinToneTargetQuality.MORE_ACCURACY)==null?void 0:l.value)?u=[{name:"d_st_c.bin",path:Le.pathToAssets+"Assets/Plugins/d_st_c.bin",byteLen:1236},{name:"d_st_m.js.json",path:Le.pathToAssets+"Assets/Plugins/d_st_m.js.json",byteLen:320112},{name:"d_st_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/d_st_m.js.bin",byteLen:9867712}]:u=[{name:"st_c.bin",path:Le.pathToAssets+"Assets/Plugins/st_c.bin",byteLen:1236},{name:"st_m.js.json",path:Le.pathToAssets+"Assets/Plugins/st_m.js.json",byteLen:39024},{name:"st_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/st_m.js.bin",byteLen:22344672}];let h=u.reduce((v,x)=>(v[x.name]={contentLength:x.byteLen,receivedLength:0,progress:0,done:!1},v),{}),d=u.map(v=>v.byteLen).reduce((v,x)=>v+x,0),f=v=>{},p=v=>x=>{if(!r)return;h[v]=x;let b=Object.keys(h),y=b.every(M=>h[M].done),g=0;y?g=d:g=b.map(M=>h[M].receivedLength).reduce((M,C)=>M+C,0),r({contentLength:d,receivedLength:g,progress:g/d,done:y})},m=u.map(v=>Ni(o.FS,v.name,v.path,p(v.name),f,v.byteLen));Ip=Promise.all(m).catch(()=>Ip=null)}return yield Ip,new t(c,o)})}constructor(e,n){this.bscAnalyzer=e,this.bsc=n}StartAnalysis(e){let n=o=>{let a=new Map([[this.bsc.MonkScale.Monk_1,"MONK_1"],[this.bsc.MonkScale.Monk_2,"MONK_2"],[this.bsc.MonkScale.Monk_3,"MONK_3"],[this.bsc.MonkScale.Monk_4,"MONK_4"],[this.bsc.MonkScale.Monk_5,"MONK_5"],[this.bsc.MonkScale.Monk_6,"MONK_6"],[this.bsc.MonkScale.Monk_7,"MONK_7"],[this.bsc.MonkScale.Monk_8,"MONK_8"],[this.bsc.MonkScale.Monk_9,"MONK_9"],[this.bsc.MonkScale.Monk_10,"MONK_10"],[this.bsc.MonkScale.UNDEFINED,"UNDEFINED"]]),c=new Map([[this.bsc.TrackStatus.off,"OFF"],[this.bsc.TrackStatus.init,"INIT"],[this.bsc.TrackStatus.recovering,"RECOVERING"],[this.bsc.TrackStatus.ok,"OK"]]),l={frameIndex:o.frameIndex,monk:a.get(o.monk),decimalMonk:o.decimalMonk,RGB:o.RGB,renderRGB:o.renderRGB,HSL:o.HSL,status:c.get(o.status)};return o.delete(),l},r=o=>{e(n(o))};this.bscAnalyzer.SetCallback(r),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var Op=class{constructor(){te(this,"features");te(this,"finishes")}LoadTemplateDefinitions(e,n,r){return xe(this,null,function*(){let o=yield fetch(n+r);if(o.ok){let a=yield o.json();return Jn.Update(e,1),a.repository}else throw new Error(`Could not retrieve "${r}"`)})}GetFeatureTemplates(e){var r;let n;return(r=window.makeupsdkLogger)==null||r.Log({message:"GetFeatureTemplates:Assets/StreamingAssets/Features/features.json",id:n=window.makeupsdkLogger.Count(),isStarting:!0}),this.features?Promise.resolve(this.features):this.LoadTemplateDefinitions("LoadFeatureTemplates",e,"Assets/StreamingAssets/Features/features.json").then(o=>{var a;return(a=window.makeupsdkLogger)==null||a.Log({message:"GetFeatureTemplates:Assets/StreamingAssets/Features/features.json",id:n,isStarting:!1}),this.features=o})}GetFinishTemplates(e){var r;let n;return(r=window.makeupsdkLogger)==null||r.Log({message:"GetFinishTemplates:Assets/StreamingAssets/Finishes/finishes.json",id:n=window.makeupsdkLogger.Count(),isStarting:!0}),this.finishes?Promise.resolve(this.finishes):this.LoadTemplateDefinitions("LoadFinishTemplates",e,"Assets/StreamingAssets/Finishes/finishes.json").then(o=>{var a;return(a=window.makeupsdkLogger)==null||a.Log({message:"GetFinishTemplates:Assets/StreamingAssets/Finishes/finishes.json",id:n,isStarting:!1}),this.finishes=o})}};var Up=class t{static Create(e){return xe(this,null,function*(){let n=e.modules.visage.module,r=n.GetFaceTracker();return new t(r,n)})}constructor(e,n){this.bscAnalyzer=e,this.bsc=n}StartAnalysis(e){this.bscAnalyzer.SetCallback(e),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var Np=null,Gp=class t{constructor(e,n){te(this,"promise",null);this.bscAnalyzer=e,this.bsc=n}static Create(e,n){return xe(this,null,function*(){let r=e.modules.visage.module,o=r.GetFaceShapeAnalysis();if(!Np){let a=[{name:"fs_c.bin",path:Le.pathToAssets+"Assets/Plugins/fs_c.bin",byteLen:1236},{name:"fs_m.js.json",path:Le.pathToAssets+"Assets/Plugins/fs_m.js.json",byteLen:80496},{name:"fs_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/fs_m.js.bin",byteLen:3751840}],c=a.reduce((f,p)=>(f[p.name]={contentLength:p.byteLen,receivedLength:0,progress:0,done:!1},f),{}),l=a.map(f=>f.byteLen).reduce((f,p)=>f+p,0),u=()=>{},h=f=>p=>{if(!n)return;c[f]=p;let m=Object.keys(c),v=m.every(b=>c[b].done),x=0;v?x=l:x=m.map(b=>c[b].receivedLength).reduce((b,y)=>b+y,0),n({contentLength:l,receivedLength:x,progress:x/l,done:v})},d=a.map(f=>Ni(r.FS,f.name,f.path,h(f.name),u,f.byteLen));Np=Promise.all(d).catch(()=>Np=null)}return yield Np,new t(o,r)})}StartAnalysis(e){let n=o=>{let a=new Map([[this.bsc.TrackStatus.off,"OFF"],[this.bsc.TrackStatus.init,"INIT"],[this.bsc.TrackStatus.recovering,"RECOVERING"],[this.bsc.TrackStatus.ok,"OK"]]),c={frameIndex:o.frameIndex,estimates:o.estimates,status:a.get(o.status)};return o.delete(),c},r=o=>{e(n(o))};this.bscAnalyzer.SetCallback(r),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var kp=class t{constructor(e,n){te(this,"promise",null);this.bscAnalyzer=e,this.bsc=n}static Create(e,n){return xe(this,null,function*(){let r=e.modules.visage.module,o=r.GetEyeToneAnalysis();return new t(o,r)})}StartAnalysis(e){let n=o=>{let a=new Map([[this.bsc.TrackStatus.off,"OFF"],[this.bsc.TrackStatus.init,"INIT"],[this.bsc.TrackStatus.recovering,"RECOVERING"],[this.bsc.TrackStatus.ok,"OK"]]),c={frameIndex:o.frameIndex,estimates:o.estimates,status:a.get(o.status)};return o.delete(),c},r=o=>{e(n(o))};this.bscAnalyzer.SetCallback(r),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var Hp=null,zp=class t{constructor(e,n){te(this,"promise",null);this.bscAnalyzer=e,this.bsc=n}static Create(e,n){return xe(this,null,function*(){let r=e.modules.visage.module,o=r.GetEyeShapeAnalysis();if(!Hp){let a=[{name:"es_c.bin",path:Le.pathToAssets+"Assets/Plugins/es_c.bin",byteLen:1236},{name:"es_m.js.json",path:Le.pathToAssets+"Assets/Plugins/es_m.js.json",byteLen:80496},{name:"es_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/es_m.js.bin",byteLen:3751840}],c=a.reduce((f,p)=>(f[p.name]={contentLength:p.byteLen,receivedLength:0,progress:0,done:!1},f),{}),l=a.map(f=>f.byteLen).reduce((f,p)=>f+p,0),u=()=>{},h=f=>p=>{if(!n)return;c[f]=p;let m=Object.keys(c),v=m.every(b=>c[b].done),x=0;v?x=l:x=m.map(b=>c[b].receivedLength).reduce((b,y)=>b+y,0),n({contentLength:l,receivedLength:x,progress:x/l,done:v})},d=a.map(f=>Ni(r.FS,f.name,f.path,h(f.name),u,f.byteLen));Hp=Promise.all(d).catch(()=>Hp=null)}return yield Hp,new t(o,r)})}StartAnalysis(e){let n=o=>{let a=new Map([[this.bsc.TrackStatus.off,"OFF"],[this.bsc.TrackStatus.init,"INIT"],[this.bsc.TrackStatus.recovering,"RECOVERING"],[this.bsc.TrackStatus.ok,"OK"]]),c={frameIndex:o.frameIndex,estimates:o.estimates,status:a.get(o.status)};return o.delete(),c},r=o=>{e(n(o))};this.bscAnalyzer.SetCallback(r),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var Vp=class t{static Create(e,n,r,o){return xe(this,null,function*(){let a=e.modules.visage.module;yield a.MountFile("Light Conditions.cfg",Le.pathToAssets+"Assets/Plugins/Light Conditions.cfg");let c=n,l=r;o&&o({contentLength:0,receivedLength:0,progress:1,done:!0});let u=a.GetLightConditionsAnalysis("Light Conditions.cfg",c,l);return new t(u,a,c,l)})}constructor(e,n,r,o){this.bscAnalyzer=e,this.bsc=n,this.uniformityThreshold=r,this.backlightThreshold=o}StartAnalysis(e){this.bscAnalyzer.SetCallback(e),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var Wp=null,jp=class t{static Create(e,n){return xe(this,null,function*(){let r=e.modules.visage.module,o=r.GetHairToneAnalysis();if(!Wp){let a=[{name:"hs_c.bin",path:Le.pathToAssets+"Assets/Plugins/hs_c.bin",byteLen:1236},{name:"hs_m.js.json",path:Le.pathToAssets+"Assets/Plugins/hs_m.js.json",byteLen:53392},{name:"hs_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/hs_m.js.bin",byteLen:4297568}],c=a.reduce((f,p)=>(f[p.name]={contentLength:p.byteLen,receivedLength:0,progress:0,done:!1},f),{}),l=a.map(f=>f.byteLen).reduce((f,p)=>f+p,0),u=()=>{},h=f=>p=>{if(!n)return;c[f]=p;let m=Object.keys(c),v=m.every(b=>c[b].done),x=0;v?x=l:x=m.map(b=>c[b].receivedLength).reduce((b,y)=>b+y,0),n({contentLength:l,receivedLength:x,progress:x/l,done:v})},d=a.map(f=>Ni(r.FS,f.name,f.path,h(f.name),u,f.byteLen));Wp=Promise.all(d).catch(()=>Wp=null)}return yield Wp,new t(o,r)})}constructor(e,n){this.bscAnalyzer=e,this.bsc=n}StartAnalysis(e){this.bscAnalyzer.SetCallback(e),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var il=class extends Error{constructor(e,n="Fetch failed"){super(n),this.name="FetchError",this.cause=e}},ol=class extends Error{constructor(e,n){super(`${e} with id ${n} was not found.`),this.name="NotFoundError",this.entity=e,this.id=n}};function ah(t){return xe(this,null,function*(){return(yield(yield fetch(t,{method:"GET",headers:{Accept:"application/json"}})).json()).data})}function vB(t){return xe(this,null,function*(){return ah(`${t.url}/finishes?access_token=${t.accessToken}&language_code=${t.languageCode}`)})}function yB(t,e){return xe(this,null,function*(){return ah(`${t.url}/product_usage_patterns/${e}?access_token=${t.accessToken}&language_code=${t.languageCode}`)})}function xB(t,e){return xe(this,null,function*(){return ah(`${t.url}/products/${e}/shade_colors?access_token=${t.accessToken}&language_code=${t.languageCode}`)})}function _B(t,e){return xe(this,null,function*(){return ah(`${t.url}/product_usage_patterns/${e}/usage_pattern_areas?access_token=${t.accessToken}&language_code=${t.languageCode}`)})}function YT(t,e){return xe(this,null,function*(){let n=yield ah(`${t.url}/shade_colors/${e}?access_token=${t.accessToken}`);if(n instanceof Error)throw n;let r=n.at(0);if(!r)throw new ol("ShadeColors",e);return r.product})}function $T(t,e){return xe(this,null,function*(){let n=vB(t).catch(f=>new il(f,"Couldn't fetch finishes.")),r=yB(t,e).catch(f=>new il(f,`Couldn't fetch product usage pattern ${e}.`)),o=_B(t,e).catch(f=>new il(f,`Couldn't fetch usage pattern arreas for product usage pattern ${e}.`)),[a,c,l]=yield Promise.all([n,r,o]);if(a instanceof Error)throw a;if(c instanceof Error)throw c;if(l instanceof Error)throw l;let u=c.at(0);if(!u)throw new ol("ProductUsagePattern",e);let h=xB(t,u.product).catch(f=>new il(f,`Couldn't fetch shadecolors for product ${u.product}.`)),[d]=yield Promise.all([h]);if(d instanceof Error)throw d;return{id:u.id,product:u.product,usagePatternAreas:l.map(f=>{let p=d.find(v=>v.id===f.shadeColor);if(!p)throw new ol("ShadeColor",f.shadeColor);let m=a.find(v=>v.id===p.finish);if(!m)throw new ol("Finish",p.finish);return{applicationArea:f.applicationArea,shadeColor:{id:p.id,colorOpacity:p.colorOpacity,finishOpacity:p.finishOpacity,rendering:p.rendering,finish:{name:m.name}}}})}})}var Yp,JT,ch,vy,lh,yy,uh,xy,hh,_y,Xp=class{constructor(e,n,r){ba(this,Yp);ba(this,ch);ba(this,lh);ba(this,uh);ba(this,hh);rl(_r.instance,"Engine is not initialized."),this.globalEngine=_r.instance,this.features=e,this.finishes=n,this.makeupEngineAnalytics=r,this.effectsRecord=new Map}GetView(){return Jt.renderer.domElement}onFrameRendered(e){return this.globalEngine.onIterationComplete(e)}FetchProductUsagePattern(e){return xe(this,null,function*(){var c,l;let{id:n,languageCode:r}=e,o=(c=this.makeupEngineAnalytics)==null?void 0:c.cmsURL,a=(l=this.makeupEngineAnalytics)==null?void 0:l.accessToken;if(!o||!a)throw new Error("Please define cmsURL or accessToken to use FetchProductUsagePattern method.");return $T({url:o,accessToken:a,languageCode:r},n)})}IsMakeupDisplayed(e){let n=e.id;if(!this.effectsRecord.has(n))return!1;let r=this.effectsRecord.get(n);return r?r.effects.every(o=>this.globalEngine.IsMakeupDisplayed(o)):!1}CreateMakeup(r){return xe(this,arguments,function*(e,n=[0,0,1,1]){if(this.effectsRecord.has(e.id))throw new Error("Product usage pattern with id already exists");let o=[],a=e.usagePatternAreas.map(c=>ui(this,Yp,JT).call(this,c));for(let{feature:c,finish:l}of a){let u=yield this.globalEngine.CreateMakeup(c,l,n);o.push(u)}this.effectsRecord.set(e.id,{pup:e,effects:o})})}RemoveMakeup(e){let n=e.id;if(!this.effectsRecord.has(n))return;let r=this.effectsRecord.get(n);if(!r)return;let o=qp(r.pup.usagePatternAreas,r.effects);this.IsMakeupDisplayed(r.pup)&&ui(this,uh,xy).call(this,r.pup,o),r.effects.forEach(a=>{this.globalEngine.RemoveMakeup(a)}),this.effectsRecord.delete(n)}DisplayMakeup(e){let n=e.id,r=this.effectsRecord.get(n);if(!r)return;let o=qp(r.pup.usagePatternAreas,r.effects);this.IsMakeupDisplayed(r.pup)||ui(this,lh,yy).call(this,r.pup,o),r.effects.forEach(a=>{this.globalEngine.DisplayMakeup(a)})}HideMakeup(e){let n=e.id,r=this.effectsRecord.get(n);if(!r)return;let o=qp(r.pup.usagePatternAreas,r.effects);this.IsMakeupDisplayed(r.pup)&&ui(this,uh,xy).call(this,r.pup,o),r.effects.forEach(a=>{this.globalEngine.DisplayMakeup(a)})}UpdateMakeup(r){return xe(this,arguments,function*(e,n={}){var d;if(!this.effectsRecord.has(e.id))return;let o=n==null?void 0:n.boundingBox,a=(d=n==null?void 0:n.analyticsDebounceTime)!=null?d:300,c=this.effectsRecord.get(e.id);if(!c)return;let l=c.effects;if(!(l!=null&&l.length))return;let u=qp(e.usagePatternAreas,l);for(let{upa:f,effect:p}of u){let m=p.elements.find(x=>x.name==="Color");m&&(m.color=ZT(f.shadeColor.rendering,f.shadeColor.colorOpacity/100));let v=p.elements[p.elements.length-1];v&&(v.color.a=f.shadeColor.finishOpacity/100),o&&(p.boundingBox=o)}let h=l.map(f=>this.globalEngine.UpdateMakeup(f));this.IsMakeupDisplayed(c.pup)&&Df(e.id,()=>ui(this,lh,yy).call(this,c.pup,u),a),yield Promise.all(h)})}};Yp=new WeakSet,JT=function(e){let n=this.features.find(a=>a.name===e.applicationArea);rl(n,"Feature template not found for AplicationArea "+e.applicationArea);let r=n.elements.findIndex(a=>a.name==="Color");if(r>=0){let a=JSON.parse(JSON.stringify(n)),c=a.elements[r];c.color=ZT(e.shadeColor.rendering,e.shadeColor.colorOpacity/100),n=a}let o=this.finishes.find(a=>a.name===e.shadeColor.finish.name);return rl(o,"Finish template not found for "+e.shadeColor.finish.name),o=_a(li({},o),{transparency:e.shadeColor.finishOpacity/100}),{feature:n,finish:o}},ch=new WeakSet,vy=function(e,n){return{application_area_name:e.applicationArea,bounding_box:n.boundingBox,color_opacity:Math.round(e.shadeColor.colorOpacity),effect:n.id,finish_name:e.shadeColor.finish.name,finish_opacity:Math.round(e.shadeColor.finishOpacity),rendering_hex:e.shadeColor.rendering,session_product_interaction:void 0,shade_color:e.shadeColor.id}},lh=new WeakSet,yy=function(e,n){return xe(this,null,function*(){if(e.product||(yield ui(this,hh,_y).call(this,e)),this.makeupEngineAnalytics){let r=e.product?{type:"PRODUCT_SIMULATED",productId:e.product}:null;this.makeupEngineAnalytics.sendProductAndEffects(r,n.map(({upa:o,effect:a})=>({type:"EFFECT_SIMULATED",payload:ui(this,ch,vy).call(this,o,a)})))}})},uh=new WeakSet,xy=function(e,n){return xe(this,null,function*(){if(e.product||(yield ui(this,hh,_y).call(this,e)),this.makeupEngineAnalytics){let r=e.product?{type:"PRODUCT_DISABLED",productId:e.product}:null;this.makeupEngineAnalytics.sendProductAndEffects(r,n.map(({upa:o,effect:a})=>({type:"EFFECT_DISABLED",payload:ui(this,ch,vy).call(this,o,a)})))}})},hh=new WeakSet,_y=function(e){return xe(this,null,function*(){var r,o,a;let n=(r=e.usagePatternAreas.at(0))==null?void 0:r.shadeColor.id;if(n)try{let c=(o=this.makeupEngineAnalytics)==null?void 0:o.cmsURL,l=(a=this.makeupEngineAnalytics)==null?void 0:a.accessToken;if(!c||!l)throw new Error("Please define cmsURL or accessToken to use FetchProductUsagePattern method.");let u=yield YT({url:c,accessToken:l},n);u&&(e.product=u)}catch(c){return Promise.resolve()}})};function bB(t){t=t.replace(/^0x/,""),t.length===3&&(t=t.split("").map(function(o){return o+o}).join(""));let e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return[e,n,r]}function ZT(t,e=1){let[n,r,o]=bB(t).map(a=>a/255);return new jn(n,r,o,e)}function qp(t,e){let n=Math.min(t.length,e.length);return t.slice(0,n).map((r,o)=>({upa:r,effect:e[o]}))}var $p=null,Zp=class t{constructor(e,n){te(this,"promise",null);this.bscAnalyzer=e,this.bsc=n}static Create(e,n){return xe(this,null,function*(){let r=e.modules.visage.module,o=r.GetLipShapeAnalysis();if(!$p){let a=[{name:"ls_c.bin",path:Le.pathToAssets+"Assets/Plugins/ls_c.bin",byteLen:1236},{name:"ls_m.js.json",path:Le.pathToAssets+"Assets/Plugins/ls_m.js.json",byteLen:80496},{name:"ls_m.js.bin",path:Le.pathToAssets+"Assets/Plugins/ls_m.js.bin",byteLen:3751840}],c=a.reduce((f,p)=>(f[p.name]={contentLength:p.byteLen,receivedLength:0,progress:0,done:!1},f),{}),l=a.map(f=>f.byteLen).reduce((f,p)=>f+p,0),u=()=>{},h=f=>p=>{if(!n)return;c[f]=p;let m=Object.keys(c),v=m.every(b=>c[b].done),x=0;v?x=l:x=m.map(b=>c[b].receivedLength).reduce((b,y)=>b+y,0),n({contentLength:l,receivedLength:x,progress:x/l,done:v})},d=a.map(f=>Ni(r.FS,f.name,f.path,h(f.name),u,f.byteLen));$p=Promise.all(d).catch(()=>$p=null)}return yield $p,new t(o,r)})}StartAnalysis(e){let n=o=>{let a=new Map([[this.bsc.TrackStatus.off,"OFF"],[this.bsc.TrackStatus.init,"INIT"],[this.bsc.TrackStatus.recovering,"RECOVERING"],[this.bsc.TrackStatus.ok,"OK"]]),c={frameIndex:o.frameIndex,estimates:o.estimates,status:a.get(o.status)};return o.delete(),c},r=o=>{e(n(o))};this.bscAnalyzer.SetCallback(r),this.bscAnalyzer.StartAnalysis()}StopAnalysis(){this.bscAnalyzer.StopAnalysis()}Reset(){this.bscAnalyzer.Reset()}};var wB=t=>{Jn.SetOnProgressCallback(t)},Bp=Object.freeze({MORE_SPEED:0,MORE_ACCURACY:1}),by=Object.freeze({HIGH:0,LOW:1}),Jp,MB="https://cms.arbelle.ai:3000/api/v2.0",EB=(a,c,...l)=>xe(void 0,[a,c,...l],function*(t,e,n=by.HIGH,r="",o=MB){var v,x;if(Jp)return Jp;let u=null;r&&o&&(u=yield bh.create(o,r)),Le.pathToAssets=t;let h=yield XT(e),d=n==by.HIGH?"high":"low",f=`${Le.pathToAssets}Assets/Plugins/Facial Features Tracker - ${d}.cfg`,p=yield h.modules.visage.module.AnalyticsCollectionConfig.Create(o,r,(x=(v=yield u)==null?void 0:v.sessionUuid)!=null?x:"",1e3);yield h.modules.visage.module.CreateBSCProvider(f,p);let m=new wh(h);return Jp=new wy(h,m,u),Jp}),wy=class{constructor(e,n,r){this.makeupEngine=void 0,this.cmsMakeupEngine=void 0,this.modulesManager=e,this.frameProvider=n,this.sdkAnalytics=r,this.sdkAnalytics&&window.addEventListener("pagehide",()=>{var o;(o=this.sdkAnalytics)==null||o.onUnload()}),this.featuresAndFinishesService=new Op}GetFrameProvider(){return this.frameProvider}GetSessionUUID(){var e,n;return(n=(e=this.sdkAnalytics)==null?void 0:e.sessionUuid)!=null?n:""}CreateMakeUpEngine(e,n,r=!1){return xe(this,null,function*(){return this.CreateMakeupEngine(e,n,r)})}CreateMakeupEngine(e,n,r=!1){return xe(this,null,function*(){if(_r.instance||_r.Initialize({frameProvider:this.frameProvider,modulesManager:this.modulesManager},{width:e,height:n},r),this.makeupEngine!==void 0)return this.makeupEngine;let o=Le.pathToAssets,[a,c]=yield Promise.all([this.featuresAndFinishesService.GetFeatureTemplates(o),this.featuresAndFinishesService.GetFinishTemplates(o)]);return this.makeupEngine=new Lp(a,c,this.sdkAnalytics),this.makeupEngine})}CreateCmsMakeupEngine(e,n,r=!1){return xe(this,null,function*(){if(_r.instance||_r.Initialize({frameProvider:this.frameProvider,modulesManager:this.modulesManager},{width:e,height:n},r),this.cmsMakeupEngine!==void 0)return this.cmsMakeupEngine;let o=Le.pathToAssets,[a,c]=yield Promise.all([this.featuresAndFinishesService.GetFeatureTemplates(o),this.featuresAndFinishesService.GetFinishTemplates(o)]);return this.cmsMakeupEngine=new Xp(a,c,this.sdkAnalytics),this.cmsMakeupEngine})}SetSkinToneTargetQuality(e){this.skinToneTargetQuality=e}CreateSkinToneAnalyzer(e=void 0){return xe(this,null,function*(){var r;return yield Dp.Create(this.modulesManager,(r=this.skinToneTargetQuality)!=null?r:Bp.MORE_SPEED,e)})}CreateEyeToneAnalyzer(e=void 0){return xe(this,null,function*(){return yield kp.Create(this.modulesManager,e)})}CreateFaceTracker(){return xe(this,null,function*(){return yield Up.Create(this.modulesManager)})}CreateFaceShapeAnalyzer(e=void 0){return xe(this,null,function*(){return yield Gp.Create(this.modulesManager,e)})}CreateHairToneAnalyzer(e=void 0){return xe(this,null,function*(){return yield jp.Create(this.modulesManager,e)})}SetLightConditionsUniformityThreshold(e){this.lightConditionsUniformityThreshold=e}SetLightConditionsBacklightThreshold(e){this.lightConditionsBacklightThreshold=e}CreateLightConditionsAnalyzer(e=void 0){return xe(this,null,function*(){return yield Vp.Create(this.modulesManager,this.lightConditionsUniformityThreshold,this.lightConditionsBacklightThreshold,e)})}CreateLipShapeAnalyzer(e=void 0){return xe(this,null,function*(){return yield Zp.Create(this.modulesManager,e)})}CreateEyeShapeAnalyzer(e=void 0){return xe(this,null,function*(){return yield zp.Create(this.modulesManager,e)})}};var QT=li({},My),SB=QT;
if (typeof module.exports == "object" && typeof exports == "object") {
  var __cp = (to, from, except, desc) => {
    if ((from && typeof from === "object") || typeof from === "function") {
      for (let key of Object.getOwnPropertyNames(from)) {
        if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
        Object.defineProperty(to, key, {
          get: () => from[key],
          enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
        });
      }
    }
    return to;
  };
  module.exports = __cp(module.exports, exports);
}
return module.exports;
}))
