(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerpolicy&&(s.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?s.credentials="include":r.crossorigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();var eu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function O_(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){if(this instanceof i){var r=[null];r.push.apply(r,arguments);var s=Function.bind.apply(e,r);return new s}return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}function Ys(){}Ys.prototype.addEventListener=function(n,e){var t=this.__events=this.__events||{},i=t[n]=t[n]||[];i.indexOf(e)<0&&i.push(e)};Ys.prototype.removeEventListener=function(n,e){var t=this.__events=this.__events||{},i=t[n];if(i){var r=i.indexOf(e);r>=0&&i.splice(r,1)}};Ys.prototype.emit=function(n,e){var t=this.__events=this.__events||{},i=t[n],r=Array.prototype.slice.call(arguments,1);if(i)for(var s=0;s=0&&(this._queue.splice(t,1),n.cb.apply(null,e))}};Vi.prototype._next=function(){if(!this._paused&&this._queue.length&&!this._currentTask){if(this._lastFinished!=null){var n=vm()-this._lastFinished,e=this._delay-n;if(e>0){setTimeout(this._next.bind(this),e);return}}var t=this._queue.shift();this._start(t)}};var _m=Vi;function k_(n,e,t,i){i=i||{};var r;t!=null&&t.absoluteWidth!=null?r=t.absoluteWidth/n:t!=null&&t.relativeWidth!=null?r=t.relativeWidth:r=1;var s;t&&t.absoluteHeight!=null?s=t.absoluteHeight/e:t!=null&&t.relativeHeight!=null?s=t.relativeHeight:s=1;var a;t!=null&&t.absoluteX!=null?a=t.absoluteX/n:t!=null&&t.relativeX!=null?a=t.relativeX:a=0;var o;return t!=null&&t.absoluteY!=null?o=t.absoluteY/e:t!=null&&t.relativeY!=null?o=t.relativeY:o=0,i.x=a,i.y=o,i.width=r,i.height=s,i}var ym=k_;function U_(n){return function(t){var i,r;try{r=n()}catch(s){i=s}finally{i?t(i):t(null,r)}}}var xm=U_;function B_(n){var e=!1,t;return function(){return e||(e=!0,t=n.apply(null,arguments)),t}}var Gu=B_,H_=Gu;function V_(n){return function(){if(!arguments.length)throw new Error("cancelized: expected at least one argument");var t=Array.prototype.slice.call(arguments,0),i=t[t.length-1]=H_(t[t.length-1]);function r(){i.apply(null,arguments)}return n.apply(null,t),r}}var wm=V_;function G_(n){for(var e in n)n.hasOwnProperty(e)&&(n[e]=void 0)}var wt=G_;function Wu(){this._renderers={}}Wu.prototype.set=function(n,e,t){this._renderers[n]||(this._renderers[n]={}),this._renderers[n][e]=t};Wu.prototype.get=function(n,e){var t=this._renderers[n]&&this._renderers[n][e];return t||null};var W_=Wu,$_=Et,q_=_m,X_=ym,Y_=xm,Z_=wm,j_=wt,K_=W_;function J_(n,e){return n.cmp(e)}function Q_(n,e){return-n.cmp(e)}function pt(n){this._progressive=!!(n&&n.progressive),this._layers=[],this._renderers=[],this._tilesToLoad=[],this._tilesToRender=[],this._tmpVisible=[],this._tmpChildren=[],this._width=0,this._height=0,this._tmpRect={},this._tmpSize={},this._createTextureWorkQueue=new q_,this._emitRenderInvalid=this._emitRenderInvalid.bind(this),this._rendererRegistry=new K_}$_(pt);pt.prototype.destroy=function(){this.removeAllLayers(),j_(this)};pt.prototype.registerRenderer=function(n,e,t){return this._rendererRegistry.set(n,e,t)};pt.prototype.domElement=function(){throw new Error("Stage implementation must override domElement")};pt.prototype.width=function(){return this._width};pt.prototype.height=function(){return this._height};pt.prototype.size=function(n){return n=n||{},n.width=this._width,n.height=this._height,n};pt.prototype.setSize=function(n){this._width=n.width,this._height=n.height,this.setSizeForType(),this.emit("resize"),this._emitRenderInvalid()};pt.prototype.setSizeForType=function(n){throw new Error("Stage implementation must override setSizeForType")};pt.prototype.loadImage=function(){throw new Error("Stage implementation must override loadImage")};pt.prototype._emitRenderInvalid=function(){this.emit("renderInvalid")};pt.prototype.validateLayer=function(n){throw new Error("Stage implementation must override validateLayer")};pt.prototype.listLayers=function(){return[].concat(this._layers)};pt.prototype.hasLayer=function(n){return this._layers.indexOf(n)>=0};pt.prototype.addLayer=function(n,e){if(this._layers.indexOf(n)>=0)throw new Error("Layer already in stage");if(e==null&&(e=this._layers.length),e<0||e>this._layers.length)throw new Error("Invalid layer position");this.validateLayer(n);var t=n.geometry().type,i=n.view().type,r=this._rendererRegistry.get(t,i);if(!r)throw new Error("No "+this.type+" renderer avaiable for "+t+" geometry and "+i+" view");var s=this.createRenderer(r);this._layers.splice(e,0,n),this._renderers.splice(e,0,s),n.addEventListener("viewChange",this._emitRenderInvalid),n.addEventListener("effectsChange",this._emitRenderInvalid),n.addEventListener("fixedLevelChange",this._emitRenderInvalid),n.addEventListener("textureStoreChange",this._emitRenderInvalid),this._emitRenderInvalid()};pt.prototype.moveLayer=function(n,e){var t=this._layers.indexOf(n);if(t<0)throw new Error("No such layer in stage");if(e<0||e>=this._layers.length)throw new Error("Invalid layer position");n=this._layers.splice(t,1)[0];var i=this._renderers.splice(t,1)[0];this._layers.splice(e,0,n),this._renderers.splice(e,0,i),this._emitRenderInvalid()};pt.prototype.removeLayer=function(n){var e=this._layers.indexOf(n);if(e<0)throw new Error("No such layer in stage");var t=this._layers.splice(e,1)[0],i=this._renderers.splice(e,1)[0];this.destroyRenderer(i),t.removeEventListener("viewChange",this._emitRenderInvalid),t.removeEventListener("effectsChange",this._emitRenderInvalid),t.removeEventListener("fixedLevelChange",this._emitRenderInvalid),t.removeEventListener("textureStoreChange",this._emitRenderInvalid),this._emitRenderInvalid()};pt.prototype.removeAllLayers=function(){for(;this._layers.length>0;)this.removeLayer(this._layers[0])};pt.prototype.startFrame=function(){throw new Error("Stage implementation must override startFrame")};pt.prototype.endFrame=function(){throw new Error("Stage implementation must override endFrame")};pt.prototype.render=function(){var n,e,t=this._tilesToLoad,i=this._tilesToRender,r=!0,s,a=this._width,o=this._height,l=this._tmpRect,c=this._tmpSize;if(!(a<=0||o<=0)){for(this.startFrame(),n=0;n1&&ie[1]||""}function u(se){var ie=c.match(se);return ie&&ie.length>1&&ie[2]||""}var d=h(/(ipod|iphone|ipad)/i).toLowerCase(),f=/like android/i.test(c),m=!f&&/android/i.test(c),g=/nexus\s*[0-6]\s*/i.test(c),p=!g&&/nexus\s*[0-9]+/i.test(c),v=/CrOS/.test(c),x=/silk/i.test(c),_=/sailfish/i.test(c),w=/tizen/i.test(c),y=/(web|hpw)(o|0)s/i.test(c),b=/windows phone/i.test(c),S=!b&&/windows/i.test(c),M=!d&&!x&&/macintosh/i.test(c),T=!m&&!_&&!w&&!y&&/linux/i.test(c),C=u(/edg([ea]|ios)\/(\d+(\.\d+)?)/i),O=h(/version\/(\d+(\.\d+)?)/i),U=/tablet/i.test(c)&&!/tablet pc/i.test(c),F=!U&&/[^-]mobi/i.test(c),z=/xbox/i.test(c),L;/opera/i.test(c)?L={name:"Opera",opera:e,version:O||h(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(c)?L={name:"Opera",opera:e,version:h(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||O}:/SamsungBrowser/i.test(c)?L={name:"Samsung Internet for Android",samsungBrowser:e,version:O||h(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/Whale/i.test(c)?L={name:"NAVER Whale browser",whale:e,version:h(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)}:/MZBrowser/i.test(c)?L={name:"MZ Browser",mzbrowser:e,version:h(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/coast/i.test(c)?L={name:"Opera Coast",coast:e,version:O||h(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/focus/i.test(c)?L={name:"Focus",focus:e,version:h(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)}:/yabrowser/i.test(c)?L={name:"Yandex Browser",yandexbrowser:e,version:O||h(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(c)?L={name:"UC Browser",ucbrowser:e,version:h(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(c)?L={name:"Maxthon",maxthon:e,version:h(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(c)?L={name:"Epiphany",epiphany:e,version:h(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(c)?L={name:"Puffin",puffin:e,version:h(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(c)?L={name:"Sleipnir",sleipnir:e,version:h(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(c)?L={name:"K-Meleon",kMeleon:e,version:h(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:b?(L={name:"Windows Phone",osname:"Windows Phone",windowsphone:e},C?(L.msedge=e,L.version=C):(L.msie=e,L.version=h(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(c)?L={name:"Internet Explorer",msie:e,version:h(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:v?L={name:"Chrome",osname:"Chrome OS",chromeos:e,chromeBook:e,chrome:e,version:h(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/edg([ea]|ios)/i.test(c)?L={name:"Microsoft Edge",msedge:e,version:C}:/vivaldi/i.test(c)?L={name:"Vivaldi",vivaldi:e,version:h(/vivaldi\/(\d+(\.\d+)?)/i)||O}:_?L={name:"Sailfish",osname:"Sailfish OS",sailfish:e,version:h(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(c)?L={name:"SeaMonkey",seamonkey:e,version:h(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(c)?(L={name:"Firefox",firefox:e,version:h(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(c)&&(L.firefoxos=e,L.osname="Firefox OS")):x?L={name:"Amazon Silk",silk:e,version:h(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(c)?L={name:"PhantomJS",phantom:e,version:h(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(c)?L={name:"SlimerJS",slimer:e,version:h(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(c)||/rim\stablet/i.test(c)?L={name:"BlackBerry",osname:"BlackBerry OS",blackberry:e,version:O||h(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:y?(L={name:"WebOS",osname:"WebOS",webos:e,version:O||h(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(c)&&(L.touchpad=e)):/bada/i.test(c)?L={name:"Bada",osname:"Bada",bada:e,version:h(/dolfin\/(\d+(\.\d+)?)/i)}:w?L={name:"Tizen",osname:"Tizen",tizen:e,version:h(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||O}:/qupzilla/i.test(c)?L={name:"QupZilla",qupzilla:e,version:h(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||O}:/chromium/i.test(c)?L={name:"Chromium",chromium:e,version:h(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||O}:/chrome|crios|crmo/i.test(c)?L={name:"Chrome",chrome:e,version:h(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:m?L={name:"Android",version:O}:/safari|applewebkit/i.test(c)?(L={name:"Safari",safari:e},O&&(L.version=O)):d?(L={name:d=="iphone"?"iPhone":d=="ipad"?"iPad":"iPod"},O&&(L.version=O)):/googlebot/i.test(c)?L={name:"Googlebot",googlebot:e,version:h(/googlebot\/(\d+(\.\d+))/i)||O}:L={name:h(/^(.*)\/(.*) /),version:u(/^(.*)\/(.*) /)},!L.msedge&&/(apple)?webkit/i.test(c)?(/(apple)?webkit\/537\.36/i.test(c)?(L.name=L.name||"Blink",L.blink=e):(L.name=L.name||"Webkit",L.webkit=e),!L.version&&O&&(L.version=O)):!L.opera&&/gecko\//i.test(c)&&(L.name=L.name||"Gecko",L.gecko=e,L.version=L.version||h(/gecko\/(\d+(\.\d+)?)/i)),!L.windowsphone&&(m||L.silk)?(L.android=e,L.osname="Android"):!L.windowsphone&&d?(L[d]=e,L.ios=e,L.osname="iOS"):M?(L.mac=e,L.osname="macOS"):z?(L.xbox=e,L.osname="Xbox"):S?(L.windows=e,L.osname="Windows"):T&&(L.linux=e,L.osname="Linux");function K(se){switch(se){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}var G="";L.windows?G=K(h(/Windows ((NT|XP)( \d\d?.\d)?)/i)):L.windowsphone?G=h(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):L.mac?(G=h(/Mac OS X (\d+([_\.\s]\d+)*)/i),G=G.replace(/[_\s]/g,".")):d?(G=h(/os (\d+([_\s]\d+)*) like mac os x/i),G=G.replace(/[_\s]/g,".")):m?G=h(/android[ \/-](\d+(\.\d+)*)/i):L.webos?G=h(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):L.blackberry?G=h(/rim\stablet\sos\s(\d+(\.\d+)*)/i):L.bada?G=h(/bada\/(\d+(\.\d+)*)/i):L.tizen&&(G=h(/tizen[\/\s](\d+(\.\d+)*)/i)),G&&(L.osversion=G);var W=!L.windows&&G.split(".")[0];return U||p||d=="ipad"||m&&(W==3||W>=4&&!F)||L.silk?L.tablet=e:(F||d=="iphone"||d=="ipod"||m||g||L.blackberry||L.webos||L.bada)&&(L.mobile=e),L.msedge||L.msie&&L.version>=10||L.yandexbrowser&&L.version>=15||L.vivaldi&&L.version>=1||L.chrome&&L.version>=20||L.samsungBrowser&&L.version>=4||L.whale&&a([L.version,"1.0"])===1||L.mzbrowser&&a([L.version,"6.0"])===1||L.focus&&a([L.version,"1.0"])===1||L.firefox&&L.version>=20||L.safari&&L.version>=6||L.opera&&L.version>=10||L.ios&&L.osversion&&L.osversion.split(".")[0]>=6||L.blackberry&&L.version>=10.1||L.chromium&&L.version>=20?L.a=e:L.msie&&L.version<10||L.chrome&&L.version<20||L.firefox&&L.version<20||L.safari&&L.version<6||L.opera&&L.version<10||L.ios&&L.osversion&&L.osversion.split(".")[0]<6||L.chromium&&L.version<20?L.c=e:L.x=e,L}var i=t(typeof navigator<"u"&&navigator.userAgent||"");i.test=function(c){for(var h=0;h=0;){if(u[0][h]>u[1][h])return 1;if(u[0][h]===u[1][h]){if(h===0)return 0}else return-1}}function o(c,h,u){var d=i;typeof h=="string"&&(u=h,h=void 0),h===void 0&&(h=!1),u&&(d=t(u));var f=""+d.version;for(var m in c)if(c.hasOwnProperty(m)&&d[m]){if(typeof c[m]!="string")throw new Error("Browser version in the minVersion map should be a string: "+m+": "+String(c));return a([f,c[m]])<0}return h}function l(c,h,u){return!o(c,h,u)}return i.isUnsupportedBrowser=o,i.compareVersions=a,i.check=l,i._detect=t,i.detect=t,i})})(ay);var Wc=$u,oy=Sm,ly=ts,Tm=Mm,cy=Gu,hy=!!Tm.createImageBitmap&&!ly.firefox,uy={imageOrientation:"flipY",premultiplyAlpha:"premultiply"};function fc(n){this._stage=n}fc.prototype.loadImage=function(n,e,t){var i=this,r=new Image;r.crossOrigin="anonymous";var s=e&&e.x||0,a=e&&e.y||0,o=e&&e.width||1,l=e&&e.height||1;t=cy(t),r.onload=function(){i._handleLoad(r,s,a,o,l,t)},r.onerror=function(){i._handleError(n,t)},r.src=n;function c(){r.onload=r.onerror=null,r.src="",t.apply(null,arguments)}return c};fc.prototype._handleLoad=function(n,e,t,i,r,s){if(e===0&&t===0&&i===1&&r===1){s(null,new Wc(n));return}if(e*=n.naturalWidth,t*=n.naturalHeight,i*=n.naturalWidth,r*=n.naturalHeight,hy)Tm.createImageBitmap(n,e,t,i,r,uy).then(function(l){s(null,new Wc(l))});else{var a=document.createElement("canvas");a.width=i,a.height=r;var o=a.getContext("2d");o.drawImage(n,e,t,i,r,0,0,i,r),s(null,new Wc(a))}};fc.prototype._handleError=function(n,e){e(new oy("Network error: "+n))};var dy=fc,fy=1;function py(){if(typeof window<"u"){if(window.devicePixelRatio)return window.devicePixelRatio;var n=window.screen;if(n&&n.deviceXDPI&&n.logicalXDPI)return n.deviceXDPI/n.logicalXDPI;if(n&&n.systemXDPI&&n.logicalXDPI)return n.systemXDPI/n.logicalXDPI}return fy}var pc=py;function my(n){return(n&n-1)==0}var gy=my;function qu(n){for(var e=document.documentElement.style,t=["Moz","Webkit","Khtml","O","ms"],i=0;it)throw new Error("Layer has level with tile size larger than maximum texture size ("+e+" vs. "+t+")")};Jt.prototype.createRenderer=function(n){for(var e=this._rendererInstances,t=0;t=0&&e.splice(t,1)}};Jt.prototype.startFrame=function(){var n=this._gl;if(!n)throw new Error("Bad WebGL context - maybe context was lost?");n.viewport(0,0,n.drawingBufferWidth,n.drawingBufferHeight),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),n.enable(n.DEPTH_TEST),n.enable(n.BLEND),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA)};Jt.prototype.endFrame=function(){};Jt.prototype.takeSnapshot=function(n){(typeof n!="object"||n==null)&&(n={});var e=n.quality;if(typeof e>"u"&&(e=75),typeof e!="number"||e<0||e>100)throw new Error("WebGLStage: Snapshot quality needs to be a number between 0 and 100");return this.render(),this._domElement.toDataURL("image/jpeg",e/100)};Jt.type=Jt.prototype.type="webgl";function Yu(n,e,t){this._stage=n,this._gl=n._gl,this._texture=null,this._timestamp=null,this._width=this._height=null,this.refresh(e,t)}Yu.prototype.refresh=function(n,e){var t=this._gl,i=this._stage,r,s=e.timestamp();if(s!==this._timestamp){var a=e.element(),o=e.width(),l=e.height();if(o!==this._width||l!==this._height){var c=i.maxTextureSize();if(o>c)throw new Error("Texture width larger than max size ("+o+" vs. "+c+")");if(l>c)throw new Error("Texture height larger than max size ("+l+" vs. "+c+")");this._texture&&t.deleteTexture(r),r=this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,r),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,a)}else r=this._texture,t.bindTexture(t.TEXTURE_2D,r),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),a instanceof HTMLVideoElement&&Fy.videoUseTexImage2D?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,a):t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,a);i._generateMipmaps&&tf(o)&&tf(l)?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.generateMipmap(t.TEXTURE_2D)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null),this._timestamp=s,this._width=o,this._height=l}};Yu.prototype.destroy=function(){this._texture&&this._gl.deleteTexture(this._texture),zy(this)};Jt.TextureClass=Jt.prototype.TextureClass=Yu;var Cm=Jt,Ae=1e-6,je=typeof Float32Array<"u"?Float32Array:Array,jn=Math.random;function ky(n){je=n}var Uy=Math.PI/180;function By(n){return n*Uy}function Hy(n,e){return Math.abs(n-e)<=Ae*Math.max(1,Math.abs(n),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});const Vy=Object.freeze(Object.defineProperty({__proto__:null,get ARRAY_TYPE(){return je},EPSILON:Ae,RANDOM:jn,equals:Hy,setMatrixArrayType:ky,toRadian:By},Symbol.toStringTag,{value:"Module"}));function Gy(){var n=new je(4);return je!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n}function Wy(n){var e=new je(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function $y(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function qy(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=1,n}function Xy(n,e,t,i){var r=new je(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function Yy(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function Zy(n,e){if(n===e){var t=e[1];n[1]=e[2],n[2]=t}else n[0]=e[0],n[1]=e[2],n[2]=e[1],n[3]=e[3];return n}function jy(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=t*s-r*i;return a?(a=1/a,n[0]=s*a,n[1]=-i*a,n[2]=-r*a,n[3]=t*a,n):null}function Ky(n,e){var t=e[0];return n[0]=e[3],n[1]=-e[1],n[2]=-e[2],n[3]=t,n}function Jy(n){return n[0]*n[3]-n[2]*n[1]}function Lm(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1],c=t[2],h=t[3];return n[0]=i*o+s*l,n[1]=r*o+a*l,n[2]=i*c+s*h,n[3]=r*c+a*h,n}function Qy(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+s*o,n[1]=r*l+a*o,n[2]=i*-o+s*l,n[3]=r*-o+a*l,n}function ex(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1];return n[0]=i*o,n[1]=r*o,n[2]=s*l,n[3]=a*l,n}function tx(n,e){var t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=-t,n[3]=i,n}function nx(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=e[1],n}function ix(n){return"mat2("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"}function rx(n){return Math.hypot(n[0],n[1],n[2],n[3])}function sx(n,e,t,i){return n[2]=i[2]/i[0],t[0]=i[0],t[1]=i[1],t[3]=i[3]-n[2]*t[1],[n,e,t]}function ax(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function Pm(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function ox(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function lx(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=e[0],o=e[1],l=e[2],c=e[3];return Math.abs(t-a)<=Ae*Math.max(1,Math.abs(t),Math.abs(a))&&Math.abs(i-o)<=Ae*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-l)<=Ae*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(s-c)<=Ae*Math.max(1,Math.abs(s),Math.abs(c))}function cx(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function hx(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}var ux=Lm,dx=Pm;const fx=Object.freeze(Object.defineProperty({__proto__:null,LDU:sx,add:ax,adjoint:Ky,clone:Wy,copy:$y,create:Gy,determinant:Jy,equals:lx,exactEquals:ox,frob:rx,fromRotation:tx,fromScaling:nx,fromValues:Xy,identity:qy,invert:jy,mul:ux,multiply:Lm,multiplyScalar:cx,multiplyScalarAndAdd:hx,rotate:Qy,scale:ex,set:Yy,str:ix,sub:dx,subtract:Pm,transpose:Zy},Symbol.toStringTag,{value:"Module"}));function px(){var n=new je(6);return je!=Float32Array&&(n[1]=0,n[2]=0,n[4]=0,n[5]=0),n[0]=1,n[3]=1,n}function mx(n){var e=new je(6);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e}function gx(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n}function vx(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=1,n[4]=0,n[5]=0,n}function _x(n,e,t,i,r,s){var a=new je(6);return a[0]=n,a[1]=e,a[2]=t,a[3]=i,a[4]=r,a[5]=s,a}function yx(n,e,t,i,r,s,a){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n}function xx(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=t*s-i*r;return l?(l=1/l,n[0]=s*l,n[1]=-i*l,n[2]=-r*l,n[3]=t*l,n[4]=(r*o-s*a)*l,n[5]=(i*a-t*o)*l,n):null}function wx(n){return n[0]*n[3]-n[1]*n[2]}function Rm(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1],u=t[2],d=t[3],f=t[4],m=t[5];return n[0]=i*c+s*h,n[1]=r*c+a*h,n[2]=i*u+s*d,n[3]=r*u+a*d,n[4]=i*f+s*m+o,n[5]=r*f+a*m+l,n}function Mx(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=Math.sin(t),h=Math.cos(t);return n[0]=i*h+s*c,n[1]=r*h+a*c,n[2]=i*-c+s*h,n[3]=r*-c+a*h,n[4]=o,n[5]=l,n}function bx(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1];return n[0]=i*c,n[1]=r*c,n[2]=s*h,n[3]=a*h,n[4]=o,n[5]=l,n}function Sx(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=i*c+s*h+o,n[5]=r*c+a*h+l,n}function Tx(n,e){var t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=-t,n[3]=i,n[4]=0,n[5]=0,n}function Ex(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=e[1],n[4]=0,n[5]=0,n}function Ax(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=1,n[4]=e[0],n[5]=e[1],n}function Cx(n){return"mat2d("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+", "+n[4]+", "+n[5]+")"}function Lx(n){return Math.hypot(n[0],n[1],n[2],n[3],n[4],n[5],1)}function Px(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n}function Im(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n}function Rx(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n}function Ix(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n}function Dx(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]}function Ox(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=n[4],o=n[5],l=e[0],c=e[1],h=e[2],u=e[3],d=e[4],f=e[5];return Math.abs(t-l)<=Ae*Math.max(1,Math.abs(t),Math.abs(l))&&Math.abs(i-c)<=Ae*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-h)<=Ae*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(s-u)<=Ae*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(a-d)<=Ae*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-f)<=Ae*Math.max(1,Math.abs(o),Math.abs(f))}var zx=Rm,Fx=Im;const Nx=Object.freeze(Object.defineProperty({__proto__:null,add:Px,clone:mx,copy:gx,create:px,determinant:wx,equals:Ox,exactEquals:Dx,frob:Lx,fromRotation:Tx,fromScaling:Ex,fromTranslation:Ax,fromValues:_x,identity:vx,invert:xx,mul:zx,multiply:Rm,multiplyScalar:Rx,multiplyScalarAndAdd:Ix,rotate:Mx,scale:bx,set:yx,str:Cx,sub:Fx,subtract:Im,translate:Sx},Symbol.toStringTag,{value:"Module"}));function Dm(){var n=new je(9);return je!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function kx(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n}function Ux(n){var e=new je(9);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e}function Bx(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Hx(n,e,t,i,r,s,a,o,l){var c=new je(9);return c[0]=n,c[1]=e,c[2]=t,c[3]=i,c[4]=r,c[5]=s,c[6]=a,c[7]=o,c[8]=l,c}function Vx(n,e,t,i,r,s,a,o,l,c){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n}function Gx(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n}function Wx(n,e){if(n===e){var t=e[1],i=e[2],r=e[5];n[1]=e[3],n[2]=e[6],n[3]=t,n[5]=e[7],n[6]=i,n[7]=r}else n[0]=e[0],n[1]=e[3],n[2]=e[6],n[3]=e[1],n[4]=e[4],n[5]=e[7],n[6]=e[2],n[7]=e[5],n[8]=e[8];return n}function $x(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=-h*s+o*l,f=c*s-a*l,m=t*u+i*d+r*f;return m?(m=1/m,n[0]=u*m,n[1]=(-h*i+r*c)*m,n[2]=(o*i-r*a)*m,n[3]=d*m,n[4]=(h*t-r*l)*m,n[5]=(-o*t+r*s)*m,n[6]=f*m,n[7]=(-c*t+i*l)*m,n[8]=(a*t-i*s)*m,n):null}function qx(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return n[0]=a*h-o*c,n[1]=r*c-i*h,n[2]=i*o-r*a,n[3]=o*l-s*h,n[4]=t*h-r*l,n[5]=r*s-t*o,n[6]=s*c-a*l,n[7]=i*l-t*c,n[8]=t*a-i*s,n}function Xx(n){var e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],a=n[5],o=n[6],l=n[7],c=n[8];return e*(c*s-a*l)+t*(-c*r+a*o)+i*(l*r-s*o)}function Om(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=t[0],f=t[1],m=t[2],g=t[3],p=t[4],v=t[5],x=t[6],_=t[7],w=t[8];return n[0]=d*i+f*a+m*c,n[1]=d*r+f*o+m*h,n[2]=d*s+f*l+m*u,n[3]=g*i+p*a+v*c,n[4]=g*r+p*o+v*h,n[5]=g*s+p*l+v*u,n[6]=x*i+_*a+w*c,n[7]=x*r+_*o+w*h,n[8]=x*s+_*l+w*u,n}function Yx(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=t[0],f=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=o,n[5]=l,n[6]=d*i+f*a+c,n[7]=d*r+f*o+h,n[8]=d*s+f*l+u,n}function Zx(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=Math.sin(t),f=Math.cos(t);return n[0]=f*i+d*a,n[1]=f*r+d*o,n[2]=f*s+d*l,n[3]=f*a-d*i,n[4]=f*o-d*r,n[5]=f*l-d*s,n[6]=c,n[7]=h,n[8]=u,n}function jx(n,e,t){var i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Kx(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=e[0],n[7]=e[1],n[8]=1,n}function Jx(n,e){var t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=-t,n[4]=i,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n}function Qx(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=e[1],n[5]=0,n[6]=0,n[7]=0,n[8]=1,n}function e1(n,e){return n[0]=e[0],n[1]=e[1],n[2]=0,n[3]=e[2],n[4]=e[3],n[5]=0,n[6]=e[4],n[7]=e[5],n[8]=1,n}function t1(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,h=i*a,u=i*o,d=r*a,f=r*o,m=r*l,g=s*a,p=s*o,v=s*l;return n[0]=1-u-m,n[3]=h-v,n[6]=d+p,n[1]=h+v,n[4]=1-c-m,n[7]=f-g,n[2]=d-p,n[5]=f+g,n[8]=1-c-u,n}function n1(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],g=e[13],p=e[14],v=e[15],x=t*o-i*a,_=t*l-r*a,w=t*c-s*a,y=i*l-r*o,b=i*c-s*o,S=r*c-s*l,M=h*g-u*m,T=h*p-d*m,C=h*v-f*m,O=u*p-d*g,U=u*v-f*g,F=d*v-f*p,z=x*F-_*U+w*O+y*C-b*T+S*M;return z?(z=1/z,n[0]=(o*F-l*U+c*O)*z,n[1]=(l*C-a*F-c*T)*z,n[2]=(a*U-o*C+c*M)*z,n[3]=(r*U-i*F-s*O)*z,n[4]=(t*F-r*C+s*T)*z,n[5]=(i*C-t*U-s*M)*z,n[6]=(g*S-p*b+v*y)*z,n[7]=(p*w-m*S-v*_)*z,n[8]=(m*b-g*w+v*x)*z,n):null}function i1(n,e,t){return n[0]=2/e,n[1]=0,n[2]=0,n[3]=0,n[4]=-2/t,n[5]=0,n[6]=-1,n[7]=1,n[8]=1,n}function r1(n){return"mat3("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+", "+n[4]+", "+n[5]+", "+n[6]+", "+n[7]+", "+n[8]+")"}function s1(n){return Math.hypot(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8])}function a1(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n}function zm(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n}function o1(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n}function l1(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n}function c1(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]}function h1(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=n[4],o=n[5],l=n[6],c=n[7],h=n[8],u=e[0],d=e[1],f=e[2],m=e[3],g=e[4],p=e[5],v=e[6],x=e[7],_=e[8];return Math.abs(t-u)<=Ae*Math.max(1,Math.abs(t),Math.abs(u))&&Math.abs(i-d)<=Ae*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(r-f)<=Ae*Math.max(1,Math.abs(r),Math.abs(f))&&Math.abs(s-m)<=Ae*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(a-g)<=Ae*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-p)<=Ae*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(l-v)<=Ae*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(c-x)<=Ae*Math.max(1,Math.abs(c),Math.abs(x))&&Math.abs(h-_)<=Ae*Math.max(1,Math.abs(h),Math.abs(_))}var u1=Om,d1=zm;const f1=Object.freeze(Object.defineProperty({__proto__:null,add:a1,adjoint:qx,clone:Ux,copy:Bx,create:Dm,determinant:Xx,equals:h1,exactEquals:c1,frob:s1,fromMat2d:e1,fromMat4:kx,fromQuat:t1,fromRotation:Jx,fromScaling:Qx,fromTranslation:Kx,fromValues:Hx,identity:Gx,invert:$x,mul:u1,multiply:Om,multiplyScalar:o1,multiplyScalarAndAdd:l1,normalFromMat4:n1,projection:i1,rotate:Zx,scale:jx,set:Vx,str:r1,sub:d1,subtract:zm,translate:Yx,transpose:Wx},Symbol.toStringTag,{value:"Module"}));function p1(){var n=new je(16);return je!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function m1(n){var e=new je(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function g1(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function v1(n,e,t,i,r,s,a,o,l,c,h,u,d,f,m,g){var p=new je(16);return p[0]=n,p[1]=e,p[2]=t,p[3]=i,p[4]=r,p[5]=s,p[6]=a,p[7]=o,p[8]=l,p[9]=c,p[10]=h,p[11]=u,p[12]=d,p[13]=f,p[14]=m,p[15]=g,p}function _1(n,e,t,i,r,s,a,o,l,c,h,u,d,f,m,g,p){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n[9]=h,n[10]=u,n[11]=d,n[12]=f,n[13]=m,n[14]=g,n[15]=p,n}function Fm(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function y1(n,e){if(n===e){var t=e[1],i=e[2],r=e[3],s=e[6],a=e[7],o=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=a,n[14]=o}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function x1(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],g=e[13],p=e[14],v=e[15],x=t*o-i*a,_=t*l-r*a,w=t*c-s*a,y=i*l-r*o,b=i*c-s*o,S=r*c-s*l,M=h*g-u*m,T=h*p-d*m,C=h*v-f*m,O=u*p-d*g,U=u*v-f*g,F=d*v-f*p,z=x*F-_*U+w*O+y*C-b*T+S*M;return z?(z=1/z,n[0]=(o*F-l*U+c*O)*z,n[1]=(r*U-i*F-s*O)*z,n[2]=(g*S-p*b+v*y)*z,n[3]=(d*b-u*S-f*y)*z,n[4]=(l*C-a*F-c*T)*z,n[5]=(t*F-r*C+s*T)*z,n[6]=(p*w-m*S-v*_)*z,n[7]=(h*S-d*w+f*_)*z,n[8]=(a*U-o*C+c*M)*z,n[9]=(i*C-t*U-s*M)*z,n[10]=(m*b-g*w+v*x)*z,n[11]=(u*w-h*b-f*x)*z,n[12]=(o*T-a*O-l*M)*z,n[13]=(t*O-i*T+r*M)*z,n[14]=(g*_-m*y-p*x)*z,n[15]=(h*y-u*_+d*x)*z,n):null}function w1(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],g=e[13],p=e[14],v=e[15];return n[0]=o*(d*v-f*p)-u*(l*v-c*p)+g*(l*f-c*d),n[1]=-(i*(d*v-f*p)-u*(r*v-s*p)+g*(r*f-s*d)),n[2]=i*(l*v-c*p)-o*(r*v-s*p)+g*(r*c-s*l),n[3]=-(i*(l*f-c*d)-o*(r*f-s*d)+u*(r*c-s*l)),n[4]=-(a*(d*v-f*p)-h*(l*v-c*p)+m*(l*f-c*d)),n[5]=t*(d*v-f*p)-h*(r*v-s*p)+m*(r*f-s*d),n[6]=-(t*(l*v-c*p)-a*(r*v-s*p)+m*(r*c-s*l)),n[7]=t*(l*f-c*d)-a*(r*f-s*d)+h*(r*c-s*l),n[8]=a*(u*v-f*g)-h*(o*v-c*g)+m*(o*f-c*u),n[9]=-(t*(u*v-f*g)-h*(i*v-s*g)+m*(i*f-s*u)),n[10]=t*(o*v-c*g)-a*(i*v-s*g)+m*(i*c-s*o),n[11]=-(t*(o*f-c*u)-a*(i*f-s*u)+h*(i*c-s*o)),n[12]=-(a*(u*p-d*g)-h*(o*p-l*g)+m*(o*d-l*u)),n[13]=t*(u*p-d*g)-h*(i*p-r*g)+m*(i*d-r*u),n[14]=-(t*(o*p-l*g)-a*(i*p-r*g)+m*(i*l-r*o)),n[15]=t*(o*d-l*u)-a*(i*d-r*u)+h*(i*l-r*o),n}function M1(n){var e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],a=n[5],o=n[6],l=n[7],c=n[8],h=n[9],u=n[10],d=n[11],f=n[12],m=n[13],g=n[14],p=n[15],v=e*a-t*s,x=e*o-i*s,_=e*l-r*s,w=t*o-i*a,y=t*l-r*a,b=i*l-r*o,S=c*m-h*f,M=c*g-u*f,T=c*p-d*f,C=h*g-u*m,O=h*p-d*m,U=u*p-d*g;return v*U-x*O+_*C+w*T-y*M+b*S}function Nm(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],f=e[10],m=e[11],g=e[12],p=e[13],v=e[14],x=e[15],_=t[0],w=t[1],y=t[2],b=t[3];return n[0]=_*i+w*o+y*u+b*g,n[1]=_*r+w*l+y*d+b*p,n[2]=_*s+w*c+y*f+b*v,n[3]=_*a+w*h+y*m+b*x,_=t[4],w=t[5],y=t[6],b=t[7],n[4]=_*i+w*o+y*u+b*g,n[5]=_*r+w*l+y*d+b*p,n[6]=_*s+w*c+y*f+b*v,n[7]=_*a+w*h+y*m+b*x,_=t[8],w=t[9],y=t[10],b=t[11],n[8]=_*i+w*o+y*u+b*g,n[9]=_*r+w*l+y*d+b*p,n[10]=_*s+w*c+y*f+b*v,n[11]=_*a+w*h+y*m+b*x,_=t[12],w=t[13],y=t[14],b=t[15],n[12]=_*i+w*o+y*u+b*g,n[13]=_*r+w*l+y*d+b*p,n[14]=_*s+w*c+y*f+b*v,n[15]=_*a+w*h+y*m+b*x,n}function b1(n,e,t){var i=t[0],r=t[1],s=t[2],a,o,l,c,h,u,d,f,m,g,p,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(a=e[0],o=e[1],l=e[2],c=e[3],h=e[4],u=e[5],d=e[6],f=e[7],m=e[8],g=e[9],p=e[10],v=e[11],n[0]=a,n[1]=o,n[2]=l,n[3]=c,n[4]=h,n[5]=u,n[6]=d,n[7]=f,n[8]=m,n[9]=g,n[10]=p,n[11]=v,n[12]=a*i+h*r+m*s+e[12],n[13]=o*i+u*r+g*s+e[13],n[14]=l*i+d*r+p*s+e[14],n[15]=c*i+f*r+v*s+e[15]),n}function S1(n,e,t){var i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function T1(n,e,t,i){var r=i[0],s=i[1],a=i[2],o=Math.hypot(r,s,a),l,c,h,u,d,f,m,g,p,v,x,_,w,y,b,S,M,T,C,O,U,F,z,L;return o0?(t[0]=(o*a+h*i+l*s-c*r)*2/u,t[1]=(l*a+h*r+c*i-o*s)*2/u,t[2]=(c*a+h*s+o*r-l*i)*2/u):(t[0]=(o*a+h*i+l*s-c*r)*2,t[1]=(l*a+h*r+c*i-o*s)*2,t[2]=(c*a+h*s+o*r-l*i)*2),km(n,e,t),n}function Um(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function Bm(n,e){var t=e[0],i=e[1],r=e[2],s=e[4],a=e[5],o=e[6],l=e[8],c=e[9],h=e[10];return n[0]=Math.hypot(t,i,r),n[1]=Math.hypot(s,a,o),n[2]=Math.hypot(l,c,h),n}function Hm(n,e){var t=new je(3);Bm(t,e);var i=1/t[0],r=1/t[1],s=1/t[2],a=e[0]*i,o=e[1]*r,l=e[2]*s,c=e[4]*i,h=e[5]*r,u=e[6]*s,d=e[8]*i,f=e[9]*r,m=e[10]*s,g=a+h+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,n[3]=.25*p,n[0]=(u-f)/p,n[1]=(d-l)/p,n[2]=(o-c)/p):a>h&&a>m?(p=Math.sqrt(1+a-h-m)*2,n[3]=(u-f)/p,n[0]=.25*p,n[1]=(o+c)/p,n[2]=(d+l)/p):h>m?(p=Math.sqrt(1+h-a-m)*2,n[3]=(d-l)/p,n[0]=(o+c)/p,n[1]=.25*p,n[2]=(u+f)/p):(p=Math.sqrt(1+m-a-h)*2,n[3]=(o-c)/p,n[0]=(d+l)/p,n[1]=(u+f)/p,n[2]=.25*p),n}function F1(n,e,t,i){var r=e[0],s=e[1],a=e[2],o=e[3],l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,f=r*h,m=s*c,g=s*h,p=a*h,v=o*l,x=o*c,_=o*h,w=i[0],y=i[1],b=i[2];return n[0]=(1-(m+p))*w,n[1]=(d+_)*w,n[2]=(f-x)*w,n[3]=0,n[4]=(d-_)*y,n[5]=(1-(u+p))*y,n[6]=(g+v)*y,n[7]=0,n[8]=(f+x)*b,n[9]=(g-v)*b,n[10]=(1-(u+m))*b,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function N1(n,e,t,i,r){var s=e[0],a=e[1],o=e[2],l=e[3],c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,m=s*u,g=a*h,p=a*u,v=o*u,x=l*c,_=l*h,w=l*u,y=i[0],b=i[1],S=i[2],M=r[0],T=r[1],C=r[2],O=(1-(g+v))*y,U=(f+w)*y,F=(m-_)*y,z=(f-w)*b,L=(1-(d+v))*b,K=(p+x)*b,G=(m+_)*S,W=(p-x)*S,se=(1-(d+g))*S;return n[0]=O,n[1]=U,n[2]=F,n[3]=0,n[4]=z,n[5]=L,n[6]=K,n[7]=0,n[8]=G,n[9]=W,n[10]=se,n[11]=0,n[12]=t[0]+M-(O*M+z*T+G*C),n[13]=t[1]+T-(U*M+L*T+W*C),n[14]=t[2]+C-(F*M+K*T+se*C),n[15]=1,n}function k1(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,h=i*a,u=i*o,d=r*a,f=r*o,m=r*l,g=s*a,p=s*o,v=s*l;return n[0]=1-u-m,n[1]=h+v,n[2]=d-p,n[3]=0,n[4]=h-v,n[5]=1-c-m,n[6]=f+g,n[7]=0,n[8]=d+p,n[9]=f-g,n[10]=1-c-u,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function U1(n,e,t,i,r,s,a){var o=1/(t-e),l=1/(r-i),c=1/(s-a);return n[0]=s*2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*l,n[6]=0,n[7]=0,n[8]=(t+e)*o,n[9]=(r+i)*l,n[10]=(a+s)*c,n[11]=-1,n[12]=0,n[13]=0,n[14]=a*s*2*c,n[15]=0,n}function B1(n,e,t,i,r){var s=1/Math.tan(e/2),a;return n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0?(a=1/(i-r),n[10]=(r+i)*a,n[14]=2*r*i*a):(n[10]=-1,n[14]=-2*i),n}function H1(n,e,t,i){var r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),l=2/(a+o),c=2/(r+s);return n[0]=l,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=c,n[6]=0,n[7]=0,n[8]=-((a-o)*l*.5),n[9]=(r-s)*c*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function V1(n,e,t,i,r,s,a){var o=1/(e-t),l=1/(i-r),c=1/(s-a);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*l,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*c,n[11]=0,n[12]=(e+t)*o,n[13]=(r+i)*l,n[14]=(a+s)*c,n[15]=1,n}function G1(n,e,t,i){var r,s,a,o,l,c,h,u,d,f,m=e[0],g=e[1],p=e[2],v=i[0],x=i[1],_=i[2],w=t[0],y=t[1],b=t[2];return Math.abs(m-w)0&&(f=1/Math.sqrt(f),h*=f,u*=f,d*=f);var m=l*d-c*u,g=c*h-o*d,p=o*u-l*h;return f=m*m+g*g+p*p,f>0&&(f=1/Math.sqrt(f),m*=f,g*=f,p*=f),n[0]=m,n[1]=g,n[2]=p,n[3]=0,n[4]=u*p-d*g,n[5]=d*m-h*p,n[6]=h*g-u*m,n[7]=0,n[8]=h,n[9]=u,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=a,n[15]=1,n}function $1(n){return"mat4("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+", "+n[4]+", "+n[5]+", "+n[6]+", "+n[7]+", "+n[8]+", "+n[9]+", "+n[10]+", "+n[11]+", "+n[12]+", "+n[13]+", "+n[14]+", "+n[15]+")"}function q1(n){return Math.hypot(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}function X1(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function Vm(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function Y1(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function Z1(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function j1(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function K1(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=n[4],o=n[5],l=n[6],c=n[7],h=n[8],u=n[9],d=n[10],f=n[11],m=n[12],g=n[13],p=n[14],v=n[15],x=e[0],_=e[1],w=e[2],y=e[3],b=e[4],S=e[5],M=e[6],T=e[7],C=e[8],O=e[9],U=e[10],F=e[11],z=e[12],L=e[13],K=e[14],G=e[15];return Math.abs(t-x)<=Ae*Math.max(1,Math.abs(t),Math.abs(x))&&Math.abs(i-_)<=Ae*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(r-w)<=Ae*Math.max(1,Math.abs(r),Math.abs(w))&&Math.abs(s-y)<=Ae*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(a-b)<=Ae*Math.max(1,Math.abs(a),Math.abs(b))&&Math.abs(o-S)<=Ae*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(l-M)<=Ae*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(c-T)<=Ae*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(h-C)<=Ae*Math.max(1,Math.abs(h),Math.abs(C))&&Math.abs(u-O)<=Ae*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(d-U)<=Ae*Math.max(1,Math.abs(d),Math.abs(U))&&Math.abs(f-F)<=Ae*Math.max(1,Math.abs(f),Math.abs(F))&&Math.abs(m-z)<=Ae*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(g-L)<=Ae*Math.max(1,Math.abs(g),Math.abs(L))&&Math.abs(p-K)<=Ae*Math.max(1,Math.abs(p),Math.abs(K))&&Math.abs(v-G)<=Ae*Math.max(1,Math.abs(v),Math.abs(G))}var J1=Nm,Q1=Vm;const ew=Object.freeze(Object.defineProperty({__proto__:null,add:X1,adjoint:w1,clone:m1,copy:g1,create:p1,determinant:M1,equals:K1,exactEquals:j1,frob:q1,fromQuat:k1,fromQuat2:z1,fromRotation:R1,fromRotationTranslation:km,fromRotationTranslationScale:F1,fromRotationTranslationScaleOrigin:N1,fromScaling:P1,fromTranslation:L1,fromValues:v1,fromXRotation:I1,fromYRotation:D1,fromZRotation:O1,frustum:U1,getRotation:Hm,getScaling:Bm,getTranslation:Um,identity:Fm,invert:x1,lookAt:G1,mul:J1,multiply:Nm,multiplyScalar:Y1,multiplyScalarAndAdd:Z1,ortho:V1,perspective:B1,perspectiveFromFieldOfView:H1,rotate:T1,rotateX:E1,rotateY:A1,rotateZ:C1,scale:S1,set:_1,str:$1,sub:Q1,subtract:Vm,targetTo:W1,translate:b1,transpose:y1},Symbol.toStringTag,{value:"Module"}));function Zu(){var n=new je(3);return je!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function tw(n){var e=new je(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function Gm(n){var e=n[0],t=n[1],i=n[2];return Math.hypot(e,t,i)}function tu(n,e,t){var i=new je(3);return i[0]=n,i[1]=e,i[2]=t,i}function nw(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function iw(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function rw(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function Wm(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function $m(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function qm(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function sw(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function aw(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function ow(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function lw(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function cw(n,e){return n[0]=Math.round(e[0]),n[1]=Math.round(e[1]),n[2]=Math.round(e[2]),n}function hw(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function uw(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function Xm(n,e){var t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.hypot(t,i,r)}function Ym(n,e){var t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function Zm(n){var e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function dw(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function fw(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function jm(n,e){var t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function ju(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function ql(n,e,t){var i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2];return n[0]=r*l-s*o,n[1]=s*a-i*l,n[2]=i*o-r*a,n}function pw(n,e,t,i){var r=e[0],s=e[1],a=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=a+i*(t[2]-a),n}function mw(n,e,t,i,r,s){var a=s*s,o=a*(2*s-3)+1,l=a*(s-2)+s,c=a*(s-1),h=a*(3-2*s);return n[0]=e[0]*o+t[0]*l+i[0]*c+r[0]*h,n[1]=e[1]*o+t[1]*l+i[1]*c+r[1]*h,n[2]=e[2]*o+t[2]*l+i[2]*c+r[2]*h,n}function gw(n,e,t,i,r,s){var a=1-s,o=a*a,l=s*s,c=o*a,h=3*s*o,u=3*l*a,d=l*s;return n[0]=e[0]*c+t[0]*h+i[0]*u+r[0]*d,n[1]=e[1]*c+t[1]*h+i[1]*u+r[1]*d,n[2]=e[2]*c+t[2]*h+i[2]*u+r[2]*d,n}function vw(n,e){e=e||1;var t=jn()*2*Math.PI,i=jn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function _w(n,e,t){var i=e[0],r=e[1],s=e[2],a=t[3]*i+t[7]*r+t[11]*s+t[15];return a=a||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/a,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/a,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/a,n}function yw(n,e,t){var i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function xw(n,e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=e[0],l=e[1],c=e[2],h=r*c-s*l,u=s*o-i*c,d=i*l-r*o,f=r*d-s*u,m=s*h-i*d,g=i*u-r*h,p=a*2;return h*=p,u*=p,d*=p,f*=2,m*=2,g*=2,n[0]=o+h+f,n[1]=l+u+m,n[2]=c+d+g,n}function ww(n,e,t,i){var r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Mw(n,e,t,i){var r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function bw(n,e,t,i){var r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sw(n,e){var t=n[0],i=n[1],r=n[2],s=e[0],a=e[1],o=e[2],l=Math.sqrt(t*t+i*i+r*r),c=Math.sqrt(s*s+a*a+o*o),h=l*c,u=h&&ju(n,e)/h;return Math.acos(Math.min(Math.max(u,-1),1))}function Tw(n){return n[0]=0,n[1]=0,n[2]=0,n}function Ew(n){return"vec3("+n[0]+", "+n[1]+", "+n[2]+")"}function Aw(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function Cw(n,e){var t=n[0],i=n[1],r=n[2],s=e[0],a=e[1],o=e[2];return Math.abs(t-s)<=Ae*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-a)<=Ae*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-o)<=Ae*Math.max(1,Math.abs(r),Math.abs(o))}var Lw=Wm,Pw=$m,Rw=qm,Iw=Xm,Dw=Ym,Km=Gm,Ow=Zm,zw=function(){var n=Zu();return function(e,t,i,r,s,a){var o,l;for(t||(t=3),i||(i=0),r?l=Math.min(r*t+i,e.length):l=e.length,o=i;o0&&(a=1/Math.sqrt(a)),n[0]=t*a,n[1]=i*a,n[2]=r*a,n[3]=s*a,n}function ug(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function $w(n,e,t,i){var r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],a=t[0]*i[3]-t[3]*i[0],o=t[1]*i[2]-t[2]*i[1],l=t[1]*i[3]-t[3]*i[1],c=t[2]*i[3]-t[3]*i[2],h=e[0],u=e[1],d=e[2],f=e[3];return n[0]=u*c-d*l+f*o,n[1]=-(h*c)+d*a-f*s,n[2]=h*l-u*a+f*r,n[3]=-(h*o)+u*s-d*r,n}function dg(n,e,t,i){var r=e[0],s=e[1],a=e[2],o=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=a+i*(t[2]-a),n[3]=o+i*(t[3]-o),n}function qw(n,e){e=e||1;var t,i,r,s,a,o;do t=jn()*2-1,i=jn()*2-1,a=t*t+i*i;while(a>=1);do r=jn()*2-1,s=jn()*2-1,o=r*r+s*s;while(o>=1);var l=Math.sqrt((1-a)/o);return n[0]=e*t,n[1]=e*i,n[2]=e*r*l,n[3]=e*s*l,n}function Xw(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*a,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*a,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*a,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*a,n}function Yw(n,e,t){var i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2],c=t[3],h=c*i+o*s-l*r,u=c*r+l*i-a*s,d=c*s+a*r-o*i,f=-a*i-o*r-l*s;return n[0]=h*c+f*-a+u*-l-d*-o,n[1]=u*c+f*-o+d*-a-h*-l,n[2]=d*c+f*-l+h*-o-u*-a,n[3]=e[3],n}function Zw(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function jw(n){return"vec4("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"}function fg(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function pg(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=e[0],o=e[1],l=e[2],c=e[3];return Math.abs(t-a)<=Ae*Math.max(1,Math.abs(t),Math.abs(a))&&Math.abs(i-o)<=Ae*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-l)<=Ae*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(s-c)<=Ae*Math.max(1,Math.abs(s),Math.abs(c))}var Kw=rg,Jw=sg,Qw=ag,eM=lg,tM=cg,nM=Ku,iM=Ju,rM=function(){var n=Jm();return function(e,t,i,r,s,a){var o,l;for(t||(t=4),i||(i=0),r?l=Math.min(r*t+i,e.length):l=e.length,o=i;oAe?(n[0]=e[0]/i,n[1]=e[1]/i,n[2]=e[2]/i):(n[0]=1,n[1]=0,n[2]=0),t}function lM(n,e){var t=ed(n,e);return Math.acos(2*t*t-1)}function gg(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1],c=t[2],h=t[3];return n[0]=i*h+a*o+r*c-s*l,n[1]=r*h+a*l+s*o-i*c,n[2]=s*h+a*c+i*l-r*o,n[3]=a*h-i*o-r*l-s*c,n}function vg(n,e,t){t*=.5;var i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+a*o,n[1]=r*l+s*o,n[2]=s*l-r*o,n[3]=a*l-i*o,n}function _g(n,e,t){t*=.5;var i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l-s*o,n[1]=r*l+a*o,n[2]=s*l+i*o,n[3]=a*l-r*o,n}function yg(n,e,t){t*=.5;var i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+r*o,n[1]=r*l-i*o,n[2]=s*l+a*o,n[3]=a*l-s*o,n}function cM(n,e){var t=e[0],i=e[1],r=e[2];return n[0]=t,n[1]=i,n[2]=r,n[3]=Math.sqrt(Math.abs(1-t*t-i*i-r*r)),n}function xg(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=Math.sqrt(t*t+i*i+r*r),o=Math.exp(s),l=a>0?o*Math.sin(a)/a:0;return n[0]=t*l,n[1]=i*l,n[2]=r*l,n[3]=o*Math.cos(a),n}function wg(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=Math.sqrt(t*t+i*i+r*r),o=a>0?Math.atan2(a,s)/a:0;return n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=.5*Math.log(t*t+i*i+r*r+s*s),n}function hM(n,e,t){return wg(n,e),bg(n,n,t),xg(n,n),n}function Xl(n,e,t,i){var r=e[0],s=e[1],a=e[2],o=e[3],l=t[0],c=t[1],h=t[2],u=t[3],d,f,m,g,p;return f=r*l+s*c+a*h+o*u,f<0&&(f=-f,l=-l,c=-c,h=-h,u=-u),1-f>Ae?(d=Math.acos(f),m=Math.sin(d),g=Math.sin((1-i)*d)/m,p=Math.sin(i*d)/m):(g=1-i,p=i),n[0]=g*r+p*l,n[1]=g*s+p*c,n[2]=g*a+p*h,n[3]=g*o+p*u,n}function uM(n){var e=jn(),t=jn(),i=jn(),r=Math.sqrt(1-e),s=Math.sqrt(e);return n[0]=r*Math.sin(2*Math.PI*t),n[1]=r*Math.cos(2*Math.PI*t),n[2]=s*Math.sin(2*Math.PI*i),n[3]=s*Math.cos(2*Math.PI*i),n}function dM(n,e){var t=e[0],i=e[1],r=e[2],s=e[3],a=t*t+i*i+r*r+s*s,o=a?1/a:0;return n[0]=-t*o,n[1]=-i*o,n[2]=-r*o,n[3]=s*o,n}function fM(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n}function Mg(n,e){var t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);var s=(r+1)%3,a=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[a*3+a]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+a]-e[a*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[a]=(e[a*3+r]+e[r*3+a])*i}return n}function pM(n,e,t,i){var r=.5*Math.PI/180;e*=r,t*=r,i*=r;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(t),l=Math.cos(t),c=Math.sin(i),h=Math.cos(i);return n[0]=s*l*h-a*o*c,n[1]=a*o*h+s*l*c,n[2]=a*l*c-s*o*h,n[3]=a*l*h+s*o*c,n}function mM(n){return"quat("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"}var gM=Qm,vM=eg,Qu=tg,_M=ng,yM=ig,xM=gg,bg=og,ed=ug,wM=dg,td=Ku,MM=td,nd=Ju,bM=nd,id=hg,SM=fg,TM=pg,EM=function(){var n=Zu(),e=tu(1,0,0),t=tu(0,1,0);return function(i,r,s){var a=ju(r,s);return a<-.999999?(ql(n,e,r),Km(n)<1e-6&&ql(n,t,r),jm(n,n),mg(i,n,Math.PI),i):a>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(ql(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+a,id(i,i))}}(),AM=function(){var n=ic(),e=ic();return function(t,i,r,s,a,o){return Xl(n,i,a,o),Xl(e,r,s,o),Xl(t,n,e,2*o*(1-o)),t}}(),CM=function(){var n=Dm();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],id(e,Mg(e,n))}}();const LM=Object.freeze(Object.defineProperty({__proto__:null,add:yM,calculateW:cM,clone:gM,conjugate:fM,copy:Qu,create:ic,dot:ed,equals:TM,exactEquals:SM,exp:xg,fromEuler:pM,fromMat3:Mg,fromValues:vM,getAngle:lM,getAxisAngle:oM,identity:aM,invert:dM,len:MM,length:td,lerp:wM,ln:wg,mul:xM,multiply:gg,normalize:id,pow:hM,random:uM,rotateX:vg,rotateY:_g,rotateZ:yg,rotationTo:EM,scale:bg,set:_M,setAxes:CM,setAxisAngle:mg,slerp:Xl,sqlerp:AM,sqrLen:bM,squaredLength:nd,str:mM},Symbol.toStringTag,{value:"Module"}));function PM(){var n=new je(8);return je!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[4]=0,n[5]=0,n[6]=0,n[7]=0),n[3]=1,n}function RM(n){var e=new je(8);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e}function IM(n,e,t,i,r,s,a,o){var l=new je(8);return l[0]=n,l[1]=e,l[2]=t,l[3]=i,l[4]=r,l[5]=s,l[6]=a,l[7]=o,l}function DM(n,e,t,i,r,s,a){var o=new je(8);o[0]=n,o[1]=e,o[2]=t,o[3]=i;var l=r*.5,c=s*.5,h=a*.5;return o[4]=l*i+c*t-h*e,o[5]=c*i+h*n-l*t,o[6]=h*i+l*e-c*n,o[7]=-l*n-c*e-h*t,o}function Sg(n,e,t){var i=t[0]*.5,r=t[1]*.5,s=t[2]*.5,a=e[0],o=e[1],l=e[2],c=e[3];return n[0]=a,n[1]=o,n[2]=l,n[3]=c,n[4]=i*c+r*l-s*o,n[5]=r*c+s*a-i*l,n[6]=s*c+i*o-r*a,n[7]=-i*a-r*o-s*l,n}function OM(n,e){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n[4]=e[0]*.5,n[5]=e[1]*.5,n[6]=e[2]*.5,n[7]=0,n}function zM(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=0,n[5]=0,n[6]=0,n[7]=0,n}function FM(n,e){var t=ic();Hm(t,e);var i=new je(3);return Um(i,e),Sg(n,t,i),n}function Tg(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n}function NM(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n[4]=0,n[5]=0,n[6]=0,n[7]=0,n}function kM(n,e,t,i,r,s,a,o,l){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n}var UM=Qu;function BM(n,e){return n[0]=e[4],n[1]=e[5],n[2]=e[6],n[3]=e[7],n}var HM=Qu;function VM(n,e){return n[4]=e[0],n[5]=e[1],n[6]=e[2],n[7]=e[3],n}function GM(n,e){var t=e[4],i=e[5],r=e[6],s=e[7],a=-e[0],o=-e[1],l=-e[2],c=e[3];return n[0]=(t*c+s*a+i*l-r*o)*2,n[1]=(i*c+s*o+r*a-t*l)*2,n[2]=(r*c+s*l+t*o-i*a)*2,n}function WM(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0]*.5,l=t[1]*.5,c=t[2]*.5,h=e[4],u=e[5],d=e[6],f=e[7];return n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=a*o+r*c-s*l+h,n[5]=a*l+s*o-i*c+u,n[6]=a*c+i*l-r*o+d,n[7]=-i*o-r*l-s*c+f,n}function $M(n,e,t){var i=-e[0],r=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=o*a+h*i+l*s-c*r,d=l*a+h*r+c*i-o*s,f=c*a+h*s+o*r-l*i,m=h*a-o*i-l*r-c*s;return vg(n,e,t),i=n[0],r=n[1],s=n[2],a=n[3],n[4]=u*a+m*i+d*s-f*r,n[5]=d*a+m*r+f*i-u*s,n[6]=f*a+m*s+u*r-d*i,n[7]=m*a-u*i-d*r-f*s,n}function qM(n,e,t){var i=-e[0],r=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=o*a+h*i+l*s-c*r,d=l*a+h*r+c*i-o*s,f=c*a+h*s+o*r-l*i,m=h*a-o*i-l*r-c*s;return _g(n,e,t),i=n[0],r=n[1],s=n[2],a=n[3],n[4]=u*a+m*i+d*s-f*r,n[5]=d*a+m*r+f*i-u*s,n[6]=f*a+m*s+u*r-d*i,n[7]=m*a-u*i-d*r-f*s,n}function XM(n,e,t){var i=-e[0],r=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=o*a+h*i+l*s-c*r,d=l*a+h*r+c*i-o*s,f=c*a+h*s+o*r-l*i,m=h*a-o*i-l*r-c*s;return yg(n,e,t),i=n[0],r=n[1],s=n[2],a=n[3],n[4]=u*a+m*i+d*s-f*r,n[5]=d*a+m*r+f*i-u*s,n[6]=f*a+m*s+u*r-d*i,n[7]=m*a-u*i-d*r-f*s,n}function YM(n,e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=e[0],l=e[1],c=e[2],h=e[3];return n[0]=o*a+h*i+l*s-c*r,n[1]=l*a+h*r+c*i-o*s,n[2]=c*a+h*s+o*r-l*i,n[3]=h*a-o*i-l*r-c*s,o=e[4],l=e[5],c=e[6],h=e[7],n[4]=o*a+h*i+l*s-c*r,n[5]=l*a+h*r+c*i-o*s,n[6]=c*a+h*s+o*r-l*i,n[7]=h*a-o*i-l*r-c*s,n}function ZM(n,e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1],c=t[2],h=t[3];return n[0]=i*h+a*o+r*c-s*l,n[1]=r*h+a*l+s*o-i*c,n[2]=s*h+a*c+i*l-r*o,n[3]=a*h-i*o-r*l-s*c,o=t[4],l=t[5],c=t[6],h=t[7],n[4]=i*h+a*o+r*c-s*l,n[5]=r*h+a*l+s*o-i*c,n[6]=s*h+a*c+i*l-r*o,n[7]=a*h-i*o-r*l-s*c,n}function jM(n,e,t,i){if(Math.abs(i)0){t=Math.sqrt(t);var i=e[0]/t,r=e[1]/t,s=e[2]/t,a=e[3]/t,o=e[4],l=e[5],c=e[6],h=e[7],u=i*o+r*l+s*c+a*h;n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=(o-i*u)/t,n[5]=(l-r*u)/t,n[6]=(c-s*u)/t,n[7]=(h-a*u)/t}return n}function ab(n){return"quat2("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+", "+n[4]+", "+n[5]+", "+n[6]+", "+n[7]+")"}function ob(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]}function lb(n,e){var t=n[0],i=n[1],r=n[2],s=n[3],a=n[4],o=n[5],l=n[6],c=n[7],h=e[0],u=e[1],d=e[2],f=e[3],m=e[4],g=e[5],p=e[6],v=e[7];return Math.abs(t-h)<=Ae*Math.max(1,Math.abs(t),Math.abs(h))&&Math.abs(i-u)<=Ae*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-d)<=Ae*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(s-f)<=Ae*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=Ae*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(o-g)<=Ae*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(l-p)<=Ae*Math.max(1,Math.abs(l),Math.abs(p))&&Math.abs(c-v)<=Ae*Math.max(1,Math.abs(c),Math.abs(v))}const cb=Object.freeze(Object.defineProperty({__proto__:null,add:KM,clone:RM,conjugate:nb,copy:Tg,create:PM,dot:Ag,equals:lb,exactEquals:ob,fromMat4:FM,fromRotation:zM,fromRotationTranslation:Sg,fromRotationTranslationValues:DM,fromTranslation:OM,fromValues:IM,getDual:BM,getReal:UM,getTranslation:GM,identity:NM,invert:tb,len:ib,length:Cg,lerp:eb,mul:JM,multiply:Eg,normalize:sb,rotateAroundAxis:jM,rotateByQuatAppend:YM,rotateByQuatPrepend:ZM,rotateX:$M,rotateY:qM,rotateZ:XM,scale:QM,set:kM,setDual:VM,setReal:HM,sqrLen:rb,squaredLength:mc,str:ab,translate:WM},Symbol.toStringTag,{value:"Module"}));function Lg(){var n=new je(2);return je!=Float32Array&&(n[0]=0,n[1]=0),n}function hb(n){var e=new je(2);return e[0]=n[0],e[1]=n[1],e}function ub(n,e){var t=new je(2);return t[0]=n,t[1]=e,t}function db(n,e){return n[0]=e[0],n[1]=e[1],n}function fb(n,e,t){return n[0]=e,n[1]=t,n}function pb(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Pg(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Rg(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function Ig(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function mb(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function gb(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function vb(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function _b(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function yb(n,e){return n[0]=Math.round(e[0]),n[1]=Math.round(e[1]),n}function xb(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function wb(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function Dg(n,e){var t=e[0]-n[0],i=e[1]-n[1];return Math.hypot(t,i)}function Og(n,e){var t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function zg(n){var e=n[0],t=n[1];return Math.hypot(e,t)}function Fg(n){var e=n[0],t=n[1];return e*e+t*t}function Mb(n,e){return n[0]=-e[0],n[1]=-e[1],n}function bb(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function Sb(n,e){var t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function Tb(n,e){return n[0]*e[0]+n[1]*e[1]}function Eb(n,e,t){var i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function Ab(n,e,t,i){var r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function Cb(n,e){e=e||1;var t=jn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function Lb(n,e,t){var i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function Pb(n,e,t){var i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function Rb(n,e,t){var i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function Ib(n,e,t){var i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function Db(n,e,t,i){var r=e[0]-t[0],s=e[1]-t[1],a=Math.sin(i),o=Math.cos(i);return n[0]=r*o-s*a+t[0],n[1]=r*a+s*o+t[1],n}function Ob(n,e){var t=n[0],i=n[1],r=e[0],s=e[1],a=Math.sqrt(t*t+i*i)*Math.sqrt(r*r+s*s),o=a&&(t*r+i*s)/a;return Math.acos(Math.min(Math.max(o,-1),1))}function zb(n){return n[0]=0,n[1]=0,n}function Fb(n){return"vec2("+n[0]+", "+n[1]+")"}function Nb(n,e){return n[0]===e[0]&&n[1]===e[1]}function kb(n,e){var t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=Ae*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=Ae*Math.max(1,Math.abs(i),Math.abs(s))}var Ub=zg,Bb=Pg,Hb=Rg,Vb=Ig,Gb=Dg,Wb=Og,$b=Fg,qb=function(){var n=Lg();return function(e,t,i,r,s,a){var o,l;for(t||(t=2),i||(i=0),r?l=Math.min(r*t+i,e.length):l=e.length,o=i;o>6}return n+=n<<3,n^=n>>11,n+=n<<15,n>=0?n:-n}var gc=nT;function iT(n,e){return(+n%(e=+e)+e)%e}var yr=iT,rd=yr,rT=64;function ls(n){if(n!=null&&(!isFinite(n)||Math.floor(n)!==n||n<1))throw new Error("Set: invalid capacity");this._capacity=this._capacity||rT,this._buckets=[];for(var e=0;e0;){var o=i.pop();if(!r.has(o)&&n.intersects(o.vertices(s))){r.add(o);for(var l=o.neighbors(),c=0;ce?1:0}var po=oT,lT=po;function cT(n,e){for(var t=[],i=0;i=c||p<0||p>=h){var _=this.centerX(),w=this.centerY();g<0?(gn.set(i,-.5,w,-.5),x=Jo[r][0]):g>=c?(gn.set(i,.5,w,-.5),x=Jo[r][1]):p<0?(gn.set(i,_,.5,-.5),x=Jo[r][2]):p>=h&&(gn.set(i,_,-.5,-.5),x=Jo[r][3]);var y;y=is[r],Za(i,0,y.x,y.y),y=is[x],Za(i,0,-y.x,-y.y),g=ac(Math.floor((.5+i[0])*c),0,c-1),p=ac(Math.floor((.5-i[1])*h),0,h-1)}u.push(new Dt(x,g,p,v,n))}return e.set(this,u),u};Dt.prototype.hash=function(){return fT(ns.indexOf(this.face),this.z,this.y,this.x)};Dt.prototype.equals=function(n){return this._geometry===n._geometry&&this.face===n.face&&this.z===n.z&&this.y===n.y&&this.x===n.x};Dt.prototype.cmp=function(n){return Ko(this.z,n.z)||Ko(ns.indexOf(this.face),ns.indexOf(n.face))||Ko(this.y,n.y)||Ko(this.x,n.x)};Dt.prototype.str=function(){return"CubeTile("+tile.face+", "+tile.x+", "+tile.y+", "+tile.z+")"};function cs(n){if(this.constructor.super_.call(this,n),this._size=n.size,this._tileSize=n.tileSize,this._size%this._tileSize!==0)throw new Error("Level size is not multiple of tile size: "+this._size+" "+this._tileSize)}dT(cs,gT);cs.prototype.width=function(){return this._size};cs.prototype.height=function(){return this._size};cs.prototype.tileWidth=function(){return this._tileSize};cs.prototype.tileHeight=function(){return this._tileSize};cs.prototype._validateWithParentLevel=function(n){var e=this.width(),t=this.height(),i=this.tileWidth(),r=this.tileHeight(),s=this.numHorizontalTiles(),a=this.numVerticalTiles(),o=n.width(),l=n.height(),c=n.tileWidth(),h=n.tileHeight(),u=n.numHorizontalTiles(),d=n.numVerticalTiles();if(e%o!==0)throw new Error("Level width must be multiple of parent level: "+e+" vs. "+o);if(t%l!==0)throw new Error("Level height must be multiple of parent level: "+t+" vs. "+l);if(s%u!==0)throw new Error("Number of horizontal tiles must be multiple of parent level: "+s+" ("+e+"/"+i+") vs. "+u+" ("+o+"/"+c+")");if(a%d!==0)throw new Error("Number of vertical tiles must be multiple of parent level: "+a+" ("+t+"/"+r+") vs. "+d+" ("+l+"/"+h+")")};function Fi(n){if(yT(n)!=="array")throw new Error("Level list must be an array");this.levelList=vT(n,cs),this.selectableLevelList=_T(this.levelList);for(var e=1;e=0&&(s=!0)}if(!s)return!1}return!0};Ue.prototype.selectLevel=function(n){for(var e=e0()*this._height,t=Math.tan(.5*this._fov),i=0;i=e)return r}return n[n.length-1]};Ue.prototype.coordinatesToScreen=function(n,e){var t=this._tmpVec;e||(e={});var i=this._width,r=this._height;if(i<=0||r<=0)return e.x=null,e.y=null,null;var s=n.yaw,a=n.pitch,o=Math.sin(s)*Math.cos(a),l=-Math.sin(a),c=-Math.cos(s)*Math.cos(a);if(tn.set(t,o,l,c,1),tn.transformMat4(t,t,this.projection()),t[3]>=0)e.x=i*(t[0]/t[3]+1)/2,e.y=r*(1-t[1]/t[3])/2;else return e.x=null,e.y=null,null;return e};Ue.prototype.screenToCoordinates=function(n,e){var t=this._tmpVec;e||(e={});var i=this._width,r=this._height,s=2*n.x/i-1,a=1-2*n.y/r;tn.set(t,s,a,1,1),tn.transformMat4(t,t,this.inverseProjection());var o=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);return e.yaw=Math.atan2(t[0],-t[2]),e.pitch=Math.acos(t[1]/o)-Math.PI/2,this._normalizeCoordinates(e),e};Ue.prototype.coordinatesToPerspectiveTransform=function(n,e,t){t=t||"";var i=this._height,r=this._width,s=this._fov,a=.5*i/Math.tan(s/2),o="";return o+="translateX("+ii(r/2)+"px) ",o+="translateY("+ii(i/2)+"px) ",o+="translateX(-50%) translateY(-50%) ",o+="perspective("+ii(a)+"px) ",o+="translateZ("+ii(a)+"px) ",o+="rotateZ("+ii(-this._roll)+"rad) ",o+="rotateX("+ii(-this._pitch)+"rad) ",o+="rotateY("+ii(this._yaw)+"rad) ",o+="rotateY("+ii(-n.yaw)+"rad) ",o+="rotateX("+ii(n.pitch)+"rad) ",o+="translateZ("+ii(-e)+"px) ",o+=t+" ",o};Ue.limit={yaw:function(n,e){return function(i){return i.yaw=Hr(i.yaw,n,e),i}},pitch:function(n,e){return function(i){return i.pitch=Hr(i.pitch,n,e),i}},roll:function(n,e){return function(i){return i.roll=Hr(i.roll,n,e),i}},hfov:function(n,e){return function(i){var r=i.width,s=i.height;if(r>0&&s>0){var a=ja.htov(n,r,s),o=ja.htov(e,r,s);i.fov=Hr(i.fov,a,o)}return i}},vfov:function(n,e){return function(i){return i.fov=Hr(i.fov,n,e),i}},resolution:function(n){return function(t){var i=t.height;if(i){var r=e0()*i,s=2*Math.atan(r/n);t.fov=Hr(t.fov,s,1/0)}return t}},traditional:function(n,e,t){return t=t??e,YT(Ue.limit.resolution(n),Ue.limit.vfov(0,e),Ue.limit.hfov(0,t),Ue.limit.pitch(-Math.PI/2,Math.PI/2))}};Ue.type=Ue.prototype.type="rectilinear";var r2=Ue,s2=Et,oc=rn.mat4,Ka=rn.vec4,t0=pc,xs=od,Pi=la,a2=wt,o2=0,l2=0,n0=.5,i0=.5,c2=1,h2=[1,0,1,0],u2=[-1,-1,1,1],d2=1e-6;function tt(n,e){if(!(n&&n.mediaAspectRatio!=null))throw new Error("mediaAspectRatio must be defined");this._x=n&&n.x!=null?n.x:n0,this._y=n&&n.y!=null?n.y:i0,this._zoom=n&&n.zoom!=null?n.zoom:c2,this._mediaAspectRatio=n.mediaAspectRatio,this._width=n&&n.width!=null?n.width:o2,this._height=n&&n.height!=null?n.height:l2,this._limiter=e||null,this._projMatrix=oc.create(),this._invProjMatrix=oc.create(),this._frustum=[0,0,0,0],this._projectionChanged=!0,this._params={},this._vec=Ka.create(),this._update()}s2(tt);tt.prototype.destroy=function(){a2(this)};tt.prototype.x=function(){return this._x};tt.prototype.y=function(){return this._y};tt.prototype.zoom=function(){return this._zoom};tt.prototype.mediaAspectRatio=function(){return this._mediaAspectRatio};tt.prototype.width=function(){return this._width};tt.prototype.height=function(){return this._height};tt.prototype.size=function(n){return n=n||{},n.width=this._width,n.height=this._height,n};tt.prototype.parameters=function(n){return n=n||{},n.x=this._x,n.y=this._y,n.zoom=this._zoom,n.mediaAspectRatio=this._mediaAspectRatio,n};tt.prototype.limiter=function(){return this._limiter};tt.prototype.setX=function(n){this._resetParams(),this._params.x=n,this._update(this._params)};tt.prototype.setY=function(n){this._resetParams(),this._params.y=n,this._update(this._params)};tt.prototype.setZoom=function(n){this._resetParams(),this._params.zoom=n,this._update(this._params)};tt.prototype.offsetX=function(n){this.setX(this._x+n)};tt.prototype.offsetY=function(n){this.setY(this._y+n)};tt.prototype.offsetZoom=function(n){this.setZoom(this._zoom+n)};tt.prototype.setMediaAspectRatio=function(n){this._resetParams(),this._params.mediaAspectRatio=n,this._update(this._params)};tt.prototype.setSize=function(n){this._resetParams(),this._params.width=n.width,this._params.height=n.height,this._update(this._params)};tt.prototype.setParameters=function(n){this._resetParams(),this._params.x=n.x,this._params.y=n.y,this._params.zoom=n.zoom,this._params.mediaAspectRatio=n.mediaAspectRatio,this._update(this._params)};tt.prototype.setLimiter=function(n){this._limiter=n||null,this._update()};tt.prototype._resetParams=function(){var n=this._params;n.x=null,n.y=null,n.zoom=null,n.mediaAspectRatio=null,n.width=null,n.height=null};tt.prototype._update=function(n){n==null&&(this._resetParams(),n=this._params);var e=this._x,t=this._y,i=this._zoom,r=this._mediaAspectRatio,s=this._width,a=this._height;if(n.x=n.x!=null?n.x:e,n.y=n.y!=null?n.y:t,n.zoom=n.zoom!=null?n.zoom:i,n.mediaAspectRatio=n.mediaAspectRatio!=null?n.mediaAspectRatio:r,n.width=n.width!=null?n.width:s,n.height=n.height!=null?n.height:a,this._limiter&&(n=this._limiter(n),!n))throw new Error("Bad view limiter");var o=n.x,l=n.y,c=n.zoom,h=n.mediaAspectRatio,u=n.width,d=n.height;if(!xs(o)||!xs(l)||!xs(c)||!xs(h)||!xs(u)||!xs(d))throw new Error("Bad view - suspect a broken limiter");c=Pi(c,d2,1/0),this._x=o,this._y=l,this._zoom=c,this._mediaAspectRatio=h,this._width=u,this._height=d,(o!==e||l!==t||c!==i||h!==r||u!==s||d!==a)&&(this._projectionChanged=!0,this.emit("change")),(u!==s||d!==a)&&this.emit("resize")};tt.prototype._zoomX=function(){return this._zoom};tt.prototype._zoomY=function(){var n=this._mediaAspectRatio,e=this._width/this._height,t=this._zoom,i=t*n/e;return isNaN(i)&&(i=t),i};tt.prototype.updateWithControlParameters=function(n){var e=this.zoom(),t=this._zoomX(),i=this._zoomY();this.offsetX(n.axisScaledX*t+n.x*e),this.offsetY(n.axisScaledY*i+n.y*e),this.offsetZoom(n.zoom*e)};tt.prototype._updateProjection=function(){var n=this._projMatrix,e=this._invProjMatrix,t=this._frustum;if(this._projectionChanged){var i=this._x,r=this._y,s=this._zoomX(),a=this._zoomY(),o=t[0]=.5-r+.5*a,l=t[1]=i-.5+.5*s,c=t[2]=.5-r-.5*a,h=t[3]=i-.5-.5*s;oc.ortho(n,h,l,c,o,-1,1),oc.invert(e,n),this._projectionChanged=!1}};tt.prototype.projection=function(){return this._updateProjection(),this._projMatrix};tt.prototype.inverseProjection=function(){return this._updateProjection(),this._invProjMatrix};tt.prototype.intersects=function(n){this._updateProjection();for(var e=this._frustum,t=0;t0&&l[r]>i){a=!0;break}}if(!a)return!1}return!0};tt.prototype.selectLevel=function(n){for(var e=t0()*this.width(),t=this._zoom,i=0;i=e)return r}return n[n.length-1]};tt.prototype.coordinatesToScreen=function(n,e){var t=this._vec;e||(e={});var i=this._width,r=this._height;if(i<=0||r<=0)return e.x=null,e.y=null,null;var s=n&&n.x!=null?n.x:n0,a=n&&n.y!=null?n.y:i0;Ka.set(t,s-.5,.5-a,-1,1),Ka.transformMat4(t,t,this.projection());for(var o=0;o<3;o++)t[o]/=t[3];return e.x=i*(t[0]+1)/2,e.y=r*(1-t[1])/2,e};tt.prototype.screenToCoordinates=function(n,e){var t=this._vec;e||(e={});var i=this._width,r=this._height,s=2*n.x/i-1,a=1-2*n.y/r;return Ka.set(t,s,a,1,1),Ka.transformMat4(t,t,this.inverseProjection()),e.x=.5+t[0],e.y=.5-t[1],e};tt.limit={x:function(n,e){return function(i){return i.x=Pi(i.x,n,e),i}},y:function(n,e){return function(i){return i.y=Pi(i.y,n,e),i}},zoom:function(n,e){return function(i){return i.zoom=Pi(i.zoom,n,e),i}},resolution:function(n){return function(t){if(t.width<=0||t.height<=0)return t;var i=t.width,r=t0()*i/n;return t.zoom=Pi(t.zoom,r,1/0),t}},visibleX:function(n,e){return function(i){var r=e-n;i.zoom>r&&(i.zoom=r);var s=n+.5*i.zoom,a=e-.5*i.zoom;return i.x=Pi(i.x,s,a),i}},visibleY:function(n,e){return function(i){if(i.width<=0||i.height<=0)return i;var r=i.width/i.height,s=r/i.mediaAspectRatio,a=(e-n)*s;i.zoom>a&&(i.zoom=a);var o=n+.5*i.zoom/s,l=e-.5*i.zoom/s;return i.y=Pi(i.y,o,l),i}},letterbox:function(){return function(e){if(e.width<=0||e.height<=0)return e;var t=e.width/e.height,i=1,r=t/e.mediaAspectRatio;e.mediaAspectRatio>=t&&(e.zoom=Math.min(e.zoom,i)),e.mediaAspectRatio<=t&&(e.zoom=Math.min(e.zoom,r));var s,a;e.zoom>i?s=a=.5:(s=0+.5*e.zoom/i,a=1-.5*e.zoom/i);var o,l;return e.zoom>r?o=l=.5:(o=0+.5*e.zoom/r,l=1-.5*e.zoom/r),e.x=Pi(e.x,s,a),e.y=Pi(e.y,o,l),e}}};tt.type=tt.prototype.type="flat";var f2=tt,p2=_m,m2=yr;function vo(n){this._concurrency=n&&n.concurrency||1,this._paused=n&&!!n.paused||!1,this._pool=[];for(var e=0;e0?this._pinMap.set(n,e):(this._pinMap.del(n),!this._visible.has(n)&&!this._previouslyVisible.has(n)&&this._unloadTile(n));else throw new Error("TextureStore: unpin when not pinned");return e};Qt.prototype.query=function(n){var e=this._itemMap.get(n),t=this._pinMap.get(n)||0;return{visible:this._visible.has(n),previouslyVisible:this._previouslyVisible.has(n),hasAsset:e!=null&&e.asset()!=null,hasTexture:e!=null&&e.texture()!=null,pinned:t!==0,pinCount:t}};var l0=Qt;function K2(n,e){for(var t in e)n[t]=e[t];return n}var c0=K2,J2=Et,Q2=c0,eE=wt;function en(n,e,t,i,r){r=r||{};var s=this;this._source=n,this._geometry=e,this._view=t,this._textureStore=i,this._effects=r.effects||{},this._fixedLevelIndex=null,this._viewChangeHandler=function(){s.emit("viewChange",s.view())},this._view.addEventListener("change",this._viewChangeHandler),this._textureStoreChangeHandler=function(){s.emit("textureStoreChange",s.textureStore())},this._textureStore.addEventListener("textureLoad",this._textureStoreChangeHandler),this._textureStore.addEventListener("textureError",this._textureStoreChangeHandler),this._textureStore.addEventListener("textureInvalid",this._textureStoreChangeHandler)}J2(en);en.prototype.destroy=function(){this._view.removeEventListener("change",this._viewChangeHandler),this._textureStore.removeEventListener("textureLoad",this._textureStoreChangeHandler),this._textureStore.removeEventListener("textureError",this._textureStoreChangeHandler),this._textureStore.removeEventListener("textureInvalid",this._textureStoreChangeHandler),eE(this)};en.prototype.source=function(){return this._source};en.prototype.geometry=function(){return this._geometry};en.prototype.view=function(){return this._view};en.prototype.textureStore=function(){return this._textureStore};en.prototype.effects=function(){return this._effects};en.prototype.setEffects=function(n){this._effects=n,this.emit("effectsChange",this._effects)};en.prototype.mergeEffects=function(n){Q2(this._effects,n),this.emit("effectsChange",this._effects)};en.prototype.fixedLevel=function(){return this._fixedLevelIndex};en.prototype.setFixedLevel=function(n){if(n!==this._fixedLevelIndex){if(n!=null&&(n>=this._geometry.levelList.length||n<0))throw new Error("Level index out of range: "+n);this._fixedLevelIndex=n,this.emit("fixedLevelChange",this._fixedLevelIndex)}};en.prototype._selectLevel=function(){var n;return this._fixedLevelIndex!=null?n=this._geometry.levelList[this._fixedLevelIndex]:n=this._view.selectLevel(this._geometry.selectableLevelList),n};en.prototype.visibleTiles=function(n){var e=this._selectLevel();return this._geometry.visibleTiles(this._view,e,n)};en.prototype.pinLevel=function(n){for(var e=this._geometry.levelList[n],t=this._geometry.levelTiles(e),i=0;i0?Math.max(0,n-e):0}var Wi=ki,rE=Et,sE=Wi,aE=wt;function ha(n,e,t,i,r){if(!n)throw new Error("KeyControlMethod: keyCode must be defined");if(!e)throw new Error("KeyControlMethod: parameter must be defined");if(!t)throw new Error("KeyControlMethod: velocity must be defined");if(!i)throw new Error("KeyControlMethod: friction must be defined");r=r||document,this._keyCode=n,this._parameter=e,this._velocity=t,this._friction=i,this._element=r,this._keydownHandler=this._handlePress.bind(this),this._keyupHandler=this._handleRelease.bind(this),this._blurHandler=this._handleBlur.bind(this),this._element.addEventListener("keydown",this._keydownHandler),this._element.addEventListener("keyup",this._keyupHandler),window.addEventListener("blur",this._blurHandler),this._dynamics=new sE,this._pressing=!1}rE(ha);ha.prototype.destroy=function(){this._element.removeEventListener("keydown",this._keydownHandler),this._element.removeEventListener("keyup",this._keyupHandler),window.removeEventListener("blur",this._blurHandler),aE(this)};ha.prototype._handlePress=function(n){n.keyCode===this._keyCode&&(this._pressing=!0,this._dynamics.velocity=this._velocity,this._dynamics.friction=0,this.emit("parameterDynamics",this._parameter,this._dynamics),this.emit("active"))};ha.prototype._handleRelease=function(n){n.keyCode===this._keyCode&&(this._pressing&&(this._dynamics.friction=this._friction,this.emit("parameterDynamics",this._parameter,this._dynamics),this.emit("inactive")),this._pressing=!1)};ha.prototype._handleBlur=function(){this._dynamics.velocity=0,this.emit("parameterDynamics",this._parameter,this._dynamics),this.emit("inactive"),this._pressing=!1};var d0=ha,lc={},oE={get exports(){return lc},set exports(n){lc=n}};/*! Hammer.JS - v2.0.4 - 2014-09-28 * http://hammerjs.github.io/ * * Copyright (c) 2014 Jorik Tangelder; * Licensed under the MIT license */(function(n){(function(e,t,i,r){var s=["","webkit","moz","MS","ms","o"],a=t.createElement("div"),o="function",l=Math.round,c=Math.abs,h=Date.now;function u(A,I,N){return setTimeout(v(A,N),I)}function d(A,I,N){return Array.isArray(A)?(f(A,N[I],N),!0):!1}function f(A,I,N){var j;if(A)if(A.forEach)A.forEach(I,N);else if(A.length!==r)for(j=0;j-1}function M(A){return A.trim().split(/\s+/g)}function T(A,I,N){if(A.indexOf&&!N)return A.indexOf(I);for(var j=0;jni[I]}):j=j.sort()),j}function U(A,I){for(var N,j,fe=I[0].toUpperCase()+I.slice(1),He=0;He1&&!N.firstMultiple?N.firstMultiple=re(I):fe===1&&(N.firstMultiple=!1);var He=N.firstInput,ct=N.firstMultiple,on=ct?ct.center:He.center,fn=I.center=ae(j);I.timeStamp=h(),I.deltaTime=I.timeStamp-He.timeStamp,I.angle=q(on,fn),I.distance=oe(on,fn),E(N,I),I.offsetDirection=Te(I.deltaX,I.deltaY),I.scale=ct?Ne(ct.pointers,j):1,I.rotation=ct?Le(ct.pointers,j):0,H(N,I);var ni=A.element;b(I.srcEvent.target,ni)&&(ni=I.srcEvent.target),I.target=ni}function E(A,I){var N=I.center,j=A.offsetDelta||{},fe=A.prevDelta||{},He=A.prevInput||{};(I.eventType===he||He.eventType===we)&&(fe=A.prevDelta={x:He.deltaX||0,y:He.deltaY||0},j=A.offsetDelta={x:N.x,y:N.y}),I.deltaX=fe.x+(N.x-j.x),I.deltaY=fe.y+(N.y-j.y)}function H(A,I){var N=A.lastInterval||I,j=I.timeStamp-N.timeStamp,fe,He,ct,on;if(I.eventType!=ge&&(j>de||N.velocity===r)){var fn=N.deltaX-I.deltaX,ni=N.deltaY-I.deltaY,ys=me(j,fn,ni);He=ys.x,ct=ys.y,fe=c(ys.x)>c(ys.y)?ys.x:ys.y,on=Te(fn,ni),A.lastInterval=I}else fe=N.velocity,He=N.velocityX,ct=N.velocityY,on=N.direction;I.velocity=fe,I.velocityX=He,I.velocityY=ct,I.direction=on}function re(A){for(var I=[],N=0;N=c(I)?A>0?ve:Ve:I>0?te:ee}function oe(A,I,N){N||(N=Be);var j=I[N[0]]-A[N[0]],fe=I[N[1]]-A[N[1]];return Math.sqrt(j*j+fe*fe)}function q(A,I,N){N||(N=Be);var j=I[N[0]]-A[N[0]],fe=I[N[1]]-A[N[1]];return Math.atan2(fe,j)*180/Math.PI}function Le(A,I){return q(I[1],I[0],De)-q(A[1],A[0],De)}function Ne(A,I){return oe(I[0],I[1],De)/oe(A[0],A[1],De)}var Ee={mousedown:he,mousemove:X,mouseup:we},Pe="mousedown",Re="mousemove mouseup";function Qe(){this.evEl=Pe,this.evWin=Re,this.allow=!0,this.pressed=!1,Se.apply(this,arguments)}p(Qe,Se,{handler:function(I){var N=Ee[I.type];N&he&&I.button===0&&(this.pressed=!0),N&X&&I.which!==1&&(N=we),!(!this.pressed||!this.allow)&&(N&we&&(this.pressed=!1),this.callback(this.manager,N,{pointers:[I],changedPointers:[I],pointerType:Y,srcEvent:I}))}});var _t={pointerdown:he,pointermove:X,pointerup:we,pointercancel:ge,pointerout:ge},Nt={2:ie,3:$,4:Y,5:le},k="pointerdown",J="pointermove pointerup pointercancel";e.MSPointerEvent&&(k="MSPointerDown",J="MSPointerMove MSPointerUp MSPointerCancel");function ce(){this.evEl=k,this.evWin=J,Se.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}p(ce,Se,{handler:function(I){var N=this.store,j=!1,fe=I.type.toLowerCase().replace("ms",""),He=_t[fe],ct=Nt[I.pointerType]||I.pointerType,on=ct==ie,fn=T(N,I.pointerId,"pointerId");He&he&&(I.button===0||on)?fn<0&&(N.push(I),fn=N.length-1):He&(we|ge)&&(j=!0),!(fn<0)&&(N[fn]=I,this.callback(this.manager,He,{pointers:N,changedPointers:[I],pointerType:ct,srcEvent:I}),j&&N.splice(fn,1))}});var be={touchstart:he,touchmove:X,touchend:we,touchcancel:ge},Ie="touchstart",at="touchstart touchmove touchend touchcancel";function Ot(){this.evTarget=Ie,this.evWin=at,this.started=!1,Se.apply(this,arguments)}p(Ot,Se,{handler:function(I){var N=be[I.type];if(N===he&&(this.started=!0),!!this.started){var j=Zt.call(this,I,N);N&(we|ge)&&j[0].length-j[1].length===0&&(this.started=!1),this.callback(this.manager,N,{pointers:j[0],changedPointers:j[1],pointerType:ie,srcEvent:I})}}});function Zt(A,I){var N=C(A.touches),j=C(A.changedTouches);return I&(we|ge)&&(N=O(N.concat(j),"identifier",!0)),[N,j]}var yi={touchstart:he,touchmove:X,touchend:we,touchcancel:ge},yt="touchstart touchmove touchend touchcancel";function yn(){this.evTarget=yt,this.targetIds={},Se.apply(this,arguments)}p(yn,Se,{handler:function(I){var N=yi[I.type],j=xn.call(this,I,N);j&&this.callback(this.manager,N,{pointers:j[0],changedPointers:j[1],pointerType:ie,srcEvent:I})}});function xn(A,I){var N=C(A.touches),j=this.targetIds;if(I&(he|X)&&N.length===1)return j[N[0].identifier]=!0,[N,N];var fe,He,ct=C(A.changedTouches),on=[],fn=this.target;if(He=N.filter(function(ni){return b(ni.target,fn)}),I===he)for(fe=0;fe-1&&this.requireFail.splice(I,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(A){return!!this.simultaneous[A.id]},emit:function(A){var I=this,N=this.state;function j(fe){I.manager.emit(I.options.event+(fe?xi(N):""),A)}N=Xe&&j(!0)},tryEmit:function(A){if(this.canEmit())return this.emit(A);this.state=bt},canEmit:function(){for(var A=0;AI.threshold&&fe&I.direction},attrTest:function(A){return dn.prototype.attrTest.call(this,A)&&(this.state&ke||!(this.state&ke)&&this.directionTest(A))},emit:function(A){this.pX=A.deltaX,this.pY=A.deltaY;var I=At(A.direction);I&&this.manager.emit(this.options.event+I,A),this._super.emit.call(this,A)}});function Vn(){dn.apply(this,arguments)}p(Vn,dn,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Z]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.scale-1)>this.options.threshold||this.state&ke)},emit:function(A){if(this._super.emit.call(this,A),A.scale!==1){var I=A.scale<1?"in":"out";this.manager.emit(this.options.event+I,A)}}});function _s(){Vt.apply(this,arguments),this._timer=null,this._input=null}p(_s,Vt,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[D]},process:function(A){var I=this.options,N=A.pointers.length===I.pointers,j=A.distanceI.time;if(this._input=A,!j||!N||A.eventType&(we|ge)&&!fe)this.reset();else if(A.eventType&he)this.reset(),this._timer=u(function(){this.state=$e,this.tryEmit()},I.time,this);else if(A.eventType&we)return $e;return bt},reset:function(){clearTimeout(this._timer)},emit:function(A){this.state===$e&&(A&&A.eventType&we?this.manager.emit(this.options.event+"up",A):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}});function wi(){dn.apply(this,arguments)}p(wi,dn,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Z]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.rotation)>this.options.threshold||this.state&ke)}});function Ar(){dn.apply(this,arguments)}p(Ar,dn,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:ue|Me,pointers:1},getTouchAction:function(){return Ct.prototype.getTouchAction.call(this)},attrTest:function(A){var I=this.options.direction,N;return I&(ue|Me)?N=A.velocity:I&ue?N=A.velocityX:I&Me&&(N=A.velocityY),this._super.attrTest.call(this,A)&&I&A.direction&&A.distance>this.options.threshold&&c(N)>this.options.velocity&&A.eventType&we},emit:function(A){var I=At(A.direction);I&&this.manager.emit(this.options.event+I,A),this.manager.emit(this.options.event,A)}});function kt(){Vt.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}p(kt,Vt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[V]},process:function(A){var I=this.options,N=A.pointers.length===I.pointers,j=A.distance=0){var t=this._methods.splice(e,1)[0];t.instance.removeEventListener("parameterDynamics",t.parameterDynamicsHandler)}};Jn.prototype.has=function(n){return this._indexOfInstance(n)>=0};Jn.prototype._indexOfInstance=function(n){for(var e=0;e0&&this.emit("active"),this.emit("enabled"),this._updateComposer())};mt.prototype.disable=function(){this._enabled&&(this._enabled=!1,this._activeCount>0&&this.emit("inactive"),this.emit("disabled"),this._updateComposer())};mt.prototype.attach=function(n){this._attachedRenderLoop&&this.detach(),this._attachedRenderLoop=n,this._beforeRenderHandler=this._updateViewsWithControls.bind(this),this._changeHandler=n.renderOnNextFrame.bind(n),this._attachedRenderLoop.addEventListener("beforeRender",this._beforeRenderHandler),this._composer.addEventListener("change",this._changeHandler)};mt.prototype.detach=function(){this._attachedRenderLoop&&(this._attachedRenderLoop.removeEventListener("beforeRender",this._beforeRenderHandler),this._composer.removeEventListener("change",this._changeHandler),this._beforeRenderHandler=null,this._changeHandler=null,this._attachedRenderLoop=null)};mt.prototype.attached=function(){return this._attachedRenderLoop!=null};mt.prototype._listen=function(n){var e=this._methods[n];if(!e)throw new Error("Bad method id");e.instance.addEventListener("active",e.activeHandler),e.instance.addEventListener("inactive",e.inactiveHandler)};mt.prototype._unlisten=function(n){var e=this._methods[n];if(!e)throw new Error("Bad method id");e.instance.removeEventListener("active",e.activeHandler),e.instance.removeEventListener("inactive",e.inactiveHandler)};mt.prototype._handleActive=function(n){var e=this._methods[n];if(!e)throw new Error("Bad method id");if(!e.enabled)throw new Error("Should not receive event from disabled control method");e.active||(e.active=!0,this._incrementActiveCount())};mt.prototype._handleInactive=function(n){var e=this._methods[n];if(!e)throw new Error("Bad method id");if(!e.enabled)throw new Error("Should not receive event from disabled control method");e.active&&(e.active=!1,this._decrementActiveCount())};mt.prototype._incrementActiveCount=function(){this._activeCount++,w0&&this._checkActiveCount(),this._enabled&&this._activeCount===1&&this.emit("active")};mt.prototype._decrementActiveCount=function(){this._activeCount--,w0&&this._checkActiveCount(),this._enabled&&this._activeCount===0&&this.emit("inactive")};mt.prototype._checkActiveCount=function(){var n=0;for(var e in this._methods){var t=this._methods[e];t.enabled&&t.active&&n++}if(n!=this._activeCount)throw new Error("Bad control state")};mt.prototype._updateComposer=function(){var n=this._composer;for(var e in this._methods){var t=this._methods[e],i=this._enabled&&t.enabled;i&&!n.has(t.instance)&&n.add(t.instance),!i&&n.has(t.instance)&&n.remove(t.instance)}};mt.prototype._updateViewsWithControls=function(){var n=this._composer.offsets();n.changing&&this._attachedRenderLoop.renderOnNextFrame(),this.updatedViews_.length=0;for(var e=this._attachedRenderLoop.stage().listLayers(),t=0;t=0};In.prototype.listHotspots=function(){return[].concat(this._hotspots)};In.prototype.destroyHotspot=function(n){var e=this._hotspots.indexOf(n);if(e<0)throw new Error("No such hotspot");this._hotspots.splice(e,1),n.destroy(),this.emit("hotspotsChange")};In.prototype.hide=function(){this._visible&&(this._visible=!1,this._visibilityOrRectChanged=!0,this._update())};In.prototype.show=function(){this._visible||(this._visible=!0,this._visibilityOrRectChanged=!0,this._update())};In.prototype._update=function(){var n=this._hotspotContainerWrapper,e=this._stage.width(),t=this._stage.height(),i=this._tmpRect;if(this._visibilityOrRectChanged||this._rect&&(e!==this._stageWidth||t!==this._stageHeight)){var r=this._visible;n.style.display=r?"block":"none",r&&(this._rect?(t3(e,t,this._rect,i),Mf(n,e*i.x,t*i.y),s3(n,e*i.width,t*i.height),n3(n)):(Mf(n,0,0),r3(n),i3(n))),this._stageWidth=e,this._stageHeight=t,this._visibilityOrRectChanged=!1}for(var s=0;s0;)this.destroyLayer(this._layers[0])};Yt.prototype.switchTo=function(n,e){return this._viewer.switchScene(this,n,e)};Yt.prototype.lookTo=function(n,e,t){var i=this;if(e=e||{},t=t||u3,d3(n)!=="object")throw new Error("Target view parameters must be an object");var r=function(m){return(m*=2)<1?.5*m*m:-.5*(--m*(m-2)-1)},s=e.ease!=null?e.ease:r,a=e.controlsInterrupt!=null?e.controlsInterrupt:!1,o=e.transitionDuration!=null?e.transitionDuration:1e3,l=e.shortest!=null?e.shortest:!0,c=this._view,h=c.parameters(),u={};Tf(u,n),Tf(u,h),l&&c.normalizeToClosest&&c.normalizeToClosest(u,u);var d=function(){var m=!1;return function(g,p){if(p>=o&&m)return null;var v=Math.min(p/o,1);for(var x in g){var _=h[x],w=u[x];g[x]=_+s(v)*(w-_)}return m=p>=o,g}},f=this._viewer.controls().enabled();a||this._viewer.controls().disable(),this.startMovement(d,function(){f&&i._viewer.controls().enable(),t()})};Yt.prototype.startMovement=function(n,e){var t=this._viewer.renderLoop();this._movement&&this.stopMovement();var i=n();if(typeof i!="function")throw new Error("Bad movement");this._movement=n,this._movementStep=i,this._movementStartTime=E0(),this._movementParams={},this._movementCallback=e,t.addEventListener("beforeRender",this._updateMovementHandler),t.renderOnNextFrame()};Yt.prototype.stopMovement=function(){var n=this._movementCallback,e=this._viewer.renderLoop();this._movement&&(this._movement=null,this._movementStep=null,this._movementStartTime=null,this._movementParams=null,this._movementCallback=null,e.removeEventListener("beforeRender",this._updateMovementHandler),n&&n())};Yt.prototype.movement=function(){return this._movement};Yt.prototype._updateMovement=function(){if(!this._movement)throw new Error("Should not call update");var n=this._viewer.renderLoop(),e=this._view,t=E0()-this._movementStartTime,i=this._movementStep,r=this._movementParams;r=e.parameters(r),r=i(r,t),r==null?this.stopMovement():(e.setParameters(r),n.renderOnNextFrame())};Yt.prototype._updateHotspotContainer=function(){this.visible()?this._hotspotContainer.show():this._hotspotContainer.hide()};var A0=Yt,p3=Et,m3=gi,C0=os,g3={duration:1/0};function vi(n){n=m3(n||{},g3),this._duration=n.duration,this._startTime=null,this._handle=null,this._check=this._check.bind(this)}p3(vi);vi.prototype.start=function(){this._startTime=C0(),this._handle==null&&this._duration<1/0&&this._setup(this._duration)};vi.prototype.started=function(){return this._startTime!=null};vi.prototype.stop=function(){this._startTime=null,this._handle!=null&&(clearTimeout(this._handle),this._handle=null)};vi.prototype._setup=function(n){this._handle=setTimeout(this._check,n)};vi.prototype._teardown=function(){clearTimeout(this._handle),this._handle=null};vi.prototype._check=function(){var n=C0(),e=n-this._startTime,t=this._duration-e;this._teardown(),t<=0?(this.emit("timeout"),this._startTime=null):t<1/0&&this._setup(t)};vi.prototype.duration=function(){return this._duration};vi.prototype.setDuration=function(n){this._duration=n,this._startTime!=null&&this._check()};var v3=vi,_3=gi,y3=wt,x3={active:"move",inactive:"default",disabled:"default"};function da(n,e,t,i){i=_3(i||{},x3),this._element=t,this._controls=n,this._id=e,this._attached=!1,this._setActiveCursor=this._setCursor.bind(this,i.active),this._setInactiveCursor=this._setCursor.bind(this,i.inactive),this._setDisabledCursor=this._setCursor.bind(this,i.disabled),this._setOriginalCursor=this._setCursor.bind(this,this._element.style.cursor),this._updateAttachmentHandler=this._updateAttachment.bind(this),n.addEventListener("methodEnabled",this._updateAttachmentHandler),n.addEventListener("methodDisabled",this._updateAttachmentHandler),n.addEventListener("enabled",this._updateAttachmentHandler),n.addEventListener("disabled",this._updateAttachmentHandler),this._updateAttachment()}da.prototype.destroy=function(){this._detachFromControlMethod(this._controls.method(this._id)),this._setOriginalCursor(),this._controls.removeEventListener("methodEnabled",this._updateAttachmentHandler),this._controls.removeEventListener("methodDisabled",this._updateAttachmentHandler),this._controls.removeEventListener("enabled",this._updateAttachmentHandler),this._controls.removeEventListener("disabled",this._updateAttachmentHandler),y3(this)};da.prototype._updateAttachment=function(){var n=this._controls,e=this._id;n.enabled()&&n.method(e).enabled?this._attachToControlMethod(n.method(e)):this._detachFromControlMethod(n.method(e))};da.prototype._attachToControlMethod=function(n){this._attached||(n.instance.addEventListener("active",this._setActiveCursor),n.instance.addEventListener("inactive",this._setInactiveCursor),n.active?this._setActiveCursor():this._setInactiveCursor(),this._attached=!0)};da.prototype._detachFromControlMethod=function(n){this._attached&&(n.instance.removeEventListener("active",this._setActiveCursor),n.instance.removeEventListener("inactive",this._setInactiveCursor),this._setDisabledCursor(),this._attached=!1)};da.prototype._setCursor=function(n){this._element.style.cursor=n};var w3=da,M3=gi,th=g0,b3=v0,S3=y0,T3=x0,Dn=d0,E3={mouseViewMode:"drag",dragMode:"pan"};function A3(n,e,t){t=M3(t||{},E3);var i={mouseViewDrag:new th(e,"mouse"),mouseViewQtvr:new b3(e,"mouse"),leftArrowKey:new Dn(37,"x",-.7,3),rightArrowKey:new Dn(39,"x",.7,3),upArrowKey:new Dn(38,"y",-.7,3),downArrowKey:new Dn(40,"y",.7,3),plusKey:new Dn(107,"zoom",-.7,3),minusKey:new Dn(109,"zoom",.7,3),wKey:new Dn(87,"y",-.7,3),aKey:new Dn(65,"x",-.7,3),sKey:new Dn(83,"y",.7,3),dKey:new Dn(68,"x",.7,3),qKey:new Dn(81,"roll",.7,3),eKey:new Dn(69,"roll",-.7,3)},r=["scrollZoom","touchView","pinch"];t.scrollZoom!==!1&&(i.scrollZoom=new S3(e));var s={arrowKeys:["leftArrowKey","rightArrowKey","upArrowKey","downArrowKey"],plusMinusKeys:["plusKey","minusKey"],wasdKeys:["wKey","aKey","sKey","dKey"],qeKeys:["qKey","eKey"]};switch(t.dragMode){case"pinch":i.pinch=new th(e,"touch",{hammerEvent:"pinch"});break;case"pan":i.touchView=new th(e,"touch"),i.pinch=new T3(e,"touch");break;default:throw new Error("Unknown drag mode: "+t.dragMode)}switch(t.mouseViewMode){case"drag":r.push("mouseViewDrag");break;case"qtvr":r.push("mouseViewQtvr");break;default:throw new Error("Unknown mouse view mode: "+t.mouseViewMode)}for(var a in i){var o=i[a];n.registerMethod(a,o),r.indexOf(a)>=0&&n.enableMethod(a)}for(var l in s){var c=s[l];n.addMethodGroup(l,c)}return i}var L0=A3,Ef=os;function C3(n,e,t){var i=!1,r=Ef();function s(){if(!i){var a=(Ef()-r)/n;a<1?(e(a),requestAnimationFrame(s)):(e(1),t())}}return e(0),requestAnimationFrame(s),function(){i=!0,t.apply(null,arguments)}}var P0=C3,L3=Et,P3=u0,R3=M0,I3=A0,D3=v3,O3=Cm,z3=w3,Af=wc,F3=L0,N3=Xg,k3=Sn.setOverflowHidden,U3=Sn.setAbsolute,B3=Sn.setFullSize,H3=P0,V3=_o,G3=wt;function ht(n,e){e=e||{},this._domElement=n,k3(n),this._stage=new O3(e.stage),N3(this._stage),this._domElement.appendChild(this._stage.domElement()),this._controlContainer=document.createElement("div"),U3(this._controlContainer),B3(this._controlContainer),n.appendChild(this._controlContainer),this._size={},this.updateSize(),this._updateSizeListener=this.updateSize.bind(this),window.addEventListener("resize",this._updateSizeListener),this._renderLoop=new P3(this._stage),this._controls=new R3,this._controlMethods=F3(this._controls,this._controlContainer,e.controls),this._controls.attach(this._renderLoop),this._hammerManagerTouch=Af.get(this._controlContainer,"touch"),this._hammerManagerMouse=Af.get(this._controlContainer,"mouse"),this._dragCursor=new z3(this._controls,"mouseViewDrag",n,e.cursors&&e.cursors.drag||{}),this._renderLoop.start(),this._scenes=[],this._currentScene=null,this._replacedScene=null,this._cancelCurrentTween=null,this._layerChangeHandler=this._updateSceneLayers.bind(this),this._viewChangeHandler=this.emit.bind(this,"viewChange"),this._idleTimer=new D3,this._idleTimer.start(),this._resetIdleTimerHandler=this._resetIdleTimer.bind(this),this.addEventListener("viewChange",this._resetIdleTimerHandler),this._triggerIdleTimerHandler=this._triggerIdleTimer.bind(this),this._idleTimer.addEventListener("timeout",this._triggerIdleTimerHandler),this._stopMovementHandler=this.stopMovement.bind(this),this._controls.addEventListener("active",this._stopMovementHandler),this.addEventListener("sceneChange",this._stopMovementHandler),this._idleMovement=null}L3(ht);ht.prototype.destroy=function(){window.removeEventListener("resize",this._updateSizeListener),this._currentScene&&this._removeSceneEventListeners(this._currentScene),this._replacedScene&&this._removeSceneEventListeners(this._replacedScene),this._dragCursor.destroy();for(var n in this._controlMethods)this._controlMethods[n].destroy();for(;this._scenes.length;)this.destroyScene(this._scenes[0]);this._domElement.removeChild(this._stage.domElement()),this._stage.destroy(),this._renderLoop.destroy(),this._controls.destroy(),this._controls=null,this._cancelCurrentTween&&this._cancelCurrentTween(),G3(this)};ht.prototype.updateSize=function(){var n=this._size;n.width=this._domElement.clientWidth,n.height=this._domElement.clientHeight,this._stage.setSize(n)};ht.prototype.stage=function(){return this._stage};ht.prototype.renderLoop=function(){return this._renderLoop};ht.prototype.controls=function(){return this._controls};ht.prototype.domElement=function(){return this._domElement};ht.prototype.createScene=function(n){n=n||{};var e=this.createEmptyScene({view:n.view});return e.createLayer({source:n.source,geometry:n.geometry,pinFirstLevel:n.pinFirstLevel,textureStoreOpts:n.textureStoreOpts,layerOpts:n.layerOpts}),e};ht.prototype.createEmptyScene=function(n){n=n||{};var e=new I3(this,n.view);return this._scenes.push(e),e};ht.prototype._updateSceneLayers=function(){var n,e,t=this._stage,i=this._currentScene,r=this._replacedScene,s=t.listLayers(),a=[];if(r&&(a=a.concat(r.listLayers())),i&&(a=a.concat(i.listLayers())),Math.abs(s.length-a.length)!==1)throw new Error("Stage and scene out of sync");if(a.lengths.length)for(n=0;n0;)this.destroyScene(this._scenes[0])};ht.prototype.hasScene=function(n){return this._scenes.indexOf(n)>=0};ht.prototype.listScenes=function(){return[].concat(this._scenes)};ht.prototype.scene=function(){return this._currentScene};ht.prototype.view=function(){var n=this._currentScene;return n?n.view():null};ht.prototype.lookTo=function(n,e,t){var i=this._currentScene;i&&i.lookTo(n,e,t)};ht.prototype.startMovement=function(n,e){var t=this._currentScene;t&&t.startMovement(n,e)};ht.prototype.stopMovement=function(){var n=this._currentScene;n&&n.stopMovement()};ht.prototype.movement=function(){var n=this._currentScene;if(n)return n.movement()};ht.prototype.setIdleMovement=function(n,e){this._idleTimer.setDuration(n),this._idleMovement=e};ht.prototype.breakIdleMovement=function(){this.stopMovement(),this._resetIdleTimer()};ht.prototype._resetIdleTimer=function(){this._idleTimer.start()};ht.prototype._triggerIdleTimer=function(){var n=this._idleMovement;n&&this.startMovement(n)};var W3=1e3;function $3(n,e,t){var i=e.listLayers();i.forEach(function(r){r.mergeEffects({opacity:n})}),e._hotspotContainer.domElement().style.opacity=n}ht.prototype.switchScene=function(n,e,t){var i=this;e=e||{},t=t||V3;var r=this._stage,s=this._currentScene;if(s===n){t();return}if(this._scenes.indexOf(n)<0)throw new Error("No such scene in viewer");this._cancelCurrentTween&&(this._cancelCurrentTween(),this._cancelCurrentTween=null);var a=s?s.listLayers():[],o=n.listLayers(),l=r.listLayers();if(s&&(l.length!==a.length||l.length>1&&l[0]!=a[0]))throw new Error("Stage not in sync with viewer");for(var c=e.transitionDuration!=null?e.transitionDuration:W3,h=e.transitionUpdate!=null?e.transitionUpdate:$3,u=0;uM?g=Math.min(d+v*s,t):g=Math.max(d-v*s,0),_=g*v,ob.pitch&&(b.pitch=Math.min(o,b.pitch+_))}if(l!=null&&b.fov!==o){var T=.5*f*f/a;Math.abs(l-b.fov)>T?p=Math.min(f+v*a,i):p=Math.max(f-v*a,0),w=p*v,lb.fov&&(b.fov=Math.min(l,b.fov+w))}return h=S,u=m,d=g,f=p,b}}}var tA=eA;function nA(n,e){function t(){e&&e.length>0?n.apply(null,e):n()}setTimeout(t,0)}var iA=nA;function rA(n){return n*Math.PI/180}var sA=rA;function aA(n){return n*180/Math.PI}var oA=aA,On={WebGlStage:Cm,WebGlCubeRenderer:Vg,WebGlFlatRenderer:Wg,WebGlEquirectRenderer:qg,registerDefaultRenderers:Xg,CubeGeometry:wT,FlatGeometry:RT,EquirectGeometry:NT,RectilinearView:r2,FlatView:f2,ImageUrlSource:P2,SingleAssetSource:R2,StaticAsset:$u,DynamicAsset:F2,TextureStore:l0,Layer:h0,RenderLoop:u0,KeyControlMethod:d0,DragControlMethod:g0,QtvrControlMethod:v0,ScrollZoomControlMethod:y0,PinchZoomControlMethod:x0,VelocityControlMethod:OE,ElementPressControlMethod:kE,Controls:M0,Dynamics:Wi,Viewer:q3,Scene:A0,Hotspot:S0,HotspotContainer:T0,colorEffects:K3,registerDefaultControls:L0,autorotate:tA,util:{async:xm,cancelize:wm,chain:cd,clamp:la,clearOwnProperties:wt,cmp:po,compose:Qg,convertFov:Jg,decimal:ld,defaults:gi,defer:iA,degToRad:sA,delay:r0,dom:Sn,extend:c0,hash:gc,inherits:fi,mod:yr,noop:_o,now:os,once:Gu,pixelRatio:pc,radToDeg:oA,real:od,retry:s0,tween:P0,type:go},dependencies:{bowser:ts,glMatrix:rn,eventEmitter:Et,hammerjs:lc}};const Cf=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Oi=(()=>{if(typeof document>"u")return!1;const n=Cf[0],e={};for(const t of Cf)if((t==null?void 0:t[1])in document){for(const[r,s]of t.entries())e[n[r]]=s;return e}return!1})(),Lf={change:Oi.fullscreenchange,error:Oi.fullscreenerror};let An={request(n=document.documentElement,e){return new Promise((t,i)=>{const r=()=>{An.off("change",r),t()};An.on("change",r);const s=n[Oi.requestFullscreen](e);s instanceof Promise&&s.then(r).catch(i)})},exit(){return new Promise((n,e)=>{if(!An.isFullscreen){n();return}const t=()=>{An.off("change",t),n()};An.on("change",t);const i=document[Oi.exitFullscreen]();i instanceof Promise&&i.then(t).catch(e)})},toggle(n,e){return An.isFullscreen?An.exit():An.request(n,e)},onchange(n){An.on("change",n)},onerror(n){An.on("error",n)},on(n,e){const t=Lf[n];t&&document.addEventListener(t,e,!1)},off(n,e){const t=Lf[n];t&&document.removeEventListener(t,e,!1)},raw:Oi};Object.defineProperties(An,{isFullscreen:{get:()=>Boolean(document[Oi.fullscreenElement])},element:{enumerable:!0,get:()=>document[Oi.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>Boolean(document[Oi.fullscreenEnabled])}});Oi||(An={isEnabled:!1});const Qo=An,lA={scenes:[{id:"0-ffl_360_hall",name:"FFL_360_hall",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:3.040927703803046,pitch:.07837767885853353,fov:1.3199838779965631},linkHotspots:[{yaw:2.041897119573256,pitch:.1954954777122495,rotation:4.71238898038469,target:"1-ffl_360_laundry"},{yaw:2.192700119643936,pitch:.06884780062970286,rotation:5.497787143782138,target:"2-ffl_360_booking"},{yaw:2.810787745718697,pitch:.04782076857823725,rotation:0,target:"4-ffl_360_coworking"},{yaw:-2.549866049903736,pitch:.16296850944018537,rotation:7.853981633974483,target:"7-ffl_360_gym"},{yaw:-2.758252116179296,pitch:.06393147813708744,rotation:7.853981633974483,target:"6-ffl_360_playroom"},{yaw:-2.9063682443257655,pitch:.030441573446204018,rotation:7.853981633974483,target:"5-ffl_360_bike"}],infoHotspots:[{yaw:3.167795580473452,pitch:.0587174066254203,title:"First Floor Lounge
",text:"Här ett exempel på vad vi menar med First Floor Lounge.
Framtidens tvättstuga.

En välkomnande gemensam yta för alla grannar.
Belägen i bottenplan och med fria siktlinjer skapar man trygghet för alla som vistas i de gemensamma utrymmena som ingår i First Floor Lounge.
",offset:[0,50]},{yaw:2.3920577067600637,pitch:.03884909945629033,title:"First Floor Lounge
",text:"Vi vill att alla som tvättar - eller på annat sätt vistas i First Floor Lounge - ska känna sig trygga.

Samtidigt som man inväntar sin tvätt får man möjlighet att träffa grannar, underhålla rastlösa barn eller kanske köra ett träningspass.

Mer tvättande i gemensam tvättstuga tjänar all i längden på; Ökad trygghet, möjlighet till ett större socialt sammanhang och givetvis, sett ur ett ekonomiskt perspektiv blir det i längden lägre kostnader för alla."}]},{id:"1-ffl_360_laundry",name:"FFL_360_laundry",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:.13559865727033404,pitch:.0774239470641902,fov:1.3199838779965631},linkHotspots:[{yaw:2.0246458177637967,pitch:-.07866772983819459,rotation:4.71238898038469,target:"3-ffl_360_spontan"},{yaw:2.926138972766643,pitch:.013045243732538125,rotation:5.497787143782138,target:"2-ffl_360_booking"},{yaw:-2.987885244372233,pitch:.08830680690073578,rotation:0,target:"4-ffl_360_coworking"},{yaw:-2.515519871779558,pitch:.02727936595805147,rotation:7.0685834705770345,target:"5-ffl_360_bike"},{yaw:-1.8177068920159698,pitch:.07429852363630296,rotation:1.5707963267948966,target:"7-ffl_360_gym"}],infoHotspots:[{yaw:.9764527642467584,pitch:-.18687428826751074,title:"En modern tvättstuga
med hög effektivitet
",text:"Inred tvättstugan med moderna energisnåla maskiner så får du en tids-och kostnadseffektiv lösning.
Professionella maskiner har en livslängd som är 10-15 gånger längre än en vanlig konsumentmaskin.
Den avancerade tekniken i en professionell maskin ger både kortare och effektivare tvättprogram med både snabbare och bättre tvättresultat - och med längre livstid på maskinerna.",offset:[-450,-150]},{yaw:-.5041104135543714,pitch:-.20267053914561764,title:"En modern tvättstuga
med hög effektivitet
",text:"Vi vill att alla som tvättar i gemensam tvättstuga ska känna sig lika bekväma att tvätta här som i lägenheten.
Det ska finnas möjlighet att kunna koppla av och invänta sin tvätt i en trevlig miljö om man vill stanna kvar i tvättstugan.

I vår vison ingår det sköna sittmöbler, gott om plats för att hantera tvätt.
Viktigt är även fönster och glasdörrar för att öka tryggheten i tvättstugan."}]},{id:"2-ffl_360_booking",name:"FFL_360_booking",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:.022823536372234443,pitch:.0018883889527856468,fov:1.3199838779965631},linkHotspots:[{yaw:-.4116670125658999,pitch:.21430130864888142,rotation:.7853981633974483,target:"1-ffl_360_laundry"},{yaw:1.337643176024578,pitch:.15523322536770223,rotation:10.995574287564278,target:"3-ffl_360_spontan"},{yaw:-2.714573094981043,pitch:.20657499966599957,rotation:0,target:"4-ffl_360_coworking"},{yaw:-2.2638757275497596,pitch:.10050612181542995,rotation:.7853981633974483,target:"5-ffl_360_bike"},{yaw:-1.758046470987443,pitch:.13706880350538064,rotation:0,target:"6-ffl_360_playroom"},{yaw:-1.4060295516174328,pitch:.15045374723608873,rotation:.7853981633974483,target:"7-ffl_360_gym"},{yaw:-.784509432860677,pitch:.2246384264130601,rotation:.7853981633974483,target:"0-ffl_360_hall"}],infoHotspots:[{yaw:.08638741570074515,pitch:-.3362681695989913,title:"Bokningssystem",text:"Ett bokningssystem som har full kommunikation med maskinerna och skickar meddelande via en mobil app när tvätten är klar att hämtas.
Systemet har full driftsövervakning och kan även redovisa energiförbrukning för hela huset eller i enskild bostad.",offset:[100,0]}]},{id:"3-ffl_360_spontan",name:"FFL_360_spontan",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:.6365690860929973,pitch:.19800673251377177,fov:1.3199838779965631},linkHotspots:[{yaw:-2.313208160396636,pitch:.1140419072185882,rotation:4.71238898038469,target:"4-ffl_360_coworking"},{yaw:-2.0812397289466347,pitch:.1118882046741021,rotation:.7853981633974483,target:"5-ffl_360_bike"},{yaw:-1.703186594596886,pitch:.10901513812544728,rotation:0,target:"6-ffl_360_playroom"},{yaw:-1.442052124043462,pitch:.09464165641549371,rotation:.7853981633974483,target:"7-ffl_360_gym"},{yaw:-1.2134558137506524,pitch:.34760653290311794,rotation:.7853981633974483,target:"2-ffl_360_booking"},{yaw:-.7770440886030343,pitch:.11225563647670533,rotation:1.5707963267948966,target:"1-ffl_360_laundry"}],infoHotspots:[{yaw:.5094876029886777,pitch:-.1871649939904767,title:"Spontantvätt",text:"Alla måste tvätta akut ibland.
En obokningsbar spontantvätt är lösningen",offset:[-350,0]}]},{id:"4-ffl_360_coworking",name:"FFL_360_coworking",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:-1.2927111426857572,pitch:.39589128967338993,fov:1.3199838779965631},linkHotspots:[{yaw:.26861594424669377,pitch:.11557770394838762,rotation:7.0685834705770345,target:"2-ffl_360_booking"},{yaw:-1.0431035245189566,pitch:.11269234899482505,rotation:6.283185307179586,target:"6-ffl_360_playroom"},{yaw:.5170529832601396,pitch:.1851960065356799,rotation:1.5707963267948966,target:"3-ffl_360_spontan"},{yaw:.09059024619995881,pitch:.09475305539406165,rotation:0,target:"1-ffl_360_laundry"},{yaw:-.2991211025232303,pitch:.08253576670870011,rotation:0,target:"0-ffl_360_hall"}],infoHotspots:[{yaw:-1.5564078007537212,pitch:-.11611899768436196,title:"Co-Workingytor",text:"Co-workingytor skapar mervärde och kan hyras ut till boende eller företag...ett sätt att öka intäkterna till fastighetsägare eller bostadsrättsförening"}]},{id:"5-ffl_360_bike",name:"FFL_360_bike",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:-1.677355456718887,pitch:.10778294210459549,fov:1.3199838779965631},linkHotspots:[{yaw:-.4286736761344798,pitch:.172732783252588,rotation:5.497787143782138,target:"6-ffl_360_playroom"},{yaw:-.018864915276973093,pitch:.07988078807235865,rotation:6.283185307179586,target:"7-ffl_360_gym"},{yaw:.21160275362636582,pitch:.116910110072034,rotation:0,target:"0-ffl_360_hall"},{yaw:.6831098217916711,pitch:.0608232941762239,rotation:0,target:"1-ffl_360_laundry"},{yaw:.849638703431502,pitch:.061008806025590445,rotation:5.497787143782138,target:"2-ffl_360_booking"},{yaw:1.0384020833770542,pitch:.03541188404365769,rotation:5.497787143782138,target:"3-ffl_360_spontan"},{yaw:1.25248575085166,pitch:.1356424185609022,rotation:1.5707963267948966,target:"4-ffl_360_coworking"}],infoHotspots:[{yaw:-1.6703179534216446,pitch:-.16719480919302754,title:"Cykelrum
",text:"Som fastighetsägare vill man inte att cyklar spolas av i lägenheterna.
Ett cykelrum med reparationsmöjligheter är att föredra."}]},{id:"6-ffl_360_playroom",name:"FFL_360_playroom",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:-1.323765109589555,pitch:.09441944763924326,fov:1.3199838779965631},linkHotspots:[{yaw:-.10235718589352238,pitch:.08370418452610728,rotation:5.497787143782138,target:"7-ffl_360_gym"},{yaw:.5669282569707477,pitch:.03211113310286251,rotation:0,target:"1-ffl_360_laundry"},{yaw:.9942633871151685,pitch:.07369650869302191,rotation:5.497787143782138,target:"2-ffl_360_booking"},{yaw:1.174259205342988,pitch:.03620491972127482,rotation:4.71238898038469,target:"3-ffl_360_spontan"},{yaw:1.744135606852291,pitch:.17399003251002298,rotation:.7853981633974483,target:"4-ffl_360_coworking"},{yaw:-2.6844554637856106,pitch:.17083324397907163,rotation:0,target:"5-ffl_360_bike"}],infoHotspots:[{yaw:-1.2108354257893232,pitch:-.13377196217848208,title:"Lekrum
",text:"Tillgång till lekrum kan underlätta när man sköter tvätt med barn."}]},{id:"7-ffl_360_gym",name:"FFL_360_gym",levels:[{tileSize:256,size:256,fallbackOnly:!0},{tileSize:512,size:512},{tileSize:512,size:1024},{tileSize:512,size:2048}],faceSize:2048,initialViewParameters:{yaw:-.7642376598573613,pitch:.048627331092266246,fov:1.5707963267948966},linkHotspots:[{yaw:.4972018324345875,pitch:.4119466572920132,rotation:0,target:"0-ffl_360_hall"},{yaw:1.0863567381315402,pitch:.005021562242065514,rotation:6.283185307179586,target:"1-ffl_360_laundry"},{yaw:1.4516633349491421,pitch:.09703143283194748,rotation:5.497787143782138,target:"2-ffl_360_booking"},{yaw:1.6497589173802343,pitch:.015612771190323116,rotation:4.71238898038469,target:"3-ffl_360_spontan"},{yaw:2.5274635250251682,pitch:.08396862833624397,rotation:0,target:"4-ffl_360_coworking"},{yaw:-2.891435122742852,pitch:.10048564261855297,rotation:.7853981633974483,target:"5-ffl_360_bike"},{yaw:-2.605226552582536,pitch:.1928051854581998,rotation:1.5707963267948966,target:"6-ffl_360_playroom"}],infoHotspots:[{yaw:-.462363593251645,pitch:-.09646838787831413,title:"Gym",text:"Enligt en opinionsstudie i q4 2021 kan ett gym få 40% att använda tvättstugan i större utsträckning.
Gym kan antingen drivas av kommersiell aktör eller ägas av fastighetsägare eller bostadsrättsförening."}]}],name:"First Floor Lounge",settings:{mouseViewMode:"drag",autorotateEnabled:!1,fullscreenButton:!1,viewControlButtons:!1}};/*! * camera-controls * https://github.com/yomotsu/camera-controls * (c) 2017 @yomotsu * Released under the MIT License. */const jt={LEFT:1,RIGHT:2,MIDDLE:4},pe=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768});function Pr(n){return n.isPerspectiveCamera}function rr(n){return n.isOrthographicCamera}const Ms=Math.PI*2,Pf=Math.PI/2,I0=1e-5;function Tt(n,e=I0){return Math.abs(n){e.x+=t.clientX,e.y+=t.clientY}),e.x/=n.length,e.y/=n.length}function sh(n,e){return rr(n)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}function If(n){return n.invert?n.invert():n.inverse(),n}let cA=class{constructor(){this._listeners={}}addEventListener(e,t){const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}removeEventListener(e,t){const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,a=r.length;s{},this._enabled=!0,this._state=pe.NONE,this._viewport=null,this._affectOffset=!1,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._activePointers=[],this._truckInternal=(i,r,s)=>{if(Pr(this._camera)){const a=et.copy(this._camera.position).sub(this._target),o=this._camera.getEffectiveFOV()*Fe.MathUtils.DEG2RAD,l=a.length()*Math.tan(o*.5),c=this.truckSpeed*i*l/this._elementRect.height,h=this.truckSpeed*r*l/this._elementRect.height;this.verticalDragToForward?(s?this.setFocalOffset(this._focalOffsetEnd.x+c,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(c,0,!0),this.forward(-h,!0)):s?this.setFocalOffset(this._focalOffsetEnd.x+c,this._focalOffsetEnd.y+h,this._focalOffsetEnd.z,!0):this.truck(c,h,!0)}else if(rr(this._camera)){const a=this._camera,o=i*(a.right-a.left)/a.zoom/this._elementRect.width,l=r*(a.top-a.bottom)/a.zoom/this._elementRect.height;s?this.setFocalOffset(this._focalOffsetEnd.x+o,this._focalOffsetEnd.y+l,this._focalOffsetEnd.z,!0):this.truck(o,l,!0)}},this._rotateInternal=(i,r)=>{const s=Ms*this.azimuthRotateSpeed*i/this._elementRect.height,a=Ms*this.polarRotateSpeed*r/this._elementRect.height;this.rotate(s,a,!0)},this._dollyInternal=(i,r,s)=>{const a=Math.pow(.95,-i*this.dollySpeed),o=this._sphericalEnd.radius*a,l=this._sphericalEnd.radius,c=l*(i>=0?-1:1);this.dollyTo(o),this.infinityDolly&&(o{const a=Math.pow(.95,i*this.dollySpeed),o=this._zoomEnd;this.zoomTo(this._zoom*a),this.dollyToCursor&&(this._dollyControlAmount+=this._zoomEnd-o,this._dollyControlCoord.set(r,s))},typeof Fe>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new Fe.Quaternion().setFromUnitVectors(this._camera.up,tl),this._yAxisUpSpaceInverse=If(this._yAxisUpSpace.clone()),this._state=pe.NONE,this._domElement=t,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none","setAttribute"in this._domElement&&this._domElement.setAttribute("data-camera-controls-version",hA),this._target=new Fe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Fe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new Fe.Spherical().setFromVector3(et.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new Fe.Vector3,new Fe.Vector3,new Fe.Vector3,new Fe.Vector3],this._updateNearPlaneCorners(),this._boundary=new Fe.Box3(new Fe.Vector3(-1/0,-1/0,-1/0),new Fe.Vector3(1/0,1/0,1/0)),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlAmount=0,this._dollyControlCoord=new Fe.Vector2,this.mouseButtons={left:pe.ROTATE,middle:pe.DOLLY,right:pe.TRUCK,wheel:Pr(this._camera)?pe.DOLLY:rr(this._camera)?pe.ZOOM:pe.NONE},this.touches={one:pe.TOUCH_ROTATE,two:Pr(this._camera)?pe.TOUCH_DOLLY_TRUCK:rr(this._camera)?pe.TOUCH_ZOOM_TRUCK:pe.NONE,three:pe.TOUCH_TRUCK},this._domElement){const i=new Fe.Vector2,r=new Fe.Vector2,s=new Fe.Vector2,a=y=>{if(!this._enabled)return;const b={pointerId:y.pointerId,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",c,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",c,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),x(y)},o=y=>{if(!this._enabled)return;const b={pointerId:0,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",f),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",f),x(y)},l=y=>{this._enabled&&(y.preventDefault(),Array.prototype.forEach.call(y.changedTouches,b=>{const S={pointerId:b.identifier,clientX:b.clientX,clientY:b.clientY,deltaX:0,deltaY:0};this._activePointers.push(S)}),this._domElement.ownerDocument.removeEventListener("touchmove",u,{passive:!1}),this._domElement.ownerDocument.removeEventListener("touchend",m),this._domElement.ownerDocument.addEventListener("touchmove",u,{passive:!1}),this._domElement.ownerDocument.addEventListener("touchend",m),x(y))},c=y=>{y.cancelable&&y.preventDefault();const b=y.pointerId,S=this._findPointerById(b);if(S){if(S.clientX=y.clientX,S.clientY=y.clientY,S.deltaX=y.movementX,S.deltaY=y.movementY,y.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=0,(y.buttons&jt.LEFT)===jt.LEFT&&(this._state=this._state|this.mouseButtons.left),(y.buttons&jt.MIDDLE)===jt.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&jt.RIGHT)===jt.RIGHT&&(this._state=this._state|this.mouseButtons.right);_()}},h=y=>{const b=this._findPointerById(0);b&&(b.clientX=y.clientX,b.clientY=y.clientY,b.deltaX=y.movementX,b.deltaY=y.movementY,this._state=0,(y.buttons&jt.LEFT)===jt.LEFT&&(this._state=this._state|this.mouseButtons.left),(y.buttons&jt.MIDDLE)===jt.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&jt.RIGHT)===jt.RIGHT&&(this._state=this._state|this.mouseButtons.right),_())},u=y=>{y.cancelable&&y.preventDefault(),Array.prototype.forEach.call(y.changedTouches,b=>{const S=b.identifier,M=this._findPointerById(S);M&&(M.clientX=b.clientX,M.clientY=b.clientY)}),_()},d=y=>{const b=y.pointerId,S=this._findPointerById(b);if(S&&this._activePointers.splice(this._activePointers.indexOf(S),1),y.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=pe.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=pe.NONE;w()},f=()=>{const y=this._findPointerById(0);y&&this._activePointers.splice(this._activePointers.indexOf(y),1),this._state=pe.NONE,w()},m=y=>{switch(Array.prototype.forEach.call(y.changedTouches,b=>{const S=b.identifier,M=this._findPointerById(S);M&&this._activePointers.splice(this._activePointers.indexOf(M),1)}),this._activePointers.length){case 0:this._state=pe.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}w()};let g=-1;const p=y=>{if(!this._enabled||this.mouseButtons.wheel===pe.NONE)return;if(y.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===pe.ROTATE||this.mouseButtons.wheel===pe.TRUCK){const C=performance.now();g-C<1e3&&this._getClientRect(this._elementRect),g=C}const b=uA?-1:-3,S=y.deltaMode===1?y.deltaY/b:y.deltaY/(b*10),M=this.dollyToCursor?(y.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(y.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case pe.ROTATE:{this._rotateInternal(y.deltaX,y.deltaY);break}case pe.TRUCK:{this._truckInternal(y.deltaX,y.deltaY,!1);break}case pe.OFFSET:{this._truckInternal(y.deltaX,y.deltaY,!0);break}case pe.DOLLY:{this._dollyInternal(-S,M,T);break}case pe.ZOOM:{this._zoomInternal(-S,M,T);break}}this.dispatchEvent({type:"control"})},v=y=>{this._enabled&&y.preventDefault()},x=y=>{if(!this._enabled)return;if(rh(this._activePointers,wn),this._getClientRect(this._elementRect),i.copy(wn),r.copy(wn),this._activePointers.length>=2){const S=wn.x-this._activePointers[1].clientX,M=wn.y-this._activePointers[1].clientY,T=Math.sqrt(S*S+M*M);s.set(0,T);const C=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,O=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(C,O)}if("touches"in y||"pointerType"in y&&y.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=0,(y.buttons&jt.LEFT)===jt.LEFT&&(this._state=this._state|this.mouseButtons.left),(y.buttons&jt.MIDDLE)===jt.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&jt.RIGHT)===jt.RIGHT&&(this._state=this._state|this.mouseButtons.right);this.dispatchEvent({type:"controlstart"})},_=()=>{if(!this._enabled)return;rh(this._activePointers,wn);const y=this._domElement&&document.pointerLockElement===this._domElement,b=y?-this._activePointers[0].deltaX:r.x-wn.x,S=y?-this._activePointers[0].deltaY:r.y-wn.y;if(r.copy(wn),((this._state&pe.ROTATE)===pe.ROTATE||(this._state&pe.TOUCH_ROTATE)===pe.TOUCH_ROTATE||(this._state&pe.TOUCH_DOLLY_ROTATE)===pe.TOUCH_DOLLY_ROTATE||(this._state&pe.TOUCH_ZOOM_ROTATE)===pe.TOUCH_ZOOM_ROTATE)&&this._rotateInternal(b,S),(this._state&pe.DOLLY)===pe.DOLLY||(this._state&pe.ZOOM)===pe.ZOOM){const M=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&pe.DOLLY)===pe.DOLLY?this._dollyInternal(S*el,M,T):this._zoomInternal(S*el,M,T)}if((this._state&pe.TOUCH_DOLLY)===pe.TOUCH_DOLLY||(this._state&pe.TOUCH_ZOOM)===pe.TOUCH_ZOOM||(this._state&pe.TOUCH_DOLLY_TRUCK)===pe.TOUCH_DOLLY_TRUCK||(this._state&pe.TOUCH_ZOOM_TRUCK)===pe.TOUCH_ZOOM_TRUCK||(this._state&pe.TOUCH_DOLLY_OFFSET)===pe.TOUCH_DOLLY_OFFSET||(this._state&pe.TOUCH_ZOOM_OFFSET)===pe.TOUCH_ZOOM_OFFSET||(this._state&pe.TOUCH_DOLLY_ROTATE)===pe.TOUCH_DOLLY_ROTATE||(this._state&pe.TOUCH_ZOOM_ROTATE)===pe.TOUCH_ZOOM_ROTATE){const M=wn.x-this._activePointers[1].clientX,T=wn.y-this._activePointers[1].clientY,C=Math.sqrt(M*M+T*T),O=s.y-C;s.set(0,C);const U=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,F=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&pe.TOUCH_DOLLY)===pe.TOUCH_DOLLY||(this._state&pe.TOUCH_DOLLY_ROTATE)===pe.TOUCH_DOLLY_ROTATE||(this._state&pe.TOUCH_DOLLY_TRUCK)===pe.TOUCH_DOLLY_TRUCK||(this._state&pe.TOUCH_DOLLY_OFFSET)===pe.TOUCH_DOLLY_OFFSET?this._dollyInternal(O*el,U,F):this._zoomInternal(O*el,U,F)}((this._state&pe.TRUCK)===pe.TRUCK||(this._state&pe.TOUCH_TRUCK)===pe.TOUCH_TRUCK||(this._state&pe.TOUCH_DOLLY_TRUCK)===pe.TOUCH_DOLLY_TRUCK||(this._state&pe.TOUCH_ZOOM_TRUCK)===pe.TOUCH_ZOOM_TRUCK)&&this._truckInternal(b,S,!1),((this._state&pe.OFFSET)===pe.OFFSET||(this._state&pe.TOUCH_OFFSET)===pe.TOUCH_OFFSET||(this._state&pe.TOUCH_DOLLY_OFFSET)===pe.TOUCH_DOLLY_OFFSET||(this._state&pe.TOUCH_ZOOM_OFFSET)===pe.TOUCH_ZOOM_OFFSET)&&this._truckInternal(b,S,!0),this.dispatchEvent({type:"control"})},w=()=>{rh(this._activePointers,wn),r.copy(wn),this._activePointers.length===0&&(this._domElement.ownerDocument.removeEventListener("pointermove",c,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("touchmove",u,{passive:!1}),this._domElement.ownerDocument.removeEventListener("touchend",m),this.dispatchEvent({type:"controlend"}))};this._domElement.addEventListener("pointerdown",a),Df&&this._domElement.addEventListener("mousedown",o),Df&&this._domElement.addEventListener("touchstart",l),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",v),this._removeAllEventListeners=()=>{this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("mousedown",o),this._domElement.removeEventListener("touchstart",l),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",v),this._domElement.ownerDocument.removeEventListener("pointermove",c,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("touchmove",u,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",f),this._domElement.ownerDocument.removeEventListener("touchend",m)},this.cancel=()=>{this._state!==pe.NONE&&(this._state=pe.NONE,this._activePointers.length=0,w())}}this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="")}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){const r=Fe.MathUtils.clamp(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=Fe.MathUtils.clamp(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const a=!i||St(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&St(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){const i=this._sphericalEnd.radius,r=Fe.MathUtils.clamp(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){const o=this._collisionTest(),l=St(o,this._spherical.radius);if(!(i>r)&&l)return Promise.resolve();this._sphericalEnd.radius=Math.min(r,o)}else this._sphericalEnd.radius=r;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||St(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._zoomEnd=Fe.MathUtils.clamp(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||St(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),ri.setFromMatrixColumn(this._camera.matrix,0),si.setFromMatrixColumn(this._camera.matrix,1),ri.multiplyScalar(e),si.multiplyScalar(-t);const r=et.copy(ri).add(si),s=gt.copy(this._targetEnd).add(r);return this.moveTo(s.x,s.y,s.z,i)}forward(e,t=!1){et.setFromMatrixColumn(this._camera.matrix,0),et.crossVectors(this._camera.up,et),et.multiplyScalar(e);const i=gt.copy(this._targetEnd).add(et);return this.moveTo(i.x,i.y,i.z,t)}moveTo(e,t,i,r=!1){const s=et.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const a=!r||St(this._target.x,this._targetEnd.x,this.restThreshold)&&St(this._target.y,this._targetEnd.y,this.restThreshold)&&St(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}fitToBox(e,t,{cover:i=!1,paddingLeft:r=0,paddingRight:s=0,paddingBottom:a=0,paddingTop:o=0}={}){const l=[],c=e.isBox3?Zs.copy(e):Zs.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=Rf(this._sphericalEnd.theta,Pf),u=Rf(this._sphericalEnd.phi,Pf);l.push(this.rotateTo(h,u,t));const d=et.setFromSpherical(this._sphericalEnd).normalize(),f=kf.setFromUnitVectors(d,ah),m=St(Math.abs(d.y),1);m&&f.multiply(lh.setFromAxisAngle(tl,h)),f.multiply(this._yAxisUpSpaceInverse);const g=Nf.makeEmpty();gt.copy(c.min).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.min).setX(c.max.x).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.min).setY(c.max.y).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.max).setZ(c.min.z).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.min).setZ(c.max.z).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.max).setY(c.min.y).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.max).setX(c.min.x).applyQuaternion(f),g.expandByPoint(gt),gt.copy(c.max).applyQuaternion(f),g.expandByPoint(gt),g.min.x-=r,g.min.y-=a,g.max.x+=s,g.max.y+=o,f.setFromUnitVectors(ah,d),m&&f.premultiply(lh.invert()),f.premultiply(this._yAxisUpSpace);const p=g.getSize(et),v=g.getCenter(gt).applyQuaternion(f);if(Pr(this._camera)){const x=this.getDistanceToFitBox(p.x,p.y,p.z,i);l.push(this.moveTo(v.x,v.y,v.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(rr(this._camera)){const x=this._camera,_=x.right-x.left,w=x.top-x.bottom,y=i?Math.max(_/p.x,w/p.y):Math.min(_/p.x,w/p.y);l.push(this.moveTo(v.x,v.y,v.z,t)),l.push(this.zoomTo(y,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const i=[],s=e instanceof Fe.Sphere?oh.copy(e):dA(e,oh);if(i.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),Pr(this._camera)){const a=this.getDistanceToFitSphere(s.radius);i.push(this.dollyTo(a,t))}else if(rr(this._camera)){const a=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,l=2*s.radius,c=Math.min(a/l,o/l);i.push(this.zoomTo(c,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,r,s,a,o=!1){const l=gt.set(r,s,a),c=et.set(e,t,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!o||St(this._target.x,this._targetEnd.x,this.restThreshold)&&St(this._target.y,this._targetEnd.y,this.restThreshold)&&St(this._target.z,this._targetEnd.z,this.restThreshold)&&St(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&St(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&St(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,i,r,s,a,o,l,c,h,u,d,f,m=!1){const g=et.set(r,s,a),p=gt.set(e,t,i);Gn.setFromVector3(p.sub(g).applyQuaternion(this._yAxisUpSpace));const v=bs.set(h,u,d),x=gt.set(o,l,c);Sa.setFromVector3(x.sub(v).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(g.lerp(v,f));const _=Sa.theta-Gn.theta,w=Sa.phi-Gn.phi,y=Sa.radius-Gn.radius;this._sphericalEnd.set(Gn.radius+y*f,Gn.phi+w*f,Gn.theta+_*f),this.normalizeRotations(),this._needsUpdate=!0,m||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!m||St(this._target.x,this._targetEnd.x,this.restThreshold)&&St(this._target.y,this._targetEnd.y,this.restThreshold)&&St(this._target.z,this._targetEnd.z,this.restThreshold)&&St(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&St(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&St(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(e,t,i,r=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,i,r=!1){const s=this.getPosition(et),a=this.setLookAt(s.x,s.y,s.z,e,t,i,r);return this._sphericalEnd.phi=Fe.MathUtils.clamp(this.polarAngle,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,i,r=!1){this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd),this._affectOffset=!Tt(this._focalOffset.x)||!Tt(this._focalOffset.y)||!Tt(this._focalOffset.z);const s=!r||St(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&St(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&St(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),ri.setFromMatrixColumn(this._camera.matrixWorldInverse,0),si.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Rr.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=et.set(e,t,i),s=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);ri.multiplyScalar(a.x),si.multiplyScalar(a.y),Rr.multiplyScalar(a.z),et.copy(ri).add(si).add(Rr),et.z=et.z+s,this.dollyTo(s,!1),this.setFocalOffset(-et.x,et.y,-et.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new Fe.Vector4,typeof e=="number"?this._viewport.set(e,t,i,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,r=!1){if(sh(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,a=this._camera.getEffectiveFOV()*Fe.MathUtils.DEG2RAD,o=this._camera.aspect;return((r?s>o:si.pointerId===e?(t=i,!0):!1),t}_encloseToBoundary(e,t,i){const r=t.lengthSq();if(r===0)return e;const s=gt.copy(t).add(e),o=this._boundary.clampPoint(s,bs).sub(s),l=o.lengthSq();if(l===0)return e.add(t);if(l===r)return e;if(i===0)return e.add(t).add(o);{const c=1+i*l/t.dot(o);return e.add(gt.copy(t).multiplyScalar(c)).add(o.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Pr(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Fe.MathUtils.DEG2RAD,r=Math.tan(i*.5)*t,s=r*e.aspect;this._nearPlaneCorners[0].set(-s,-r,0),this._nearPlaneCorners[1].set(s,-r,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(-s,r,0)}else if(rr(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,r=e.right*t,s=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(i,s,0),this._nearPlaneCorners[1].set(r,s,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(i,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||sh(this._camera,"_collisionTest"))return e;const i=et.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);ch.lookAt(Of,i,this._camera.up);for(let r=0;r<4;r++){const s=gt.copy(this._nearPlaneCorners[r]);s.applyMatrix4(ch);const a=bs.addVectors(this._target,s);nl.set(a,i),nl.far=this._spherical.radius+1;const o=nl.intersectObjects(this.colliderMeshes);o.length!==0&&o[0].distance{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_removeAllEventListeners(){}}function dA(n,e){const t=e,i=t.center;Zs.makeEmpty(),n.traverseVisible(s=>{s.isMesh&&Zs.expandByObject(s)}),Zs.getCenter(i);let r=0;return n.traverseVisible(s=>{if(!s.isMesh)return;const a=s,o=a.geometry.clone();if(o.applyMatrix4(a.matrixWorld),o.isBufferGeometry){const c=o.attributes.position;for(let h=0,u=c.count;h>8&255]+ln[n>>16&255]+ln[n>>24&255]+"-"+ln[e&255]+ln[e>>8&255]+"-"+ln[e>>16&15|64]+ln[e>>24&255]+"-"+ln[t&63|128]+ln[t>>8&255]+"-"+ln[t>>16&255]+ln[t>>24&255]+ln[i&255]+ln[i>>8&255]+ln[i>>16&255]+ln[i>>24&255]).toLowerCase()}function Ft(n,e,t){return Math.max(e,Math.min(t,n))}function yd(n,e){return(n%e+e)%e}function qA(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function XA(n,e,t){return n!==e?(t-n)/(e-n):0}function qa(n,e,t){return(1-t)*n+t*e}function YA(n,e,t,i){return qa(n,e,1-Math.exp(-t*i))}function ZA(n,e=1){return e-Math.abs(yd(n,e*2)-e)}function jA(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function KA(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function JA(n,e){return n+Math.floor(Math.random()*(e-n+1))}function QA(n,e){return n+Math.random()*(e-n)}function eC(n){return n*(.5-Math.random())}function tC(n){n!==void 0&&(Bf=n);let e=Bf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nC(n){return n*Jr}function iC(n){return n*io}function Du(n){return(n&n-1)===0&&n!==0}function Rv(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function uc(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function rC(n,e,t,i,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),f=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*h,l*u,l*d,o*c);break;case"YZY":n.set(l*d,o*h,l*u,o*c);break;case"ZXZ":n.set(l*u,l*d,o*h,o*c);break;case"XZX":n.set(o*h,l*m,l*f,o*c);break;case"YXY":n.set(l*f,o*h,l*m,o*c);break;case"ZYZ":n.set(l*m,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ii(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function vt(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var ro=Object.freeze({__proto__:null,DEG2RAD:Jr,RAD2DEG:io,generateUUID:Ln,clamp:Ft,euclideanModulo:yd,mapLinear:qA,inverseLerp:XA,lerp:qa,damp:YA,pingpong:ZA,smoothstep:jA,smootherstep:KA,randInt:JA,randFloat:QA,randFloatSpread:eC,seededRandom:tC,degToRad:nC,radToDeg:iC,isPowerOfTwo:Du,ceilPowerOfTwo:Rv,floorPowerOfTwo:uc,setQuaternionFromProperEuler:rC,normalize:vt,denormalize:Ii});class ne{constructor(e=0,t=0){ne.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vn{constructor(){vn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,i,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],u=i[7],d=i[2],f=i[5],m=i[8],g=r[0],p=r[3],v=r[6],x=r[1],_=r[4],w=r[7],y=r[2],b=r[5],S=r[8];return s[0]=a*g+o*x+l*y,s[3]=a*p+o*_+l*b,s[6]=a*v+o*w+l*S,s[1]=c*g+h*x+u*y,s[4]=c*p+h*_+u*b,s[7]=c*v+h*w+u*S,s[2]=d*g+f*x+m*y,s[5]=d*p+f*_+m*b,s[8]=d*v+f*w+m*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*s,f=c*s-a*l,m=t*u+i*d+r*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/m;return e[0]=u*g,e[1]=(r*c-h*i)*g,e[2]=(o*i-r*a)*g,e[3]=d*g,e[4]=(h*t-r*l)*g,e[5]=(r*s-o*t)*g,e[6]=f*g,e[7]=(i*l-c*t)*g,e[8]=(a*t-i*s)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(hh.makeScale(e,t)),this}rotate(e){return this.premultiply(hh.makeRotation(-e)),this}translate(e,t){return this.premultiply(hh.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const hh=new vn;function Iv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const sC={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function $s(n,e){return new sC[n](e)}function so(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Qr(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function ec(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const uh={[Yn]:{[na]:Qr},[na]:{[Yn]:ec}},cn={legacyMode:!0,get workingColorSpace(){return na},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,e,t){if(this.legacyMode||e===t||!e||!t)return n;if(uh[e]&&uh[e][t]!==void 0){const i=uh[e][t];return n.r=i(n.r),n.g=i(n.g),n.b=i(n.b),n}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(n,e){return this.convert(n,this.workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this.workingColorSpace)}},Dv={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},Gt={r:0,g:0,b:0},Wn={h:0,s:0,l:0},il={h:0,s:0,l:0};function dh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function rl(n,e){return e.r=n.r,e.g=n.g,e.b=n.b,e}class xe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}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,t=Yn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,cn.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=cn.workingColorSpace){return this.r=e,this.g=t,this.b=i,cn.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=cn.workingColorSpace){if(e=yd(e,1),t=Ft(t,0,1),i=Ft(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=dh(a,s,e+1/3),this.g=dh(a,s,e),this.b=dh(a,s,e-1/3)}return cn.toWorkingColorSpace(this,r),this}setStyle(e,t=Yn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,cn.toWorkingColorSpace(this,t),i(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,cn.toWorkingColorSpace(this,t),i(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const l=parseFloat(s[1])/360,c=parseFloat(s[2])/100,h=parseFloat(s[3])/100;return i(s[4]),this.setHSL(l,c,h,t)}break}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,cn.toWorkingColorSpace(this,t),this;if(a===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,cn.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Yn){const i=Dv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}copyLinearToSRGB(e){return this.r=ec(e.r),this.g=ec(e.g),this.b=ec(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yn){return cn.fromWorkingColorSpace(rl(this,Gt),e),Ft(Gt.r*255,0,255)<<16^Ft(Gt.g*255,0,255)<<8^Ft(Gt.b*255,0,255)<<0}getHexString(e=Yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=cn.workingColorSpace){cn.fromWorkingColorSpace(rl(this,Gt),t);const i=Gt.r,r=Gt.g,s=Gt.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case i:l=(r-s)/u+(r"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ss===void 0&&(Ss=so("canvas")),Ss.width=e.width,Ss.height=e.height;const i=Ss.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Ss}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=so("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Sc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case fr:e.x=e.x-Math.floor(e.x);break;case nn:e.x=e.x<0?0:1;break;case ea:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case fr:e.y=e.y-Math.floor(e.y);break;case nn:e.y=e.y<0?0:1;break;case ea:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}Pt.DEFAULT_IMAGE=null;Pt.DEFAULT_MAPPING=Sc;Pt.DEFAULT_ANISOTROPY=1;class dt{constructor(e=0,t=0,i=0,r=1){dt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],g=l[2],p=l[6],v=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-g)<.01&&Math.abs(m-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+g)<.1&&Math.abs(m+p)<.1&&Math.abs(c+f+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(c+1)/2,w=(f+1)/2,y=(v+1)/2,b=(h+d)/4,S=(u+g)/4,M=(m+p)/4;return _>w&&_>y?_<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(_),r=b/i,s=S/i):w>y?w<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),i=b/r,s=M/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=S/s,r=M/s),this.set(i,r,s,t),this}let x=Math.sqrt((p-m)*(p-m)+(u-g)*(u-g)+(d-h)*(d-h));return Math.abs(x)<.001&&(x=1),this.x=(p-m)/x,this.y=(u-g)/x,this.z=(d-h)/x,this.w=Math.acos((c+f+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Hn extends qi{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new Pt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.internalFormat=i.internalFormat!==void 0?i.internalFormat:null,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:Mt,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!1,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null,this.samples=i.samples!==void 0?i.samples:0}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Yr(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class To extends Pt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=It,this.minFilter=It,this.wrapR=nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class oC extends Hn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new To(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class Ac extends Pt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=It,this.minFilter=It,this.wrapR=nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lC extends Hn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ac(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class cC extends Hn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let a=0;a=0?1:-1,_=1-v*v;if(_>Number.EPSILON){const y=Math.sqrt(_),b=Math.atan2(y,v*x);p=Math.sin(p*b)/y,o=Math.sin(o*b)/y}const w=o*x;if(l=l*p+d*w,c=c*p+f*w,h=h*p+m*w,u=u*p+g*w,p===1-o){const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],h=i[r+3],u=s[a],d=s[a+1],f=s[a+2],m=s[a+3];return e[t]=o*m+h*u+l*f-c*d,e[t+1]=l*m+h*d+c*u-o*f,e[t+2]=c*m+h*f+o*d-l*u,e[t+3]=h*m-o*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(r/2),u=o(s/2),d=l(i/2),f=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-r)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(r+a)/f,this._z=(s+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-c)/f,this._x=(r+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(a-r)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ft(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-r*o,this._w=a*h-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=a*u+this._w*d,this._x=i*u+this._x*d,this._y=r*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class R{constructor(e=0,t=0,i=0){R.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Hf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Hf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=l*t+a*r-o*i,h=l*i+o*t-s*r,u=l*r+s*i-a*t,d=-s*t-a*i-o*r;return this.x=c*l+d*-s+h*-o-u*-a,this.y=h*l+d*-a+u*-s-c*-o,this.z=u*l+d*-o+c*-a-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return ph.copy(this).projectOnVector(e),this.sub(ph)}reflect(e){return this.sub(ph.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ph=new R,Hf=new hn;class Sr{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,o=-1/0;for(let l=0,c=e.length;ls&&(s=h),u>a&&(a=u),d>o&&(o=d)}return this.min.set(t,i,r),this.max.set(s,a,o),this}setFromBufferAttribute(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,o=-1/0;for(let l=0,c=e.count;ls&&(s=h),u>a&&(a=u),d>o&&(o=d)}return this.min.set(t,i,r),this.max.set(s,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ir),Ir.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ta),sl.subVectors(this.max,Ta),Ts.subVectors(e.a,Ta),Es.subVectors(e.b,Ta),As.subVectors(e.c,Ta),Ki.subVectors(Es,Ts),Ji.subVectors(As,Es),Dr.subVectors(Ts,As);let t=[0,-Ki.z,Ki.y,0,-Ji.z,Ji.y,0,-Dr.z,Dr.y,Ki.z,0,-Ki.x,Ji.z,0,-Ji.x,Dr.z,0,-Dr.x,-Ki.y,Ki.x,0,-Ji.y,Ji.x,0,-Dr.y,Dr.x,0];return!gh(t,Ts,Es,As,sl)||(t=[1,0,0,0,1,0,0,0,1],!gh(t,Ts,Es,As,sl))?!1:(al.crossVectors(Ki,Ji),t=[al.x,al.y,al.z],gh(t,Ts,Es,As,sl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ir.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Ir).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:(Mi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Mi=[new R,new R,new R,new R,new R,new R,new R,new R],Ir=new R,mh=new Sr,Ts=new R,Es=new R,As=new R,Ki=new R,Ji=new R,Dr=new R,Ta=new R,sl=new R,al=new R,Or=new R;function gh(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Or.fromArray(n,s);const o=r.x*Math.abs(Or.x)+r.y*Math.abs(Or.y)+r.z*Math.abs(Or.z),l=e.dot(Or),c=t.dot(Or),h=i.dot(Or);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const hC=new Sr,Ea=new R,vh=new R;class Tr{constructor(e=new R,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):hC.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ea.subVectors(e,this.center);const t=Ea.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Ea,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(vh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ea.copy(e.center).add(vh)),this.expandByPoint(Ea.copy(e.center).sub(vh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bi=new R,_h=new R,ol=new R,Qi=new R,yh=new R,ll=new R,xh=new R;class Eo{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,bi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=bi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bi.copy(this.direction).multiplyScalar(t).add(this.origin),bi.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){_h.copy(e).add(t).multiplyScalar(.5),ol.copy(t).sub(e).normalize(),Qi.copy(this.origin).sub(_h);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ol),o=Qi.dot(this.direction),l=-Qi.dot(ol),c=Qi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=s*h,u>=0)if(d>=-m)if(d<=m){const g=1/h;u*=g,d*=g,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return i&&i.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(ol).multiplyScalar(d).add(_h),f}intersectSphere(e,t){bi.subVectors(e.center,this.origin);const i=bi.dot(this.direction),r=bi.dot(bi)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return o<0&&l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),i>l||o>r)||((o>i||i!==i)&&(i=o),(l=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,bi)!==null}intersectTriangle(e,t,i,r,s){yh.subVectors(t,e),ll.subVectors(i,e),xh.crossVectors(yh,ll);let a=this.direction.dot(xh),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Qi.subVectors(this.origin,e);const l=o*this.direction.dot(ll.crossVectors(Qi,ll));if(l<0)return null;const c=o*this.direction.dot(yh.cross(Qi));if(c<0||l+c>a)return null;const h=-o*Qi.dot(xh);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ge{constructor(){Ge.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,i,r,s,a,o,l,c,h,u,d,f,m,g,p){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=s,v[5]=a,v[9]=o,v[13]=l,v[2]=c,v[6]=h,v[10]=u,v[14]=d,v[3]=f,v[7]=m,v[11]=g,v[15]=p,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 Ge().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Cs.setFromMatrixColumn(e,0).length(),s=1/Cs.setFromMatrixColumn(e,1).length(),a=1/Cs.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=a*h,f=a*u,m=o*h,g=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+m*c,t[5]=d-g*c,t[9]=-o*l,t[2]=g-d*c,t[6]=m+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,f=l*u,m=c*h,g=c*u;t[0]=d+g*o,t[4]=m*o-f,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-m,t[6]=g+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,f=l*u,m=c*h,g=c*u;t[0]=d-g*o,t[4]=-a*u,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*h,t[9]=g-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,f=a*u,m=o*h,g=o*u;t[0]=l*h,t[4]=m*c-f,t[8]=d*c+g,t[1]=l*u,t[5]=g*c+d,t[9]=f*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,m=o*l,g=o*c;t[0]=l*h,t[4]=g-d*u,t[8]=m*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*u+m,t[10]=d-g*u}else if(e.order==="XZY"){const d=a*l,f=a*c,m=o*l,g=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+g,t[5]=a*h,t[9]=f*u-m,t[2]=m*u-f,t[6]=o*h,t[10]=g*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(uC,e,dC)}lookAt(e,t,i){const r=this.elements;return Tn.subVectors(e,t),Tn.lengthSq()===0&&(Tn.z=1),Tn.normalize(),er.crossVectors(i,Tn),er.lengthSq()===0&&(Math.abs(i.z)===1?Tn.x+=1e-4:Tn.z+=1e-4,Tn.normalize(),er.crossVectors(i,Tn)),er.normalize(),cl.crossVectors(Tn,er),r[0]=er.x,r[4]=cl.x,r[8]=Tn.x,r[1]=er.y,r[5]=cl.y,r[9]=Tn.y,r[2]=er.z,r[6]=cl.z,r[10]=Tn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],u=i[5],d=i[9],f=i[13],m=i[2],g=i[6],p=i[10],v=i[14],x=i[3],_=i[7],w=i[11],y=i[15],b=r[0],S=r[4],M=r[8],T=r[12],C=r[1],O=r[5],U=r[9],F=r[13],z=r[2],L=r[6],K=r[10],G=r[14],W=r[3],se=r[7],ie=r[11],$=r[15];return s[0]=a*b+o*C+l*z+c*W,s[4]=a*S+o*O+l*L+c*se,s[8]=a*M+o*U+l*K+c*ie,s[12]=a*T+o*F+l*G+c*$,s[1]=h*b+u*C+d*z+f*W,s[5]=h*S+u*O+d*L+f*se,s[9]=h*M+u*U+d*K+f*ie,s[13]=h*T+u*F+d*G+f*$,s[2]=m*b+g*C+p*z+v*W,s[6]=m*S+g*O+p*L+v*se,s[10]=m*M+g*U+p*K+v*ie,s[14]=m*T+g*F+p*G+v*$,s[3]=x*b+_*C+w*z+y*W,s[7]=x*S+_*O+w*L+y*se,s[11]=x*M+_*U+w*K+y*ie,s[15]=x*T+_*F+w*G+y*$,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],m=e[3],g=e[7],p=e[11],v=e[15];return m*(+s*l*u-r*c*u-s*o*d+i*c*d+r*o*f-i*l*f)+g*(+t*l*f-t*c*d+s*a*d-r*a*f+r*c*h-s*l*h)+p*(+t*c*u-t*o*f-s*a*u+i*a*f+s*o*h-i*c*h)+v*(-r*o*h-t*l*u+t*o*d+r*a*u-i*a*d+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],g=e[13],p=e[14],v=e[15],x=u*p*c-g*d*c+g*l*f-o*p*f-u*l*v+o*d*v,_=m*d*c-h*p*c-m*l*f+a*p*f+h*l*v-a*d*v,w=h*g*c-m*u*c+m*o*f-a*g*f-h*o*v+a*u*v,y=m*u*l-h*g*l-m*o*d+a*g*d+h*o*p-a*u*p,b=t*x+i*_+r*w+s*y;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/b;return e[0]=x*S,e[1]=(g*d*s-u*p*s-g*r*f+i*p*f+u*r*v-i*d*v)*S,e[2]=(o*p*s-g*l*s+g*r*c-i*p*c-o*r*v+i*l*v)*S,e[3]=(u*l*s-o*d*s-u*r*c+i*d*c+o*r*f-i*l*f)*S,e[4]=_*S,e[5]=(h*p*s-m*d*s+m*r*f-t*p*f-h*r*v+t*d*v)*S,e[6]=(m*l*s-a*p*s-m*r*c+t*p*c+a*r*v-t*l*v)*S,e[7]=(a*d*s-h*l*s+h*r*c-t*d*c-a*r*f+t*l*f)*S,e[8]=w*S,e[9]=(m*u*s-h*g*s-m*i*f+t*g*f+h*i*v-t*u*v)*S,e[10]=(a*g*s-m*o*s+m*i*c-t*g*c-a*i*v+t*o*v)*S,e[11]=(h*o*s-a*u*s-h*i*c+t*u*c+a*i*f-t*o*f)*S,e[12]=y*S,e[13]=(h*g*r-m*u*r+m*i*d-t*g*d-h*i*p+t*u*p)*S,e[14]=(m*o*r-a*g*r-m*i*l+t*g*l+a*i*p-t*o*p)*S,e[15]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*S,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+i,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,m=s*u,g=a*h,p=a*u,v=o*u,x=l*c,_=l*h,w=l*u,y=i.x,b=i.y,S=i.z;return r[0]=(1-(g+v))*y,r[1]=(f+w)*y,r[2]=(m-_)*y,r[3]=0,r[4]=(f-w)*b,r[5]=(1-(d+v))*b,r[6]=(p+x)*b,r[7]=0,r[8]=(m+_)*S,r[9]=(p-x)*S,r[10]=(1-(d+g))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=Cs.set(r[0],r[1],r[2]).length();const a=Cs.set(r[4],r[5],r[6]).length(),o=Cs.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],$n.copy(this);const c=1/s,h=1/a,u=1/o;return $n.elements[0]*=c,$n.elements[1]*=c,$n.elements[2]*=c,$n.elements[4]*=h,$n.elements[5]*=h,$n.elements[6]*=h,$n.elements[8]*=u,$n.elements[9]*=u,$n.elements[10]*=u,t.setFromRotationMatrix($n),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a){const o=this.elements,l=2*s/(t-e),c=2*s/(i-r),h=(t+e)/(t-e),u=(i+r)/(i-r),d=-(a+s)/(a-s),f=-2*a*s/(a-s);return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=f,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,i,r,s,a){const o=this.elements,l=1/(t-e),c=1/(i-r),h=1/(a-s),u=(t+e)*l,d=(i+r)*c,f=(a+s)*h;return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=-2*h,o[14]=-f,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Cs=new R,$n=new Ge,uC=new R(0,0,0),dC=new R(1,1,1),er=new R,cl=new R,Tn=new R,Vf=new Ge,Gf=new hn;class pa{constructor(e=0,t=0,i=0,r=pa.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(Ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ft(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ft(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ft(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Ft(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Vf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Vf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Gf.setFromEuler(this),this.setFromQuaternion(Gf,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=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}pa.DefaultOrder="XYZ";pa.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Cc{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Aa,e,pC),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Aa,mC,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i0&&(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(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){r.children=[];for(let o=0;o0){r.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){qn.subVectors(r,t),Ti.subVectors(i,t),wh.subVectors(e,t);const a=qn.dot(qn),o=qn.dot(Ti),l=qn.dot(wh),c=Ti.dot(Ti),h=Ti.dot(wh),u=a*c-o*o;if(u===0)return s.set(-2,-1,-1);const d=1/u,f=(c*l-o*h)*d,m=(a*h-o*l)*d;return s.set(1-f-m,m,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Ei),Ei.x>=0&&Ei.y>=0&&Ei.x+Ei.y<=1}static getUV(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,Ei),l.set(0,0),l.addScaledVector(s,Ei.x),l.addScaledVector(a,Ei.y),l.addScaledVector(o,Ei.z),l}static isFrontFacing(e,t,i,r){return qn.subVectors(i,t),Ti.subVectors(e,t),qn.cross(Ti).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qn.subVectors(this.c,this.b),Ti.subVectors(this.a,this.b),qn.cross(Ti).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Un.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return Un.getUV(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return Un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Un.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Ps.subVectors(r,i),Rs.subVectors(s,i),Mh.subVectors(e,i);const l=Ps.dot(Mh),c=Rs.dot(Mh);if(l<=0&&c<=0)return t.copy(i);bh.subVectors(e,r);const h=Ps.dot(bh),u=Rs.dot(bh);if(h>=0&&u<=h)return t.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Ps,a);Sh.subVectors(e,s);const f=Ps.dot(Sh),m=Rs.dot(Sh);if(m>=0&&f<=m)return t.copy(s);const g=f*c-l*m;if(g<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Rs,o);const p=h*m-f*u;if(p<=0&&u-h>=0&&f-m>=0)return Zf.subVectors(s,r),o=(u-h)/(u-h+(f-m)),t.copy(r).addScaledVector(Zf,o);const v=1/(p+g+d);return a=g*v,o=d*v,t.copy(i).addScaledVector(Ps,a).addScaledVector(Rs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let vC=0;class $t extends qi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vC++}),this.uuid=Ln(),this.name="",this.type="Material",this.blending=jr,this.side=Ui,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=fd,this.blendDst=pd,this.blendEquation=Wr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=cc,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Pv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ql,this.stencilZFail=Ql,this.stencilZPass=Ql,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const r=this[t];if(r===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==jr&&(i.blending=this.blending),this.side!==Ui&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(i.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=this.flatShading),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Mn extends $t{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(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=So,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ut=new R,ul=new ne;class lt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=no,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;st.far?null:{distance:c,point:gl.clone(),object:n}}function vl(n,e,t,i,r,s,a,o,l){n.getVertexPosition(a,La),n.getVertexPosition(o,Pa),n.getVertexPosition(l,Ra);const c=EC(n,e,t,i,La,Pa,Ra,Ch);if(c){r&&(fl.fromBufferAttribute(r,a),pl.fromBufferAttribute(r,o),ml.fromBufferAttribute(r,l),c.uv=Un.getUV(Ch,La,Pa,Ra,fl,pl,ml,new ne)),s&&(fl.fromBufferAttribute(s,a),pl.fromBufferAttribute(s,o),ml.fromBufferAttribute(s,l),c.uv2=Un.getUV(Ch,La,Pa,Ra,fl,pl,ml,new ne));const h={a,b:o,c:l,normal:new R,materialIndex:0};Un.getNormal(La,Pa,Ra,h.normal),c.face=h}return c}class _i extends Ye{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Ce(c,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(u,2));function m(g,p,v,x,_,w,y,b,S,M,T){const C=w/S,O=y/M,U=w/2,F=y/2,z=b/2,L=S+1,K=M+1;let G=0,W=0;const se=new R;for(let ie=0;ie0?1:-1,h.push(se.x,se.y,se.z),u.push(Y/S),u.push(1-ie/M),G+=1}}for(let ie=0;ie0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Lc extends it{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Wt extends Lc{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=io*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Jr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return io*2*Math.atan(Math.tan(Jr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Jr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Os=-90,zs=1;class zv extends it{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i;const r=new Wt(Os,zs,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);const s=new Wt(Os,zs,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);const a=new Wt(Os,zs,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);const o=new Wt(Os,zs,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(0,-1,0),this.add(o);const l=new Wt(Os,zs,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);const c=new Wt(Os,zs,e,t);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,-1),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();const i=this.renderTarget,[r,s,a,o,l,c]=this.children,h=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=li,e.xr.enabled=!1;const f=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,o),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=f,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(h),e.toneMapping=u,e.xr.enabled=d,i.texture.needsPMREMUpdate=!0}}class Ao extends Pt{constructor(e,t,i,r,s,a,o,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:ur,super(e,t,i,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Fv extends Hn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Ao(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Mt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={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 #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},r=new _i(5,5,5),s=new Kn({name:"CubemapFromEquirect",uniforms:ia(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:bn,blending:zi});s.uniforms.tEquirect.value=t;const a=new Bt(r,s),o=t.minFilter;return t.minFilter===ui&&(t.minFilter=Mt),new zv(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}const Lh=new R,PC=new R,RC=new vn;class ar{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=Lh.subVectors(i,t).cross(PC.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const i=e.delta(Lh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(i).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||RC.getNormalMatrix(e),r=this.coplanarPoint(Lh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Fs=new Tr,_l=new R;class Pc{constructor(e=new ar,t=new ar,i=new ar,r=new ar,s=new ar,a=new ar){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){const t=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],f=i[9],m=i[10],g=i[11],p=i[12],v=i[13],x=i[14],_=i[15];return t[0].setComponents(o-r,u-l,g-d,_-p).normalize(),t[1].setComponents(o+r,u+l,g+d,_+p).normalize(),t[2].setComponents(o+s,u+c,g+f,_+v).normalize(),t[3].setComponents(o-s,u-c,g-f,_-v).normalize(),t[4].setComponents(o-a,u-h,g-m,_-x).normalize(),t[5].setComponents(o+a,u+h,g+m,_+x).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Fs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Fs)}intersectsSprite(e){return Fs.center.set(0,0,0),Fs.radius=.7071067811865476,Fs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fs)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,_l.y=r.normal.y>0?e.max.y:e.min.y,_l.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(_l)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Nv(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function IC(n,e){const t=e.isWebGL2,i=new WeakMap;function r(c,h){const u=c.array,d=c.usage,f=n.createBuffer();n.bindBuffer(h,f),n.bufferData(h,u,d),c.onUploadCallback();let m;if(u instanceof Float32Array)m=5126;else if(u instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)m=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=5123;else if(u instanceof Int16Array)m=5122;else if(u instanceof Uint32Array)m=5125;else if(u instanceof Int32Array)m=5124;else if(u instanceof Int8Array)m=5120;else if(u instanceof Uint8Array)m=5121;else if(u instanceof Uint8ClampedArray)m=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){const d=h.array,f=h.updateRange;n.bindBuffer(u,c),f.count===-1?n.bufferSubData(u,0,d):(t?n.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):n.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),h.onUploadCallback()}function a(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=i.get(c);h&&(n.deleteBuffer(h.buffer),i.delete(c))}function l(c,h){if(c.isGLBufferAttribute){const d=i.get(c);(!d||d.version 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 ); } 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_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif`,VC=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,GC=`#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, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,WC=`#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`,$C=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,qC=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,XC=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,YC=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,ZC=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,jC=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,KC=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,JC=`#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; } vec3 pow2( const in vec3 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 max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } 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 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 USE_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 ); } 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 luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, 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 ); }`,QC=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.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 ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); 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`,eL=`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`,tL=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,nL=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,iL=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,rL=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,sL="gl_FragColor = linearToOutputTexel( gl_FragColor );",aL=`vec4 LinearToLinear( in vec4 value ) { return value; } 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 ); }`,oL=`#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 ) ); #else vec4 envColor = vec4( 0.0 ); #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`,lL=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,cL=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,hL=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,uL=`#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`,dL=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,fL=`#ifdef USE_FOG varying float vFogDepth; #endif`,pL=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,mL=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,gL=`#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 vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,vL=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,_L=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,yL=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,xL=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wL=`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 vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( 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 } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.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 getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.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 getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.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 vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,ML=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`,bL=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,SL=`varying vec3 vViewPosition; 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; reflectedLight.directDiffuse += irradiance * BRDF_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_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,TL=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,EL=`varying vec3 vViewPosition; 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; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, 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_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,AL=`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.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #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_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`,CL=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); 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; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #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.roughness; 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; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_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_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 USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += 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 ); }`,LL=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #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 ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( 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; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #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 ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 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 ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( 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.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,PL=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,RL=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,IL=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,DL=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,OL=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,zL=`#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`,FL=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,NL=`#ifdef USE_MAP uniform sampler2D map; #endif`,kL=`#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 diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,UL=`#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`,BL=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,HL=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,VL=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,GL=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,WL=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,$L=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else 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 #endif`,qL=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,XL=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #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, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,YL=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,ZL=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,jL=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,KL=`#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, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,JL=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,QL=`#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, faceDirection ); #endif #endif`,eP=`#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`,tP=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,nP=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,iP=`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 ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } 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 ); }`,rP=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,sP=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,aP=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,oP=`#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`,lP=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,cP=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,hP=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #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 ]; 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; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 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`,uP=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #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 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`,dP=`#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 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_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ 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`,fP=`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, vSpotLightCoord[ 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; }`,pP=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,mP=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; 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; } #endif`,gP=`#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`,vP=`#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`,_P=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,yP=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,xP=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,wP=`#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; }`,MP=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,bP=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,SP=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,TP=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,EP=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,AP=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,CP=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,LP=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,PP=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const RP=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,IP=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,DP=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,OP=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,zP=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,FP=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,NP=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,kP=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include 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 }`,UP=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,BP=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,HP=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,VP=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,GP=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,WP=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,$P=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,qP=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include 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 += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,XP=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,YP=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,ZP=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,jP=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include 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 ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,KP=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,JP=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,QP=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,eR=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,tR=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,nR=`#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,iR=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,rR=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,sR=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,aR=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,oR=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,lR=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,cR=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,hR=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,Ze={alphamap_fragment:DC,alphamap_pars_fragment:OC,alphatest_fragment:zC,alphatest_pars_fragment:FC,aomap_fragment:NC,aomap_pars_fragment:kC,begin_vertex:UC,beginnormal_vertex:BC,bsdfs:HC,iridescence_fragment:VC,bumpmap_pars_fragment:GC,clipping_planes_fragment:WC,clipping_planes_pars_fragment:$C,clipping_planes_pars_vertex:qC,clipping_planes_vertex:XC,color_fragment:YC,color_pars_fragment:ZC,color_pars_vertex:jC,color_vertex:KC,common:JC,cube_uv_reflection_fragment:QC,defaultnormal_vertex:eL,displacementmap_pars_vertex:tL,displacementmap_vertex:nL,emissivemap_fragment:iL,emissivemap_pars_fragment:rL,encodings_fragment:sL,encodings_pars_fragment:aL,envmap_fragment:oL,envmap_common_pars_fragment:lL,envmap_pars_fragment:cL,envmap_pars_vertex:hL,envmap_physical_pars_fragment:ML,envmap_vertex:uL,fog_vertex:dL,fog_pars_vertex:fL,fog_fragment:pL,fog_pars_fragment:mL,gradientmap_pars_fragment:gL,lightmap_fragment:vL,lightmap_pars_fragment:_L,lights_lambert_fragment:yL,lights_lambert_pars_fragment:xL,lights_pars_begin:wL,lights_toon_fragment:bL,lights_toon_pars_fragment:SL,lights_phong_fragment:TL,lights_phong_pars_fragment:EL,lights_physical_fragment:AL,lights_physical_pars_fragment:CL,lights_fragment_begin:LL,lights_fragment_maps:PL,lights_fragment_end:RL,logdepthbuf_fragment:IL,logdepthbuf_pars_fragment:DL,logdepthbuf_pars_vertex:OL,logdepthbuf_vertex:zL,map_fragment:FL,map_pars_fragment:NL,map_particle_fragment:kL,map_particle_pars_fragment:UL,metalnessmap_fragment:BL,metalnessmap_pars_fragment:HL,morphcolor_vertex:VL,morphnormal_vertex:GL,morphtarget_pars_vertex:WL,morphtarget_vertex:$L,normal_fragment_begin:qL,normal_fragment_maps:XL,normal_pars_fragment:YL,normal_pars_vertex:ZL,normal_vertex:jL,normalmap_pars_fragment:KL,clearcoat_normal_fragment_begin:JL,clearcoat_normal_fragment_maps:QL,clearcoat_pars_fragment:eP,iridescence_pars_fragment:tP,output_fragment:nP,packing:iP,premultiplied_alpha_fragment:rP,project_vertex:sP,dithering_fragment:aP,dithering_pars_fragment:oP,roughnessmap_fragment:lP,roughnessmap_pars_fragment:cP,shadowmap_pars_fragment:hP,shadowmap_pars_vertex:uP,shadowmap_vertex:dP,shadowmask_pars_fragment:fP,skinbase_vertex:pP,skinning_pars_vertex:mP,skinning_vertex:gP,skinnormal_vertex:vP,specularmap_fragment:_P,specularmap_pars_fragment:yP,tonemapping_fragment:xP,tonemapping_pars_fragment:wP,transmission_fragment:MP,transmission_pars_fragment:bP,uv_pars_fragment:SP,uv_pars_vertex:TP,uv_vertex:EP,uv2_pars_fragment:AP,uv2_pars_vertex:CP,uv2_vertex:LP,worldpos_vertex:PP,background_vert:RP,background_frag:IP,backgroundCube_vert:DP,backgroundCube_frag:OP,cube_vert:zP,cube_frag:FP,depth_vert:NP,depth_frag:kP,distanceRGBA_vert:UP,distanceRGBA_frag:BP,equirect_vert:HP,equirect_frag:VP,linedashed_vert:GP,linedashed_frag:WP,meshbasic_vert:$P,meshbasic_frag:qP,meshlambert_vert:XP,meshlambert_frag:YP,meshmatcap_vert:ZP,meshmatcap_frag:jP,meshnormal_vert:KP,meshnormal_frag:JP,meshphong_vert:QP,meshphong_frag:eR,meshphysical_vert:tR,meshphysical_frag:nR,meshtoon_vert:iR,meshtoon_frag:rR,points_vert:sR,points_frag:aR,shadow_vert:oR,shadow_frag:lR,sprite_vert:cR,sprite_frag:hR},ye={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new vn},uv2Transform:{value:new vn},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},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 ne(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 xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new ne(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new vn}}},Zn={basic:{uniforms:mn([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:mn([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:mn([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:mn([ye.common,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.roughnessmap,ye.metalnessmap,ye.fog,ye.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:mn([ye.common,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.gradientmap,ye.fog,ye.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:mn([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:mn([ye.points,ye.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:mn([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:mn([ye.common,ye.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:mn([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:mn([ye.sprite,ye.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distanceRGBA:{uniforms:mn([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ze.distanceRGBA_vert,fragmentShader:Ze.distanceRGBA_frag},shadow:{uniforms:mn([ye.lights,ye.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};Zn.physical={uniforms:mn([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ne(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};const yl={r:0,b:0,g:0};function uR(n,e,t,i,r,s,a){const o=new xe(0);let l=s===!0?0:1,c,h,u=null,d=0,f=null;function m(p,v){let x=!1,_=v.isScene===!0?v.background:null;_&&_.isTexture&&(_=(v.backgroundBlurriness>0?t:e).get(_));const w=n.xr,y=w.getSession&&w.getSession();y&&y.environmentBlendMode==="additive"&&(_=null),_===null?g(o,l):_&&_.isColor&&(g(_,1),x=!0),(n.autoClear||x)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),_&&(_.isCubeTexture||_.mapping===fa)?(h===void 0&&(h=new Bt(new _i(1,1,1),new Kn({name:"BackgroundCubeMaterial",uniforms:ia(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.backgroundCube.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(b,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=_.encoding!==ot,(u!==_||d!==_.version||f!==n.toneMapping)&&(h.material.needsUpdate=!0,u=_,d=_.version,f=n.toneMapping),h.layers.enableAll(),p.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new Bt(new ma(2,2),new Kn({name:"BackgroundMaterial",uniforms:ia(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:Ui,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=_.encoding!==ot,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(u!==_||d!==_.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,u=_,d=_.version,f=n.toneMapping),c.layers.enableAll(),p.unshift(c,c.geometry,c.material,0,0,null))}function g(p,v){p.getRGB(yl,Ov(n)),i.buffers.color.setClear(yl.r,yl.g,yl.b,v,a)}return{getClearColor:function(){return o},setClearColor:function(p,v=1){o.set(p),l=v,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(p){l=p,g(o,l)},render:m}}function dR(n,e,t,i){const r=n.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),a=i.isWebGL2||s!==null,o={},l=p(null);let c=l,h=!1;function u(z,L,K,G,W){let se=!1;if(a){const ie=g(G,K,L);c!==ie&&(c=ie,f(c.object)),se=v(z,G,K,W),se&&x(z,G,K,W)}else{const ie=L.wireframe===!0;(c.geometry!==G.id||c.program!==K.id||c.wireframe!==ie)&&(c.geometry=G.id,c.program=K.id,c.wireframe=ie,se=!0)}W!==null&&t.update(W,34963),(se||h)&&(h=!1,M(z,L,K,G),W!==null&&n.bindBuffer(34963,t.get(W).buffer))}function d(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function f(z){return i.isWebGL2?n.bindVertexArray(z):s.bindVertexArrayOES(z)}function m(z){return i.isWebGL2?n.deleteVertexArray(z):s.deleteVertexArrayOES(z)}function g(z,L,K){const G=K.wireframe===!0;let W=o[z.id];W===void 0&&(W={},o[z.id]=W);let se=W[L.id];se===void 0&&(se={},W[L.id]=se);let ie=se[G];return ie===void 0&&(ie=p(d()),se[G]=ie),ie}function p(z){const L=[],K=[],G=[];for(let W=0;W=0){const de=W[Y];let he=se[Y];if(he===void 0&&(Y==="instanceMatrix"&&z.instanceMatrix&&(he=z.instanceMatrix),Y==="instanceColor"&&z.instanceColor&&(he=z.instanceColor)),de===void 0||de.attribute!==he||he&&de.data!==he.data)return!0;ie++}return c.attributesNum!==ie||c.index!==G}function x(z,L,K,G){const W={},se=L.attributes;let ie=0;const $=K.getAttributes();for(const Y in $)if($[Y].location>=0){let de=se[Y];de===void 0&&(Y==="instanceMatrix"&&z.instanceMatrix&&(de=z.instanceMatrix),Y==="instanceColor"&&z.instanceColor&&(de=z.instanceColor));const he={};he.attribute=de,de&&de.data&&(he.data=de.data),W[Y]=he,ie++}c.attributes=W,c.attributesNum=ie,c.index=G}function _(){const z=c.newAttributes;for(let L=0,K=z.length;L=0){let le=W[$];if(le===void 0&&($==="instanceMatrix"&&z.instanceMatrix&&(le=z.instanceMatrix),$==="instanceColor"&&z.instanceColor&&(le=z.instanceColor)),le!==void 0){const de=le.normalized,he=le.itemSize,X=t.get(le);if(X===void 0)continue;const we=X.buffer,ge=X.type,Oe=X.bytesPerElement;if(le.isInterleavedBufferAttribute){const ve=le.data,Ve=ve.stride,te=le.offset;if(ve.isInstancedInterleavedBuffer){for(let ee=0;ee0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";S="mediump"}return S==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&n instanceof WebGL2ComputeRenderingContext;let o=t.precision!==void 0?t.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=a||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=n.getParameter(34930),d=n.getParameter(35660),f=n.getParameter(3379),m=n.getParameter(34076),g=n.getParameter(34921),p=n.getParameter(36347),v=n.getParameter(36348),x=n.getParameter(36349),_=d>0,w=a||e.has("OES_texture_float"),y=_&&w,b=a?n.getParameter(36183):0;return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:r,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:p,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:_,floatFragmentTextures:w,floatVertexTextures:y,maxSamples:b}}function mR(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new ar,o=new vn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){const m=u.length!==0||d||i!==0||r;return r=d,t=h(u,f,0),i=u.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1,c()},this.setState=function(u,d,f){const m=u.clippingPlanes,g=u.clipIntersection,p=u.clipShadows,v=n.get(u);if(!r||m===null||m.length===0||s&&!p)s?h(null):c();else{const x=s?0:i,_=x*4;let w=v.clippingState||null;l.value=w,w=h(m,d,_,f);for(let y=0;y!==_;++y)w[y]=t[y];v.clippingState=w,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,f,m){const g=u!==null?u.length:0;let p=null;if(g!==0){if(p=l.value,m!==!0||p===null){const v=f+g*4,x=d.matrixWorldInverse;o.getNormalMatrix(x),(p===null||p.length0){const c=new Fv(l.height/2);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Co extends Lc{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const qs=4,Kf=[.125,.215,.35,.446,.526,.582],$r=20,Ph=new Co,Jf=new xe;let Rh=null;const Vr=(1+Math.sqrt(5))/2,Ns=1/Vr,Qf=[new R(1,1,1),new R(-1,1,1),new R(1,1,-1),new R(-1,1,-1),new R(0,Vr,Ns),new R(0,Vr,-Ns),new R(Ns,0,Vr),new R(-Ns,0,Vr),new R(Vr,Ns,0),new R(-Vr,Ns,0)];class Ou{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){Rh=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=np(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=tp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?_:0,_,_),h.setRenderTarget(r),g&&h.render(m,o),h.render(e,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=p}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===ur||e.mapping===dr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=np()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=tp());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Bt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;xl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Ph)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;r$r&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${$r}`);const v=[];let x=0;for(let S=0;S<$r;++S){const M=S/g,T=Math.exp(-M*M/2);v.push(T),S===0?x+=T:S_-qs?r-_+qs:0),b=4*(this._cubeSize-w);xl(t,y,b,3*w,2*w),l.setRenderTarget(t),l.render(u,Ph)}}function vR(n){const e=[],t=[],i=[];let r=n;const s=n-qs+1+Kf.length;for(let a=0;an-qs?l=Kf[a-n+qs-1]:a===0&&(l=0),i.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,g=3,p=2,v=1,x=new Float32Array(g*m*f),_=new Float32Array(p*m*f),w=new Float32Array(v*m*f);for(let b=0;b2?0:-1,T=[S,M,0,S+2/3,M,0,S+2/3,M+1,0,S,M,0,S+2/3,M+1,0,S,M+1,0];x.set(T,g*m*b),_.set(d,p*m*b);const C=[b,b,b,b,b,b];w.set(C,v*m*b)}const y=new Ye;y.setAttribute("position",new lt(x,g)),y.setAttribute("uv",new lt(_,p)),y.setAttribute("faceIndex",new lt(w,v)),e.push(y),r>qs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function ep(n,e,t){const i=new Hn(n,e,t);return i.texture.mapping=fa,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function _R(n,e,t){const i=new Float32Array($r),r=new R(0,1,0);return new Kn({name:"SphericalGaussianBlur",defines:{n:$r,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Sd(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:zi,depthTest:!1,depthWrite:!1})}function tp(){return new Kn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Sd(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:zi,depthTest:!1,depthWrite:!1})}function np(){return new Kn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Sd(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:zi,depthTest:!1,depthWrite:!1})}function Sd(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function yR(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===Qs||l===Qa,h=l===ur||l===dr;if(c||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=e.get(o);return t===null&&(t=new Ou(n)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),e.set(o,u),u.texture}else{if(e.has(o))return e.get(o).texture;{const u=o.image;if(c&&u&&u.height>0||h&&u&&r(u)){t===null&&(t=new Ou(n));const d=c?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,d),o.addEventListener("dispose",s),d.texture}else return null}}}return o}function r(o){let l=0;const c=6;for(let h=0;he.maxTextureSize&&(U=Math.ceil(O/e.maxTextureSize),O=e.maxTextureSize);const F=new Float32Array(O*U*4*p),z=new To(F,O,U,p);z.type=Bn,z.needsUpdate=!0;const L=C*4;for(let G=0;G0)return n;const r=e*t;let s=ip[r];if(s===void 0&&(s=new Float32Array(r),ip[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function qt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${o}: ${t[a]}`)}return i.join(` `)}function xI(n){switch(n){case Bi:return["Linear","( value )"];case ot:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function hp(n,e,t){const i=n.getShaderParameter(e,35713),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` `+r+` `+yI(n.getShaderSource(e),a)}else return r}function wI(n,e){const t=xI(e);return"vec4 "+n+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function MI(n,e){let t;switch(e){case rv:t="Linear";break;case sv:t="Reinhard";break;case av:t="OptimizedCineon";break;case md:t="ACESFilmic";break;case ov:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function bI(n){return[n.extensionDerivatives||n.envMapCubeUVHeight||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Va).join(` `)}function SI(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function TI(n,e){const t={},i=n.getProgramParameter(e,35721);for(let r=0;r/gm;function zu(n){return n.replace(EI,AI)}function AI(n,e){const t=Ze[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return zu(t)}const CI=/#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 fp(n){return n.replace(CI,LI)}function LI(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(p+=` `),v=[f,m].filter(Va).join(` `),v.length>0&&(v+=` `)):(p=[pp(t),"#define SHADER_NAME "+t.shaderName,m,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.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","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Va).join(` `),v=[f,pp(t),"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==li?"#define TONE_MAPPING":"",t.toneMapping!==li?Ze.tonemapping_pars_fragment:"",t.toneMapping!==li?MI("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ze.encodings_pars_fragment,wI("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Va).join(` `)),a=zu(a),a=up(a,t),a=dp(a,t),o=zu(o),o=up(o,t),o=dp(o,t),a=fp(a),o=fp(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es `,p=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+p,v=["#define varying in",t.glslVersion===Iu?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Iu?"":"#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(` `)+` `+v);const _=x+p+a,w=x+v+o,y=cp(r,35633,_),b=cp(r,35632,w);if(r.attachShader(g,y),r.attachShader(g,b),t.index0AttributeName!==void 0?r.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(g,0,"position"),r.linkProgram(g),n.debug.checkShaderErrors){const T=r.getProgramInfoLog(g).trim(),C=r.getShaderInfoLog(y).trim(),O=r.getShaderInfoLog(b).trim();let U=!0,F=!0;if(r.getProgramParameter(g,35714)===!1){U=!1;const z=hp(r,y,"vertex"),L=hp(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(g,35715)+` Program Info Log: `+T+` `+z+` `+L)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(C===""||O==="")&&(F=!1);F&&(this.diagnostics={runnable:U,programLog:T,vertexShader:{log:C,prefix:p},fragmentShader:{log:O,prefix:v}})}r.deleteShader(y),r.deleteShader(b);let S;this.getUniforms=function(){return S===void 0&&(S=new tc(r,g)),S};let M;return this.getAttributes=function(){return M===void 0&&(M=TI(r,g)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.name=t.shaderName,this.id=_I++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=y,this.fragmentShader=b,this}let FI=0;class NI{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new kI(e),t.set(e,i)),i}}class kI{constructor(e){this.id=FI++,this.code=e,this.usedTimes=0}}function UI(n,e,t,i,r,s,a){const o=new Cc,l=new NI,c=[],h=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures;let f=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(M,T,C,O,U){const F=O.fog,z=U.geometry,L=M.isMeshStandardMaterial?O.environment:null,K=(M.isMeshStandardMaterial?t:e).get(M.envMap||L),G=K&&K.mapping===fa?K.image.height:null,W=m[M.type];M.precision!==null&&(f=r.getMaxPrecision(M.precision),f!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",f,"instead."));const se=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,ie=se!==void 0?se.length:0;let $=0;z.morphAttributes.position!==void 0&&($=1),z.morphAttributes.normal!==void 0&&($=2),z.morphAttributes.color!==void 0&&($=3);let Y,le,de,he;if(W){const Ve=Zn[W];Y=Ve.vertexShader,le=Ve.fragmentShader}else Y=M.vertexShader,le=M.fragmentShader,l.update(M),de=l.getVertexShaderID(M),he=l.getFragmentShaderID(M);const X=n.getRenderTarget(),we=M.alphaTest>0,ge=M.clearcoat>0,Oe=M.iridescence>0;return{isWebGL2:h,shaderID:W,shaderName:M.type,vertexShader:Y,fragmentShader:le,defines:M.defines,customVertexShaderID:de,customFragmentShaderID:he,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:f,instancing:U.isInstancedMesh===!0,instancingColor:U.isInstancedMesh===!0&&U.instanceColor!==null,supportsVertexTextures:d,outputEncoding:X===null?n.outputEncoding:X.isXRRenderTarget===!0?X.texture.encoding:Bi,map:!!M.map,matcap:!!M.matcap,envMap:!!K,envMapMode:K&&K.mapping,envMapCubeUVHeight:G,lightMap:!!M.lightMap,aoMap:!!M.aoMap,emissiveMap:!!M.emissiveMap,bumpMap:!!M.bumpMap,normalMap:!!M.normalMap,objectSpaceNormalMap:M.normalMapType===Lv,tangentSpaceNormalMap:M.normalMapType===br,decodeVideoTexture:!!M.map&&M.map.isVideoTexture===!0&&M.map.encoding===ot,clearcoat:ge,clearcoatMap:ge&&!!M.clearcoatMap,clearcoatRoughnessMap:ge&&!!M.clearcoatRoughnessMap,clearcoatNormalMap:ge&&!!M.clearcoatNormalMap,iridescence:Oe,iridescenceMap:Oe&&!!M.iridescenceMap,iridescenceThicknessMap:Oe&&!!M.iridescenceThicknessMap,displacementMap:!!M.displacementMap,roughnessMap:!!M.roughnessMap,metalnessMap:!!M.metalnessMap,specularMap:!!M.specularMap,specularIntensityMap:!!M.specularIntensityMap,specularColorMap:!!M.specularColorMap,opaque:M.transparent===!1&&M.blending===jr,alphaMap:!!M.alphaMap,alphaTest:we,gradientMap:!!M.gradientMap,sheen:M.sheen>0,sheenColorMap:!!M.sheenColorMap,sheenRoughnessMap:!!M.sheenRoughnessMap,transmission:M.transmission>0,transmissionMap:!!M.transmissionMap,thicknessMap:!!M.thicknessMap,combine:M.combine,vertexTangents:!!M.normalMap&&!!z.attributes.tangent,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,vertexUvs:!!M.map||!!M.bumpMap||!!M.normalMap||!!M.specularMap||!!M.alphaMap||!!M.emissiveMap||!!M.roughnessMap||!!M.metalnessMap||!!M.clearcoatMap||!!M.clearcoatRoughnessMap||!!M.clearcoatNormalMap||!!M.iridescenceMap||!!M.iridescenceThicknessMap||!!M.displacementMap||!!M.transmissionMap||!!M.thicknessMap||!!M.specularIntensityMap||!!M.specularColorMap||!!M.sheenColorMap||!!M.sheenRoughnessMap,uvsVertexOnly:!(M.map||M.bumpMap||M.normalMap||M.specularMap||M.alphaMap||M.emissiveMap||M.roughnessMap||M.metalnessMap||M.clearcoatNormalMap||M.iridescenceMap||M.iridescenceThicknessMap||M.transmission>0||M.transmissionMap||M.thicknessMap||M.specularIntensityMap||M.specularColorMap||M.sheen>0||M.sheenColorMap||M.sheenRoughnessMap)&&!!M.displacementMap,fog:!!F,useFog:M.fog===!0,fogExp2:F&&F.isFogExp2,flatShading:!!M.flatShading,sizeAttenuation:M.sizeAttenuation,logarithmicDepthBuffer:u,skinning:U.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:ie,morphTextureStride:$,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&C.length>0,shadowMapType:n.shadowMap.type,toneMapping:M.toneMapped?n.toneMapping:li,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===bo,flipSided:M.side===bn,useDepthPacking:!!M.depthPacking,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:M.extensions&&M.extensions.derivatives,extensionFragDepth:M.extensions&&M.extensions.fragDepth,extensionDrawBuffers:M.extensions&&M.extensions.drawBuffers,extensionShaderTextureLOD:M.extensions&&M.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:M.customProgramCacheKey()}}function p(M){const T=[];if(M.shaderID?T.push(M.shaderID):(T.push(M.customVertexShaderID),T.push(M.customFragmentShaderID)),M.defines!==void 0)for(const C in M.defines)T.push(C),T.push(M.defines[C]);return M.isRawShaderMaterial===!1&&(v(T,M),x(T,M),T.push(n.outputEncoding)),T.push(M.customProgramCacheKey),T.join()}function v(M,T){M.push(T.precision),M.push(T.outputEncoding),M.push(T.envMapMode),M.push(T.envMapCubeUVHeight),M.push(T.combine),M.push(T.vertexUvs),M.push(T.fogExp2),M.push(T.sizeAttenuation),M.push(T.morphTargetsCount),M.push(T.morphAttributeCount),M.push(T.numDirLights),M.push(T.numPointLights),M.push(T.numSpotLights),M.push(T.numSpotLightMaps),M.push(T.numHemiLights),M.push(T.numRectAreaLights),M.push(T.numDirLightShadows),M.push(T.numPointLightShadows),M.push(T.numSpotLightShadows),M.push(T.numSpotLightShadowsWithMaps),M.push(T.shadowMapType),M.push(T.toneMapping),M.push(T.numClippingPlanes),M.push(T.numClipIntersection),M.push(T.depthPacking)}function x(M,T){o.disableAll(),T.isWebGL2&&o.enable(0),T.supportsVertexTextures&&o.enable(1),T.instancing&&o.enable(2),T.instancingColor&&o.enable(3),T.map&&o.enable(4),T.matcap&&o.enable(5),T.envMap&&o.enable(6),T.lightMap&&o.enable(7),T.aoMap&&o.enable(8),T.emissiveMap&&o.enable(9),T.bumpMap&&o.enable(10),T.normalMap&&o.enable(11),T.objectSpaceNormalMap&&o.enable(12),T.tangentSpaceNormalMap&&o.enable(13),T.clearcoat&&o.enable(14),T.clearcoatMap&&o.enable(15),T.clearcoatRoughnessMap&&o.enable(16),T.clearcoatNormalMap&&o.enable(17),T.iridescence&&o.enable(18),T.iridescenceMap&&o.enable(19),T.iridescenceThicknessMap&&o.enable(20),T.displacementMap&&o.enable(21),T.specularMap&&o.enable(22),T.roughnessMap&&o.enable(23),T.metalnessMap&&o.enable(24),T.gradientMap&&o.enable(25),T.alphaMap&&o.enable(26),T.alphaTest&&o.enable(27),T.vertexColors&&o.enable(28),T.vertexAlphas&&o.enable(29),T.vertexUvs&&o.enable(30),T.vertexTangents&&o.enable(31),T.uvsVertexOnly&&o.enable(32),M.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.skinning&&o.enable(4),T.morphTargets&&o.enable(5),T.morphNormals&&o.enable(6),T.morphColors&&o.enable(7),T.premultipliedAlpha&&o.enable(8),T.shadowMapEnabled&&o.enable(9),T.physicallyCorrectLights&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.specularIntensityMap&&o.enable(15),T.specularColorMap&&o.enable(16),T.transmission&&o.enable(17),T.transmissionMap&&o.enable(18),T.thicknessMap&&o.enable(19),T.sheen&&o.enable(20),T.sheenColorMap&&o.enable(21),T.sheenRoughnessMap&&o.enable(22),T.decodeVideoTexture&&o.enable(23),T.opaque&&o.enable(24),M.push(o.mask)}function _(M){const T=m[M.type];let C;if(T){const O=Zn[T];C=bd.clone(O.uniforms)}else C=M.uniforms;return C}function w(M,T){let C;for(let O=0,U=c.length;O0?i.push(v):f.transparent===!0?r.push(v):t.push(v)}function l(u,d,f,m,g,p){const v=a(u,d,f,m,g,p);f.transmission>0?i.unshift(v):f.transparent===!0?r.unshift(v):t.unshift(v)}function c(u,d){t.length>1&&t.sort(u||HI),i.length>1&&i.sort(d||mp),r.length>1&&r.sort(d||mp)}function h(){for(let u=e,d=n.length;u=s.length?(a=new gp,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function GI(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new xe};break;case"SpotLight":t={position:new R,direction:new R,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new R,halfWidth:new R,halfHeight:new R};break}return n[e.id]=t,t}}}function WI(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let $I=0;function qI(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function XI(n,e){const t=new GI,i=WI(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let h=0;h<9;h++)r.probe.push(new R);const s=new R,a=new Ge,o=new Ge;function l(h,u){let d=0,f=0,m=0;for(let O=0;O<9;O++)r.probe[O].set(0,0,0);let g=0,p=0,v=0,x=0,_=0,w=0,y=0,b=0,S=0,M=0;h.sort(qI);const T=u!==!0?Math.PI:1;for(let O=0,U=h.length;O0&&(e.isWebGL2||n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=ye.LTC_FLOAT_1,r.rectAreaLTC2=ye.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=ye.LTC_HALF_1,r.rectAreaLTC2=ye.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const C=r.hash;(C.directionalLength!==g||C.pointLength!==p||C.spotLength!==v||C.rectAreaLength!==x||C.hemiLength!==_||C.numDirectionalShadows!==w||C.numPointShadows!==y||C.numSpotShadows!==b||C.numSpotMaps!==S)&&(r.directional.length=g,r.spot.length=v,r.rectArea.length=x,r.point.length=p,r.hemi.length=_,r.directionalShadow.length=w,r.directionalShadowMap.length=w,r.pointShadow.length=y,r.pointShadowMap.length=y,r.spotShadow.length=b,r.spotShadowMap.length=b,r.directionalShadowMatrix.length=w,r.pointShadowMatrix.length=y,r.spotLightMatrix.length=b+S-M,r.spotLightMap.length=S,r.numSpotLightShadowsWithMaps=M,C.directionalLength=g,C.pointLength=p,C.spotLength=v,C.rectAreaLength=x,C.hemiLength=_,C.numDirectionalShadows=w,C.numPointShadows=y,C.numSpotShadows=b,C.numSpotMaps=S,r.version=$I++)}function c(h,u){let d=0,f=0,m=0,g=0,p=0;const v=u.matrixWorldInverse;for(let x=0,_=h.length;x<_;x++){const w=h[x];if(w.isDirectionalLight){const y=r.directional[d];y.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),y.direction.sub(s),y.direction.transformDirection(v),d++}else if(w.isSpotLight){const y=r.spot[m];y.position.setFromMatrixPosition(w.matrixWorld),y.position.applyMatrix4(v),y.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),y.direction.sub(s),y.direction.transformDirection(v),m++}else if(w.isRectAreaLight){const y=r.rectArea[g];y.position.setFromMatrixPosition(w.matrixWorld),y.position.applyMatrix4(v),o.identity(),a.copy(w.matrixWorld),a.premultiply(v),o.extractRotation(a),y.halfWidth.set(w.width*.5,0,0),y.halfHeight.set(0,w.height*.5,0),y.halfWidth.applyMatrix4(o),y.halfHeight.applyMatrix4(o),g++}else if(w.isPointLight){const y=r.point[f];y.position.setFromMatrixPosition(w.matrixWorld),y.position.applyMatrix4(v),f++}else if(w.isHemisphereLight){const y=r.hemi[p];y.direction.setFromMatrixPosition(w.matrixWorld),y.direction.transformDirection(v),p++}}}return{setup:l,setupView:c,state:r}}function vp(n,e){const t=new XI(n,e),i=[],r=[];function s(){i.length=0,r.length=0}function a(u){i.push(u)}function o(u){r.push(u)}function l(u){t.setup(i,u)}function c(u){t.setupView(i,u)}return{init:s,state:{lightsArray:i,shadowsArray:r,lights:t},setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function YI(n,e){let t=new WeakMap;function i(s,a=0){const o=t.get(s);let l;return o===void 0?(l=new vp(n,e),t.set(s,[l])):a>=o.length?(l=new vp(n,e),o.push(l)):l=o[a],l}function r(){t=new WeakMap}return{get:i,dispose:r}}class Td extends $t{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Av,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ed extends $t{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new R,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const ZI=`void main() { gl_Position = vec4( position, 1.0 ); }`,jI=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 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, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function KI(n,e,t){let i=new Pc;const r=new ne,s=new ne,a=new dt,o=new Td({depthPacking:Cv}),l=new Ed,c={},h=t.maxTextureSize,u={0:bn,1:Ui,2:bo},d=new Kn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ne},radius:{value:4}},vertexShader:ZI,fragmentShader:jI}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Ye;m.setAttribute("position",new lt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Bt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dd,this.render=function(w,y,b){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;const S=n.getRenderTarget(),M=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),C=n.state;C.setBlending(zi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let O=0,U=w.length;Oh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/L.x),r.x=s.x*L.x,z.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/L.y),r.y=s.y*L.y,z.mapSize.y=s.y)),z.map===null){const G=this.type!==Ws?{minFilter:It,magFilter:It}:{};z.map=new Hn(r.x,r.y,G),z.map.texture.name=F.name+".shadowMap",z.camera.updateProjectionMatrix()}n.setRenderTarget(z.map),n.clear();const K=z.getViewportCount();for(let G=0;G0||y.map&&y.alphaTest>0){const U=C.uuid,F=y.uuid;let z=c[U];z===void 0&&(z={},c[U]=z);let L=z[F];L===void 0&&(L=C.clone(),z[F]=L),C=L}return C.visible=y.visible,C.wireframe=y.wireframe,T===Ws?C.side=y.shadowSide!==null?y.shadowSide:y.side:C.side=y.shadowSide!==null?y.shadowSide:u[y.side],C.alphaMap=y.alphaMap,C.alphaTest=y.alphaTest,C.map=y.map,C.clipShadows=y.clipShadows,C.clippingPlanes=y.clippingPlanes,C.clipIntersection=y.clipIntersection,C.displacementMap=y.displacementMap,C.displacementScale=y.displacementScale,C.displacementBias=y.displacementBias,C.wireframeLinewidth=y.wireframeLinewidth,C.linewidth=y.linewidth,b.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(b.matrixWorld),C.nearDistance=S,C.farDistance=M),C}function _(w,y,b,S,M){if(w.visible===!1)return;if(w.layers.test(y.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&M===Ws)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);const O=e.update(w),U=w.material;if(Array.isArray(U)){const F=O.groups;for(let z=0,L=F.length;z=1):W.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),K=G>=2);let se=null,ie={};const $=n.getParameter(3088),Y=n.getParameter(2978),le=new dt().fromArray($),de=new dt().fromArray(Y);function he(k,J,ce){const be=new Uint8Array(4),Ie=n.createTexture();n.bindTexture(k,Ie),n.texParameteri(k,10241,9728),n.texParameteri(k,10240,9728);for(let at=0;at"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let g;const p=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(P,E){return v?new OffscreenCanvas(P,E):so("canvas")}function _(P,E,H,re){let ae=1;if((P.width>re||P.height>re)&&(ae=re/Math.max(P.width,P.height)),ae<1||E===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){const me=E?uc:Math.floor,Te=me(ae*P.width),oe=me(ae*P.height);g===void 0&&(g=x(Te,oe));const q=H?x(Te,oe):g;return q.width=Te,q.height=oe,q.getContext("2d").drawImage(P,0,0,Te,oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Te+"x"+oe+")."),q}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function w(P){return Du(P.width)&&Du(P.height)}function y(P){return o?!1:P.wrapS!==nn||P.wrapT!==nn||P.minFilter!==It&&P.minFilter!==Mt}function b(P,E){return P.generateMipmaps&&E&&P.minFilter!==It&&P.minFilter!==Mt}function S(P){n.generateMipmap(P)}function M(P,E,H,re,ae=!1){if(o===!1)return E;if(P!==null){if(n[P]!==void 0)return n[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let me=E;return E===6403&&(H===5126&&(me=33326),H===5131&&(me=33325),H===5121&&(me=33321)),E===33319&&(H===5126&&(me=33328),H===5131&&(me=33327),H===5121&&(me=33323)),E===6408&&(H===5126&&(me=34836),H===5131&&(me=34842),H===5121&&(me=re===ot&&ae===!1?35907:32856),H===32819&&(me=32854),H===32820&&(me=32855)),(me===33325||me===33326||me===33327||me===33328||me===34842||me===34836)&&e.get("EXT_color_buffer_float"),me}function T(P,E,H){return b(P,H)===!0||P.isFramebufferTexture&&P.minFilter!==It&&P.minFilter!==Mt?Math.log2(Math.max(E.width,E.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?E.mipmaps.length:1}function C(P){return P===It||P===eo||P===js?9728:9729}function O(P){const E=P.target;E.removeEventListener("dispose",O),F(E),E.isVideoTexture&&m.delete(E)}function U(P){const E=P.target;E.removeEventListener("dispose",U),L(E)}function F(P){const E=i.get(P);if(E.__webglInit===void 0)return;const H=P.source,re=p.get(H);if(re){const ae=re[E.__cacheKey];ae.usedTimes--,ae.usedTimes===0&&z(P),Object.keys(re).length===0&&p.delete(H)}i.remove(P)}function z(P){const E=i.get(P);n.deleteTexture(E.__webglTexture);const H=P.source,re=p.get(H);delete re[E.__cacheKey],a.memory.textures--}function L(P){const E=P.texture,H=i.get(P),re=i.get(E);if(re.__webglTexture!==void 0&&(n.deleteTexture(re.__webglTexture),a.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let ae=0;ae<6;ae++)n.deleteFramebuffer(H.__webglFramebuffer[ae]),H.__webglDepthbuffer&&n.deleteRenderbuffer(H.__webglDepthbuffer[ae]);else{if(n.deleteFramebuffer(H.__webglFramebuffer),H.__webglDepthbuffer&&n.deleteRenderbuffer(H.__webglDepthbuffer),H.__webglMultisampledFramebuffer&&n.deleteFramebuffer(H.__webglMultisampledFramebuffer),H.__webglColorRenderbuffer)for(let ae=0;ae=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),K+=1,P}function se(P){const E=[];return E.push(P.wrapS),E.push(P.wrapT),E.push(P.wrapR||0),E.push(P.magFilter),E.push(P.minFilter),E.push(P.anisotropy),E.push(P.internalFormat),E.push(P.format),E.push(P.type),E.push(P.generateMipmaps),E.push(P.premultiplyAlpha),E.push(P.flipY),E.push(P.unpackAlignment),E.push(P.encoding),E.join()}function ie(P,E){const H=i.get(P);if(P.isVideoTexture&&ut(P),P.isRenderTargetTexture===!1&&P.version>0&&H.__version!==P.version){const re=P.image;if(re===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(H,P,E);return}}t.bindTexture(3553,H.__webglTexture,33984+E)}function $(P,E){const H=i.get(P);if(P.version>0&&H.__version!==P.version){ge(H,P,E);return}t.bindTexture(35866,H.__webglTexture,33984+E)}function Y(P,E){const H=i.get(P);if(P.version>0&&H.__version!==P.version){ge(H,P,E);return}t.bindTexture(32879,H.__webglTexture,33984+E)}function le(P,E){const H=i.get(P);if(P.version>0&&H.__version!==P.version){Oe(H,P,E);return}t.bindTexture(34067,H.__webglTexture,33984+E)}const de={[fr]:10497,[nn]:33071,[ea]:33648},he={[It]:9728,[eo]:9984,[js]:9986,[Mt]:9729,[Tc]:9985,[ui]:9987};function X(P,E,H){if(H?(n.texParameteri(P,10242,de[E.wrapS]),n.texParameteri(P,10243,de[E.wrapT]),(P===32879||P===35866)&&n.texParameteri(P,32882,de[E.wrapR]),n.texParameteri(P,10240,he[E.magFilter]),n.texParameteri(P,10241,he[E.minFilter])):(n.texParameteri(P,10242,33071),n.texParameteri(P,10243,33071),(P===32879||P===35866)&&n.texParameteri(P,32882,33071),(E.wrapS!==nn||E.wrapT!==nn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(P,10240,C(E.magFilter)),n.texParameteri(P,10241,C(E.minFilter)),E.minFilter!==It&&E.minFilter!==Mt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const re=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===It||E.minFilter!==js&&E.minFilter!==ui||E.type===Bn&&e.has("OES_texture_float_linear")===!1||o===!1&&E.type===oi&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||i.get(E).__currentAnisotropy)&&(n.texParameterf(P,re.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,r.getMaxAnisotropy())),i.get(E).__currentAnisotropy=E.anisotropy)}}function we(P,E){let H=!1;P.__webglInit===void 0&&(P.__webglInit=!0,E.addEventListener("dispose",O));const re=E.source;let ae=p.get(re);ae===void 0&&(ae={},p.set(re,ae));const me=se(E);if(me!==P.__cacheKey){ae[me]===void 0&&(ae[me]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,H=!0),ae[me].usedTimes++;const Te=ae[P.__cacheKey];Te!==void 0&&(ae[P.__cacheKey].usedTimes--,Te.usedTimes===0&&z(E)),P.__cacheKey=me,P.__webglTexture=ae[me].texture}return H}function ge(P,E,H){let re=3553;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(re=35866),E.isData3DTexture&&(re=32879);const ae=we(P,E),me=E.source;t.bindTexture(re,P.__webglTexture,33984+H);const Te=i.get(me);if(me.version!==Te.__version||ae===!0){t.activeTexture(33984+H),n.pixelStorei(37440,E.flipY),n.pixelStorei(37441,E.premultiplyAlpha),n.pixelStorei(3317,E.unpackAlignment),n.pixelStorei(37443,0);const oe=y(E)&&w(E.image)===!1;let q=_(E.image,oe,!1,h);q=rt(E,q);const Le=w(q)||o,Ne=s.convert(E.format,E.encoding);let Ee=s.convert(E.type),Pe=M(E.internalFormat,Ne,Ee,E.encoding,E.isVideoTexture);X(re,E,Le);let Re;const Qe=E.mipmaps,_t=o&&E.isVideoTexture!==!0,Nt=Te.__version===void 0||ae===!0,k=T(E,q,Le);if(E.isDepthTexture)Pe=6402,o?E.type===Bn?Pe=36012:E.type===lr?Pe=33190:E.type===Kr?Pe=35056:Pe=33189:E.type===Bn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===cr&&Pe===6402&&E.type!==gd&&E.type!==lr&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=lr,Ee=s.convert(E.type)),E.format===rs&&Pe===6402&&(Pe=34041,E.type!==Kr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=Kr,Ee=s.convert(E.type))),Nt&&(_t?t.texStorage2D(3553,1,Pe,q.width,q.height):t.texImage2D(3553,0,Pe,q.width,q.height,0,Ne,Ee,null));else if(E.isDataTexture)if(Qe.length>0&&Le){_t&&Nt&&t.texStorage2D(3553,k,Pe,Qe[0].width,Qe[0].height);for(let J=0,ce=Qe.length;J>=1,ce>>=1}}else if(Qe.length>0&&Le){_t&&Nt&&t.texStorage2D(3553,k,Pe,Qe[0].width,Qe[0].height);for(let J=0,ce=Qe.length;J0&&Nt++,t.texStorage2D(34067,Nt,Re,q[0].width,q[0].height));for(let J=0;J<6;J++)if(oe){Qe?t.texSubImage2D(34069+J,0,0,0,q[J].width,q[J].height,Ee,Pe,q[J].data):t.texImage2D(34069+J,0,Re,q[J].width,q[J].height,0,Ee,Pe,q[J].data);for(let ce=0;ce=34069&&ae<=34074)&&n.framebufferTexture2D(36160,re,ae,i.get(H).__webglTexture,0),t.bindFramebuffer(36160,null)}function Ve(P,E,H){if(n.bindRenderbuffer(36161,P),E.depthBuffer&&!E.stencilBuffer){let re=33189;if(H||Se(E)){const ae=E.depthTexture;ae&&ae.isDepthTexture&&(ae.type===Bn?re=36012:ae.type===lr&&(re=33190));const me=De(E);Se(E)?d.renderbufferStorageMultisampleEXT(36161,me,re,E.width,E.height):n.renderbufferStorageMultisample(36161,me,re,E.width,E.height)}else n.renderbufferStorage(36161,re,E.width,E.height);n.framebufferRenderbuffer(36160,36096,36161,P)}else if(E.depthBuffer&&E.stencilBuffer){const re=De(E);H&&Se(E)===!1?n.renderbufferStorageMultisample(36161,re,35056,E.width,E.height):Se(E)?d.renderbufferStorageMultisampleEXT(36161,re,35056,E.width,E.height):n.renderbufferStorage(36161,34041,E.width,E.height),n.framebufferRenderbuffer(36160,33306,36161,P)}else{const re=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let ae=0;ae0&&Se(P)===!1){const oe=me?E:[E];H.__webglMultisampledFramebuffer=n.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,H.__webglMultisampledFramebuffer);for(let q=0;q0&&Se(P)===!1){const E=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],H=P.width,re=P.height;let ae=16384;const me=[],Te=P.stencilBuffer?33306:36096,oe=i.get(P),q=P.isWebGLMultipleRenderTargets===!0;if(q)for(let Le=0;Le0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function ut(P){const E=a.render.frame;m.get(P)!==E&&(m.set(P,E),P.update())}function rt(P,E){const H=P.encoding,re=P.format,ae=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===hc||H!==Bi&&(H===ot?o===!1?e.has("EXT_sRGB")===!0&&re===Cn?(P.format=hc,P.minFilter=Mt,P.generateMipmaps=!1):E=xd.sRGBToLinear(E):(re!==Cn||ae!==pr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",H)),E}this.allocateTextureUnit=W,this.resetTextureUnits=G,this.setTexture2D=ie,this.setTexture2DArray=$,this.setTexture3D=Y,this.setTextureCube=le,this.rebindTextures=ue,this.setupRenderTarget=Me,this.updateRenderTargetMipmap=_e,this.updateMultisampleRenderTarget=Be,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=ve,this.useMultisampledRTT=Se}function Vv(n,e,t){const i=t.isWebGL2;function r(s,a=null){let o;if(s===pr)return 5121;if(s===uv)return 32819;if(s===dv)return 32820;if(s===lv)return 5120;if(s===cv)return 5122;if(s===gd)return 5123;if(s===hv)return 5124;if(s===lr)return 5125;if(s===Bn)return 5126;if(s===oi)return i?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===fv)return 6406;if(s===Cn)return 6408;if(s===mv)return 6409;if(s===gv)return 6410;if(s===cr)return 6402;if(s===rs)return 34041;if(s===pv)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===hc)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===vv)return 6403;if(s===_v)return 36244;if(s===yv)return 33319;if(s===xv)return 33320;if(s===wv)return 36249;if(s===Yl||s===Zl||s===jl||s===Kl)if(a===ot)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===Yl)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Zl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===jl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Kl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Yl)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Zl)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===jl)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Kl)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===uu||s===du||s===fu||s===pu)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===uu)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===du)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===fu)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===pu)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Mv)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===mu||s===gu)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===mu)return a===ot?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===gu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===vu||s===_u||s===yu||s===xu||s===wu||s===Mu||s===bu||s===Su||s===Tu||s===Eu||s===Au||s===Cu||s===Lu||s===Pu)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===vu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===_u)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===yu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===xu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===wu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Mu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===bu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Su)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Tu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Eu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Au)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Cu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Lu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Pu)return a===ot?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ru)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Ru)return a===ot?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Kr?i?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}class Gv extends Wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}let Di=class extends it{constructor(){super(),this.isGroup=!0,this.type="Group"}};const eD={type:"move"};class Dh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Di,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Di,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Di,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const g of e.hand.values()){const p=t.getJointPose(g,i),v=this._getHandJoint(c,g);p!==null&&(v.matrix.fromArray(p.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=p.radius),v.visible=p!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(eD)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Di;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class Wv extends Pt{constructor(e,t,i,r,s,a,o,l,c,h){if(h=h!==void 0?h:cr,h!==cr&&h!==rs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===cr&&(i=lr),i===void 0&&h===rs&&(i=Kr),super(null,r,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:It,this.minFilter=l!==void 0?l:It,this.flipY=!1,this.generateMipmaps=!1}}class tD extends qi{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=null,c=null,h=null,u=null,d=null,f=null;const m=t.getContextAttributes();let g=null,p=null;const v=[],x=[],_=new Set,w=new Map,y=new Wt;y.layers.enable(1),y.viewport=new dt;const b=new Wt;b.layers.enable(2),b.viewport=new dt;const S=[y,b],M=new Gv;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let Y=v[$];return Y===void 0&&(Y=new Dh,v[$]=Y),Y.getTargetRaySpace()},this.getControllerGrip=function($){let Y=v[$];return Y===void 0&&(Y=new Dh,v[$]=Y),Y.getGripSpace()},this.getHand=function($){let Y=v[$];return Y===void 0&&(Y=new Dh,v[$]=Y),Y.getHandSpace()};function O($){const Y=x.indexOf($.inputSource);if(Y===-1)return;const le=v[Y];le!==void 0&&le.dispatchEvent({type:$.type,data:$.inputSource})}function U(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",U),r.removeEventListener("inputsourceschange",F);for(let $=0;$=0&&(x[de]=null,v[de].disconnect(le))}for(let Y=0;Y<$.added.length;Y++){const le=$.added[Y];let de=x.indexOf(le);if(de===-1){for(let X=0;X=x.length){x.push(le),de=X;break}else if(x[X]===null){x[X]=le,de=X;break}if(de===-1)break}const he=v[de];he&&he.connect(le)}}const z=new R,L=new R;function K($,Y,le){z.setFromMatrixPosition(Y.matrixWorld),L.setFromMatrixPosition(le.matrixWorld);const de=z.distanceTo(L),he=Y.projectionMatrix.elements,X=le.projectionMatrix.elements,we=he[14]/(he[10]-1),ge=he[14]/(he[10]+1),Oe=(he[9]+1)/he[5],ve=(he[9]-1)/he[5],Ve=(he[8]-1)/he[0],te=(X[8]+1)/X[0],ee=we*Ve,ue=we*te,Me=de/(-Ve+te),_e=Me*-Ve;Y.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(_e),$.translateZ(Me),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert();const Be=we+Me,De=ge+Me,Se=ee-_e,ut=ue+(de-_e),rt=Oe*ge/De*Be,P=ve*ge/De*Be;$.projectionMatrix.makePerspective(Se,ut,rt,P,Be,De)}function G($,Y){Y===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(Y.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;M.near=b.near=y.near=$.near,M.far=b.far=y.far=$.far,(T!==M.near||C!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);const Y=$.parent,le=M.cameras;G(M,Y);for(let he=0;hehe&&(w.set(de,de.lastChangedTime),i.dispatchEvent({type:"planechanged",data:de}))}}f=null}const ie=new Nv;ie.setAnimationLoop(se),this.setAnimationLoop=function($){W=$},this.dispose=function(){}}}function nD(n,e){function t(g,p){p.color.getRGB(g.fogColor.value,Ov(n)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function i(g,p,v,x,_){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(g,p):p.isMeshToonMaterial?(r(g,p),h(g,p)):p.isMeshPhongMaterial?(r(g,p),c(g,p)):p.isMeshStandardMaterial?(r(g,p),u(g,p),p.isMeshPhysicalMaterial&&d(g,p,_)):p.isMeshMatcapMaterial?(r(g,p),f(g,p)):p.isMeshDepthMaterial?r(g,p):p.isMeshDistanceMaterial?(r(g,p),m(g,p)):p.isMeshNormalMaterial?r(g,p):p.isLineBasicMaterial?(s(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?o(g,p,v,x):p.isSpriteMaterial?l(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map),p.alphaMap&&(g.alphaMap.value=p.alphaMap),p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===bn&&(g.bumpScale.value*=-1)),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===bn&&g.normalScale.value.negate()),p.specularMap&&(g.specularMap.value=p.specularMap),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);const v=e.get(p).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap){g.lightMap.value=p.lightMap;const w=n.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=p.lightMapIntensity*w}p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity);let x;p.map?x=p.map:p.specularMap?x=p.specularMap:p.displacementMap?x=p.displacementMap:p.normalMap?x=p.normalMap:p.bumpMap?x=p.bumpMap:p.roughnessMap?x=p.roughnessMap:p.metalnessMap?x=p.metalnessMap:p.alphaMap?x=p.alphaMap:p.emissiveMap?x=p.emissiveMap:p.clearcoatMap?x=p.clearcoatMap:p.clearcoatNormalMap?x=p.clearcoatNormalMap:p.clearcoatRoughnessMap?x=p.clearcoatRoughnessMap:p.iridescenceMap?x=p.iridescenceMap:p.iridescenceThicknessMap?x=p.iridescenceThicknessMap:p.specularIntensityMap?x=p.specularIntensityMap:p.specularColorMap?x=p.specularColorMap:p.transmissionMap?x=p.transmissionMap:p.thicknessMap?x=p.thicknessMap:p.sheenColorMap?x=p.sheenColorMap:p.sheenRoughnessMap&&(x=p.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix));let _;p.aoMap?_=p.aoMap:p.lightMap&&(_=p.lightMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uv2Transform.value.copy(_.matrix))}function s(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function o(g,p,v,x){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=x*.5,p.map&&(g.map.value=p.map),p.alphaMap&&(g.alphaMap.value=p.alphaMap),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);let _;p.map?_=p.map:p.alphaMap&&(_=p.alphaMap),_!==void 0&&(_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uvTransform.value.copy(_.matrix))}function l(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map),p.alphaMap&&(g.alphaMap.value=p.alphaMap),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);let v;p.map?v=p.map:p.alphaMap&&(v=p.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function c(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function h(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function u(g,p){g.roughness.value=p.roughness,g.metalness.value=p.metalness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap),p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap),e.get(p).envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function d(g,p,v){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap)),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap),p.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),g.clearcoatNormalMap.value=p.clearcoatNormalMap,p.side===bn&&g.clearcoatNormalScale.value.negate())),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap)),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap)}function f(g,p){p.matcap&&(g.matcap.value=p.matcap)}function m(g,p){g.referencePosition.value.copy(p.referencePosition),g.nearDistance.value=p.nearDistance,g.farDistance.value=p.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:i}}function iD(n,e,t,i){let r={},s={},a=[];const o=t.isWebGL2?n.getParameter(35375):0;function l(x,_){const w=_.program;i.uniformBlockBinding(x,w)}function c(x,_){let w=r[x.id];w===void 0&&(m(x),w=h(x),r[x.id]=w,x.addEventListener("dispose",p));const y=_.program;i.updateUBOMapping(x,y);const b=e.render.frame;s[x.id]!==b&&(d(x),s[x.id]=b)}function h(x){const _=u();x.__bindingPointIndex=_;const w=n.createBuffer(),y=x.__size,b=x.usage;return n.bindBuffer(35345,w),n.bufferData(35345,y,b),n.bindBuffer(35345,null),n.bindBufferBase(35345,_,w),w}function u(){for(let x=0;x0){b=w%y;const U=y-b;b!==0&&U-C.boundary<0&&(w+=y-b,T.__offset=w)}w+=C.storage}return b=w%y,b>0&&(w+=y-b),x.__size=w,x.__cache={},this}function g(x){const _={boundary:0,storage:0};return typeof x=="number"?(_.boundary=4,_.storage=4):x.isVector2?(_.boundary=8,_.storage=8):x.isVector3||x.isColor?(_.boundary=16,_.storage=12):x.isVector4?(_.boundary=16,_.storage=16):x.isMatrix3?(_.boundary=48,_.storage=48):x.isMatrix4?(_.boundary=64,_.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),_}function p(x){const _=x.target;_.removeEventListener("dispose",p);const w=a.indexOf(_.__bindingPointIndex);a.splice(w,1),n.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function v(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:v}}function rD(){const n=so("canvas");return n.style.display="block",n}function Ad(n={}){this.isWebGLRenderer=!0;const e=n.canvas!==void 0?n.canvas:rD(),t=n.context!==void 0?n.context:null,i=n.depth!==void 0?n.depth:!0,r=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,a=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,o=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1;let h;t!==null?h=t.getContextAttributes().alpha:h=n.alpha!==void 0?n.alpha:!1;let u=null,d=null;const f=[],m=[];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.outputEncoding=Bi,this.physicallyCorrectLights=!1,this.toneMapping=li,this.toneMappingExposure=1;const g=this;let p=!1,v=0,x=0,_=null,w=-1,y=null;const b=new dt,S=new dt;let M=null,T=e.width,C=e.height,O=1,U=null,F=null;const z=new dt(0,0,T,C),L=new dt(0,0,T,C);let K=!1;const G=new Pc;let W=!1,se=!1,ie=null;const $=new Ge,Y=new ne,le=new R,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function he(){return _===null?O:1}let X=t;function we(D,V){for(let Z=0;Z0?d=m[m.length-1]:d=null,f.pop(),f.length>0?u=f[f.length-1]:u=null};function Ot(D,V,Z,B){if(D.visible===!1)return;if(D.layers.test(V.layers)){if(D.isGroup)Z=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(V);else if(D.isLight)d.pushLight(D),D.castShadow&&d.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||G.intersectsSprite(D)){B&&le.setFromMatrixPosition(D.matrixWorld).applyMatrix4($);const We=De.update(D),qe=D.material;qe.visible&&u.push(D,We,qe,Z,le.z,null)}}else if((D.isMesh||D.isLine||D.isPoints)&&(D.isSkinnedMesh&&D.skeleton.frame!==Ve.render.frame&&(D.skeleton.update(),D.skeleton.frame=Ve.render.frame),!D.frustumCulled||G.intersectsObject(D))){B&&le.setFromMatrixPosition(D.matrixWorld).applyMatrix4($);const We=De.update(D),qe=D.material;if(Array.isArray(qe)){const ke=We.groups;for(let Ke=0,Xe=ke.length;Ke0&&yi(Q,V,Z),B&&ve.viewport(b.copy(B)),Q.length>0&&yt(Q,V,Z),ze.length>0&&yt(ze,V,Z),We.length>0&&yt(We,V,Z),ve.buffers.depth.setTest(!0),ve.buffers.depth.setMask(!0),ve.buffers.color.setMask(!0),ve.setPolygonOffset(!1)}function yi(D,V,Z){const B=Oe.isWebGL2;ie===null&&(ie=new Hn(1,1,{generateMipmaps:!0,type:ge.has("EXT_color_buffer_half_float")?oi:pr,minFilter:ui,samples:B&&s===!0?4:0})),g.getDrawingBufferSize(Y),B?ie.setSize(Y.x,Y.y):ie.setSize(uc(Y.x),uc(Y.y));const Q=g.getRenderTarget();g.setRenderTarget(ie),g.clear();const ze=g.toneMapping;g.toneMapping=li,yt(D,V,Z),g.toneMapping=ze,ee.updateMultisampleRenderTarget(ie),ee.updateRenderTargetMipmap(ie),g.setRenderTarget(Q)}function yt(D,V,Z){const B=V.isScene===!0?V.overrideMaterial:null;for(let Q=0,ze=D.length;Q0&&ee.useMultisampledRTT(D)===!1?Q=te.get(D).__webglMultisampledFramebuffer:Q=Xe,b.copy(D.viewport),S.copy(D.scissor),M=D.scissorTest}else b.copy(z).multiplyScalar(O).floor(),S.copy(L).multiplyScalar(O).floor(),M=K;if(ve.bindFramebuffer(36160,Q)&&Oe.drawBuffers&&B&&ve.drawBuffers(D,Q),ve.viewport(b),ve.scissor(S),ve.setScissorTest(M),ze){const ke=te.get(D.texture);X.framebufferTexture2D(36160,36064,34069+V,ke.__webglTexture,Z)}else if(We){const ke=te.get(D.texture),Ke=V||0;X.framebufferTextureLayer(36160,36064,ke.__webglTexture,Z||0,Ke)}w=-1},this.readRenderTargetPixels=function(D,V,Z,B,Q,ze,We){if(!(D&&D.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let qe=te.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&We!==void 0&&(qe=qe[We]),qe){ve.bindFramebuffer(36160,qe);try{const ke=D.texture,Ke=ke.format,Xe=ke.type;if(Ke!==Cn&&oe.convert(Ke)!==X.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const $e=Xe===oi&&(ge.has("EXT_color_buffer_half_float")||Oe.isWebGL2&&ge.has("EXT_color_buffer_float"));if(Xe!==pr&&oe.convert(Xe)!==X.getParameter(35738)&&!(Xe===Bn&&(Oe.isWebGL2||ge.has("OES_texture_float")||ge.has("WEBGL_color_buffer_float")))&&!$e){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=D.width-B&&Z>=0&&Z<=D.height-Q&&X.readPixels(V,Z,B,Q,oe.convert(Ke),oe.convert(Xe),ze)}finally{const ke=_!==null?te.get(_).__webglFramebuffer:null;ve.bindFramebuffer(36160,ke)}}},this.copyFramebufferToTexture=function(D,V,Z=0){const B=Math.pow(2,-Z),Q=Math.floor(V.image.width*B),ze=Math.floor(V.image.height*B);ee.setTexture2D(V,0),X.copyTexSubImage2D(3553,Z,0,0,D.x,D.y,Q,ze),ve.unbindTexture()},this.copyTextureToTexture=function(D,V,Z,B=0){const Q=V.image.width,ze=V.image.height,We=oe.convert(Z.format),qe=oe.convert(Z.type);ee.setTexture2D(Z,0),X.pixelStorei(37440,Z.flipY),X.pixelStorei(37441,Z.premultiplyAlpha),X.pixelStorei(3317,Z.unpackAlignment),V.isDataTexture?X.texSubImage2D(3553,B,D.x,D.y,Q,ze,We,qe,V.image.data):V.isCompressedTexture?X.compressedTexSubImage2D(3553,B,D.x,D.y,V.mipmaps[0].width,V.mipmaps[0].height,We,V.mipmaps[0].data):X.texSubImage2D(3553,B,D.x,D.y,We,qe,V.image),B===0&&Z.generateMipmaps&&X.generateMipmap(3553),ve.unbindTexture()},this.copyTextureToTexture3D=function(D,V,Z,B,Q=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ze=D.max.x-D.min.x+1,We=D.max.y-D.min.y+1,qe=D.max.z-D.min.z+1,ke=oe.convert(B.format),Ke=oe.convert(B.type);let Xe;if(B.isData3DTexture)ee.setTexture3D(B,0),Xe=32879;else if(B.isDataArrayTexture)ee.setTexture2DArray(B,0),Xe=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(37440,B.flipY),X.pixelStorei(37441,B.premultiplyAlpha),X.pixelStorei(3317,B.unpackAlignment);const $e=X.getParameter(3314),xt=X.getParameter(32878),bt=X.getParameter(3316),Vt=X.getParameter(3315),xi=X.getParameter(32877),At=Z.isCompressedTexture?Z.mipmaps[0]:Z.image;X.pixelStorei(3314,At.width),X.pixelStorei(32878,At.height),X.pixelStorei(3316,D.min.x),X.pixelStorei(3315,D.min.y),X.pixelStorei(32877,D.min.z),Z.isDataTexture||Z.isData3DTexture?X.texSubImage3D(Xe,Q,V.x,V.y,V.z,ze,We,qe,ke,Ke,At.data):Z.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(Xe,Q,V.x,V.y,V.z,ze,We,qe,ke,At.data)):X.texSubImage3D(Xe,Q,V.x,V.y,V.z,ze,We,qe,ke,Ke,At),X.pixelStorei(3314,$e),X.pixelStorei(32878,xt),X.pixelStorei(3316,bt),X.pixelStorei(3315,Vt),X.pixelStorei(32877,xi),Q===0&&B.generateMipmaps&&X.generateMipmap(Xe),ve.unbindTexture()},this.initTexture=function(D){D.isCubeTexture?ee.setTextureCube(D,0):D.isData3DTexture?ee.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?ee.setTexture2DArray(D,0):ee.setTexture2D(D,0),ve.unbindTexture()},this.resetState=function(){v=0,x=0,_=null,ve.reset(),q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class $v extends Ad{}$v.prototype.isWebGL1Renderer=!0;class Ic{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Ic(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Dc{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new Dc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Cd extends it{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class Lo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=no,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ln()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:l,point:Ia.clone(),uv:Un.getUV(Ia,wl,Oa,Ml,_p,Oh,yp,new ne),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function bl(n,e,t,i,r,s){Hs.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Da.x=s*Hs.x-r*Hs.y,Da.y=r*Hs.x+s*Hs.y):Da.copy(Hs),n.copy(e),n.x+=Da.x,n.y+=Da.y,n.applyMatrix4(qv)}const Sl=new R,xp=new R;class Yv extends it{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){Sl.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Sl);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Sl.setFromMatrixPosition(e.matrixWorld),xp.setFromMatrixPosition(this.matrixWorld);const i=Sl.distanceTo(xp)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;rl)continue;d.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(d);Me.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,a.start),x=Math.min(p.count,a.start+a.count);for(let _=v,w=x-1;_l)continue;d.applyMatrix4(this.matrixWorld);const b=e.ray.origin.distanceTo(d);be.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class lD extends Pt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Mt,this.magFilter=s!==void 0?s:Mt,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class cD extends Pt{constructor(e,t,i){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=i,this.magFilter=It,this.minFilter=It,this.generateMipmaps=!1,this.needsUpdate=!0}}class Od extends Pt{constructor(e,t,i,r,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class hD extends Od{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=nn}}class uD extends Pt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ei{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const h=i[r],d=i[r+1]-h,f=(a-h)/d;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=t||(a.isVector2?new ne:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new R,r=[],s=[],a=[],o=new R,l=new Ge;for(let f=0;f<=e;f++){const m=f/e;r[f]=this.getTangentAt(m,new R)}s[0]=new R,a[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=c&&(c=h,i.set(1,0,0)),u<=c&&(c=u,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(r[f-1],r[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Ft(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(Ft(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],f*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Fc extends ei{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t){const i=t||new ne,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=r[(o-1)%s]:(Ll.subVectors(r[0],r[1]).add(r[0]),c=Ll);const u=r[o%s],d=r[(o+1)%s];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return i.set(zp(o,l.x,c.x,h.x,u.x),zp(o,l.y,c.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class va extends Ye{constructor(e=[new ne(0,-.5),new ne(.5,0),new ne(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ft(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new R,d=new ne,f=new R,m=new R,g=new R;let p=0,v=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:p=e[x+1].x-e[x].x,v=e[x+1].y-e[x].y,f.x=v*1,f.y=-p,f.z=v*0,g.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(g.x,g.y,g.z);break;default:p=e[x+1].x-e[x].x,v=e[x+1].y-e[x].y,f.x=v*1,f.y=-p,f.z=v*0,m.copy(f),f.x+=g.x,f.y+=g.y,f.z+=g.z,f.normalize(),l.push(f.x,f.y,f.z),g.copy(m)}for(let x=0;x<=t;x++){const _=i+x*h*r,w=Math.sin(_),y=Math.cos(_);for(let b=0;b<=e.length-1;b++){u.x=e[b].x*w,u.y=e[b].y,u.z=e[b].x*y,a.push(u.x,u.y,u.z),d.x=x/t,d.y=b/(e.length-1),o.push(d.x,d.y);const S=l[3*b+0]*w,M=l[3*b+1],T=l[3*b+0]*y;c.push(S,M,T)}}for(let x=0;x0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new Ce(u,3)),this.setAttribute("normal",new Ce(d,3)),this.setAttribute("uv",new Ce(f,2));function x(){const w=new R,y=new R;let b=0;const S=(t-e)/i;for(let M=0;M<=s;M++){const T=[],C=M/s,O=C*(t-e)+e;for(let U=0;U<=r;U++){const F=U/r,z=F*l+o,L=Math.sin(z),K=Math.cos(z);y.x=O*L,y.y=-C*i+p,y.z=O*K,u.push(y.x,y.y,y.z),w.set(L,S,K).normalize(),d.push(w.x,w.y,w.z),f.push(F,1-C),T.push(m++)}g.push(T)}for(let M=0;M.9&&S<.1&&(_<.2&&(a[x+0]+=1),w<.2&&(a[x+2]+=1),y<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function f(x,_){const w=x*3;_.x=e[w+0],_.y=e[w+1],_.z=e[w+2]}function m(){const x=new R,_=new R,w=new R,y=new R,b=new ne,S=new ne,M=new ne;for(let T=0,C=0;T80*t){o=c=n[0],l=h=n[1];for(let m=t;mc&&(c=u),d>h&&(h=d);f=Math.max(c-o,h-l),f=f!==0?32767/f:0}return oo(s,a,t,o,l,f,0),a}};function t_(n,e,t,i,r){let s,a;if(r===zD(n,e,t,i)>0)for(s=e;s=e;s-=i)a=Fp(s,n[s],n[s+1],a);return a&&kc(a,a.next)&&(co(a),a=a.next),a}function as(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(kc(t,t.next)||Lt(t.prev,t,t.next)===0)){if(co(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function oo(n,e,t,i,r,s,a){if(!n)return;!a&&s&&LD(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?wD(n,i,r,s):xD(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),co(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=MD(as(n),e,t),oo(n,e,t,i,r,s,2)):a===2&&bD(n,e,t,i,r,s):oo(as(n),e,t,i,r,s,1);break}}}function xD(n){const e=n.prev,t=n,i=n.next;if(Lt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&Xs(r,o,s,l,a,c,m.x,m.y)&&Lt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function wD(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Lt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,f=ol?o>c?o:c:l>c?l:c,p=h>u?h>d?h:d:u>d?u:d,v=Nu(f,m,e,t,i),x=Nu(g,p,e,t,i);let _=n.prevZ,w=n.nextZ;for(;_&&_.z>=v&&w&&w.z<=x;){if(_.x>=f&&_.x<=g&&_.y>=m&&_.y<=p&&_!==r&&_!==a&&Xs(o,h,l,u,c,d,_.x,_.y)&&Lt(_.prev,_,_.next)>=0||(_=_.prevZ,w.x>=f&&w.x<=g&&w.y>=m&&w.y<=p&&w!==r&&w!==a&&Xs(o,h,l,u,c,d,w.x,w.y)&&Lt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;_&&_.z>=v;){if(_.x>=f&&_.x<=g&&_.y>=m&&_.y<=p&&_!==r&&_!==a&&Xs(o,h,l,u,c,d,_.x,_.y)&&Lt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;w&&w.z<=x;){if(w.x>=f&&w.x<=g&&w.y>=m&&w.y<=p&&w!==r&&w!==a&&Xs(o,h,l,u,c,d,w.x,w.y)&&Lt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function MD(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!kc(r,s)&&n_(r,i,i.next,s)&&lo(r,s)&&lo(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),co(i),co(i.next),i=n=s),i=i.next}while(i!==n);return as(i)}function bD(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&ID(a,o)){let l=i_(a,o);a=as(a,a.next),l=as(l,l.next),oo(a,e,t,i,r,s,0),oo(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function SD(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x=t.x&&t.x>=l&&s!==t.x&&Xs(ar.x||t.x===r.x&&CD(r,t)))&&(r=t,h=u)),t=t.next;while(t!==o);return r}function CD(n,e){return Lt(n.prev,n,e.prev)<0&&Lt(e.next,n,n.next)<0}function LD(n,e,t,i){let r=n;do r.z===0&&(r.z=Nu(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,PD(r)}function PD(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function Nu(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function RD(n){let e=n,t=n;do(e.x=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function ID(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!DD(n,e)&&(lo(n,e)&&lo(e,n)&&OD(n,e)&&(Lt(n.prev,n,e.prev)||Lt(n,e.prev,e))||kc(n,e)&&Lt(n.prev,n,n.next)>0&&Lt(e.prev,e,e.next)>0)}function Lt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function kc(n,e){return n.x===e.x&&n.y===e.y}function n_(n,e,t,i){const r=Ol(Lt(n,e,t)),s=Ol(Lt(n,e,i)),a=Ol(Lt(t,i,n)),o=Ol(Lt(t,i,e));return!!(r!==s&&a!==o||r===0&&Dl(n,t,e)||s===0&&Dl(n,i,e)||a===0&&Dl(t,n,i)||o===0&&Dl(t,e,i))}function Dl(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ol(n){return n>0?1:n<0?-1:0}function DD(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&n_(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function lo(n,e){return Lt(n.prev,n,n.next)<0?Lt(n,e,n.next)>=0&&Lt(n,n.prev,e)>=0:Lt(n,e,n.prev)<0||Lt(n,n.next,e)<0}function OD(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function i_(n,e){const t=new ku(n.i,n.x,n.y),i=new ku(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Fp(n,e,t,i){const r=new ku(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function co(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function ku(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function zD(n,e,t,i){let r=0;for(let s=e,a=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function kp(n,e){for(let t=0;tNumber.EPSILON){const H=Math.sqrt(P),re=Math.sqrt(ut*ut+rt*rt),ae=ee.x-Se/H,me=ee.y+De/H,Te=ue.x-rt/re,oe=ue.y+ut/re,q=((Te-ae)*rt-(oe-me)*ut)/(De*rt-Se*ut);Me=ae+De*q-te.x,_e=me+Se*q-te.y;const Le=Me*Me+_e*_e;if(Le<=2)return new ne(Me,_e);Be=Math.sqrt(Le/2)}else{let H=!1;De>Number.EPSILON?ut>Number.EPSILON&&(H=!0):De<-Number.EPSILON?ut<-Number.EPSILON&&(H=!0):Math.sign(Se)===Math.sign(rt)&&(H=!0),H?(Me=-Se,_e=De,Be=Math.sqrt(P)):(Me=De,_e=Se,Be=Math.sqrt(P/2))}return new ne(Me/Be,_e/Be)}const se=[];for(let te=0,ee=z.length,ue=ee-1,Me=te+1;te=0;te--){const ee=te/p,ue=f*Math.cos(ee*Math.PI/2),Me=m*Math.sin(ee*Math.PI/2)+g;for(let _e=0,Be=z.length;_e=0;){const Me=ue;let _e=ue-1;_e<0&&(_e=te.length-1);for(let Be=0,De=h+p*2;Be0)&&f.push(_,w,b),(v!==i-1||l0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class o_ extends $t{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=br,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=So,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class l_ extends $t{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=br,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class c_ extends $t{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=br,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class h_ extends $t{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=br,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=So,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class u_ extends $t{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=br,this.normalScale=new ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class d_ extends un{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Nn(n,e,t){return Hd(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)}function Zr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Hd(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function f_(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Uu(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Vd(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function UD(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l=i)){u.push(c.times[f]);for(let g=0;gs.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[m]){const v=m*u+h,x=v+u-h;g=Nn(o.values,v,x)}else{const v=o.createInterpolant(),x=h,_=u-h;v.evaluate(s),g=Nn(v.resultBuffer,x,_)}l==="quaternion"&&new hn().fromArray(g).normalize().conjugate().toArray(g);const p=c.times.length;for(let v=0;v=s)){const o=t[1];e=s)break t}a=i,i=0;break n}break e}for(;i>>1;et;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=Nn(i,s,a),this.values=Nn(this.values,s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Hd(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=Nn(this.times),t=Nn(this.values),i=this.getValueSize(),r=this.getInterpolation()===Jl,s=e.length-1;let a=1;for(let o=1;o0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=Nn(e,0,a),this.values=Nn(t,0,a*i)):(this.times=e,this.values=t),this}clone(){const e=Nn(this.times,0),t=Nn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}ti.prototype.TimeBufferType=Float32Array;ti.prototype.ValueBufferType=Float32Array;ti.prototype.DefaultInterpolation=ss;class ms extends ti{}ms.prototype.ValueTypeName="bool";ms.prototype.ValueBufferType=Array;ms.prototype.DefaultInterpolation=ta;ms.prototype.InterpolantFactoryMethodLinear=void 0;ms.prototype.InterpolantFactoryMethodSmooth=void 0;class Wd extends ti{}Wd.prototype.ValueTypeName="color";class sa extends ti{}sa.prototype.ValueTypeName="number";class g_ extends xa{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)hn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class gr extends ti{InterpolantFactoryMethodLinear(e){return new g_(this.times,this.values,this.getValueSize(),e)}}gr.prototype.ValueTypeName="quaternion";gr.prototype.DefaultInterpolation=ss;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class gs extends ti{}gs.prototype.ValueTypeName="string";gs.prototype.ValueBufferType=Array;gs.prototype.DefaultInterpolation=ta;gs.prototype.InterpolantFactoryMethodLinear=void 0;gs.prototype.InterpolantFactoryMethodSmooth=void 0;class aa extends ti{}aa.prototype.ValueTypeName="vector";class oa{constructor(e,t=-1,i,r=Ec){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Ln(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(GD(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(ti.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,d,f,m,g){if(f.length!==0){const p=[],v=[];Vd(f,p,v,m),p.length!==0&&g.push(new u(d,p,v))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ai[e]!==void 0){Ai[e].push({onLoad:t,onProgress:i,onError:r});return}Ai[e]=[],Ai[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Ai[e],u=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,m=f!==0;let g=0;const p=new ReadableStream({start(v){x();function x(){u.read().then(({done:_,value:w})=>{if(_)v.close();else{g+=w.byteLength;const y=new ProgressEvent("progress",{lengthComputable:m,loaded:g,total:f});for(let b=0,S=h.length;b{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{vr.add(e,c);const h=Ai[e];delete Ai[e];for(let u=0,d=h.length;u{const h=Ai[e];if(h===void 0)throw this.manager.itemError(e),c;delete Ai[e];for(let u=0,d=h.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class $D extends _n{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Pn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new ne().fromArray(a.value);break;case"v3":r.uniforms[s].value=new R().fromArray(a.value);break;case"v4":r.uniforms[s].value=new dt().fromArray(a.value);break;case"m3":r.uniforms[s].value=new vn().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Ge().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new ne().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new ne().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:s_,SpriteMaterial:Ld,RawShaderMaterial:a_,ShaderMaterial:Kn,PointsMaterial:zc,MeshPhysicalMaterial:Yi,MeshStandardMaterial:Go,MeshPhongMaterial:o_,MeshToonMaterial:l_,MeshNormalMaterial:c_,MeshLambertMaterial:h_,MeshDepthMaterial:Td,MeshDistanceMaterial:Ed,MeshBasicMaterial:Mn,MeshMatcapMaterial:u_,LineDashedMaterial:d_,LineBasicMaterial:un,Material:$t};return new t[e]}}class hi{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i0){const l=new Uc(t);s=new ho(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c0){r=new ho(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=vr.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){vr.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){r&&r(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let zl;class Zd{static getContext(){return zl===void 0&&(zl=new(window.AudioContext||window.webkitAudioContext)),zl}static setContext(e){zl=e}}class QD extends _n{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Pn(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{const l=o.slice(0);Zd.getContext().decodeAudioData(l,function(h){t(h)})}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}}class eO extends Hc{constructor(e,t,i=1){super(void 0,i),this.isHemisphereLightProbe=!0;const r=new xe().set(e),s=new xe().set(t),a=new R(r.r,r.g,r.b),o=new R(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(l),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(c)}}class tO extends Hc{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const i=new xe().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const qp=new Ge,Xp=new Ge,zr=new Ge;class nO{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Wt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Wt,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}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,zr.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(Jr*t.fov*.5)/t.zoom;let o,l;Xp.elements[12]=-r,qp.elements[12]=r,o=-a*t.aspect+s,l=a*t.aspect+s,zr.elements[0]=2*t.near/(l-o),zr.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(zr),o=-a*t.aspect-s,l=a*t.aspect-s,zr.elements[0]=2*t.near/(l-o),zr.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(zr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Xp),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(qp)}}class jd{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Yp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Yp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Yp(){return(typeof performance>"u"?Date:performance).now()}const Fr=new R,Zp=new hn,iO=new R,Nr=new R;class rO extends it{constructor(){super(),this.type="AudioListener",this.context=Zd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new jd}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Fr,Zp,iO),Nr.set(0,0,-1).applyQuaternion(Zp),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Fr.x,r),t.positionY.linearRampToValueAtTime(Fr.y,r),t.positionZ.linearRampToValueAtTime(Fr.z,r),t.forwardX.linearRampToValueAtTime(Nr.x,r),t.forwardY.linearRampToValueAtTime(Nr.y,r),t.forwardZ.linearRampToValueAtTime(Nr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Fr.x,Fr.y,Fr.z),t.setOrientation(Nr.x,Nr.y,Nr.z,i.x,i.y,i.z)}}class T_ extends it{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=0){if(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;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,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,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){hn.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;hn.multiplyQuaternionsFlat(e,a,e,t,e,i),hn.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Kd="\\[\\]\\.:\\/",lO=new RegExp("["+Kd+"]","g"),Jd="[^"+Kd+"]",cO="[^"+Kd.replace("\\.","")+"]",hO=/((?:WC+[\/:])*)/.source.replace("WC",Jd),uO=/(WCOD+)?/.source.replace("WCOD",cO),dO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Jd),fO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Jd),pO=new RegExp("^"+hO+uO+dO+fO+"$"),mO=["material","materials","bones","map"];class gO{constructor(e,t,i){const r=i||nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class nt{constructor(e,t,i){this.path=t,this.parsedPath=i||nt.parseTrackName(t),this.node=nt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new nt.Composite(e,t,i):new nt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(lO,"")}static parseTrackName(e){const t=pO.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);mO.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let a=0;a=s){const u=s++,d=e[u];t[d.uuid]=h,e[h]=d,t[c]=u,e[u]=l;for(let f=0,m=r;f!==m;++f){const g=i[f],p=g[u],v=g[h];g[h]=p,g[u]=v}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u0&&(t[f.uuid]=u),e[u]=f,e.pop();for(let m=0,g=r;m!==g;++m){const p=i[m];p[u]=p[d],p.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(u);for(let d=h,f=l.length;d!==f;++d){const m=l[d];u[d]=new nt(m,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class _O{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:qr,endingEnd:qr};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Sv,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,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const 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,t,i){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const 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,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case vd:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Ec:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const a=i===Tv;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===bv){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Xr,r.endingEnd=Xr):(e?r.endingStart=this.zeroSlopeAtStart?Xr:qr:r.endingStart=to,t?r.endingEnd=this.zeroSlopeAtEnd?Xr:qr:r.endingEnd=to)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const yO=new Float32Array(1);class xO extends qi{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=r[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}const g=t&&t._propertyBindings[u].binding.parsedPath;m=new E_(nt.create(i,f,g),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Jp.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Qp=new R,Fl=new R;class LO{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Qp.subVectors(e,this.start),Fl.subVectors(this.end,this.start);const i=Fl.dot(Fl);let s=Fl.dot(Qp)/i;return t&&(s=Ft(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const em=new R;class PO extends it{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Ye,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{sm.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(sm,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class GO extends Qn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ye;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));const s=new un({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new xe,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class WO{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ao,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(v){const x=[];for(let _=0,w=v.length;_Number.EPSILON){if(C<0&&(S=x[b],T=-T,M=x[y],C=-C),v.yM.y)continue;if(v.y===S.y){if(v.x===S.x)return!0}else{const O=C*(v.x-S.x)-T*(v.y-S.y);if(O===0)return!0;if(O<0)continue;w=!w}}else{if(v.y!==S.y)continue;if(M.x<=v.x&&v.x<=S.x||S.x<=v.x&&v.x<=M.x)return!0}}return w}const r=ci.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new es,l.curves=o.curves,c.push(l),c;let h=!r(s[0].getPoints());h=e?!h:h;const u=[],d=[];let f=[],m=0,g;d[m]=void 0,f[m]=[];for(let v=0,x=s.length;v1){let v=!1,x=0;for(let _=0,w=d.length;_0&&v===!1&&(f=u)}let p;for(let v=0,x=d.length;v>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;!(c&8388608);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function qO(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Ft(n,-65504,65504),Ri.floatView[0]=n;const e=Ri.uint32View[0],t=e>>23&511;return Ri.baseTable[t]+((e&8388607)>>Ri.shiftTable[t])}function XO(n){const e=n>>10;return Ri.uint32View[0]=Ri.mantissaTable[Ri.offsetTable[e]+(n&1023)]+Ri.exponentTable[e],Ri.floatView[0]}var Ga=Object.freeze({__proto__:null,toHalfFloat:qO,fromHalfFloat:XO});function YO(){console.error("THREE.ImmediateRenderObject has been removed.")}class ZO extends Hn{constructor(e,t,i){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,i),this.samples=4}}class jO extends To{constructor(e,t,i,r){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,i,r)}}class KO extends Ac{constructor(e,t,i,r){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,i,r)}}class JO extends _i{constructor(e,t,i,r,s,a){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,i,r,s,a)}}class QO extends Ro{constructor(e,t,i,r){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,i,r)}}class e4 extends Io{constructor(e,t,i,r){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,i,r)}}class t4 extends Do{constructor(e,t,i,r,s,a,o){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,i,r,s,a,o)}}class n4 extends ps{constructor(e,t,i,r,s,a,o,l){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,i,r,s,a,o,l)}}class i4 extends Oo{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class r4 extends zo{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class s4 extends Fo{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class a4 extends va{constructor(e,t,i,r){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,i,r)}}class o4 extends _a{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class l4 extends ma{constructor(e,t,i,r){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,i,r)}}class c4 extends Xi{constructor(e,t,i,r){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,i,r)}}class h4 extends No{constructor(e,t,i,r,s,a){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,i,r,s,a)}}class u4 extends ko{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class d4 extends ya{constructor(e,t,i,r,s,a,o){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,i,r,s,a,o)}}class f4 extends Uo{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class p4 extends Bo{constructor(e,t,i,r,s){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,i,r,s)}}class m4 extends Ho{constructor(e,t,i,r,s,a){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,i,r,s,a)}}class g4 extends Vo{constructor(e,t,i,r,s){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,i,r,s)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:bc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=bc);const v4=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:md,AddEquation:Wr,AddOperation:iv,AdditiveAnimationBlendMode:vd,AdditiveBlending:au,AlphaFormat:fv,AlwaysDepth:j0,AlwaysStencilFunc:Pv,AmbientLight:y_,AmbientLightProbe:tO,AnimationClip:oa,AnimationLoader:$D,AnimationMixer:xO,AnimationObjectGroup:vO,AnimationUtils:HD,ArcCurve:Zv,ArrayCamera:Gv,ArrowHelper:VO,Audio:T_,AudioAnalyser:oO,AudioContext:Zd,AudioListener:rO,AudioLoader:QD,AxesHelper:GO,BackSide:bn,BasicDepthPacking:Av,BasicShadowMap:gA,Bone:Oc,BooleanKeyframeTrack:ms,Box2:CO,Box3:Sr,Box3Helper:BO,BoxBufferGeometry:JO,BoxGeometry:_i,BoxHelper:UO,BufferAttribute:lt,BufferGeometry:Ye,BufferGeometryLoader:b_,ByteType:lv,Cache:vr,Camera:Lc,CameraHelper:kO,CanvasTexture:uD,CapsuleBufferGeometry:QO,CapsuleGeometry:Ro,CatmullRomCurve3:jv,CineonToneMapping:av,CircleBufferGeometry:e4,CircleGeometry:Io,ClampToEdgeWrapping:nn,Clock:jd,Color:xe,ColorKeyframeTrack:Wd,ColorManagement:cn,CompressedArrayTexture:hD,CompressedTexture:Od,CompressedTextureLoader:qD,ConeBufferGeometry:t4,ConeGeometry:Do,CubeCamera:zv,CubeReflectionMapping:ur,CubeRefractionMapping:dr,CubeTexture:Ao,CubeTextureLoader:XD,CubeUVReflectionMapping:fa,CubicBezierCurve:Fd,CubicBezierCurve3:Kv,CubicInterpolant:p_,CullFaceBack:su,CullFaceFront:z0,CullFaceFrontBack:mA,CullFaceNone:O0,Curve:ei,CurvePath:Qv,CustomBlending:N0,CustomToneMapping:ov,CylinderBufferGeometry:n4,CylinderGeometry:ps,Cylindrical:AO,Data3DTexture:Ac,DataArrayTexture:To,DataTexture:Ks,DataTexture2DArray:jO,DataTexture3D:KO,DataTextureLoader:__,DataUtils:Ga,DecrementStencilOp:EA,DecrementWrapStencilOp:CA,DefaultLoadingManager:v_,DepthFormat:cr,DepthStencilFormat:rs,DepthTexture:Wv,DirectionalLight:Bc,DirectionalLightHelper:NO,DiscreteInterpolant:m_,DodecahedronBufferGeometry:i4,DodecahedronGeometry:Oo,DoubleSide:bo,DstAlphaFactor:W0,DstColorFactor:q0,DynamicCopyUsage:GA,DynamicDrawUsage:NA,DynamicReadUsage:BA,EdgesGeometry:e_,EllipseCurve:Fc,EqualDepth:J0,EqualStencilFunc:IA,EquirectangularReflectionMapping:Qs,EquirectangularRefractionMapping:Qa,Euler:pa,EventDispatcher:qi,ExtrudeBufferGeometry:r4,ExtrudeGeometry:zo,FileLoader:Pn,Float16BufferAttribute:bC,Float32BufferAttribute:Ce,Float64BufferAttribute:SC,FloatType:Bn,Fog:Dc,FogExp2:Ic,FramebufferTexture:cD,FrontSide:Ui,Frustum:Pc,GLBufferAttribute:SO,GLSL1:$A,GLSL3:Iu,GreaterDepth:ev,GreaterEqualDepth:Q0,GreaterEqualStencilFunc:FA,GreaterStencilFunc:OA,GridHelper:zO,Group:Di,HalfFloatType:oi,HemisphereLight:$d,HemisphereLightHelper:OO,HemisphereLightProbe:eO,IcosahedronBufferGeometry:s4,IcosahedronGeometry:Fo,ImageBitmapLoader:S_,ImageLoader:ho,ImageUtils:xd,ImmediateRenderObject:YO,IncrementStencilOp:TA,IncrementWrapStencilOp:AA,InstancedBufferAttribute:ra,InstancedBufferGeometry:M_,InstancedInterleavedBuffer:bO,InstancedMesh:Rd,Int16BufferAttribute:wC,Int32BufferAttribute:MC,Int8BufferAttribute:_C,IntType:hv,InterleavedBuffer:Lo,InterleavedBufferAttribute:mr,Interpolant:xa,InterpolateDiscrete:ta,InterpolateLinear:ss,InterpolateSmooth:Jl,InvertStencilOp:LA,KeepStencilOp:Ql,KeyframeTrack:ti,LOD:Yv,LatheBufferGeometry:a4,LatheGeometry:va,Layers:Cc,LessDepth:K0,LessEqualDepth:cc,LessEqualStencilFunc:DA,LessStencilFunc:RA,Light:Er,LightProbe:Hc,Line:Hi,Line3:LO,LineBasicMaterial:un,LineCurve:Nc,LineCurve3:Jv,LineDashedMaterial:d_,LineLoop:Id,LineSegments:Qn,LinearEncoding:Bi,LinearFilter:Mt,LinearInterpolant:Gd,LinearMipMapLinearFilter:xA,LinearMipMapNearestFilter:yA,LinearMipmapLinearFilter:ui,LinearMipmapNearestFilter:Tc,LinearSRGBColorSpace:na,LinearToneMapping:rv,Loader:_n,LoaderUtils:hi,LoadingManager:Uc,LoopOnce:bv,LoopPingPong:Tv,LoopRepeat:Sv,LuminanceAlphaFormat:gv,LuminanceFormat:mv,MOUSE:fA,Material:$t,MaterialLoader:Vc,MathUtils:ro,Matrix3:vn,Matrix4:Ge,MaxEquation:hu,Mesh:Bt,MeshBasicMaterial:Mn,MeshDepthMaterial:Td,MeshDistanceMaterial:Ed,MeshLambertMaterial:h_,MeshMatcapMaterial:u_,MeshNormalMaterial:c_,MeshPhongMaterial:o_,MeshPhysicalMaterial:Yi,MeshStandardMaterial:Go,MeshToonMaterial:l_,MinEquation:cu,MirroredRepeatWrapping:ea,MixOperation:nv,MultiplyBlending:lu,MultiplyOperation:So,NearestFilter:It,NearestMipMapLinearFilter:_A,NearestMipMapNearestFilter:vA,NearestMipmapLinearFilter:js,NearestMipmapNearestFilter:eo,NeverDepth:Z0,NeverStencilFunc:PA,NoBlending:zi,NoColorSpace:MA,NoToneMapping:li,NormalAnimationBlendMode:Ec,NormalBlending:jr,NotEqualDepth:tv,NotEqualStencilFunc:zA,NumberKeyframeTrack:sa,Object3D:it,ObjectLoader:KD,ObjectSpaceNormalMap:Lv,OctahedronBufferGeometry:o4,OctahedronGeometry:_a,OneFactor:H0,OneMinusDstAlphaFactor:$0,OneMinusDstColorFactor:X0,OneMinusSrcAlphaFactor:pd,OneMinusSrcColorFactor:G0,OrthographicCamera:Co,PCFShadowMap:dd,PCFSoftShadowMap:F0,PMREMGenerator:Ou,Path:ao,PerspectiveCamera:Wt,Plane:ar,PlaneBufferGeometry:l4,PlaneGeometry:ma,PlaneHelper:HO,PointLight:Yd,PointLightHelper:IO,Points:Dd,PointsMaterial:zc,PolarGridHelper:FO,PolyhedronBufferGeometry:c4,PolyhedronGeometry:Xi,PositionalAudio:aO,PropertyBinding:nt,PropertyMixer:E_,QuadraticBezierCurve:Nd,QuadraticBezierCurve3:kd,Quaternion:hn,QuaternionKeyframeTrack:gr,QuaternionLinearInterpolant:g_,REVISION:bc,RGBADepthPacking:Cv,RGBAFormat:Cn,RGBAIntegerFormat:wv,RGBA_ASTC_10x10_Format:Cu,RGBA_ASTC_10x5_Format:Tu,RGBA_ASTC_10x6_Format:Eu,RGBA_ASTC_10x8_Format:Au,RGBA_ASTC_12x10_Format:Lu,RGBA_ASTC_12x12_Format:Pu,RGBA_ASTC_4x4_Format:vu,RGBA_ASTC_5x4_Format:_u,RGBA_ASTC_5x5_Format:yu,RGBA_ASTC_6x5_Format:xu,RGBA_ASTC_6x6_Format:wu,RGBA_ASTC_8x5_Format:Mu,RGBA_ASTC_8x6_Format:bu,RGBA_ASTC_8x8_Format:Su,RGBA_BPTC_Format:Ru,RGBA_ETC2_EAC_Format:gu,RGBA_PVRTC_2BPPV1_Format:pu,RGBA_PVRTC_4BPPV1_Format:fu,RGBA_S3TC_DXT1_Format:Zl,RGBA_S3TC_DXT3_Format:jl,RGBA_S3TC_DXT5_Format:Kl,RGBFormat:pv,RGB_ETC1_Format:Mv,RGB_ETC2_Format:mu,RGB_PVRTC_2BPPV1_Format:du,RGB_PVRTC_4BPPV1_Format:uu,RGB_S3TC_DXT1_Format:Yl,RGFormat:yv,RGIntegerFormat:xv,RawShaderMaterial:a_,Ray:Eo,Raycaster:TO,RectAreaLight:x_,RedFormat:vv,RedIntegerFormat:_v,ReinhardToneMapping:sv,RepeatWrapping:fr,ReplaceStencilOp:SA,ReverseSubtractEquation:U0,RingBufferGeometry:h4,RingGeometry:No,SRGBColorSpace:Yn,Scene:Cd,ShaderChunk:Ze,ShaderLib:Zn,ShaderMaterial:Kn,ShadowMaterial:s_,Shape:es,ShapeBufferGeometry:u4,ShapeGeometry:ko,ShapePath:WO,ShapeUtils:ci,ShortType:cv,Skeleton:Po,SkeletonHelper:RO,SkinnedMesh:Pd,Source:Yr,Sphere:Tr,SphereBufferGeometry:d4,SphereGeometry:ya,Spherical:EO,SphericalHarmonics3:w_,SplineCurve:Ud,SpotLight:Xd,SpotLightHelper:PO,Sprite:Xv,SpriteMaterial:Ld,SrcAlphaFactor:fd,SrcAlphaSaturateFactor:Y0,SrcColorFactor:V0,StaticCopyUsage:VA,StaticDrawUsage:no,StaticReadUsage:UA,StereoCamera:nO,StreamCopyUsage:WA,StreamDrawUsage:kA,StreamReadUsage:HA,StringKeyframeTrack:gs,SubtractEquation:k0,SubtractiveBlending:ou,TOUCH:pA,TangentSpaceNormalMap:br,TetrahedronBufferGeometry:f4,TetrahedronGeometry:Uo,Texture:Pt,TextureLoader:dc,TorusBufferGeometry:p4,TorusGeometry:Bo,TorusKnotBufferGeometry:m4,TorusKnotGeometry:Ho,Triangle:Un,TriangleFanDrawMode:_d,TriangleStripDrawMode:Ev,TrianglesDrawMode:wA,TubeBufferGeometry:g4,TubeGeometry:Vo,TwoPassDoubleSide:Ha,UVMapping:Sc,Uint16BufferAttribute:wd,Uint32BufferAttribute:Md,Uint8BufferAttribute:yC,Uint8ClampedBufferAttribute:xC,Uniform:Qd,UniformsGroup:MO,UniformsLib:ye,UniformsUtils:bd,UnsignedByteType:pr,UnsignedInt248Type:Kr,UnsignedIntType:lr,UnsignedShort4444Type:uv,UnsignedShort5551Type:dv,UnsignedShortType:gd,VSMShadowMap:Ws,Vector2:ne,Vector3:R,Vector4:dt,VectorKeyframeTrack:aa,VideoTexture:lD,WebGL1Renderer:$v,WebGL3DRenderTarget:lC,WebGLArrayRenderTarget:oC,WebGLCubeRenderTarget:Fv,WebGLMultipleRenderTargets:cC,WebGLMultisampleRenderTarget:ZO,WebGLRenderTarget:Hn,WebGLRenderer:Ad,WebGLUtils:Vv,WireframeGeometry:r_,WrapAroundEnding:to,ZeroCurvatureEnding:qr,ZeroFactor:B0,ZeroSlopeEnding:Xr,ZeroStencilOp:bA,_SRGBAFormat:hc,sRGBEncoding:ot},Symbol.toStringTag,{value:"Module"}));var nc={Linear:{None:function(n){return n}},Quadratic:{In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}},Cubic:{In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}},Quartic:{In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}},Quintic:{In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}},Sinusoidal:{In:function(n){return 1-Math.cos(n*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.cos(Math.PI*n))}},Exponential:{In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}},Circular:{In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}},Elastic:{In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}},Back:{In:function(n){var e=1.70158;return n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}},Bounce:{In:function(n){return 1-nc.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?nc.Bounce.In(n*2)*.5:nc.Bounce.Out(n*2-1)*.5+.5}}},Wa;typeof self>"u"&&typeof process<"u"&&process.hrtime?Wa=function(){var n=process.hrtime();return n[0]*1e3+n[1]/1e6}:typeof self<"u"&&self.performance!==void 0&&self.performance.now!==void 0?Wa=self.performance.now.bind(self.performance):Date.now!==void 0?Wa=Date.now:Wa=function(){return new Date().getTime()};var Vs=Wa,_4=function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=Vs()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(n[t],n[t-1],t-i):s(n[r],n[r+1>t?t:r+1],i-r)},Bezier:function(n,e){for(var t=0,i=n.length-1,r=Math.pow,s=$a.Utils.Bernstein,a=0;a<=i;a++)t+=r(1-e,i-a)*r(e,a)*n[a]*s(i,a);return t},CatmullRom:function(n,e){var t=n.length-1,i=t*e,r=Math.floor(i),s=$a.Utils.CatmullRom;return n[0]===n[t]?(e<0&&(r=Math.floor(i=t*(1+e))),s(n[(r-1+t)%t],n[r],n[(r+1)%t],n[(r+2)%t],i-r)):e<0?n[0]-(s(n[0],n[0],n[1],n[1],-i)-n[0]):e>1?n[t]-(s(n[t],n[t],n[t-1],n[t-1],i-t)-n[t]):s(n[r?r-1:0],n[r],n[t1;i--)t*=i;return n[e]=t,t}}(),CatmullRom:function(n,e,t,i,r){var s=(t-n)*.5,a=(i-e)*.5,o=r*r,l=r*o;return(2*e-2*t+s+a)*l+(-3*e+3*t-2*s-a)*o+s*r+e}}},C_=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),L_=new _4,am=function(){function n(e,t){t===void 0&&(t=L_),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=nc.Linear.None,this._interpolationFunction=$a.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=C_.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),t!==void 0&&(this._duration=t),this},n.prototype.duration=function(e){return this._duration=e,this},n.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var t in this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t]}return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e!==void 0?typeof e=="string"?Vs()+parseFloat(e):e:Vs(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},n.prototype._setupProperties=function(e,t,i,r){for(var s in i){var a=e[s],o=Array.isArray(a),l=o?"array":typeof a,c=!o&&Array.isArray(i[s]);if(!(l==="undefined"||l==="function")){if(c){var h=i[s];if(h.length===0)continue;h=h.map(this._handleRelativeValue.bind(this,a)),i[s]=[a].concat(h)}if((l==="object"||o)&&a&&!c){t[s]=o?[]:{};for(var u in a)t[s][u]=a[u];r[s]=o?[]:{},this._setupProperties(a,t[s],i[s],r[s])}else typeof t[s]>"u"&&(t[s]=a),o||(t[s]*=1),c?r[s]=i[s].slice().reverse():r[s]=t[s]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=Vs()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=Vs()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;es)return!1;t&&this.start(e)}if(this._goToEnd=!1,e1?1:r;var a=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),r===1)if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(i in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]=="string"&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._repeatDelayTime!==void 0?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,l=this._chainedTweens.length;o{this.decodeDracoFile(a,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){const s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){const i=JSON.stringify(t);if(Wh.has(e)){const l=Wh.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(l=>(r=l,new Promise((c,h)=>{r._callbacks[s]={resolve:c,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),Wh.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new Ye;e.index&&t.setIndex(new lt(e.index.array,1));for(let i=0;i{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const s=x4.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const u=h.draco,d=new u.Decoder,f=new u.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{const m=t(u,d,f,c),g=m.attributes.map(p=>p.array.buffer);m.index&&g.push(m.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:m},g)}catch(m){console.error(m),self.postMessage({type:"error",id:o.id,error:m.message})}finally{u.destroy(f),u.destroy(d)}});break}};function t(a,o,l,c){const h=c.attributeIDs,u=c.attributeTypes;let d,f;const m=o.GetEncodedGeometryType(l);if(m===a.TRIANGULAR_MESH)d=new a.Mesh,f=o.DecodeBufferToMesh(l,d);else if(m===a.POINT_CLOUD)d=new a.PointCloud,f=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const g={index:null,attributes:[]};for(const p in h){const v=self[u[p]];let x,_;if(c.useUniqueIDs)_=h[p],x=o.GetAttributeByUniqueId(d,_);else{if(_=o.GetAttributeId(d,a[h[p]]),_===-1)continue;x=o.GetAttribute(d,_)}g.attributes.push(r(a,o,d,p,v,x))}return m===a.TRIANGULAR_MESH&&(g.index=i(a,o,d)),a.destroy(d),g}function i(a,o,l){const h=l.num_faces()*3,u=h*4,d=a._malloc(u);o.GetTrianglesUInt32Array(l,u,d);const f=new Uint32Array(a.HEAPF32.buffer,d,h).slice();return a._free(d),{array:f,itemSize:1}}function r(a,o,l,c,h,u){const d=u.num_components(),m=l.num_points()*d,g=m*h.BYTES_PER_ELEMENT,p=s(a,h),v=a._malloc(g);o.GetAttributeDataArrayForAllPoints(l,u,p,g,v);const x=new h(a.HEAPF32.buffer,v,m).slice();return a._free(v),{name:c,array:x,itemSize:d}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}class w4 extends _n{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new E4(t)}),this.register(function(t){return new D4(t)}),this.register(function(t){return new O4(t)}),this.register(function(t){return new C4(t)}),this.register(function(t){return new L4(t)}),this.register(function(t){return new P4(t)}),this.register(function(t){return new R4(t)}),this.register(function(t){return new T4(t)}),this.register(function(t){return new I4(t)}),this.register(function(t){return new A4(t)}),this.register(function(t){return new b4(t)}),this.register(function(t){return new z4(t)}),this.register(function(t){return new F4(t)})}load(e,t,i,r){const s=this;let a;this.resourcePath!==""?a=this.resourcePath:this.path!==""?a=this.path:a=hi.extractUrlBase(e),this.manager.itemStart(e);const o=function(c){r?r(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Pn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let s;const a={},o={};if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(hi.decodeText(new Uint8Array(e,0,4))===P_){try{a[st.KHR_BINARY_GLTF]=new N4(e)}catch(h){r&&r(h);return}s=JSON.parse(a[st.KHR_BINARY_GLTF].content)}else s=JSON.parse(hi.decodeText(new Uint8Array(e)));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new j4(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}}function M4(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const st={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class b4{constructor(e){this.parser=e,this.name=st.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class O4{constructor(e){this.parser=e,this.name=st.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=r.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,a.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class z4{constructor(e){this.name=st.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){const l=r.byteOffset||0,c=r.byteLength||0,h=r.count,u=r.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,r.mode,r.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(f),h,u,d,r.mode,r.filter),f})})}else return null}}class F4{constructor(e){this.name=st.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const c of r.primitives)if(c.mode!==Fn.TRIANGLES&&c.mode!==Fn.TRIANGLE_STRIP&&c.mode!==Fn.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=i.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(h=>(l[c]=h,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],d=c[0].count,f=[];for(const m of u){const g=new Ge,p=new R,v=new hn,x=new R(1,1,1),_=new Rd(m.geometry,m.material,d);for(let w=0;w0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Z4=new Ge;class j4{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new M4,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new dc(this.options.manager):this.textureLoader=new S_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Pn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:i,userData:{}};ka(s,o,r),or(o,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())s(h,o.children[c])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&p.setY(T,b[S*l+1]),l>=3&&p.setZ(T,b[S*l+2]),l>=4&&p.setW(T,b[S*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const l=i.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,i){const r=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"";const d=(s.samplers||{})[a.sampler]||{};return h.magFilter=lm[d.magFilter]||Mt,h.minFilter=lm[d.minFilter]||ui,h.wrapS=cm[d.wrapS]||fr,h.wrapT=cm[d.wrapT]||fr,r.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=r.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(g){const p=new Pt(g);p.needsUpdate=!0,d(p)}),t.load(hi.resolveURL(u,s.path),m,void 0,f)})}).then(function(u){return c===!0&&o.revokeObjectURL(l),u.userData.mimeType=a.mimeType||Y4(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,i,r){const s=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord!=0&&!(t==="aoMap"&&i.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+t+" not yet supported."),s.extensions[st.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[st.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[st.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return r!==void 0&&(a.encoding=r),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new zc,$t.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new un,$t.prototype.copy.call(l,i),l.color.copy(i.color),this.cache.add(o,l)),i=l}if(r||s||a){let o="ClonedMaterial:"+i.uuid+":";r&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}i.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=i}getMaterialType(){return Go}loadMaterial(e){const t=this,i=this.json,r=this.extensions,s=i.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[st.KHR_MATERIALS_UNLIT]){const u=r[st.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),c.push(u.extendParams(o,s,t))}else{const u=s.pbrMetallicRoughness||{};if(o.color=new xe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.fromArray(d),o.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",u.baseColorTexture,ot)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=bo);const h=s.alphaMode||qh.OPAQUE;if(h===qh.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===qh.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Mn&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new ne(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;o.normalScale.set(u,u)}return s.occlusionTexture!==void 0&&a!==Mn&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Mn&&(o.emissive=new xe().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&a!==Mn&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,ot)),Promise.all(c).then(function(){const u=new a(o);return s.name&&(u.name=s.name),or(u,s),t.associations.set(u,{materials:e}),s.extensions&&ka(r,u,s),u})}createUniqueName(e){const t=nt.sanitizeNodeName(e||"");let i=t;for(let r=1;this.nodeNamesUsed[i];++r)i=t+"_"+r;return this.nodeNamesUsed[i]=!0,i}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function s(o){return i[st.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return um(l,o,t)})}const a=[];for(let o=0,l=e.length;o0&&q4(v,s),v.name=t.createUniqueName(s.name||"mesh_"+e),or(v,s),p.extensions&&ka(r,v,p),t.assignFinalMaterial(v),u.push(v)}for(let f=0,m=u.length;f1?u=new Di:l.length===1?u=l[0]:u=new it,u!==l[0])for(let d=0,f=l.length;d{const u=new Map;for(const[d,f]of r.associations)(d instanceof $t||d instanceof Pt)&&u.set(d,f);return h.traverse(d=>{const f=r.associations.get(d);f!=null&&u.set(d,f)}),u};return r.associations=c(s),s})}}function K4(n,e,t){const i=e.attributes,r=new Sr;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(r.set(new R(l[0],l[1],l[2]),new R(c[0],c[1],c[2])),o.normalized){const h=Vu(Js[o.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new R,l=new R;for(let c=0,h=s.length;c(M=O.indexOf(u))&&T=_.byteLength||!(C=d(_)))return o(1,"no header found");if(!(O=C.match(w)))return o(3,"bad initial token");for(T.valid|=1,T.programtype=O[1],T.string+=C+` `;C=d(_),C!==!1;){if(T.string+=C+` `,C.charAt(0)==="#"){T.comments+=C+` `;continue}if((O=C.match(y))&&(T.gamma=parseFloat(O[1])),(O=C.match(b))&&(T.exposure=parseFloat(O[1])),(O=C.match(S))&&(T.valid|=2,T.format=O[1]),(O=C.match(M))&&(T.valid|=4,T.height=parseInt(O[1],10),T.width=parseInt(O[2],10)),T.valid&2&&T.valid&4)break}return T.valid&2?T.valid&4?T:o(3,"missing image size specifier"):o(3,"missing format specifier")},m=function(_,w,y){const b=w;if(b<8||b>32767||_[0]!==2||_[1]!==2||_[2]&128)return new Uint8Array(_);if(b!==(_[2]<<8|_[3]))return o(3,"wrong scanline width");const S=new Uint8Array(4*w*y);if(!S.length)return o(4,"unable to allocate buffer space");let M=0,T=0;const C=4*b,O=new Uint8Array(4),U=new Uint8Array(C);let F=y;for(;F>0&&T<_.byteLength;){if(T+4>_.byteLength)return o(1);if(O[0]=_[T++],O[1]=_[T++],O[2]=_[T++],O[3]=_[T++],O[0]!=2||O[1]!=2||(O[2]<<8|O[3])!=b)return o(3,"bad rgbe scanline format");let z=0,L;for(;z128;if(G&&(L-=128),L===0||z+L>C)return o(3,"bad scanline data");if(G){const W=_[T++];for(let se=0;se{I_.push(n)},e5=n=>n.children===void 0?!1:n.children.length!==0,D_=(n,e)=>{(n==null?void 0:n.children)!==void 0&&n.children.forEach((t,i)=>{e(t),e5(t)&&D_(t,e)})},Vl=(n,e=Q4)=>{I_=[],D_(n,e)};class Wo extends Bt{constructor(){const e=Wo.SkyShader,t=new Kn({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:bd.clone(e.uniforms),side:bn,depthWrite:!1});super(new _i(1,1,1),t)}}Wo.prototype.isSky=!0;Wo.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new R},up:{value:new R(0,1,0)}},vertexShader:` uniform vec3 sunPosition; uniform float rayleigh; uniform float turbidity; uniform float mieCoefficient; uniform vec3 up; varying vec3 vWorldPosition; varying vec3 vSunDirection; varying float vSunfade; varying vec3 vBetaR; varying vec3 vBetaM; varying float vSunE; // constants for atmospheric scattering const float e = 2.71828182845904523536028747135266249775724709369995957; const float pi = 3.141592653589793238462643383279502884197169; // wavelength of used primaries, according to preetham const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 ); // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function: // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn)) const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 ); // mie stuff // K coefficient for the primaries const float v = 4.0; const vec3 K = vec3( 0.686, 0.678, 0.666 ); // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 ); // earth shadow hack // cutoffAngle = pi / 1.95; const float cutoffAngle = 1.6110731556870734; const float steepness = 1.5; const float EE = 1000.0; float sunIntensity( float zenithAngleCos ) { zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 ); return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) ); } vec3 totalMie( float T ) { float c = ( 0.2 * T ) * 10E-18; return 0.434 * c * MieConst; } void main() { vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); gl_Position.z = gl_Position.w; // set z to camera.far vSunDirection = normalize( sunPosition ); vSunE = sunIntensity( dot( vSunDirection, up ) ); vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 ); float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) ); // extinction (absorbtion + out scattering) // rayleigh coefficients vBetaR = totalRayleigh * rayleighCoefficient; // mie coefficients vBetaM = totalMie( turbidity ) * mieCoefficient; }`,fragmentShader:` varying vec3 vWorldPosition; varying vec3 vSunDirection; varying float vSunfade; varying vec3 vBetaR; varying vec3 vBetaM; varying float vSunE; uniform float mieDirectionalG; uniform vec3 up; const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 ); // constants for atmospheric scattering const float pi = 3.141592653589793238462643383279502884197169; const float n = 1.0003; // refractive index of air const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius) // optical length at zenith for molecules const float rayleighZenithLength = 8.4E3; const float mieZenithLength = 1.25E3; // 66 arc seconds -> degrees, and the cosine of that const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324; // 3.0 / ( 16.0 * pi ) const float THREE_OVER_SIXTEENPI = 0.05968310365946075; // 1.0 / ( 4.0 * pi ) const float ONE_OVER_FOURPI = 0.07957747154594767; float rayleighPhase( float cosTheta ) { return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) ); } float hgPhase( float cosTheta, float g ) { float g2 = pow( g, 2.0 ); float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 ); return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse ); } void main() { vec3 direction = normalize( vWorldPosition - cameraPos ); direction = direction + vec3(0,0.7,0); // optical length // cutoff angle at 90 to avoid singularity in next formula. float zenithAngle = acos( max( 0.0, dot( up, direction ) ) ); float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) ); float sR = rayleighZenithLength * inverse; float sM = mieZenithLength * inverse; // combined extinction factor vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) ); // in scattering float cosTheta = dot( direction, vSunDirection ); float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 ); vec3 betaRTheta = vBetaR * rPhase; float mPhase = hgPhase( cosTheta, mieDirectionalG ); vec3 betaMTheta = vBetaM * mPhase; vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) ); Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) ); // nightsky float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2] float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2] vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 ); vec3 L0 = vec3( 0.1 ) * Fex; // composition + solar disc float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ); L0 += ( vSunE * 19000.0 * Fex ) * sundisk; vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 ) + vec3(0,0,0.2); vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) ); gl_FragColor = vec4( retColor, 1.0 ); #include #include }`};const Xh=".",t5="./",n5="./Lightmaps/",i5="./envmap/",fm=30*ro.DEG2RAD;let Yh=!0,ai,Ci,ir,pm,Xn,mm,Zh,jh,Ua,gm=0,Gl=0,Wl="0",$l,Kh=[];const Jh=new R,Li=new R,Br=new R(-18,0,14);let Qh;window.onload=function(){(function(){const y=lA;var b=document.querySelector("#pano"),S=document.querySelector("#titleBar .sceneName"),M=document.querySelector("#sceneList"),T=document.querySelectorAll("#sceneList .scene"),C=document.querySelector("#sceneListToggle"),O=document.querySelector("#autorotateToggle"),U=document.querySelector("#fullscreenToggle");if(window.matchMedia){var F=function(){z.matches?(document.body.classList.remove("desktop"),document.body.classList.add("mobile")):(document.body.classList.remove("mobile"),document.body.classList.add("desktop"))},z=matchMedia("(max-width: 500px), (max-height: 500px)");F(),z.addListener(F)}else document.body.classList.add("desktop");document.body.classList.add("no-touch"),window.addEventListener("touchstart",function(){document.body.classList.remove("no-touch"),document.body.classList.add("touch")}),ts.msie&&parseFloat(ts.version)<11&&document.body.classList.add("tooltip-fallback");var L={controls:{mouseViewMode:y.settings.mouseViewMode}},K=new On.Viewer(b,L),G=y.scenes.map(function(P){var E="tiles",H=On.ImageUrlSource.fromString(E+"/"+P.id+"/{z}/{f}/{y}/{x}.jpg",{cubeMapPreviewUrl:E+"/"+P.id+"/preview.jpg"}),re=new On.CubeGeometry(P.levels),ae=On.RectilinearView.limit.traditional(P.faceSize,100*Math.PI/180,120*Math.PI/180),me=new On.RectilinearView(P.initialViewParameters,ae),Te=K.createScene({source:H,geometry:re,view:me,pinFirstLevel:!0});return P.linkHotspots.forEach(function(oe){var q=Be(oe);Te.hotspotContainer().createHotspot(q,{yaw:oe.yaw,pitch:oe.pitch})}),P.infoHotspots.forEach(function(oe){var q=De(oe);Te.hotspotContainer().createHotspot(q,{yaw:oe.yaw,pitch:oe.pitch})}),{data:P,scene:Te,view:me}});Qh=G;var W=On.autorotate({yawSpeed:.1,targetPitch:0,targetFov:Math.PI/2});O.addEventListener("click",_e),Qo.enabled&&y.settings.fullscreenButton?(document.body.classList.add("fullscreen-enabled"),U.addEventListener("click",function(){Qo.toggle()}),Qo.on("change",function(){Qo.isFullscreen?U.classList.add("enabled"):U.classList.remove("enabled")})):document.body.classList.add("fullscreen-disabled"),C.addEventListener("click",ee),G.forEach(function(P){var E=document.querySelector('#sceneList .scene[data-id="'+P.data.id+'"]');E.addEventListener("click",function(){Oe(P),document.body.classList.contains("mobile")&&te()})});var se=document.querySelector("#viewUp"),ie=document.querySelector("#viewDown"),$=document.querySelector("#viewLeft"),Y=document.querySelector("#viewRight"),le=document.querySelector("#viewIn"),de=document.querySelector("#viewOut"),he=.7,X=3,we=K.controls();we.registerMethod("upElement",new On.ElementPressControlMethod(se,"y",-he,X),!0),we.registerMethod("downElement",new On.ElementPressControlMethod(ie,"y",he,X),!0),we.registerMethod("leftElement",new On.ElementPressControlMethod($,"x",-he,X),!0),we.registerMethod("rightElement",new On.ElementPressControlMethod(Y,"x",he,X),!0),we.registerMethod("inElement",new On.ElementPressControlMethod(le,"zoom",-he,X),!0),we.registerMethod("outElement",new On.ElementPressControlMethod(de,"zoom",he,X),!0);function ge(P){return P.replace("&","&").replace("<","<").replace(">",">")}function Oe(P){Me(),P.view.setParameters(P.data.initialViewParameters),P.scene.switchTo(),ue(),ve(P),Ve(P)}function ve(P){S.innerHTML=ge(P.data.name)}function Ve(P){for(var E=0;E{console.log("??"),Yh=!1,t.style.display="none"});const i=document.getElementById("webgl-cubes");document.getElementById("panorama"),document.querySelector("#titleBar .sceneName"),document.querySelector("#sceneList"),document.querySelectorAll("#sceneList .scene"),document.querySelector("#sceneListToggle");const r=document.querySelector("#autorotateToggle");document.querySelector("#fullscreenToggle"),document.getElementById("toggleDeviceOrientation");const s=document.getElementById("preloader"),a=document.querySelector(".progress");document.querySelector(".progress-indicator");const o=document.querySelector(".progress-label > strong");document.getElementById("social");const l=document.getElementById("navigation"),c=document.querySelector("#pano");function h(){(function(){ai=new Ad({powerPreference:"high-performance",antialias:!0}),ai.setClearColor(16777215),ai.setSize(window.innerWidth,window.innerHeight)})(),function(){Ci=new Wt(55,window.innerWidth/window.innerHeight,.1,1e3)}(),function(){ir=new Cd,ir.background=new xe(8900331),new dc().load(`${Xh}${i5}envmap.png`,function(M){$l=M,$l.mapping=Qs,ir.environment=$l},void 0,function(M){console.log("oops")})}(),n.appendChild(ai.domElement),function(){{const C=new $d(16777215,16777215,.5);C.color.setHSL(1,1,1),C.groundColor.setHSL(.095,1,.75),C.position.set(10,50,50)}Ci.position.z=10,Ci.position.y=10;{const C=new Bc(16777215,.2);C.color.setHSL(.1,1,.95),C.castShadow=!0,C.shadow.mapSize.set(2048,2048);const O=20;C.shadow.camera.left=-O,C.shadow.camera.right=O,C.shadow.camera.top=O,C.shadow.camera.bottom=-O}const S=new Wo;S.matrixAutoUpdate=!1,S.renderOrder=-1,S.scale.setScalar(45e4),S.position.set(Br.x,Br.y,Br.z);const M=new R,T={turbidity:1,rayleigh:.3,mieCoefficient:.005,mieDirectionalG:.9,elevation:17,azimuth:215,exposure:.75};{const{uniforms:C}=S.material;C.turbidity.value=T.turbidity,C.rayleigh.value=T.rayleigh,C.mieCoefficient.value=T.mieCoefficient,C.mieDirectionalG.value=T.mieDirectionalG;const O=ro.degToRad(90-T.elevation),U=ro.degToRad(T.azimuth);M.setFromSphericalCoords(1,O,U),C.sunPosition.value.copy(M),ai.outputEncoding=ot,ai.toneMapping=md,ir.add(S)}}(),function(){Xn=new Uf(Ci,ai.domElement),pm=Xn,Xn._truckInternal=(M,T,C)=>{},JSON.parse(JSON.stringify(Xn.azimuthAngle));const S=JSON.parse(JSON.stringify(Xn.polarAngle));Xn.minPolarAngle=S-fm,Xn.maxPolarAngle=S+fm,Xn.maxDistance=21,Xn.minDistance=14}(),function(){mm=new jd}(),d("FirstFloorLounge360.glb"),function(){e.addEventListener("click",()=>{g(!1),p(!0),ai.render(ir,Ci)})}();function y(b){const S=mm.getDelta(),M=Xn.update(S);requestAnimationFrame(y),M&&w()}window.onresize=function(){Ci.aspect=window.innerWidth/window.innerHeight,Ci.updateProjectionMatrix(),ai.setSize(window.innerWidth,window.innerHeight),w()},y()}function u(y){console.log("updating",y),Wl=y>=100?"100":`${Math.round(y)}`,o.textContent=Wl,a.style.setProperty("--progress-value",Wl),a.dataset.value=Wl,y>50?a.classList.add("progress--upper-half-value"):a.classList.contains("progress--upper-half-value")&&a.classList.remove("progress--upper-half-value")}function d(y){Ua=new Uc;const b={value:0};new am(b).to({value:10},1e3).onUpdate(S=>{u(S.value)}).onComplete(S=>{Gl=S.value,console.log("taween")}).start(),Ua.onProgress=(S,M,T)=>{console.log("loading",S,M,T),Gl=Math.round(+M/+T*100),u(Gl);const C={value:gm};console.log("still loading"),new am(C).to({value:Gl},1e3).onUpdate(U=>{u(U.value)}).onComplete(U=>{console.log("tweenning"),gm=U.value}).start()},Ua.onLoad=()=>{u(100),setTimeout(()=>{s.classList.add("hidden"),setTimeout(()=>{s.style.display="none"},1e3)},2e3),setTimeout(()=>{let S=new R;Xn.getPosition(S)},1500)},Zh=new y4(Ua),Zh.setDecoderPath("./decoder/gltf/"),jh=new w4(Ua),jh.setDRACOLoader(Zh),jh.loadAsync(`${Xh}${t5}${y}`).then(S=>{const{scene:M}=S;ir.add(M),M.position.set(Br.x,Br.y,Br.z),M.matrixAutoUpdate=!1,Vl(M,T=>{T.matrixAutoUpdate=!1,T.updateMatrix()}),f(M),x(M),M.updateMatrix(),w()})}function f(y){const b=new J4;new dc,Vl(y,S=>{let M=`${Xh}${n5}${S.name+"_filtered.hdr"}`;if(S.isMesh){const C=S.material;C.metalness>.5&&(console.log("HAS NO LIGHTMAP, is Metal",S),C.envMap=$l,C.envMapIntensity=1)}console.log("Want to load map for: "+S.name),b.loadAsync(M).then(C=>{let O=C;S.isMesh===void 0?Vl(S,F=>{m(F,O)}):m(S,O)}).catch(()=>{});const T=S.userData.name;if(T!==void 0){if(T.includes("Cloud")){let C=S;if(C.isMesh!==void 0){console.log("--- Cloud is Mesh!");const O=C.material;O.emissive=new xe(255,255,255)}}T.includes("hide")&&(S.visible=!1)}})}function m(y,b){console.log("applying map to "+y.name),b.flipY=!1;const S=y.material.clone(),M=y.name.includes("ENV")?.5:1;S.lightMap=b,S.lightMapIntensity=M,S.envMapIntensity=0,y.material=S,y.material.needsUpdate=!0,w()}function g(y){l.style.display=y?"flex":"none",c.style.visibility=y?"visible":"hidden",r.style.visibility=y?"visible":"hidden",window.dispatchEvent(new Event("resize"))}function p(y){pm.enabled=y,n.style.display=y?"flex":"none",i.style.display=y?"block":"none",t.style.display=y&&Yh?"block":"none",Yh=!1}function v(y){const b=Qh[y];b!==void 0&&(b.view.setParameters(b.data.initialViewParameters),b.scene.switchTo())}function x(y){Vl(y,b=>{if(b.name.includes("Hotspot")){let S;b.name.toLowerCase().includes("hall")?S=1:b.name.toLowerCase().includes("laundry")?S=2:b.name.toLowerCase().includes("booking")?S=3:b.name.toLowerCase().includes("spontan")?S=4:b.name.toLowerCase().includes("coworking")?S=5:b.name.toLowerCase().includes("bike")?S=6:b.name.toLowerCase().includes("playroom")?S=7:b.name.toLowerCase().includes("gym")&&(S=8),console.log("SCENE",Qh,S);let M=new R(0,0,0);M.copy(b.position),_(S,M,1)}})}function _(y,b,S){const M=new _i(S,S,S),T=new Bt(M,new Mn({color:16711680})),C=new R;C.addVectors(b,Br),T.position.set(C.x,C.y,C.z),T.matrixAutoUpdate=!1,T.updateMatrix();const O=document.createElement("div");O.id=`cube-${y}`,O.classList.add("cube-container");{const F=document.createElement("div");F.addEventListener("click",()=>{v(y-1),g(!0),p(!1),window.dispatchEvent(new Event("resize"))}),F.classList.add("cube");const z=document.createElement("img");z.src="img/point_filled.png",F.appendChild(z),F.style.width=`${S}px`,F.style.height=`${S}px`,O.appendChild(F)}T.visible=!1,ir.add(T);let U=new R(0,0,0);T.getWorldPosition(U),i.appendChild(O),Kh.push({cube:T,wrapper:O})}function w(){ai.render(ir,Ci);for(let y=0;y