diff --git a/dist/main.min.js b/dist/main.min.js index 750c149d..535c0ca8 100644 --- a/dist/main.min.js +++ b/dist/main.min.js @@ -1,2 +1,2 @@ /*! For license information please see main.min.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MeshCat=t():e.MeshCat=t()}(self,(function(){return(()=>{var __webpack_modules__={583:(e,t,n)=>{var i;e=n.nmd(e),function(){if(void 0!==e.exports)var r=n(617),s=n(549),a=n(468);var o={function:!0,object:!0};function l(e){return e&&e.Object===Object?e:null}parseFloat,parseInt;var c=o[typeof t]&&t&&!t.nodeType?t:void 0,h=o.object&&e&&!e.nodeType?e:void 0,u=(h&&h.exports,l(c&&h&&"object"==typeof n.g&&n.g)),d=l(o[typeof self]&&self),p=l(o[typeof window]&&window),f=l(o[typeof this]&&this);function m(e){return String("0000000"+e).slice(-7)}u||p!==(f&&f.window)&&p||d||f||Function("return this")(),"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),r=i.length,s=new Uint8Array(r),a=0;a=c.frameLimit||c.timeLimit&&e>=c.timeLimit)&&(G(),W());var t=new Date(null);t.setSeconds(e),c.motionBlurFrames>2?v.textContent="CCapture "+c.format+" | "+d+" frames ("+p+" inter) | "+t.toISOString().substr(11,8):v.textContent="CCapture "+c.format+" | "+d+" frames | "+t.toISOString().substr(11,8)}(),j("Frame: "+d+" "+p);for(var s=0;s=h[s].triggerTime&&(H(h[s].callback),h.splice(s,1));for(s=0;s=u[s].triggerTime&&(H(u[s].callback),u[s].triggerTime+=u[s].time);f.forEach((function(e){H(e,n-g)})),f=[]}function W(e){e||(e=function(e){return s(e,l.filename+l.extension,l.mimeType),!1}),l.save(e)}function j(e){t&&console.log(e)}return{start:function(){!function(){function e(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),z.push(this)),this._hookedTime+c.startTime}j("Capturer start"),i=window.Date.now(),n=i+c.startTime,a=window.performance.now(),r=a+c.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(e,t){var i={callback:e,time:t,triggerTime:n+t};return h.push(i),j("Timeout set to "+i.time),i},window.clearTimeout=function(e){for(var t=0;t2?(function(e){A.width===e.width&&A.height===e.height||(A.width=e.width,A.height=e.height,E=new Uint16Array(A.height*A.width*4),C.fillStyle="#0",C.fillRect(0,0,A.width,A.height))}(e),function(e){C.drawImage(e,0,0),T=C.getImageData(0,0,A.width,A.height);for(var t=0;t=.5*c.motionBlurFrames?function(){for(var e=T.data,t=0;t0&&this.frames.length/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(e){this.filename=this.baseFilename+"-part-"+m(this.part),s(e,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+m(this.part),this.step()}.bind(this)):this.step()},b.prototype.save=function(e){this.videoWriter.complete().then(e)},b.prototype.dispose=function(e){this.frames=[]},w.prototype=Object.create(_.prototype),w.prototype.start=function(){this.encoder.start(this.settings)},w.prototype.add=function(e){this.encoder.add(e)},w.prototype.save=function(e){this.callback=e,this.encoder.end()},w.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},M.prototype=Object.create(_.prototype),M.prototype.add=function(e){this.stream||(this.stream=e.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(e){this.chunks.push(e.data)}.bind(this)),this.step()},M.prototype.save=function(e){this.mediaRecorder.onstop=function(t){var n=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],e(n)}.bind(this),this.mediaRecorder.stop()},S.prototype=Object.create(_.prototype),S.prototype.add=function(e){this.sizeSet||(this.encoder.setOption("width",e.width),this.encoder.setOption("height",e.height),this.sizeSet=!0),this.canvas.width=e.width,this.canvas.height=e.height,this.ctx.drawImage(e,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},S.prototype.save=function(e){this.callback=e,this.encoder.render()},(p||d||{}).CCapture=E,void 0===(i=function(){return E}.call(t,n,t,e))||(e.exports=i)}()},549:e=>{void 0!==e.exports&&(e.exports=function(e,t,n){var i,r,s,a=window,o="application/octet-stream",l=n||o,c=e,h=document,u=h.createElement("a"),d=function(e){return String(e)},p=a.Blob||a.MozBlob||a.WebKitBlob||d,f=a.MSBlobBuilder||a.WebKitBlobBuilder||a.BlobBuilder,m=t||"download";if("true"===String(this)&&(l=(c=[c,l])[0],c=c[1]),String(c).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(function(e){for(var t=e.split(/[:;,]/),n=t[1],i=("base64"==t[2]?atob:decodeURIComponent)(t.pop()),r=i.length,s=0,a=new Uint8Array(r);s{e.exports=function e(t,n,i){function r(a,o){if(!n[a]){if(!t[a]){if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return r(t[a][1][e]||e)}),c,c.exports,e,t,n,i)}return n[a].exports}for(var s=void 0,a=0;a0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},i.prototype.removeListener=function(e,t){var n,i,a,o;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(o=a;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){i=o;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,n){var i=e("./TypedNeuQuant.js"),r=e("./LZWEncoder.js");function s(){this.page=-1,this.pages=[],this.newPage()}s.pageSize=4096,s.charMap={};for(var a=0;a<256;a++)s.charMap[a]=String.fromCharCode(a);function o(e,t){this.width=~~e,this.height=~~t,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new s}s.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(s.pageSize),this.cursor=0},s.prototype.getData=function(){for(var e="",t=0;t=s.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=e},s.prototype.writeUTFBytes=function(e){for(var t=e.length,n=0;n=0&&(this.dispose=e)},o.prototype.setRepeat=function(e){this.repeat=e},o.prototype.setTransparent=function(e){this.transparent=e},o.prototype.addFrame=function(e){this.image=e,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},o.prototype.finish=function(){this.out.writeByte(59)},o.prototype.setQuality=function(e){e<1&&(e=1),this.sample=e},o.prototype.setDither=function(e){!0===e&&(e="FloydSteinberg"),this.dither=e},o.prototype.setGlobalPalette=function(e){this.globalPalette=e},o.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},o.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},o.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new i(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},o.prototype.indexPixels=function(e){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);for(var n=0,i=0;i=0&&b+h=0&&w+c>16,(65280&e)>>8,255&e,t)},o.prototype.findClosestRGB=function(e,t,n,i){if(null===this.colorTab)return-1;if(this.neuQuant&&!i)return this.neuQuant.lookupRGB(e,t,n);for(var r=0,s=16777216,a=this.colorTab.length,o=0,l=0;o=0&&(t=7&this.dispose),t<<=2,this.out.writeByte(0|t|e),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},o.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},o.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},o.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},o.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var e=768-this.colorTab.length,t=0;t>8&255)},o.prototype.writePixels=function(){new r(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this.out)},o.prototype.stream=function(){return this.out},t.exports=o},{"./LZWEncoder.js":3,"./TypedNeuQuant.js":4}],3:[function(e,t,n){var i=5003,r=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];t.exports=function(e,t,n,s){var a,o,l,c,h,u,d=Math.max(2,s),p=new Uint8Array(256),f=new Int32Array(i),m=new Int32Array(i),g=0,_=0,v=!1;function y(e,t){p[o++]=e,o>=254&&w(t)}function x(e){b(i),_=h+2,v=!0,E(h,e)}function b(e){for(var t=0;t0&&(e.writeByte(o),e.writeBytes(p,0,o),o=0)}function M(e){return(1<0?a|=e<=8;)y(255&a,t),a>>=8,g-=8;if((_>l||v)&&(v?(l=M(n_bits=c),v=!1):(++n_bits,l=12==n_bits?4096:M(n_bits))),e==u){for(;g>0;)y(255&a,t),a>>=8,g-=8;w(t)}}this.encode=function(n){n.writeByte(d),remaining=e*t,curPixel=0,function(e,t){var n,r,s,a,d,p;for(c=e,v=!1,n_bits=c,l=M(n_bits),u=1+(h=1<=0){d=5003-s,0===s&&(d=1);do{if((s-=d)<0&&(s+=5003),f[s]===n){a=m[s];continue e}}while(f[s]>=0)}E(a,t),a=r,_<4096?(m[s]=_++,f[s]=n):x(t)}else a=m[s];E(a,t),E(u,t)}(d+1,n),n.writeByte(0)}}},{}],4:[function(e,t,n){var i=256,r=1024,s=1<<18;t.exports=function(e,t){var n,a,o,l,c;function h(e,t,i,s,a){n[t][0]-=e*(n[t][0]-i)/r,n[t][1]-=e*(n[t][1]-s)/r,n[t][2]-=e*(n[t][2]-a)/r}function u(e,t,r,a,o){for(var l,h,u=Math.abs(t-e),d=Math.min(t+e,i),p=t+1,f=t-1,m=1;pu;)h=c[m++],pu&&((l=n[f--])[0]-=h*(l[0]-r)/s,l[1]-=h*(l[1]-a)/s,l[2]-=h*(l[2]-o)/s)}function d(e,t,r){var s,a,c,h,u,d=~(1<<31),p=d,f=-1,m=f;for(s=0;s>12))>10,l[s]-=u,o[s]+=u<<10;return l[f]+=64,o[f]-=65536,m}this.buildColormap=function(){(function(){var e,t;for(n=[],a=new Int32Array(256),o=new Int32Array(i),l=new Int32Array(i),c=new Int32Array(32),e=0;e>6;for(y<=1&&(y=0),n=0;n=p&&(x-=p),0===g&&(g=1),++n%g==0)for(_-=_/f,(y=(v-=v/30)>>6)<=1&&(y=0),l=0;l>=4,n[e][1]>>=4,n[e][2]>>=4,n[e][3]=e}(),function(){var e,t,r,s,o,l,c=0,h=0;for(e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)a[t]=255}()},this.getColormap=function(){for(var e=[],t=[],r=0;r=0;)u=c?u=i:(u++,l<0&&(l=-l),(s=o[0]-e)<0&&(s=-s),(l+=s)=0&&((l=t-(o=n[d])[1])>=c?d=-1:(d--,l<0&&(l=-l),(s=o[0]-e)<0&&(s=-s),(l+=s)t;0<=t?++e:--e)n.push(null);return n}.call(this),t=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(e=0,n=t;0<=n?en;0<=n?++e:--e)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},i.prototype.abort=function(){for(var e;null!=(e=this.activeWorkers.shift());)this.log("killing active worker"),e.terminate();return this.running=!1,this.emit("abort")},i.prototype.spawnWorkers=function(){var e,t,n,i;return e=Math.min(this.options.workers,this.frames.length),function(){n=[];for(var i=t=this.freeWorkers.length;t<=e?ie;t<=e?i++:i--)n.push(i);return n}.apply(this).forEach((i=this,function(e){var t;return i.log("spawning worker "+e),(t=new Worker(i.options.workerScript)).onmessage=function(e){return i.activeWorkers.splice(i.activeWorkers.indexOf(t),1),i.freeWorkers.push(t),i.frameFinished(e.data)},i.freeWorkers.push(t)})),e},i.prototype.frameFinished=function(e){var t,n;if(this.log("frame "+e.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[e.index]=e,!0===this.options.globalPalette&&(this.options.globalPalette=e.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(t=1,n=this.freeWorkers.length;1<=n?tn;1<=n?++t:--t)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},i.prototype.finishRendering=function(){var e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m;for(o=0,r=0,l=(p=this.imageParts).length;r=this.frames.length))return e=this.frames[this.nextFrame++],n=this.freeWorkers.shift(),t=this.getTask(e),this.log("starting frame "+(t.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(t)},i.prototype.getContextData=function(e){return e.getImageData(0,0,this.options.width,this.options.height).data},i.prototype.getImageData=function(e){var t;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(t=this._canvas.getContext("2d")).setFill=this.options.background,t.fillRect(0,0,this.options.width,this.options.height),t.drawImage(e,0,0),this.getContextData(t)},i.prototype.getTask=function(e){var t,n;if(n={index:t=this.frames.indexOf(e),last:t===this.frames.length-1,delay:e.delay,dispose:e.dispose,transparent:e.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:"chrome"===r.name},null!=e.data)n.data=e.data;else if(null!=e.context)n.data=this.getContextData(e.context);else{if(null==e.image)throw new Error("Invalid frame");n.data=this.getImageData(e.image)}return n},i.prototype.log=function(){var e;if(e=1<=arguments.length?o.call(arguments,0):[],this.options.debug)return console.log.apply(console,e)},i}(i)},{"./GIFEncoder.js":2,"./browser.coffee":5,"./gif.worker.coffee":7,events:1}],7:[function(e,t,n){var i,r;i=e("./GIFEncoder.js"),r=function(e){var t,n,r,s;return t=new i(e.width,e.height),0===e.index?t.writeHeader():t.firstFrame=!1,t.setTransparent(e.transparent),t.setDispose(e.dispose),t.setRepeat(e.repeat),t.setDelay(e.delay),t.setQuality(e.quality),t.setDither(e.dither),t.setGlobalPalette(e.globalPalette),t.addFrame(e.data),e.last&&t.finish(),!0===e.globalPalette&&(e.globalPalette=t.getGlobalPalette()),r=t.stream(),e.data=r.pages,e.cursor=r.cursor,e.pageSize=r.constructor.pageSize,e.canTransfer?(s=function(){var t,i,r,s;for(s=[],t=0,i=(r=e.data).length;t{!function(){"use strict";var e=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"];function t(e){var t,n=new Uint8Array(e);for(t=0;t>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];switch(o.length%4){case 1:o+="=";break;case 2:o+="=="}return o}}(),function(){"use strict";var e,t=window.utils;e=[{field:"fileName",length:100},{field:"fileMode",length:8},{field:"uid",length:8},{field:"gid",length:8},{field:"fileSize",length:12},{field:"mtime",length:12},{field:"checksum",length:8},{field:"type",length:1},{field:"linkName",length:100},{field:"ustar",length:8},{field:"owner",length:32},{field:"group",length:32},{field:"majorNumber",length:8},{field:"minorNumber",length:8},{field:"filenamePrefix",length:155},{field:"padding",length:12}],window.header={},window.header.structure=e,window.header.format=function(n,i){var r=t.clean(512),s=0;return e.forEach((function(e){var t,i,a=n[e.field]||"";for(t=0,i=a.length;ti&&(t.push({blocks:r,length:n}),r=[],n=0),r.push(e),n+=e.headerLength+e.inputLength})),t.push({blocks:r,length:n}),t.forEach((function(t){var n=new Uint8Array(t.length),i=0;t.blocks.forEach((function(e){n.set(e.header,i),i+=e.headerLength,n.set(e.input,i),i+=e.inputLength})),e.push(n)})),e.push(new Uint8Array(1024)),new Blob(e,{type:"octet/stream"})},s.prototype.clear=function(){this.written=0,this.out=i.clean(t)},void 0!==e.exports?e.exports=s:window.Tar=s}()},376:(e,t,n)=>{"use strict";function i(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),s=Math.round(e.b),a=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+s+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+s+","+a+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+s+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+s+","+a+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+s+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+s+",a:"+a+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+a+"}":"unknown format"}n.d(t,{ZP:()=>he});var r=Array.prototype.forEach,s=Array.prototype.slice,a={BREAK:{},extend:function(e){return this.each(s.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(s.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=s.call(arguments);return function(){for(var t=s.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(r&&e.forEach&&e.forEach===r)e.forEach(t,n);else if(e.length===e.length+0){var i,s=void 0;for(s=0,i=e.length;s1?a.toArray(arguments):arguments[0];return a.each(o,(function(t){if(t.litmus(e))return a.each(t.conversions,(function(t,n){if(l=t.read(e),!1===c&&!1!==l)return c=l,l.conversionName=n,l.conversion=t,a.BREAK})),a.BREAK})),c},u=void 0,d={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),s=n*(1-t),a=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,s],[a,n,s],[s,n,o],[s,a,n],[o,s,n],[n,s,a]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),s=r-i,a=void 0;return 0===r?{h:NaN,s:0,v:0}:(a=e===r?(t-n)/s:t===r?2+(n-e)/s:4+(e-t)/s,(a/=6)<0&&(a+=1),{h:360*a,s:s/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(u=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var P=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=i||{};return r.__min=s.min,r.__max=s.max,r.__step=s.step,a.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=L(r.__impliedStep),r}return _(t,e),m(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=L(e),this}}]),t}(w),I=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var s=r,o=void 0;function l(){s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function c(e){var t=o-e.clientY;s.setValue(s.getValue()+t*s.__impliedStep),o=e.clientY}function h(){T.unbind(window,"mousemove",c),T.unbind(window,"mouseup",h),l()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),T.bind(r.__input,"change",(function(){var e=parseFloat(s.__input.value);a.isNaN(e)||s.setValue(e)})),T.bind(r.__input,"blur",(function(){l()})),T.bind(r.__input,"mousedown",(function(e){T.bind(window,"mousemove",c),T.bind(window,"mouseup",h),o=e.clientY})),T.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(s.__truncationSuspended=!0,this.blur(),s.__truncationSuspended=!1,l())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(P);function U(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var O=function(e){function t(e,n,i,r,s){f(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:s})),o=a;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(U(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){T.unbind(window,"mousemove",l),T.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(U(t,n.left,n.right,o.__min,o.__max))}function u(){T.unbind(window,"touchmove",h),T.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),T.bind(a.__background,"mousedown",(function(e){document.activeElement.blur(),T.bind(window,"mousemove",l),T.bind(window,"mouseup",c),l(e)})),T.bind(a.__background,"touchstart",(function(e){1===e.touches.length&&(T.bind(window,"touchmove",h),T.bind(window,"touchend",u),h(e))})),T.addClass(a.__background,"slider"),T.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(P),N=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,T.bind(r.__button,"click",(function(e){return e.preventDefault(),s.fire(),!1})),T.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return _(t,e),m(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(w),D=function(e){function t(e,n){f(this,t);var i=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new y(i.getValue()),i.__temp=new y(0);var r=i;i.domElement=document.createElement("div"),T.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",T.bind(i.__input,"keydown",(function(e){13===e.keyCode&&p.call(this)})),T.bind(i.__input,"blur",p),T.bind(i.__selector,"mousedown",(function(){T.addClass(this,"drag").bind(window,"mouseup",(function(){T.removeClass(r.__selector,"drag")}))})),T.bind(i.__selector,"touchstart",(function(){T.addClass(this,"drag").bind(window,"touchend",(function(){T.removeClass(r.__selector,"drag")}))}));var s,o=document.createElement("div");function l(e){g(e),T.bind(window,"mousemove",g),T.bind(window,"touchmove",g),T.bind(window,"mouseup",u),T.bind(window,"touchend",u)}function c(e){_(e),T.bind(window,"mousemove",_),T.bind(window,"touchmove",_),T.bind(window,"mouseup",d),T.bind(window,"touchend",d)}function u(){T.unbind(window,"mousemove",g),T.unbind(window,"touchmove",g),T.unbind(window,"mouseup",u),T.unbind(window,"touchend",u),m()}function d(){T.unbind(window,"mousemove",_),T.unbind(window,"touchmove",_),T.unbind(window,"mouseup",d),T.unbind(window,"touchend",d),m()}function p(){var e=h(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function m(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function g(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,s=n.clientY,a=(i-t.left)/(t.right-t.left),o=1-(s-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),a>1?a=1:a<0&&(a=0),r.__color.v=o,r.__color.s=a,r.setValue(r.__color.toOriginal()),!1}function _(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return a.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),a.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),a.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),a.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),a.extend(o.style,{width:"100%",height:"100%",background:"none"}),B(o,"top","rgba(0,0,0,0)","#000"),a.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(s=i.__hue_field).style.background="",s.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",s.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),T.bind(i.__saturation_field,"mousedown",l),T.bind(i.__saturation_field,"touchstart",l),T.bind(i.__field_knob,"mousedown",l),T.bind(i.__field_knob,"touchstart",l),T.bind(i.__hue_field,"mousedown",c),T.bind(i.__hue_field,"touchstart",c),i.__saturation_field.appendChild(o),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e=h(this.getValue());if(!1!==e){var t=!1;a.each(y.COMPONENTS,(function(n){if(!a.isUndefined(e[n])&&!a.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&a.extend(this.__color.__state,e)}a.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;a.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,B(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),a.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(w),k=["-moz-","-o-","-webkit-","-ms-",""];function B(e,t,n,i){e.style.background="",a.each(k,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var F='
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
',z=function(e,t){var n=e[t];return a.isArray(arguments[2])||a.isObject(arguments[2])?new C(e,t,arguments[2]):a.isNumber(n)?a.isNumber(arguments[2])&&a.isNumber(arguments[3])?a.isNumber(arguments[4])?new O(e,t,arguments[2],arguments[3],arguments[4]):new O(e,t,arguments[2],arguments[3]):a.isNumber(arguments[4])?new I(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new I(e,t,{min:arguments[2],max:arguments[3]}):a.isString(n)?new R(e,t):a.isFunction(n)?new N(e,t,""):a.isBoolean(n)?new A(e,t):null},G=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},H=function(){function e(){f(this,e),this.backgroundElement=document.createElement("div"),a.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),T.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),a.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;T.bind(this.backgroundElement,"click",(function(){t.hide()}))}return m(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),a.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",T.unbind(e.domElement,"webkitTransitionEnd",t),T.unbind(e.domElement,"transitionend",t),T.unbind(e.domElement,"oTransitionEnd",t)};T.bind(this.domElement,"webkitTransitionEnd",t),T.bind(this.domElement,"transitionend",t),T.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-T.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-T.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var V="Default",W=function(){try{return!!window.localStorage}catch(e){return!1}}(),j=void 0,X=!0,q=void 0,Y=!1,K=[],J=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),T.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=a.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=a.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),a.isUndefined(i.load)?i.load={preset:V}:i.preset&&(i.load.preset=i.preset),a.isUndefined(i.parent)&&i.hideable&&K.push(this),i.resizable=a.isUndefined(i.parent)&&i.resizable,i.autoPlace&&a.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,s=W&&"true"===localStorage.getItem(ne(0,"isLocal")),o=void 0,l=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),te(e,n.object,n.property,{before:i,factoryArgs:[a.toArray(arguments)]})}if(a.isArray(t)||a.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),te(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof O){var i=new I(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});a.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),T.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof I){var r=function(t){if(a.isNumber(n.__min)&&a.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var s=te(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return s.name(i),r&&s.listen(),s}return t};n.min=a.compose(r,n.min),n.max=a.compose(r,n.max)}else n instanceof A?(T.bind(t,"click",(function(){T.fakeEvent(n.__checkbox,"click")})),T.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof N?(T.bind(t,"click",(function(){T.fakeEvent(n.__button,"click")})),T.bind(t,"mouseover",(function(){T.addClass(n.__button,"hover")})),T.bind(t,"mouseout",(function(){T.removeClass(n.__button,"hover")}))):n instanceof D&&(T.addClass(t,"color"),n.updateDisplay=a.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=a.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&$(e.getRoot(),!0),t}),n.setValue)}(e,c,r),e.__controllers.push(r),r}function ne(e,t){return document.location.href+"."+t}function ie(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function re(e,t){t.style.display=e.useLocalStorage?"block":"none"}function se(e){var t=e.__save_row=document.createElement("li");T.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),T.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",T.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",T.addClass(i,"button"),T.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",T.addClass(r,"button"),T.addClass(r,"save-as");var s=document.createElement("span");s.innerHTML="Revert",T.addClass(s,"button"),T.addClass(s,"revert");var o=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?a.each(e.load.remembered,(function(t,n){ie(e,n,n===e.preset)})):ie(e,V,!1),T.bind(o,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=le(this)),e.folders={},a.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=le(this),$(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=le(this,!0)),this.load.remembered[e]=le(this),this.preset=e,ie(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){a.each(this.__controllers,(function(t){this.getRoot().load.remembered?ee(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),a.each(this.__folders,(function(e){e.revert(e)})),e||$(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&ce(this.__listening)},updateDisplay:function(){a.each(this.__controllers,(function(e){e.updateDisplay()})),a.each(this.__folders,(function(e){e.updateDisplay()}))}});const he={color:{Color:y,math:d,interpret:h},controllers:{Controller:w,BooleanController:A,OptionController:C,StringController:R,NumberController:P,NumberControllerBox:I,NumberControllerSlider:O,FunctionController:N,ColorController:D},dom:{dom:T},gui:{GUI:J},GUI:J}},973:(e,t,n)=>{"use strict";n.d(t,{eW:()=>S,oe:()=>x});var i=n(477);class r{static addMaterial(e,t,n,i,r){let s;t.name=n,i?(e[n]=t,r&&console.info('Material with name "'+n+'" was forcefully overridden.')):(s=e[n],s?s.uuid!=s.uuid&&r&&console.log('Same material name "'+s.name+'" different uuid ['+s.uuid+"|"+t.uuid+"]"):(e[n]=t,r&&console.info('Material with name "'+n+'" was added.')))}static getMaterialsJSON(e){const t={};let n;for(const i in e)n=e[i],"function"==typeof n.toJSON&&(t[i]=n.toJSON());return t}static cloneMaterial(e,t,n){let i;if(t){let s=t.materialNameOrg;s=null!=s?s:"";const a=e[s];a?(i=a.clone(),Object.assign(i,t.materialProperties),r.addMaterial(e,i,t.materialProperties.name,!0)):n&&console.info('Requested material "'+s+'" is not available!')}return i}}class s{static buildThreeConst(){return"const EventDispatcher = THREE.EventDispatcher;\nconst BufferGeometry = THREE.BufferGeometry;\nconst BufferAttribute = THREE.BufferAttribute;\nconst Box3 = THREE.Box3;\nconst Sphere = THREE.Sphere;\nconst Texture = THREE.Texture;\nconst MaterialLoader = THREE.MaterialLoader;\n"}static buildUglifiedThreeMapping(){return s.buildUglifiedNameAssignment((function(){return i.BufferGeometry}),"BufferGeometry",/_BufferGeometry/,!1)+s.buildUglifiedNameAssignment((function(){return i.BufferAttribute}),"BufferAttribute",/_BufferAttribute/,!1)+s.buildUglifiedNameAssignment((function(){return i.Box3}),"Box3",/_Box3/,!1)+s.buildUglifiedNameAssignment((function(){return i.Sphere}),"Sphere",/_Sphere/,!1)+s.buildUglifiedNameAssignment((function(){return i.Texture}),"Texture",/_Texture/,!1)+s.buildUglifiedNameAssignment((function(){return i.MaterialLoader}),"MaterialLoader",/_MaterialLoader/,!1)}static buildUglifiedThreeWtmMapping(){return s.buildUglifiedNameAssignment((function(){return a}),"DataTransport",/_DataTransport/,!0)+s.buildUglifiedNameAssignment((function(){return l}),"GeometryTransport",/_GeometryTransport/,!0)+s.buildUglifiedNameAssignment((function(){return c}),"MeshTransport",/_MeshTransport/,!0)+s.buildUglifiedNameAssignment((function(){return o}),"MaterialsTransport",/_MaterialsTransport/,!0)+s.buildUglifiedNameAssignment((function(){return r}),"MaterialUtils",/_MaterialUtils/,!0)}static buildUglifiedNameAssignment(e,t,n,i){let r=e.toString();r=r.replace(n,"").replace(/[\r\n]+/gm,""),r=r.replace(/.*return/,"").replace(/\}/,"").replace(/;/gm,"");const s=r.trim();let a="";return s!==t&&(a="const "+(i?t:s)+" = "+(i?s:t)+";\n"),a}}class a{constructor(e,t){this.main={cmd:void 0!==e?e:"unknown",id:void 0!==t?t:0,type:"DataTransport",progress:0,buffers:{},params:{}},this.transferables=[]}loadData(e){return this.main.cmd=e.cmd,this.main.id=e.id,this.main.type="DataTransport",this.setProgress(e.progress),this.setParams(e.params),e.buffers&&Object.entries(e.buffers).forEach((([e,t])=>{this.main.buffers[e]=t})),this}getCmd(){return this.main.cmd}getId(){return this.main.id}setParams(e){return null!=e&&(this.main.params=e),this}getParams(){return this.main.params}setProgress(e){return this.main.progress=e,this}addBuffer(e,t){return this.main.buffers[e]=t,this}getBuffer(e){return this.main.buffers[e]}package(e){for(let t of Object.values(this.main.buffers))if(null!=t){const n=e?t.slice(0):t;this.transferables.push(n)}return this}getMain(){return this.main}getTransferables(){return this.transferables}postMessage(e){return e.postMessage(this.main,this.transferables),this}}class o extends a{constructor(e,t){super(e,t),this.main.type="MaterialsTransport",this.main.materials={},this.main.multiMaterialNames={},this.main.cloneInstructions=[]}loadData(e){super.loadData(e),this.main.type="MaterialsTransport",Object.assign(this.main,e);const t=new i.MaterialLoader;return Object.entries(this.main.materials).forEach((([e,n])=>{this.main.materials[e]=t.parse(n)})),this}_cleanMaterial(e){return Object.entries(e).forEach((([t,n])=>{(n instanceof i.Texture||null===n)&&(e[t]=void 0)})),e}addBuffer(e,t){return super.addBuffer(e,t),this}setParams(e){return super.setParams(e),this}setMaterials(e){return null!=e&&Object.keys(e).length>0&&(this.main.materials=e),this}getMaterials(){return this.main.materials}cleanMaterials(){let e,t={};for(let n of Object.values(this.main.materials))"function"==typeof n.clone&&(e=n.clone(),t[e.name]=this._cleanMaterial(e));return this.setMaterials(t),this}package(e){return super.package(e),this.main.materials=r.getMaterialsJSON(this.main.materials),this}hasMultiMaterial(){return Object.keys(this.main.multiMaterialNames).length>0}getSingleMaterial(){return Object.keys(this.main.materials).length>0?Object.entries(this.main.materials)[0][1]:null}processMaterialTransport(e,t){for(let n=0;n{n[t]=e[i]}));else{const t=this.getSingleMaterial();null!==t&&(n=e[t.name],n||(n=t))}return n}}class l extends a{constructor(e,t){super(e,t),this.main.type="GeometryTransport",this.main.geometryType=0,this.main.geometry={},this.main.bufferGeometry=null}loadData(e){return super.loadData(e),this.main.type="GeometryTransport",this.setGeometry(e.geometry,e.geometryType)}getGeometryType(){return this.main.geometryType}setParams(e){return super.setParams(e),this}setGeometry(e,t){return this.main.geometry=e,this.main.geometryType=t,e instanceof i.BufferGeometry&&(this.main.bufferGeometry=e),this}package(e){super.package(e);const t=this.main.geometry.getAttribute("position"),n=this.main.geometry.getAttribute("normal"),i=this.main.geometry.getAttribute("uv"),r=this.main.geometry.getAttribute("color"),s=this.main.geometry.getAttribute("skinIndex"),a=this.main.geometry.getAttribute("skinWeight"),o=this.main.geometry.getIndex();return this._addBufferAttributeToTransferable(t,e),this._addBufferAttributeToTransferable(n,e),this._addBufferAttributeToTransferable(i,e),this._addBufferAttributeToTransferable(r,e),this._addBufferAttributeToTransferable(s,e),this._addBufferAttributeToTransferable(a,e),this._addBufferAttributeToTransferable(o,e),this}reconstruct(e){if(this.main.bufferGeometry instanceof i.BufferGeometry)return this;this.main.bufferGeometry=new i.BufferGeometry;const t=this.main.geometry;this._assignAttribute(t.attributes.position,"position",e),this._assignAttribute(t.attributes.normal,"normal",e),this._assignAttribute(t.attributes.uv,"uv",e),this._assignAttribute(t.attributes.color,"color",e),this._assignAttribute(t.attributes.skinIndex,"skinIndex",e),this._assignAttribute(t.attributes.skinWeight,"skinWeight",e);const n=t.index;if(null!=n){const t=e?n.array.slice(0):n.array;this.main.bufferGeometry.setIndex(new i.BufferAttribute(t,n.itemSize,n.normalized))}const r=t.boundingBox;null!==r&&(this.main.bufferGeometry.boundingBox=Object.assign(new i.Box3,r));const s=t.boundingSphere;return null!==s&&(this.main.bufferGeometry.boundingSphere=Object.assign(new i.Sphere,s)),this.main.bufferGeometry.uuid=t.uuid,this.main.bufferGeometry.name=t.name,this.main.bufferGeometry.type=t.type,this.main.bufferGeometry.groups=t.groups,this.main.bufferGeometry.drawRange=t.drawRange,this.main.bufferGeometry.userData=t.userData,this}getBufferGeometry(){return this.main.bufferGeometry}_addBufferAttributeToTransferable(e,t){if(null!=e){const n=t?e.array.slice(0):e.array;this.transferables.push(n.buffer)}return this}_assignAttribute(e,t,n){if(e){const r=n?e.array.slice(0):e.array;this.main.bufferGeometry.setAttribute(t,new i.BufferAttribute(r,e.itemSize,e.normalized))}return this}}class c extends l{constructor(e,t){super(e,t),this.main.type="MeshTransport",this.main.materialsTransport=new o}loadData(e){return super.loadData(e),this.main.type="MeshTransport",this.main.meshName=e.meshName,this.main.materialsTransport=(new o).loadData(e.materialsTransport.main),this}setParams(e){return super.setParams(e),this}setMaterialsTransport(e){return e instanceof o&&(this.main.materialsTransport=e),this}getMaterialsTransport(){return this.main.materialsTransport}setMesh(e,t){return this.main.meshName=e.name,super.setGeometry(e.geometry,t),this}package(e){return super.package(e),null!==this.main.materialsTransport&&this.main.materialsTransport.package(e),this}reconstruct(e){return super.reconstruct(e),this}}class h{static serializePrototype(e,t,n,i){let r,s=[],a="";i?(a=e.toString()+"\n\n",r=t):r=e;for(let e in r){let t=r[e],n=t.toString();"function"==typeof t&&s.push("\t"+e+": "+n+",\n\n")}a+=n+(i?".prototype":"")+" = {\n\n";for(let e=0;e0){let n;for(const i in e)n=e[i],r.addMaterial(this.materials,n,i,!0===t)}}getMaterials(){return this.materials}getMaterial(e){return this.materials[e]}clearMaterials(){this.materials={}}}class p{static comRouting(e,t,n,i,r){let s=t.data;"init"===s.cmd?null!=n?n[i](e,s.workerId,s.config):i(e,s.workerId,s.config):"execute"===s.cmd&&(null!=n?n[r](e,s.workerId,s.config):r(e,s.workerId,s.config))}}class f{constructor(e){this.taskTypes=new Map,this.verbose=!1,this.maxParallelExecutions=e||4,this.actualExecutionCount=0,this.storedExecutions=[],this.teardown=!1}setVerbose(e){return this.verbose=e,this}setMaxParallelExecutions(e){return this.maxParallelExecutions=e,this}getMaxParallelExecutions(){return this.maxParallelExecutions}supportsTaskType(e){return this.taskTypes.has(e)}registerTaskType(e,t,n,i,r,s){let a=!this.supportsTaskType(e);if(a){let a=new m(e,this.maxParallelExecutions,r,this.verbose);a.setFunctions(t,n,i),a.setDependencyDescriptions(s),this.taskTypes.set(e,a)}return a}registerTaskTypeModule(e,t){let n=!this.supportsTaskType(e);if(n){let n=new m(e,this.maxParallelExecutions,!1,this.verbose);n.setWorkerModule(t),this.taskTypes.set(e,n)}return n}async initTaskType(e,t,n){let i=this.taskTypes.get(e);if(i)if(i.status.initStarted)for(;!i.status.initComplete;)await this._wait(10);else i.status.initStarted=!0,i.isWorkerModule()?await i.createWorkerModules().then((()=>i.initWorkers(t,n))).then((()=>i.status.initComplete=!0)).catch((e=>console.error(e))):await i.loadDependencies().then((()=>i.createWorkers())).then((()=>i.initWorkers(t,n))).then((()=>i.status.initComplete=!0)).catch((e=>console.error(e)))}async _wait(e){return new Promise((t=>{setTimeout(t,e)}))}async enqueueForExecution(e,t,n,i){return new Promise(((r,s)=>{this.storedExecutions.push(new g(e,t,n,r,s,i)),this._depleteExecutions()}))}_depleteExecutions(){let e=0;for(;this.actualExecutionCount{i.onmessage=n=>{"assetAvailable"===n.data.cmd?t.assetAvailableFunction instanceof Function&&t.assetAvailableFunction(n.data):e(n)},i.onerror=n,i.postMessage({cmd:"execute",workerId:i.getId(),config:t.config},t.transferables)})).then((e=>{n.returnAvailableTask(i),t.resolve(e.data),this.actualExecutionCount--,this._depleteExecutions()})).catch((e=>{t.reject("Execution error: "+e)}))):e++}}dispose(){this.teardown=!0;for(let e of this.taskTypes.values())e.dispose();return this}}class m{constructor(e,t,n,i){this.taskType=e,this.fallback=n,this.verbose=!0===i,this.initialised=!1,this.functions={init:null,execute:null,comRouting:null,dependencies:{descriptions:[],code:[]},workerModuleUrl:null},this.workers={code:[],instances:new Array(t),available:[]},this.status={initStarted:!1,initComplete:!1}}getTaskType(){return this.taskType}setFunctions(e,t,n){this.functions.init=e,this.functions.execute=t,this.functions.comRouting=n,void 0!==this.functions.comRouting&&null!==this.functions.comRouting||(this.functions.comRouting=p.comRouting),this._addWorkerCode("init",this.functions.init.toString()),this._addWorkerCode("execute",this.functions.execute.toString()),this._addWorkerCode("comRouting",this.functions.comRouting.toString()),this.workers.code.push('self.addEventListener( "message", message => comRouting( self, message, null, init, execute ), false );')}_addWorkerCode(e,t){t.startsWith("function")?this.workers.code.push("const "+e+" = "+t+";\n\n"):this.workers.code.push("function "+t+";\n\n")}setDependencyDescriptions(e){e&&e.forEach((e=>{this.functions.dependencies.descriptions.push(e)}))}setWorkerModule(e){this.functions.workerModuleUrl=new URL(e,window.location.href)}isWorkerModule(){return null!==this.functions.workerModuleUrl}async loadDependencies(){let e=[],t=new i.FileLoader;t.setResponseType("arraybuffer");for(let n of this.functions.dependencies.descriptions){if(n.url){let i=new URL(n.url,window.location.href);e.push(t.loadAsync(i.href,(e=>{this.verbose&&console.log(e)})))}n.code&&e.push(new Promise((e=>e(n.code))))}this.verbose&&console.log("Task: "+this.getTaskType()+": Waiting for completion of loading of all dependencies."),this.functions.dependencies.code=await Promise.all(e)}async createWorkers(){let e;if(this.fallback)for(let t=0;t{let s;if(i.onmessage=e=>{this.verbose&&console.log("Init Complete: "+e.data.id),n(e)},i.onerror=r,t){s=[];for(let e=0;e0}returnAvailableTask(e){this.workers.available.push(e)}dispose(){for(let e of this.workers.instances)e.terminate()}}class g{constructor(e,t,n,i,r,s){this.taskType=e,this.config=t,this.assetAvailableFunction=n,this.resolve=i,this.reject=r,this.transferables=s}}class _ extends Worker{constructor(e,t,n){super(t,n),this.id=e}getId(){return this.id}}class v{constructor(e,t,n){this.id=e,this.functions={init:t,execute:n}}getId(){return this.id}postMessage(e,t){let n=this,i={postMessage:function(e){n.onmessage({data:e})}};p.comRouting(i,{data:e},null,n.functions.init,n.functions.execute)}terminate(){}}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class x extends i.Loader{constructor(e){super(e),this.parser=new b,this.materialStore=new d(!0),this.parser.materials=this.materialStore.getMaterials()}setLogging(e,t){return this.parser.logging.enabled=!0===e,this.parser.logging.debug=!0===t,this}setMaterialPerSmoothingGroup(e){return this.parser.aterialPerSmoothingGroup=!0===e,this}setUseOAsMesh(e){return this.parser.useOAsMesh=!0===e,this}setUseIndices(e){return this.parser.useIndices=!0===e,this}setDisregardNormals(e){return this.parser.disregardNormals=!0===e,this}setModelName(e){return e&&(this.parser.modelName=e),this}getModelName(){return this.parser.modelName}setBaseObject3d(e){return this.parser.baseObject3d=null==e?this.parser.baseObject3d:e,this}setMaterials(e){return this.materialStore.addMaterials(e,!1),this.parser.materials=this.materialStore.getMaterials(),this}setCallbackOnProgress(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onProgress=e),this}setCallbackOnError(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onError=e),this}setCallbackOnLoad(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onLoad=e),this}setCallbackOnMeshAlter(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onMeshAlter=e),this}load(e,t,n,r,s){if(!(null!=t&&t instanceof Function)){const e="onLoad is not a function! Aborting...";throw this.parser._onError(e),e}this.setCallbackOnLoad(t);const a=this;null!=r&&r instanceof Function||(r=function(e){let t=e;e.currentTarget&&null!==e.currentTarget.statusText&&(t="Error occurred while downloading!\nurl: "+e.currentTarget.responseURL+"\nstatus: "+e.currentTarget.statusText),a.parser._onError(t)}),e||r("An invalid url was provided. Unable to continue!");const o=new URL(e,window.location.href).href;let l=o;const c=o.split("/");if(c.length>2){l=c[c.length-1];let e=c.slice(0,c.length-1).join("/")+"/";void 0!==e&&(this.path=e)}if(null==n||!(n instanceof Function)){let t=0,i=0;n=function(n){if(n.lengthComputable&&(i=n.loaded/n.total,i>t)){t=i;const n='Download of "'+e+'": '+(100*i).toFixed(2)+"%";a.parser._onProgress("progressLoad",n,i)}}}this.setCallbackOnMeshAlter(s);const h=new i.FileLoader(this.manager);h.setPath(this.path||this.resourcePath),h.setResponseType("arraybuffer"),h.load(l,(function(e){a.parse(e)}),n,r)}parse(e){if(this.parser.logging.enabled&&console.info("Using OBJLoader2 version: "+x.OBJLOADER2_VERSION),null==e)throw"Provided content is not a valid ArrayBuffer or String. Unable to continue parsing";return this.parser.logging.enabled&&console.time("OBJLoader parse: "+this.modelName),e instanceof ArrayBuffer||e instanceof Uint8Array?(this.parser.logging.enabled&&console.info("Parsing arrayBuffer..."),this.parser._execute(e)):"string"==typeof e||e instanceof String?(this.parser.logging.enabled&&console.info("Parsing text..."),this.parser._executeLegacy(e)):this.parser._onError("Provided content was neither of type String nor Uint8Array! Aborting..."),this.parser.logging.enabled&&console.timeEnd("OBJLoader parse: "+this.modelName),this.parser.baseObject3d}}y(x,"OBJLOADER2_VERSION","4.0.0-dev");class b{constructor(){this.logging={enabled:!1,debug:!1},this.usedBefore=!1,this._init(),this.callbacks={onLoad:null,onError:null,onProgress:null,onMeshAlter:null}}_init(){this.contentRef=null,this.legacyMode=!1,this.materials={},this.baseObject3d=new i.Object3D,this.modelName="noname",this.materialPerSmoothingGroup=!1,this.useOAsMesh=!1,this.useIndices=!1,this.disregardNormals=!1,this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.objectId=0,this.rawMesh={objectName:"",groupName:"",activeMtlName:"",mtllibName:"",faceType:-1,subGroups:[],subGroupInUse:null,smoothingGroup:{splitMaterials:!1,normalized:-1,real:-1},counts:{doubleIndicesCount:0,faceCount:0,mtlCount:0,smoothingGroupCount:0}},this.inputObjectCount=1,this.outputObjectCount=1,this.globalCounts={vertices:0,faces:0,doubleIndicesCount:0,lineByte:0,currentByte:0,totalBytes:0}}_resetRawMesh(){this.rawMesh.subGroups=[],this.rawMesh.subGroupInUse=null,this.rawMesh.smoothingGroup.normalized=-1,this.rawMesh.smoothingGroup.real=-1,this._pushSmoothingGroup(1),this.rawMesh.counts.doubleIndicesCount=0,this.rawMesh.counts.faceCount=0,this.rawMesh.counts.mtlCount=0,this.rawMesh.counts.smoothingGroupCount=0}_configure(){if(this.usedBefore=!0,this._pushSmoothingGroup(1),this.logging.enabled){const e=Object.keys(this.materials);let t="OBJLoader2 Parser configuration:"+(e.length>0?"\n\tmaterialNames:\n\t\t- "+e.join("\n\t\t- "):"\n\tmaterialNames: None")+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseOAsMesh: "+this.useOAsMesh+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals;null!==this.callbacks.onProgress&&(t+="\n\tcallbacks.onProgress: "+this.callbacks.onProgress.name),null!==this.callbacks.onError&&(t+="\n\tcallbacks.onError: "+this.callbacks.onError.name),null!==this.callbacks.onMeshAlter&&(t+="\n\tcallbacks.onMeshAlter: "+this.callbacks.onMeshAlter.name),null!==this.callbacks.onLoad&&(t+="\n\tcallbacks.onLoad: "+this.callbacks.onLoad.name),console.info(t)}}_execute(e){this.logging.enabled&&console.time("OBJLoader2Parser.execute"),this._configure();const t=new Uint8Array(e);this.contentRef=t;const n=t.byteLength;this.globalCounts.totalBytes=n;const i=new Array(128);let r,s=0,a=0,o="",l=0;for(;l0&&(i[s++]=o),o="";break;case 47:o.length>0&&(i[s++]=o),a++,o="";break;case 10:this._processLine(i,s,a,o,l),o="",s=0,a=0;break;case 13:break;default:o+=String.fromCharCode(r)}this._processLine(i,s,a,o,l),this._finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2Parser.execute")}_executeLegacy(e){this.logging.enabled&&console.time("OBJLoader2Parser.executeLegacy"),this._configure(),this.legacyMode=!0,this.contentRef=e;const t=e.length;this.globalCounts.totalBytes=t;const n=new Array(128);let i,r=0,s=0,a="",o=0;for(;o0&&(n[r++]=a),a="";break;case"/":a.length>0&&(n[r++]=a),s++,a="";break;case"\n":this._processLine(n,r,s,a,o),a="",r=0,s=0;break;case"\r":break;default:a+=i}this._processLine(n,r,a,s),this._finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2Parser.executeLegacy")}_processLine(e,t,n,i,r){if(this.globalCounts.lineByte=this.globalCounts.currentByte,this.globalCounts.currentByte=r,t<1)return;i.length>0&&(e[t++]=i);const s=function(e,t,n,i){let r="";if(i>n){let s;if(t)for(s=n;s4&&(this.colors.push(parseFloat(e[4])),this.colors.push(parseFloat(e[5])),this.colors.push(parseFloat(e[6])));break;case"vt":this.uvs.push(parseFloat(e[1])),this.uvs.push(parseFloat(e[2]));break;case"vn":this.normals.push(parseFloat(e[1])),this.normals.push(parseFloat(e[2])),this.normals.push(parseFloat(e[3]));break;case"f":if(a=t-1,0===n)for(this._checkFaceType(0),l=2,o=a;l0?s-1:s+r.vertices.length/3),o=r.colors.length>0?a:null;const l=i.vertices;if(l.push(r.vertices[a++]),l.push(r.vertices[a++]),l.push(r.vertices[a]),null!==o){const e=i.colors;e.push(r.colors[o++]),e.push(r.colors[o++]),e.push(r.colors[o])}if(t){const e=parseInt(t);let n=2*(e>0?e-1:e+r.uvs.length/2);const s=i.uvs;s.push(r.uvs[n++]),s.push(r.uvs[n])}if(n&&!r.disregardNormals){const e=parseInt(n);let t=3*(e>0?e-1:e+r.normals.length/3);const s=i.normals;s.push(r.normals[t++]),s.push(r.normals[t++]),s.push(r.normals[t])}};if(this.useIndices){this.disregardNormals&&(n=void 0);const r=e+(t?"_"+t:"_n")+(n?"_"+n:"_n");let a=i.indexMappings[r];null==a?(a=this.rawMesh.subGroupInUse.vertices.length/3,s(),i.indexMappings[r]=a,i.indexMappingsCount++):this.rawMesh.counts.doubleIndicesCount++,i.indices.push(a)}else s();this.rawMesh.counts.faceCount++}_createRawMeshReport(e){return"Input Object number: "+e+"\n\tObject name: "+this.rawMesh.objectName+"\n\tGroup name: "+this.rawMesh.groupName+"\n\tMtllib name: "+this.rawMesh.mtllibName+"\n\tVertex count: "+this.vertices.length/3+"\n\tNormal count: "+this.normals.length/3+"\n\tUV count: "+this.uvs.length/2+"\n\tSmoothingGroup count: "+this.rawMesh.counts.smoothingGroupCount+"\n\tMaterial count: "+this.rawMesh.counts.mtlCount+"\n\tReal MeshOutputGroup count: "+this.rawMesh.subGroups.length}_finalizeRawMesh(){const e=[];let t,n,i=0,r=0,s=0,a=0,o=0,l=0;for(const c in this.rawMesh.subGroups)if(t=this.rawMesh.subGroups[c],t.vertices.length>0){if(n=t.indices,n.length>0&&r>0)for(let e=0;e0&&(c={name:""!==this.rawMesh.groupName?this.rawMesh.groupName:this.rawMesh.objectName,subGroups:e,absoluteVertexCount:i,absoluteIndexCount:s,absoluteColorCount:a,absoluteNormalCount:o,absoluteUvCount:l,faceCount:this.rawMesh.counts.faceCount,doubleIndicesCount:this.rawMesh.counts.doubleIndicesCount}),c}_processCompletedMesh(){const e=this._finalizeRawMesh(),t=null!==e;if(t){this.colors.length>0&&this.colors.length!==this.vertices.length&&this._onError("Vertex Colors were detected, but vertex count and color count do not match!"),this.logging.enabled&&this.logging.debug&&console.debug(this._createRawMeshReport(this.inputObjectCount)),this.inputObjectCount++,this._buildMesh(e);const t=this.globalCounts.currentByte/this.globalCounts.totalBytes;this._onProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*t).toFixed(2)+"%"),this._resetRawMesh()}return t}_buildMesh(e){const t=e.subGroups;this.globalCounts.vertices+=e.absoluteVertexCount/3,this.globalCounts.faces+=e.faceCount,this.globalCounts.doubleIndicesCount+=e.doubleIndicesCount;const n=new i.BufferGeometry,s=new Float32Array(e.absoluteVertexCount),a=e.absoluteIndexCount>0?new Uint32Array(e.absoluteIndexCount):null,o=e.absoluteColorCount>0?new Float32Array(e.absoluteColorCount):null,l=e.absoluteNormalCount>0?new Float32Array(e.absoluteNormalCount):null,c=e.absoluteUvCount>0?new Float32Array(e.absoluteUvCount):null;let h;n.setAttribute("position",new i.BufferAttribute(s,3,!1)),null!=l&&n.setAttribute("normal",new i.BufferAttribute(l,3,!1)),null!=c&&n.setAttribute("uv",new i.BufferAttribute(c,2,!1)),null!=o&&n.setAttribute("color",new i.BufferAttribute(o,3,!1)),null!==a&&n.setIndex(new i.BufferAttribute(a,1,!1));let u=0,d=0,p=0,f=0,m=0,g=0,_=0;const v=t.length>1,y=[],x=null!==o;let b,w,M,S,E,T=0;const A={cloneInstructions:[],multiMaterialNames:{},modelName:this.modelName,progress:this.globalCounts.currentByte/this.globalCounts.totalBytes,geometryType:this.rawMesh.faceType<4?0:6===this.rawMesh.faceType?2:1,objectId:this.objectId};for(const e in t)if(t.hasOwnProperty(e)){if(h=t[e],E=h.materialName,b=0===h.smoothingGroup,this.rawMesh.faceType<4?(S=E,x&&(S+="_vertexColor"),b&&(S+="_flat")):S=6===this.rawMesh.faceType?"defaultPointMaterial":"defaultLineMaterial",w=this.materials[E],M=this.materials[S],null==w&&null==M&&(S=x?"defaultVertexColorMaterial":"defaultMaterial",M=this.materials[S],this.logging.enabled&&console.info('object_group "'+h.objectName+"_"+h.groupName+'" was defined with unresolvable material "'+E+'"! Assigning "'+S+'".')),null==M){const e={materialNameOrg:E,materialProperties:{name:S,vertexColors:x?2:0,flatShading:b}};M=r.cloneMaterial(this.materials,e,this.logging.enabled&&this.logging.debug),A.cloneInstructions.push(e)}if(v&&(_=this.useIndices?h.indices.length:h.vertices.length/3,n.addGroup(g,_,T),M=this.materials[S],y[T]=M,A.multiMaterialNames[T]=M.name,g+=_,T++),s.set(h.vertices,u),u+=h.vertices.length,null!==a&&(a.set(h.indices,d),d+=h.indices.length),null!==o&&(o.set(h.colors,p),p+=h.colors.length),null!==l&&(l.set(h.normals,f),f+=h.normals.length),null!==c&&(c.set(h.uvs,m),m+=h.uvs.length),this.logging.enabled&&this.logging.debug){let e="";T>0&&(e="\n\t\tmaterialIndex: "+T);const t="\tOutput Object no.: "+this.outputObjectCount+"\n\t\tgroupName: "+h.groupName+"\n\t\tIndex: "+h.index+"\n\t\tfaceType: "+this.rawMesh.faceType+"\n\t\tmaterialName: "+h.materialName+"\n\t\tsmoothingGroup: "+h.smoothingGroup+e+"\n\t\tobjectName: "+h.objectName+"\n\t\t#vertices: "+h.vertices.length/3+"\n\t\t#indices: "+h.indices.length+"\n\t\t#colors: "+h.colors.length/3+"\n\t\t#uvs: "+h.uvs.length/2+"\n\t\t#normals: "+h.normals.length/3;console.debug(t)}}let C;this.outputObjectCount++,null==n.getAttribute("normal")&&n.computeVertexNormals();const R=v?y:M;C=0===A.geometryType?new i.Mesh(n,R):1===A.geometryType?new i.LineSegments(n,R):new i.Points(n,R),C.name=e.name,this._onAssetAvailable(C,A)}_finalizeParsing(){if(this.logging.enabled&&console.info("Global output object count: "+this.outputObjectCount),this._processCompletedMesh()&&this.logging.enabled){const e="Overall counts: \n\tVertices: "+this.globalCounts.vertices+"\n\tFaces: "+this.globalCounts.faces+"\n\tMultiple definitions: "+this.globalCounts.doubleIndicesCount;console.info(e)}this._onLoad()}_onProgress(e){if(null!==this.callbacks.onProgress)this.callbacks.onProgress(e);else{const t=e||"";this.logging.enabled&&this.logging.debug&&console.log(t)}}_onError(e){null!==this.callbacks.onError?this.callbacks.onError(e):this.logging.enabled&&this.logging.debug&&console.error(e)}_onAssetAvailable(e,t){this._onMeshAlter(e,t),this.baseObject3d.add(e)}_onMeshAlter(e){null!==this.callbacks.onMeshAlter&&this.callbacks.onMeshAlter(e,this.baseObject3d)}_onLoad(){null!==this.callbacks.onLoad&&this.callbacks.onLoad(this.baseObject3d,this.objectId)}static buildUglifiedMapping(){return s.buildUglifiedNameAssignment((function(){return b}),"OBJLoader2Parser",/_OBJLoader2Parser/,!0)}}class w{static buildStandardWorkerDependencies(e){return[{url:e},{code:s.buildThreeConst()},{code:w.buildThreeExtraConst()},{code:"\n\n"},{code:s.buildUglifiedThreeMapping()},{code:w.buildUglifiedThreeExtraMapping()},{code:"\n\n"},{code:h.serializeClass(a)},{code:h.serializeClass(l)},{code:h.serializeClass(c)},{code:h.serializeClass(o)},{code:h.serializeClass(r)},{code:h.serializeClass(b)},{code:h.serializeClass(u)},{code:s.buildUglifiedThreeWtmMapping()},{code:"\n\n"},{code:b.buildUglifiedMapping()},{code:"\n\n"}]}static buildThreeExtraConst(){return"const MathUtils = THREE.MathUtils;\nconst Material = THREE.Material;\nconst Object3D = THREE.Object3D;\nconst Mesh = THREE.Mesh;\n"}static buildUglifiedThreeExtraMapping(){return s.buildUglifiedNameAssignment((function(){return i.MathUtils}),"MathUtils",/_MathUtils/,!1)+s.buildUglifiedNameAssignment((function(){return i.Material}),"Material",/_Material/,!1)+s.buildUglifiedNameAssignment((function(){return i.Object3D}),"Object3D",/_Object3D/,!1)+s.buildUglifiedNameAssignment((function(){return i.Mesh}),"Mesh",/_Mesh/,!1)}static init(e,t,n){const i=(new o).loadData(n);e.obj2={parser:new b,buffer:null,materials:i.getMaterials()},e.obj2.parser._onMeshAlter=(t,n)=>{const i=new o;if(i.main.multiMaterialNames=n.multiMaterialNames,0===Object.keys(i.main.multiMaterialNames).length){const e=t.material;r.addMaterial(i.main.materials,e,e.name,!1,!1)}i.main.cloneInstructions=n.cloneInstructions,i.cleanMaterials(),new c("assetAvailable",n.objectId).setProgress(n.progress).setParams({modelName:n.modelName}).setMesh(t,n.geometryType).setMaterialsTransport(i).postMessage(e)},e.obj2.parser.callbacks.onLoad=()=>{new a("execComplete",e.obj2.parser.objectId).postMessage(e)},e.obj2.parser.callbacks.onProgress=t=>{e.obj2.parser.logging.debug&&console.debug("WorkerRunner: progress: "+t)},u.applyProperties(e.obj2.parser,i.getParams(),!1);const s=i.getBuffer("modelData");null!=s&&(e.obj2.buffer=s),new a("init",t).postMessage(e)}static execute(e,t,n){e.obj2.parser.usedBefore&&e.obj2.parser._init(),e.obj2.parser.materials=e.obj2.materials;const i=(new a).loadData(n);u.applyProperties(e.obj2.parser,i.getParams(),!1);const r=i.getBuffer("modelData");null!=r&&(e.obj2.buffer=r),e.obj2.buffer&&(e.obj2.parser.objectId=i.getId(),e.obj2.parser._execute(e.obj2.buffer))}}class M extends x{constructor(e){super(e),this.preferJsmWorker=!1,this.urls={jsmWorker:new URL(M.DEFAULT_JSM_WORKER_PATH,window.location.href),threejs:new URL(M.DEFAULT_JSM_THREEJS_PATH,window.location.href)},this.workerTaskManager=null,this.taskName="tmOBJLoader2"}setWorkerTaskManager(e,t){return this.workerTaskManager=e,t&&(this.taskName=t),this}setJsmWorker(e,t){if(this.preferJsmWorker=!0===e,!(null!=t&&t instanceof URL))throw"The url to the jsm worker is not valid. Aborting...";return this.urls.jsmWorker=t,this}setThreejsLocation(e){if(!(null!=e&&e instanceof URL))throw"The url to the jsm worker is not valid. Aborting...";return this.urls.threejs=e,this}setTerminateWorkerOnLoad(e){return this.terminateWorkerOnLoad=!0===e,this}async _buildWorkerCode(e){null!==this.workerTaskManager&&this.workerTaskManager instanceof f||(this.parser.logging.debug&&console.log("Needed to create new WorkerTaskManager"),this.workerTaskManager=new f(1),this.workerTaskManager.setVerbose(this.parser.logging.enabled&&this.parser.logging.debug)),this.workerTaskManager.supportsTaskType(this.taskName)||(this.preferJsmWorker?this.workerTaskManager.registerTaskTypeModule(this.taskName,this.urls.jsmWorker):this.workerTaskManager.registerTaskType(this.taskName,w.init,w.execute,null,!1,w.buildStandardWorkerDependencies(this.urls.threejs)),await this.workerTaskManager.initTaskType(this.taskName,e.getMain()))}load(e,t,n,i,r){const s=this;x.prototype.load.call(this,e,(function(e,n){"OBJLoader2ParallelDummy"===e.name?s.parser.logging.enabled&&s.parser.logging.debug&&console.debug("Received dummy answer from OBJLoader2Parallel#parse"):t(e,n)}),n,i,r)}parse(e){this.parser.logging.enabled&&console.info("Using OBJLoader2Parallel version: "+M.OBJLOADER2_PARALLEL_VERSION);const t=(new a).setParams({logging:{enabled:this.parser.logging.enabled,debug:this.parser.logging.debug}});this._buildWorkerCode(t).then((()=>{this.parser.logging.debug&&console.log("OBJLoader2Parallel init was performed"),this._executeWorkerParse(e)})).catch((e=>console.error(e)));let n=new i.Object3D;return n.name="OBJLoader2ParallelDummy",n}_executeWorkerParse(e){const t=new a("execute",Math.floor(Math.random()*Math.floor(65536)));t.setParams({modelName:this.parser.modelName,useIndices:this.parser.useIndices,disregardNormals:this.parser.disregardNormals,materialPerSmoothingGroup:this.parser.materialPerSmoothingGroup,useOAsMesh:this.parser.useOAsMesh,materials:r.getMaterialsJSON(this.materialStore.getMaterials())}).addBuffer("modelData",e).package(!1),this.workerTaskManager.enqueueForExecution(this.taskName,t.getMain(),(e=>this._onLoad(e)),t.getTransferables()).then((e=>{this._onLoad(e),this.terminateWorkerOnLoad&&this.workerTaskManager.dispose()})).catch((e=>console.error(e)))}_onLoad(e){let t=e.cmd;if("assetAvailable"===t){let t;if("MeshTransport"===e.type?t=(new c).loadData(e).reconstruct(!1):console.error("Received unknown asset.type: "+e.type),t){let e,n=t.getMaterialsTransport().processMaterialTransport(this.materialStore.getMaterials(),this.parser.logging.enabled);null===n&&(n=new i.MeshStandardMaterial({color:16711680})),e=0===t.getGeometryType()?new i.Mesh(t.getBufferGeometry(),n):1===t.getGeometryType()?new i.LineSegments(t.getBufferGeometry(),n):new i.Points(t.getBufferGeometry(),n),this.parser._onMeshAlter(e),this.parser.baseObject3d.add(e)}}else if("execComplete"===t){let t;"DataTransport"===e.type?(t=(new a).loadData(e),t instanceof a&&null!==this.parser.callbacks.onLoad&&this.parser.callbacks.onLoad(this.parser.baseObject3d,t.getId())):console.error("Received unknown asset.type: "+e.type)}else console.error("Received unknown command: "+t)}}y(M,"OBJLOADER2_PARALLEL_VERSION",x.OBJLOADER2_VERSION),y(M,"DEFAULT_JSM_WORKER_PATH","/src/loaders/tmOBJLoader2.js"),y(M,"DEFAULT_JSM_THREEJS_PATH","/node_modules/three/build/three.min.js");class S{static link(e,t){"function"==typeof t.setMaterials&&t.setMaterials(S.addMaterialsFromMtlLoader(e),!0)}static addMaterialsFromMtlLoader(e){let t={};return void 0!==e.preload&&e.preload instanceof Function&&(e.preload(),t=e.materials),t}}},676:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DataViewIndexOutOfBoundsError:()=>G,DecodeError:()=>x,Decoder:()=>W,EXT_TIMESTAMP:()=>b,Encoder:()=>L,ExtData:()=>v,ExtensionCodec:()=>C,decode:()=>X,decodeArrayStream:()=>ee,decodeAsync:()=>$,decodeMulti:()=>q,decodeMultiStream:()=>te,decodeStream:()=>ne,decodeTimestampExtension:()=>T,decodeTimestampToTimeSpec:()=>E,encode:()=>I,encodeDateToTimeSpec:()=>M,encodeTimeSpecToTimestamp:()=>w,encodeTimestampExtension:()=>S});var i,r,s,a=4294967295;function o(e,t,n){var i=Math.floor(n/4294967296),r=n;e.setUint32(t,i),e.setUint32(t+4,r)}function l(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var c=("undefined"==typeof process||"never"!==(null===(i=null===process||void 0===process?void 0:process.env)||void 0===i?void 0:i.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function h(e){for(var t=e.length,n=0,i=0;i=55296&&r<=56319&&i65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h)}else s.push(o);s.length>=4096&&(a+=String.fromCharCode.apply(String,s),s.length=0)}return s.length>0&&(a+=String.fromCharCode.apply(String,s)),a}var m,g=c?new TextDecoder:null,_=c?"undefined"!=typeof process&&"force"!==(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.TEXT_DECODER)?200:0:a,v=function(e,t){this.type=e,this.data=t},y=(m=function(e,t){return(m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}m(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),x=function(e){function t(n){var i=e.call(this,n)||this,r=Object.create(t.prototype);return Object.setPrototypeOf(i,r),Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:t.name}),i}return y(t,e),t}(Error),b=-1;function w(e){var t,n=e.sec,i=e.nsec;if(n>=0&&i>=0&&n<=17179869183){if(0===i&&n<=4294967295){var r=new Uint8Array(4);return(t=new DataView(r.buffer)).setUint32(0,n),r}var s=n/4294967296,a=4294967295&n;return r=new Uint8Array(8),(t=new DataView(r.buffer)).setUint32(0,i<<2|3&s),t.setUint32(4,a),r}return r=new Uint8Array(12),(t=new DataView(r.buffer)).setUint32(0,i),o(t,4,n),r}function M(e){var t=e.getTime(),n=Math.floor(t/1e3),i=1e6*(t-1e3*n),r=Math.floor(i/1e9);return{sec:n+r,nsec:i-1e9*r}}function S(e){return e instanceof Date?w(M(e)):null}function E(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:l(t,4),nsec:t.getUint32(0)};default:throw new x("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}function T(e){var t=E(e);return new Date(1e3*t.sec+t.nsec/1e6)}var A={type:b,encode:S,decode:T},C=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(A)}return e.prototype.register=function(e){var t=e.type,n=e.encode,i=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=i;else{var r=1+t;this.builtInEncoders[r]=n,this.builtInDecoders[r]=i}},e.prototype.tryToEncode=function(e,t){for(var n=0;nthis.maxDepth)throw new Error("Too deep objects in depth ".concat(t));null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: ".concat(e," bytes in UTF-8"));this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){if(e.length>d){var t=h(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),p(e,this.bytes,this.pos),this.pos+=t}else t=h(e),this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,n){for(var i=e.length,r=n,s=0;s>6&31|192;else{if(a>=55296&&a<=56319&&s>12&15|224,t[r++]=a>>6&63|128):(t[r++]=a>>18&7|240,t[r++]=a>>12&63|128,t[r++]=a>>6&63|128)}t[r++]=63&a|128}else t[r++]=a}}(e,this.bytes,this.pos),this.pos+=t},e.prototype.encodeObject=function(e,t){var n=this.extensionCodec.tryToEncode(e,this.context);if(null!=n)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: ".concat(t));this.writeU8(198),this.writeU32(t)}var n=R(e);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else{if(!(n<4294967296))throw new Error("Too large array: ".concat(n));this.writeU8(221),this.writeU32(n)}for(var i=0,r=e;i0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var i=0,r=this.caches[n-1];i=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)},e.prototype.decode=function(e,t,n){var i=this.find(e,t,n);if(null!=i)return this.hit++,i;this.miss++;var r=f(e,t,n),s=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(s,r),r},e}(),N=function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]1||o(e,t)}))})}function o(e,t){try{(n=r[e](t)).value instanceof k?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(e){h(s[0][3],e)}var n}function l(e){o("next",e)}function c(e){o("throw",e)}function h(e,t){e(t),s.shift(),s.length&&o(s[0][0],s[0][1])}},F=new DataView(new ArrayBuffer(0)),z=new Uint8Array(F.buffer),G=function(){try{F.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),H=new G("Insufficient data"),V=new O,W=function(){function e(e,t,n,i,r,s,o,l){void 0===e&&(e=C.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=a),void 0===i&&(i=a),void 0===r&&(r=a),void 0===s&&(s=a),void 0===o&&(o=a),void 0===l&&(l=V),this.extensionCodec=e,this.context=t,this.maxStrLength=n,this.maxBinLength=i,this.maxArrayLength=r,this.maxMapLength=s,this.maxExtLength=o,this.keyDecoder=l,this.totalPos=0,this.pos=0,this.view=F,this.bytes=z,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1,this.stack.length=0},e.prototype.setBuffer=function(e){this.bytes=R(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=R(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining(1)){var t=this.bytes.subarray(this.pos),n=R(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return N(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,i,r,s,a,o,l;return s=this,a=void 0,l=function(){var s,a,o,l,c,h,u,d;return N(this,(function(p){switch(p.label){case 0:s=!1,p.label=1;case 1:p.trys.push([1,6,7,12]),t=D(e),p.label=2;case 2:return[4,t.next()];case 3:if((n=p.sent()).done)return[3,5];if(o=n.value,s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o);try{a=this.doDecodeSync(),s=!0}catch(e){if(!(e instanceof G))throw e}this.totalPos+=this.pos,p.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return l=p.sent(),i={error:l},[3,12];case 7:return p.trys.push([7,,10,11]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,9];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(i)throw i.error;return[7];case 11:return[7];case 12:if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,a]}throw h=(c=this).headByte,u=c.pos,d=c.totalPos,new RangeError("Insufficient data in parsing ".concat(U(h)," at ").concat(d," (").concat(u," in the current buffer)"))}}))},new((o=void 0)||(o=Promise))((function(e,t){function n(e){try{r(l.next(e))}catch(e){t(e)}}function i(e){try{r(l.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(n,i)}r((l=l.apply(s,a||[])).next())}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return B(this,arguments,(function(){var n,i,r,s,a,o,l,c,h;return N(this,(function(u){switch(u.label){case 0:n=t,i=-1,u.label=1;case 1:u.trys.push([1,13,14,19]),r=D(e),u.label=2;case 2:return[4,k(r.next())];case 3:if((s=u.sent()).done)return[3,12];if(a=s.value,t&&0===i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(i=this.readArraySize(),n=!1,this.complete()),u.label=4;case 4:u.trys.push([4,9,,10]),u.label=5;case 5:return[4,k(this.doDecodeSync())];case 6:return[4,u.sent()];case 7:return u.sent(),0==--i?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((o=u.sent())instanceof G))throw o;return[3,10];case 10:this.totalPos+=this.pos,u.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return l=u.sent(),c={error:l},[3,19];case 14:return u.trys.push([14,,17,18]),s&&!s.done&&(h=r.return)?[4,k(h.call(r))]:[3,16];case 15:u.sent(),u.label=16;case 16:return[3,18];case 17:if(c)throw c.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!=(i=e-128)){this.pushMapState(i),this.complete();continue e}t={}}else if(e<160){if(0!=(i=e-144)){this.pushArrayState(i),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e)n=this.lookU8(),t=this.decodeUtf8String(n,1);else if(218===e)n=this.lookU16(),t=this.decodeUtf8String(n,2);else if(219===e)n=this.lookU32(),t=this.decodeUtf8String(n,4);else if(220===e){if(0!==(i=this.readU16())){this.pushArrayState(i),this.complete();continue e}t=[]}else if(221===e){if(0!==(i=this.readU32())){this.pushArrayState(i),this.complete();continue e}t=[]}else if(222===e){if(0!==(i=this.readU16())){this.pushMapState(i),this.complete();continue e}t={}}else if(223===e){if(0!==(i=this.readU32())){this.pushMapState(i),this.complete();continue e}t={}}else if(196===e){var i=this.lookU8();t=this.decodeBinary(i,1)}else if(197===e)i=this.lookU16(),t=this.decodeBinary(i,2);else if(198===e)i=this.lookU32(),t=this.decodeBinary(i,4);else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e)i=this.lookU8(),t=this.decodeExtension(i,1);else if(200===e)i=this.lookU16(),t=this.decodeExtension(i,2);else{if(201!==e)throw new x("Unrecognized type byte: ".concat(U(e)));i=this.lookU32(),t=this.decodeExtension(i,4)}this.complete();for(var r=this.stack;r.length>0;){var s=r[r.length-1];if(0===s.type){if(s.array[s.position]=t,s.position++,s.position!==s.size)continue e;r.pop(),t=s.array}else{if(1===s.type){if(void 0,"string"!=(a=typeof t)&&"number"!==a)throw new x("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new x("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}if(s.map[s.key]=t,s.readCount++,s.readCount!==s.size){s.key=null,s.type=1;continue e}r.pop(),t=s.map}}return t}var a},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new x("Unrecognized array type byte: ".concat(U(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new x("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new x("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new x("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength_?function(e,t,n){var i=e.subarray(t,t+n);return g.decode(i)}(this.bytes,r,e):f(this.bytes,r,e),this.pos+=t+e,i},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new x("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw H;var n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new x("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=l(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),j={};function X(e,t){return void 0===t&&(t=j),new W(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decode(e)}function q(e,t){return void 0===t&&(t=j),new W(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeMulti(e)}var Y=function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]1||o(e,t)}))})}function o(e,t){try{(n=r[e](t)).value instanceof K?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(e){h(s[0][3],e)}var n}function l(e){o("next",e)}function c(e){o("throw",e)}function h(e,t){e(t),s.shift(),s.length&&o(s[0][0],s[0][1])}};function Z(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function Q(e){return null!=e[Symbol.asyncIterator]?e:function(e){return J(this,arguments,(function(){var t,n,i,r;return Y(this,(function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,K(t.read())];case 3:return n=s.sent(),i=n.done,r=n.value,i?[4,K(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return Z(r),[4,K(r)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}function $(e,t){return void 0===t&&(t=j),n=this,i=void 0,s=function(){var n;return function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]{"use strict";n.r(t),n.d(t,{ACESFilmicToneMapping:()=>te,AddEquation:()=>S,AddOperation:()=>J,AdditiveAnimationBlendMode:()=>It,AdditiveBlending:()=>x,AlphaFormat:()=>Ue,AlwaysCompare:()=>_n,AlwaysDepth:()=>G,AlwaysStencilFunc:()=>cn,AmbientLight:()=>Pd,AmbientLightProbe:()=>Yd,AnimationAction:()=>bp,AnimationClip:()=>td,AnimationLoader:()=>hd,AnimationMixer:()=>Mp,AnimationObjectGroup:()=>xp,AnimationUtils:()=>Hu,ArcCurve:()=>ah,ArrayCamera:()=>Rl,ArrowHelper:()=>mf,Audio:()=>ap,AudioAnalyser:()=>dp,AudioContext:()=>jd,AudioListener:()=>sp,AudioLoader:()=>Xd,AxesHelper:()=>gf,BackSide:()=>m,BasicDepthPacking:()=>Bt,BasicShadowMap:()=>h,Bone:()=>xc,BooleanKeyframeTrack:()=>Yu,Box2:()=>Np,Box3:()=>Ri,Box3Helper:()=>hf,BoxGeometry:()=>zs,BoxHelper:()=>cf,BufferAttribute:()=>ns,BufferGeometry:()=>xs,BufferGeometryLoader:()=>Bd,ByteType:()=>Me,Cache:()=>id,Camera:()=>Xs,CameraHelper:()=>af,CanvasTexture:()=>ih,CapsuleGeometry:()=>Ah,CatmullRomCurve3:()=>dh,CineonToneMapping:()=>ee,CircleGeometry:()=>Ch,ClampToEdgeWrapping:()=>he,Clock:()=>$d,Color:()=>Xr,ColorKeyframeTrack:()=>Ku,ColorManagement:()=>ci,CompressedArrayTexture:()=>th,CompressedCubeTexture:()=>nh,CompressedTexture:()=>eh,CompressedTextureLoader:()=>ud,ConeGeometry:()=>Lh,CubeCamera:()=>Ks,CubeReflectionMapping:()=>re,CubeRefractionMapping:()=>se,CubeTexture:()=>Js,CubeTextureLoader:()=>pd,CubeUVReflectionMapping:()=>le,CubicBezierCurve:()=>gh,CubicBezierCurve3:()=>_h,CubicInterpolant:()=>Wu,CullFaceBack:()=>o,CullFaceFront:()=>l,CullFaceFrontBack:()=>c,CullFaceNone:()=>a,Curve:()=>rh,CurvePath:()=>Sh,CustomBlending:()=>M,CustomToneMapping:()=>ne,CylinderGeometry:()=>Rh,Cylindrical:()=>Up,Data3DTexture:()=>wi,DataArrayTexture:()=>xi,DataTexture:()=>bc,DataTextureLoader:()=>fd,DataUtils:()=>$r,DecrementStencilOp:()=>Zt,DecrementWrapStencilOp:()=>$t,DefaultLoadingManager:()=>sd,DepthFormat:()=>ke,DepthStencilFormat:()=>Be,DepthTexture:()=>Ul,DirectionalLight:()=>Ld,DirectionalLightHelper:()=>nf,DiscreteInterpolant:()=>Xu,DisplayP3ColorSpace:()=>jt,DodecahedronGeometry:()=>Ih,DoubleSide:()=>g,DstAlphaFactor:()=>N,DstColorFactor:()=>k,DynamicCopyUsage:()=>En,DynamicDrawUsage:()=>yn,DynamicReadUsage:()=>wn,EdgesGeometry:()=>kh,EllipseCurve:()=>sh,EqualCompare:()=>dn,EqualDepth:()=>W,EqualStencilFunc:()=>rn,EquirectangularReflectionMapping:()=>ae,EquirectangularRefractionMapping:()=>oe,Euler:()=>dr,EventDispatcher:()=>In,ExtrudeGeometry:()=>du,FileLoader:()=>cd,Float16BufferAttribute:()=>hs,Float32BufferAttribute:()=>us,Float64BufferAttribute:()=>ds,FloatType:()=>Ce,Fog:()=>zl,FogExp2:()=>Fl,FramebufferTexture:()=>$c,FrontSide:()=>f,Frustum:()=>ra,GLBufferAttribute:()=>Cp,GLSL1:()=>An,GLSL3:()=>Cn,GreaterCompare:()=>fn,GreaterDepth:()=>X,GreaterEqualCompare:()=>gn,GreaterEqualDepth:()=>j,GreaterEqualStencilFunc:()=>ln,GreaterStencilFunc:()=>an,GridHelper:()=>Zp,Group:()=>Ll,HalfFloatType:()=>Re,HemisphereLight:()=>_d,HemisphereLightHelper:()=>Jp,HemisphereLightProbe:()=>qd,IcosahedronGeometry:()=>fu,ImageBitmapLoader:()=>Vd,ImageLoader:()=>dd,ImageUtils:()=>ui,IncrementStencilOp:()=>Jt,IncrementWrapStencilOp:()=>Qt,InstancedBufferAttribute:()=>Ec,InstancedBufferGeometry:()=>kd,InstancedInterleavedBuffer:()=>Ap,InstancedMesh:()=>Uc,Int16BufferAttribute:()=>as,Int32BufferAttribute:()=>ls,Int8BufferAttribute:()=>is,IntType:()=>Te,InterleavedBuffer:()=>Hl,InterleavedBufferAttribute:()=>Wl,Interpolant:()=>Vu,InterpolateDiscrete:()=>Et,InterpolateLinear:()=>Tt,InterpolateSmooth:()=>At,InvertStencilOp:()=>en,KeepStencilOp:()=>Yt,KeyframeTrack:()=>qu,LOD:()=>cc,LatheGeometry:()=>Th,Layers:()=>pr,LessCompare:()=>un,LessDepth:()=>H,LessEqualCompare:()=>pn,LessEqualDepth:()=>V,LessEqualStencilFunc:()=>sn,LessStencilFunc:()=>nn,Light:()=>gd,LightProbe:()=>Od,Line:()=>zc,Line3:()=>Bp,LineBasicMaterial:()=>Oc,LineCurve:()=>vh,LineCurve3:()=>yh,LineDashedMaterial:()=>Nu,LineLoop:()=>Wc,LineSegments:()=>Vc,LinearDisplayP3ColorSpace:()=>Xt,LinearEncoding:()=>Dt,LinearFilter:()=>_e,LinearInterpolant:()=>ju,LinearMipMapLinearFilter:()=>be,LinearMipMapNearestFilter:()=>ye,LinearMipmapLinearFilter:()=>xe,LinearMipmapNearestFilter:()=>ve,LinearSRGBColorSpace:()=>Wt,LinearToneMapping:()=>Q,Loader:()=>ad,LoaderUtils:()=>Dd,LoadingManager:()=>rd,LoopOnce:()=>wt,LoopPingPong:()=>St,LoopRepeat:()=>Mt,LuminanceAlphaFormat:()=>De,LuminanceFormat:()=>Ne,MOUSE:()=>r,Material:()=>Gr,MaterialLoader:()=>Nd,MathUtils:()=>Xn,Matrix3:()=>Yn,Matrix4:()=>nr,MaxEquation:()=>C,Mesh:()=>Bs,MeshBasicMaterial:()=>Yr,MeshDepthMaterial:()=>Ml,MeshDistanceMaterial:()=>Sl,MeshLambertMaterial:()=>Uu,MeshMatcapMaterial:()=>Ou,MeshNormalMaterial:()=>Iu,MeshPhongMaterial:()=>Lu,MeshPhysicalMaterial:()=>Ru,MeshStandardMaterial:()=>Cu,MeshToonMaterial:()=>Pu,MinEquation:()=>A,MirroredRepeatWrapping:()=>ue,MixOperation:()=>K,MultiplyBlending:()=>w,MultiplyOperation:()=>Y,NearestFilter:()=>de,NearestMipMapLinearFilter:()=>ge,NearestMipMapNearestFilter:()=>fe,NearestMipmapLinearFilter:()=>me,NearestMipmapNearestFilter:()=>pe,NeverCompare:()=>hn,NeverDepth:()=>z,NeverStencilFunc:()=>tn,NoBlending:()=>v,NoColorSpace:()=>Ht,NoToneMapping:()=>Z,NormalAnimationBlendMode:()=>Pt,NormalBlending:()=>y,NotEqualCompare:()=>mn,NotEqualDepth:()=>q,NotEqualStencilFunc:()=>on,NumberKeyframeTrack:()=>Ju,Object3D:()=>Ar,ObjectLoader:()=>Fd,ObjectSpaceNormalMap:()=>Gt,OctahedronGeometry:()=>mu,OneFactor:()=>L,OneMinusDstAlphaFactor:()=>D,OneMinusDstColorFactor:()=>B,OneMinusSrcAlphaFactor:()=>O,OneMinusSrcColorFactor:()=>I,OrthographicCamera:()=>va,PCFShadowMap:()=>u,PCFSoftShadowMap:()=>d,PMREMGenerator:()=>Ta,Path:()=>Eh,PerspectiveCamera:()=>qs,Plane:()=>ta,PlaneGeometry:()=>oa,PlaneHelper:()=>uf,PointLight:()=>Cd,PointLightHelper:()=>Xp,Points:()=>Jc,PointsMaterial:()=>jc,PolarGridHelper:()=>Qp,PolyhedronGeometry:()=>Ph,PositionalAudio:()=>up,PropertyBinding:()=>yp,PropertyMixer:()=>pp,QuadraticBezierCurve:()=>xh,QuadraticBezierCurve3:()=>bh,Quaternion:()=>Ei,QuaternionKeyframeTrack:()=>Qu,QuaternionLinearInterpolant:()=>Zu,RED_GREEN_RGTC2_Format:()=>xt,RED_RGTC1_Format:()=>vt,REVISION:()=>i,RGBADepthPacking:()=>Ft,RGBAFormat:()=>Oe,RGBAIntegerFormat:()=>Ve,RGBA_ASTC_10x10_Format:()=>dt,RGBA_ASTC_10x5_Format:()=>ct,RGBA_ASTC_10x6_Format:()=>ht,RGBA_ASTC_10x8_Format:()=>ut,RGBA_ASTC_12x10_Format:()=>pt,RGBA_ASTC_12x12_Format:()=>ft,RGBA_ASTC_4x4_Format:()=>tt,RGBA_ASTC_5x4_Format:()=>nt,RGBA_ASTC_5x5_Format:()=>it,RGBA_ASTC_6x5_Format:()=>rt,RGBA_ASTC_6x6_Format:()=>st,RGBA_ASTC_8x5_Format:()=>at,RGBA_ASTC_8x6_Format:()=>ot,RGBA_ASTC_8x8_Format:()=>lt,RGBA_BPTC_Format:()=>mt,RGBA_ETC2_EAC_Format:()=>et,RGBA_PVRTC_2BPPV1_Format:()=>Ze,RGBA_PVRTC_4BPPV1_Format:()=>Je,RGBA_S3TC_DXT1_Format:()=>je,RGBA_S3TC_DXT3_Format:()=>Xe,RGBA_S3TC_DXT5_Format:()=>qe,RGB_BPTC_SIGNED_Format:()=>gt,RGB_BPTC_UNSIGNED_Format:()=>_t,RGB_ETC1_Format:()=>Qe,RGB_ETC2_Format:()=>$e,RGB_PVRTC_2BPPV1_Format:()=>Ke,RGB_PVRTC_4BPPV1_Format:()=>Ye,RGB_S3TC_DXT1_Format:()=>We,RGFormat:()=>Ge,RGIntegerFormat:()=>He,RawShaderMaterial:()=>Au,Ray:()=>tr,Raycaster:()=>Rp,RectAreaLight:()=>Id,RedFormat:()=>Fe,RedIntegerFormat:()=>ze,ReinhardToneMapping:()=>$,RenderTarget:()=>vi,RepeatWrapping:()=>ce,ReplaceStencilOp:()=>Kt,ReverseSubtractEquation:()=>T,RingGeometry:()=>gu,SIGNED_RED_GREEN_RGTC2_Format:()=>bt,SIGNED_RED_RGTC1_Format:()=>yt,SRGBColorSpace:()=>Vt,Scene:()=>Gl,ShaderChunk:()=>la,ShaderLib:()=>ha,ShaderMaterial:()=>js,ShadowMaterial:()=>Tu,Shape:()=>Bh,ShapeGeometry:()=>_u,ShapePath:()=>_f,ShapeUtils:()=>cu,ShortType:()=>Se,Skeleton:()=>Sc,SkeletonHelper:()=>Wp,SkinnedMesh:()=>yc,Source:()=>pi,Sphere:()=>qi,SphereGeometry:()=>vu,Spherical:()=>Ip,SphericalHarmonics3:()=>Ud,SplineCurve:()=>wh,SpotLight:()=>Md,SpotLightHelper:()=>zp,Sprite:()=>sc,SpriteMaterial:()=>jl,SrcAlphaFactor:()=>U,SrcAlphaSaturateFactor:()=>F,SrcColorFactor:()=>P,StaticCopyUsage:()=>Sn,StaticDrawUsage:()=>vn,StaticReadUsage:()=>bn,StereoCamera:()=>Qd,StreamCopyUsage:()=>Tn,StreamDrawUsage:()=>xn,StreamReadUsage:()=>Mn,StringKeyframeTrack:()=>$u,SubtractEquation:()=>E,SubtractiveBlending:()=>b,TOUCH:()=>s,TangentSpaceNormalMap:()=>zt,TetrahedronGeometry:()=>yu,Texture:()=>gi,TextureLoader:()=>md,TorusGeometry:()=>xu,TorusKnotGeometry:()=>bu,Triangle:()=>Fr,TriangleFanDrawMode:()=>Nt,TriangleStripDrawMode:()=>Ot,TrianglesDrawMode:()=>Ut,TubeGeometry:()=>wu,TwoPassDoubleSide:()=>_,UVMapping:()=>ie,Uint16BufferAttribute:()=>os,Uint32BufferAttribute:()=>cs,Uint8BufferAttribute:()=>rs,Uint8ClampedBufferAttribute:()=>ss,Uniform:()=>Sp,UniformsGroup:()=>Tp,UniformsLib:()=>ca,UniformsUtils:()=>Ws,UnsignedByteType:()=>we,UnsignedInt248Type:()=>Ie,UnsignedIntType:()=>Ae,UnsignedShort4444Type:()=>Le,UnsignedShort5551Type:()=>Pe,UnsignedShortType:()=>Ee,VSMShadowMap:()=>p,Vector2:()=>qn,Vector3:()=>Ti,Vector4:()=>_i,VectorKeyframeTrack:()=>ed,VideoTexture:()=>Qc,WebGL1Renderer:()=>Bl,WebGL3DRenderTarget:()=>Mi,WebGLArrayRenderTarget:()=>bi,WebGLCoordinateSystem:()=>Ln,WebGLCubeRenderTarget:()=>Zs,WebGLMultipleRenderTargets:()=>Si,WebGLRenderTarget:()=>yi,WebGLRenderer:()=>kl,WebGLUtils:()=>Cl,WebGPUCoordinateSystem:()=>Pn,WireframeGeometry:()=>Mu,WrapAroundEnding:()=>Lt,ZeroCurvatureEnding:()=>Ct,ZeroFactor:()=>R,ZeroSlopeEnding:()=>Rt,ZeroStencilOp:()=>qt,_SRGBAFormat:()=>Rn,createCanvasElement:()=>ei,sRGBEncoding:()=>kt});const i="156",r={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},s={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},a=0,o=1,l=2,c=3,h=0,u=1,d=2,p=3,f=0,m=1,g=2,_=2,v=0,y=1,x=2,b=3,w=4,M=5,S=100,E=101,T=102,A=103,C=104,R=200,L=201,P=202,I=203,U=204,O=205,N=206,D=207,k=208,B=209,F=210,z=0,G=1,H=2,V=3,W=4,j=5,X=6,q=7,Y=0,K=1,J=2,Z=0,Q=1,$=2,ee=3,te=4,ne=5,ie=300,re=301,se=302,ae=303,oe=304,le=306,ce=1e3,he=1001,ue=1002,de=1003,pe=1004,fe=1004,me=1005,ge=1005,_e=1006,ve=1007,ye=1007,xe=1008,be=1008,we=1009,Me=1010,Se=1011,Ee=1012,Te=1013,Ae=1014,Ce=1015,Re=1016,Le=1017,Pe=1018,Ie=1020,Ue=1021,Oe=1023,Ne=1024,De=1025,ke=1026,Be=1027,Fe=1028,ze=1029,Ge=1030,He=1031,Ve=1033,We=33776,je=33777,Xe=33778,qe=33779,Ye=35840,Ke=35841,Je=35842,Ze=35843,Qe=36196,$e=37492,et=37496,tt=37808,nt=37809,it=37810,rt=37811,st=37812,at=37813,ot=37814,lt=37815,ct=37816,ht=37817,ut=37818,dt=37819,pt=37820,ft=37821,mt=36492,gt=36494,_t=36495,vt=36283,yt=36284,xt=36285,bt=36286,wt=2200,Mt=2201,St=2202,Et=2300,Tt=2301,At=2302,Ct=2400,Rt=2401,Lt=2402,Pt=2500,It=2501,Ut=0,Ot=1,Nt=2,Dt=3e3,kt=3001,Bt=3200,Ft=3201,zt=0,Gt=1,Ht="",Vt="srgb",Wt="srgb-linear",jt="display-p3",Xt="display-p3-linear",qt=0,Yt=7680,Kt=7681,Jt=7682,Zt=7683,Qt=34055,$t=34056,en=5386,tn=512,nn=513,rn=514,sn=515,an=516,on=517,ln=518,cn=519,hn=512,un=513,dn=514,pn=515,fn=516,mn=517,gn=518,_n=519,vn=35044,yn=35048,xn=35040,bn=35045,wn=35049,Mn=35041,Sn=35046,En=35050,Tn=35042,An="100",Cn="300 es",Rn=1035,Ln=2e3,Pn=2001;class In{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+Un[e>>16&255]+Un[e>>24&255]+"-"+Un[255&t]+Un[t>>8&255]+"-"+Un[t>>16&15|64]+Un[t>>24&255]+"-"+Un[63&n|128]+Un[n>>8&255]+"-"+Un[n>>16&255]+Un[n>>24&255]+Un[255&i]+Un[i>>8&255]+Un[i>>16&255]+Un[i>>24&255]).toLowerCase()}function Bn(e,t,n){return Math.max(t,Math.min(n,e))}function Fn(e,t){return(e%t+t)%t}function zn(e,t,n){return(1-n)*e+n*t}function Gn(e){return 0==(e&e-1)&&0!==e}function Hn(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Vn(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Wn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Xn={DEG2RAD:Nn,RAD2DEG:Dn,generateUUID:kn,clamp:Bn,euclideanModulo:Fn,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:zn,damp:function(e,t,n,i){return zn(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(Fn(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(On=e);let t=On+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Nn},radToDeg:function(e){return e*Dn},isPowerOfTwo:Gn,ceilPowerOfTwo:Hn,floorPowerOfTwo:Vn,setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),f=a((i-t)/2);switch(r){case"XYX":e.set(o*h,l*u,l*d,o*c);break;case"YZY":e.set(l*d,o*h,l*u,o*c);break;case"ZXZ":e.set(l*u,l*d,o*h,o*c);break;case"XZX":e.set(o*h,l*f,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*f,o*c);break;case"ZYZ":e.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:jn,denormalize:Wn};class qn{constructor(e=0,t=0){qn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yn{constructor(e,t,n,i,r,s,a,o,l){Yn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],_=i[1],v=i[4],y=i[7],x=i[2],b=i[5],w=i[8];return r[0]=s*f+a*_+o*x,r[3]=s*m+a*v+o*b,r[6]=s*g+a*y+o*w,r[1]=l*f+c*_+h*x,r[4]=l*m+c*v+h*b,r[7]=l*g+c*y+h*w,r[2]=u*f+d*_+p*x,r[5]=u*m+d*v+p*b,r[8]=u*g+d*y+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(a*n-i*s)*f,e[3]=u*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-a*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(s*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Kn.makeScale(e,t)),this}rotate(e){return this.premultiply(Kn.makeRotation(-e)),this}translate(e,t){return this.premultiply(Kn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Kn=new Yn;function Jn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const Zn={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Qn(e,t){return new Zn[e](t)}function $n(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ei(){const e=$n("canvas");return e.style.display="block",e}const ti={};function ni(e){e in ti||(ti[e]=!0,console.warn(e))}function ii(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ri(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const si=(new Yn).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),ai=(new Yn).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]),oi={[Wt]:e=>e,[Vt]:e=>e.convertSRGBToLinear(),[jt]:function(e){return e.convertSRGBToLinear().applyMatrix3(ai)}},li={[Wt]:e=>e,[Vt]:e=>e.convertLinearToSRGB(),[jt]:function(e){return e.applyMatrix3(si).convertLinearToSRGB()}},ci={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Wt},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=oi[t],r=li[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let hi;class ui{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===hi&&(hi=$n("canvas")),hi.width=e.width,hi.height=e.height;const n=hi.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=hi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=$n("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ie)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ce:e.x=e.x-Math.floor(e.x);break;case he:e.x=e.x<0?0:1;break;case ue:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case ce:e.y=e.y-Math.floor(e.y);break;case he:e.y=e.y<0?0:1;break;case ue:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return ni("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Vt?kt:Dt}set encoding(e){ni("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===kt?Vt:Ht}}gi.DEFAULT_IMAGE=null,gi.DEFAULT_MAPPING=ie,gi.DEFAULT_ANISOTROPY=1;class _i{constructor(e=0,t=0,n=0,i=1){_i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&e>_?e_?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,t*n);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+f*r,e===1-a){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*h+o*d-l*u,e[t+1]=o*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-o*h,e[t+3]=c*p-a*h-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ti{constructor(e=0,t=0,n=0){Ti.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ci.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ci.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=o*t+s*i-a*n,c=o*n+a*t-r*i,h=o*i+r*n-s*t,u=-r*t-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ai.copy(this).projectOnVector(e),this.sub(Ai)}reflect(e){return this.sub(Ai.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ai=new Ti,Ci=new Ei;class Ri{constructor(e=new Ti(1/0,1/0,1/0),t=new Ti(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;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,Pi),Pi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Fi),zi.subVectors(this.max,Fi),Ui.subVectors(e.a,Fi),Oi.subVectors(e.b,Fi),Ni.subVectors(e.c,Fi),Di.subVectors(Oi,Ui),ki.subVectors(Ni,Oi),Bi.subVectors(Ui,Ni);let t=[0,-Di.z,Di.y,0,-ki.z,ki.y,0,-Bi.z,Bi.y,Di.z,0,-Di.x,ki.z,0,-ki.x,Bi.z,0,-Bi.x,-Di.y,Di.x,0,-ki.y,ki.x,0,-Bi.y,Bi.x,0];return!!Vi(t,Ui,Oi,Ni,zi)&&(t=[1,0,0,0,1,0,0,0,1],!!Vi(t,Ui,Oi,Ni,zi)&&(Gi.crossVectors(Di,ki),t=[Gi.x,Gi.y,Gi.z],Vi(t,Ui,Oi,Ni,zi)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Pi).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Li[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Li[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Li[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Li[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Li[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Li[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Li[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Li[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Li)),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 Li=[new Ti,new Ti,new Ti,new Ti,new Ti,new Ti,new Ti,new Ti],Pi=new Ti,Ii=new Ri,Ui=new Ti,Oi=new Ti,Ni=new Ti,Di=new Ti,ki=new Ti,Bi=new Ti,Fi=new Ti,zi=new Ti,Gi=new Ti,Hi=new Ti;function Vi(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){Hi.fromArray(e,s);const a=r.x*Math.abs(Hi.x)+r.y*Math.abs(Hi.y)+r.z*Math.abs(Hi.z),o=t.dot(Hi),l=n.dot(Hi),c=i.dot(Hi);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Wi=new Ri,ji=new Ti,Xi=new Ti;class qi{constructor(e=new Ti,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Wi.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ji.subVectors(e,this.center);const t=ji.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(ji,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Xi.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ji.copy(e.center).add(Xi)),this.expandByPoint(ji.copy(e.center).sub(Xi))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Yi=new Ti,Ki=new Ti,Ji=new Ti,Zi=new Ti,Qi=new Ti,$i=new Ti,er=new Ti;class tr{constructor(e=new Ti,t=new Ti(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yi.copy(this.origin).addScaledVector(this.direction,t),Yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ki.copy(e).add(t).multiplyScalar(.5),Ji.copy(t).sub(e).normalize(),Zi.copy(this.origin).sub(Ki);const r=.5*e.distanceTo(t),s=-this.direction.dot(Ji),a=Zi.dot(this.direction),o=-Zi.dot(Ji),l=Zi.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Ki).addScaledVector(Ji,u),d}intersectSphere(e,t){Yi.subVectors(e.center,this.origin);const n=Yi.dot(this.direction),i=Yi.dot(Yi)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(e.min.z-u.z)*h,o=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,o=(e.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Yi)}intersectTriangle(e,t,n,i,r){Qi.subVectors(t,e),$i.subVectors(n,e),er.crossVectors(Qi,$i);let s,a=this.direction.dot(er);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Zi.subVectors(this.origin,e);const o=s*this.direction.dot($i.crossVectors(Zi,$i));if(o<0)return null;const l=s*this.direction.dot(Qi.cross(Zi));if(l<0)return null;if(o+l>a)return null;const c=-s*Zi.dot(er);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class nr{constructor(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m){nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new nr).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/ir.setFromMatrixColumn(e,0).length(),r=1/ir.setFromMatrixColumn(e,1).length(),s=1/ir.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*h,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-s*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=s*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(sr,e,ar)}lookAt(e,t,n){const i=this.elements;return cr.subVectors(e,t),0===cr.lengthSq()&&(cr.z=1),cr.normalize(),or.crossVectors(n,cr),0===or.lengthSq()&&(1===Math.abs(n.z)?cr.x+=1e-4:cr.z+=1e-4,cr.normalize(),or.crossVectors(n,cr)),or.normalize(),lr.crossVectors(cr,or),i[0]=or.x,i[4]=lr.x,i[8]=cr.x,i[1]=or.y,i[5]=lr.y,i[9]=cr.y,i[2]=or.z,i[6]=lr.z,i[10]=cr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],v=n[7],y=n[11],x=n[15],b=i[0],w=i[4],M=i[8],S=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],L=i[6],P=i[10],I=i[14],U=i[3],O=i[7],N=i[11],D=i[15];return r[0]=s*b+a*E+o*R+l*U,r[4]=s*w+a*T+o*L+l*O,r[8]=s*M+a*A+o*P+l*N,r[12]=s*S+a*C+o*I+l*D,r[1]=c*b+h*E+u*R+d*U,r[5]=c*w+h*T+u*L+d*O,r[9]=c*M+h*A+u*P+d*N,r[13]=c*S+h*C+u*I+d*D,r[2]=p*b+f*E+m*R+g*U,r[6]=p*w+f*T+m*L+g*O,r[10]=p*M+f*A+m*P+g*N,r[14]=p*S+f*C+m*I+g*D,r[3]=_*b+v*E+y*R+x*U,r[7]=_*w+v*T+y*L+x*O,r[11]=_*M+v*A+y*P+x*N,r[15]=_*S+v*C+y*I+x*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+e[11]*(+t*l*h-t*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*o*h+t*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],_=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,x=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,b=t*_+n*v+i*y+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return e[0]=_*w,e[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,e[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,e[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,e[4]=v*w,e[5]=(c*m*r-p*u*r+p*i*d-t*m*d-c*i*g+t*u*g)*w,e[6]=(p*o*r-s*m*r-p*i*l+t*m*l+s*i*g-t*o*g)*w,e[7]=(s*u*r-c*o*r+c*i*l-t*u*l-s*i*d+t*o*d)*w,e[8]=y*w,e[9]=(p*h*r-c*f*r-p*n*d+t*f*d+c*n*g-t*h*g)*w,e[10]=(s*f*r-p*a*r+p*n*l-t*f*l-s*n*g+t*a*g)*w,e[11]=(c*a*r-s*h*r-c*n*l+t*h*l+s*n*d-t*a*d)*w,e[12]=x*w,e[13]=(c*f*i-p*h*i+p*n*u-t*f*u-c*n*m+t*h*m)*w,e[14]=(p*a*i-s*f*i-p*n*o+t*f*o+s*n*m-t*a*m)*w,e[15]=(s*h*i-c*a*i+c*n*o-t*h*o-s*n*u+t*a*u)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,_=o*l,v=o*c,y=o*h,x=n.x,b=n.y,w=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+y)*x,i[2]=(p-v)*x,i[3]=0,i[4]=(d-y)*b,i[5]=(1-(u+g))*b,i[6]=(m+_)*b,i[7]=0,i[8]=(p+v)*w,i[9]=(m-_)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=ir.set(i[0],i[1],i[2]).length();const s=ir.set(i[4],i[5],i[6]).length(),a=ir.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],rr.copy(this);const o=1/r,l=1/s,c=1/a;return rr.elements[0]*=o,rr.elements[1]*=o,rr.elements[2]*=o,rr.elements[4]*=l,rr.elements[5]*=l,rr.elements[6]*=l,rr.elements[8]*=c,rr.elements[9]*=c,rr.elements[10]*=c,t.setFromRotationMatrix(rr),n.x=r,n.y=s,n.z=a,this}makePerspective(e,t,n,i,r,s,a=Ln){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let d,p;if(a===Ln)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Pn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=Ln){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(s-r),u=(t+e)*l,d=(n+i)*c;let p,f;if(a===Ln)p=(s+r)*h,f=-2*h;else{if(a!==Pn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ir=new Ti,rr=new nr,sr=new Ti(0,0,0),ar=new Ti(1,1,1),or=new Ti,lr=new Ti,cr=new Ti,hr=new nr,ur=new Ei;class dr{constructor(e=0,t=0,n=0,i=dr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Bn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Bn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Bn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Bn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Bn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return hr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ur.setFromEuler(this),this.setFromQuaternion(ur,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}dr.DEFAULT_ORDER="XYZ";class pr{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yr,e,xr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yr,br,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Cr.subVectors(i,t),Rr.subVectors(n,t),Lr.subVectors(e,t);const s=Cr.dot(Cr),a=Cr.dot(Rr),o=Cr.dot(Lr),l=Rr.dot(Rr),c=Rr.dot(Lr),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Pr),Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getUV(e,t,n,i,r,s,a,o){return!1===Br&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Br=!0),this.getInterpolation(e,t,n,i,r,s,a,o)}static getInterpolation(e,t,n,i,r,s,a,o){return this.getBarycoord(e,t,n,i,Pr),o.setScalar(0),o.addScaledVector(r,Pr.x),o.addScaledVector(s,Pr.y),o.addScaledVector(a,Pr.z),o}static isFrontFacing(e,t,n,i){return Cr.subVectors(n,t),Rr.subVectors(e,t),Cr.cross(Rr).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cr.subVectors(this.c,this.b),Rr.subVectors(this.a,this.b),.5*Cr.cross(Rr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Fr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Fr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===Br&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Br=!0),Fr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return Fr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Fr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Fr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Ir.subVectors(i,n),Ur.subVectors(r,n),Nr.subVectors(e,n);const o=Ir.dot(Nr),l=Ur.dot(Nr);if(o<=0&&l<=0)return t.copy(n);Dr.subVectors(e,i);const c=Ir.dot(Dr),h=Ur.dot(Dr);if(c>=0&&h<=c)return t.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Ir,s);kr.subVectors(e,r);const d=Ir.dot(kr),p=Ur.dot(kr);if(p>=0&&d<=p)return t.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Ur,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return Or.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(Or,a);const g=1/(m+f+u);return s=f*g,a=u*g,t.copy(n).addScaledVector(Ir,s).addScaledVector(Ur,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let zr=0;class Gr extends In{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zr++}),this.uuid=kn(),this.name="",this.type="Material",this.blending=y,this.side=f,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=U,this.blendDst=O,this.blendEquation=S,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=V,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=cn,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yt,this.stencilZFail=Yt,this.stencilZPass=Yt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==y&&(n.blending=this.blending),this.side!==f&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const Hr={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},Vr={h:0,s:0,l:0},Wr={h:0,s:0,l:0};function jr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class Xr{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ci.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=ci.workingColorSpace){return this.r=e,this.g=t,this.b=n,ci.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=ci.workingColorSpace){if(e=Fn(e,1),t=Bn(t,0,1),n=Bn(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=jr(r,i,e+1/3),this.g=jr(r,i,e),this.b=jr(r,i,e-1/3)}return ci.toWorkingColorSpace(this,i),this}setStyle(e,t=Vt){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vt){const n=Hr[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ii(e.r),this.g=ii(e.g),this.b=ii(e.b),this}copyLinearToSRGB(e){return this.r=ri(e.r),this.g=ri(e.g),this.b=ri(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vt){return ci.fromWorkingColorSpace(qr.copy(this),e),65536*Math.round(Bn(255*qr.r,0,255))+256*Math.round(Bn(255*qr.g,0,255))+Math.round(Bn(255*qr.b,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ci.workingColorSpace){ci.fromWorkingColorSpace(qr.copy(this),t);const n=qr.r,i=qr.g,r=qr.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Zr(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Bn(e,-65504,65504),Kr.floatView[0]=e;const t=Kr.uint32View[0],n=t>>23&511;return Kr.baseTable[n]+((8388607&t)>>Kr.shiftTable[n])}function Qr(e){const t=e>>10;return Kr.uint32View[0]=Kr.mantissaTable[Kr.offsetTable[t]+(1023&e)]+Kr.exponentTable[t],Kr.floatView[0]}const $r={toHalfFloat:Zr,fromHalfFloat:Qr},es=new Ti,ts=new qn;class ns{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=vn,this.updateRange={offset:0,count:-1},this.gpuType=Ce,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}bs.copy(r).invert(),ws.copy(e.ray).applyMatrix4(bs),null!==n.boundingBox&&!1===ws.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,ws)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:ks.clone(),object:e}}(e,t,n,i,Es,Ts,As,Ds);if(h){r&&(Ls.fromBufferAttribute(r,o),Ps.fromBufferAttribute(r,l),Is.fromBufferAttribute(r,c),h.uv=Fr.getInterpolation(Ds,Es,Ts,As,Ls,Ps,Is,new qn)),s&&(Ls.fromBufferAttribute(s,o),Ps.fromBufferAttribute(s,l),Is.fromBufferAttribute(s,c),h.uv1=Fr.getInterpolation(Ds,Es,Ts,As,Ls,Ps,Is,new qn),h.uv2=h.uv1),a&&(Us.fromBufferAttribute(a,o),Os.fromBufferAttribute(a,l),Ns.fromBufferAttribute(a,c),h.normal=Fr.getInterpolation(Ds,Es,Ts,As,Us,Os,Ns,new Ti),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Ti,materialIndex:0};Fr.getNormal(Es,Ts,As,e.normal),h.face=e}return h}class zs extends xs{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,s,p,f,m,g,_){const v=s/m,y=p/g,x=s/2,b=p/2,w=f/2,M=m+1,S=g+1;let E=0,T=0;const A=new Ti;for(let s=0;s0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-s/g),E+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Xs extends Ar{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new nr,this.projectionMatrix=new nr,this.projectionMatrixInverse=new nr,this.coordinateSystem=Ln}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class qs extends Xs{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Dn*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Nn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Dn*Math.atan(Math.tan(.5*Nn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Nn*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ys=-90;class Ks extends Ar{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new qs(Ys,1,e,t);i.layers=this.layers,this.add(i);const r=new qs(Ys,1,e,t);r.layers=this.layers,this.add(r);const s=new qs(Ys,1,e,t);s.layers=this.layers,this.add(s);const a=new qs(Ys,1,e,t);a.layers=this.layers,this.add(a);const o=new qs(Ys,1,e,t);o.layers=this.layers,this.add(o);const l=new qs(Ys,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Ln)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Pn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,r,s,a,o,l]=this.children,c=e.getRenderTarget(),h=e.xr.enabled;e.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=u,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}}class Js extends gi{constructor(e,t,n,i,r,s,a,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:re,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Zs extends yi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(ni("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===kt?Vt:Ht),this.texture=new Js(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:_e}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new zs(5,5,5),a=new js({name:"CubemapFromEquirect",uniforms:Gs(n),vertexShader:i,fragmentShader:r,side:m,blending:v});a.uniforms.tEquirect.value=t;const o=new Bs(s,a),l=t.minFilter;return t.minFilter===xe&&(t.minFilter=_e),new Ks(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const Qs=new Ti,$s=new Ti,ea=new Yn;class ta{constructor(e=new Ti(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Qs.subVectors(n,t).cross($s.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Qs),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||ea.getNormalMatrix(e),i=this.coplanarPoint(Qs).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const na=new qi,ia=new Ti;class ra{constructor(e=new ta,t=new ta,n=new ta,i=new ta,r=new ta,s=new ta){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ln){const n=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],_=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+_).normalize(),n[3].setComponents(o-s,u-c,m-p,y-_).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),t===Ln)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(t!==Pn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),na.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),na.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(na)}intersectsSprite(e){return na.center.set(0,0,0),na.radius=.7071067811865476,na.applyMatrix4(e.matrixWorld),this.intersectsSphere(na)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ia.y=i.normal.y>0?e.max.y:e.min.y,ia.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ia)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function sa(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function aa(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},ca={common:{diffuse:{value:new Xr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yn},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yn},normalScale:{value:new qn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xr(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 Xr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0},uvTransform:{value:new Yn}},sprite:{diffuse:{value:new Xr(16777215)},opacity:{value:1},center:{value:new qn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yn},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0}}},ha={basic:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.fog]),vertexShader:la.meshbasic_vert,fragmentShader:la.meshbasic_frag},lambert:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)}}]),vertexShader:la.meshlambert_vert,fragmentShader:la.meshlambert_frag},phong:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)},specular:{value:new Xr(1118481)},shininess:{value:30}}]),vertexShader:la.meshphong_vert,fragmentShader:la.meshphong_frag},standard:{uniforms:Hs([ca.common,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.roughnessmap,ca.metalnessmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:la.meshphysical_vert,fragmentShader:la.meshphysical_frag},toon:{uniforms:Hs([ca.common,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.gradientmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)}}]),vertexShader:la.meshtoon_vert,fragmentShader:la.meshtoon_frag},matcap:{uniforms:Hs([ca.common,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,{matcap:{value:null}}]),vertexShader:la.meshmatcap_vert,fragmentShader:la.meshmatcap_frag},points:{uniforms:Hs([ca.points,ca.fog]),vertexShader:la.points_vert,fragmentShader:la.points_frag},dashed:{uniforms:Hs([ca.common,ca.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:la.linedashed_vert,fragmentShader:la.linedashed_frag},depth:{uniforms:Hs([ca.common,ca.displacementmap]),vertexShader:la.depth_vert,fragmentShader:la.depth_frag},normal:{uniforms:Hs([ca.common,ca.bumpmap,ca.normalmap,ca.displacementmap,{opacity:{value:1}}]),vertexShader:la.meshnormal_vert,fragmentShader:la.meshnormal_frag},sprite:{uniforms:Hs([ca.sprite,ca.fog]),vertexShader:la.sprite_vert,fragmentShader:la.sprite_frag},background:{uniforms:{uvTransform:{value:new Yn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:la.background_vert,fragmentShader:la.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:la.backgroundCube_vert,fragmentShader:la.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:la.cube_vert,fragmentShader:la.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:la.equirect_vert,fragmentShader:la.equirect_frag},distanceRGBA:{uniforms:Hs([ca.common,ca.displacementmap,{referencePosition:{value:new Ti},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:la.distanceRGBA_vert,fragmentShader:la.distanceRGBA_frag},shadow:{uniforms:Hs([ca.lights,ca.fog,{color:{value:new Xr(0)},opacity:{value:1}}]),vertexShader:la.shadow_vert,fragmentShader:la.shadow_frag}};ha.physical={uniforms:Hs([ha.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yn},clearcoatNormalScale:{value:new qn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yn},sheen:{value:0},sheenColor:{value:new Xr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yn},transmissionSamplerSize:{value:new qn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yn},attenuationDistance:{value:0},attenuationColor:{value:new Xr(0)},specularColor:{value:new Xr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yn},anisotropyVector:{value:new qn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yn}}]),vertexShader:la.meshphysical_vert,fragmentShader:la.meshphysical_frag};const ua={r:0,b:0,g:0};function da(e,t,n,i,r,s,a){const o=new Xr(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function g(t,n){t.getRGB(ua,Vs(e)),i.buffers.color.setClear(ua.r,ua.g,ua.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,g(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,g(o,h)},render:function(s,_){let v=!1,y=!0===_.isScene?_.background:null;y&&y.isTexture&&(y=(_.backgroundBlurriness>0?n:t).get(y)),null===y?g(o,h):y&&y.isColor&&(g(y,1),v=!0);const x=e.xr.getEnvironmentBlendMode();"additive"===x?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===x&&i.buffers.color.setClear(0,0,0,0,a),(e.autoClear||v)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),y&&(y.isCubeTexture||y.mapping===le)?(void 0===c&&(c=new Bs(new zs(1,1,1),new js({name:"BackgroundCubeMaterial",uniforms:Gs(ha.backgroundCube.uniforms),vertexShader:ha.backgroundCube.vertexShader,fragmentShader:ha.backgroundCube.fragmentShader,side:m,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&!1===y.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=y.colorSpace!==Vt,u===y&&d===y.version&&p===e.toneMapping||(c.material.needsUpdate=!0,u=y,d=y.version,p=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(void 0===l&&(l=new Bs(new oa(2,2),new js({name:"BackgroundMaterial",uniforms:Gs(ha.background.uniforms),vertexShader:ha.background.vertexShader,fragmentShader:ha.background.fragmentShader,side:f,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=y.colorSpace!==Vt,!0===y.matrixAutoUpdate&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),u===y&&d===y.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=y,d=y.version,p=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function pa(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}return c.attributesNum!==a||c.index!==i}(r,y,d,x),b&&function(e,t,n,i){const r={},s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o)if(o[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}c.attributes=r,c.attributesNum=a,c.index=i}(r,y,d,x)}else{const e=!0===l.wireframe;c.geometry===y.id&&c.program===d.id&&c.wireframe===e||(c.geometry=y.id,c.program=d.id,c.wireframe=e,b=!0)}null!==x&&n.update(x,e.ELEMENT_ARRAY_BUFFER),(b||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const t in c){const s=c[t];if(s.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||a.gpuType===Te);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),_=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,y=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?e.getParameter(e.MAX_SAMPLES):0}}function ga(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new ta,o=new Yn,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=s?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(u,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function _a(e){let t=new WeakMap;function n(e,t){return t===ae?e.mapping=re:t===oe&&(e.mapping=se),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===ae||s===oe){if(t.has(r))return n(t.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new Zs(s.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class va extends Xs{constructor(e=-1,t=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const ya=[.125,.215,.35,.446,.526,.582],xa=new va,ba=new Xr;let wa=null;const Ma=(1+Math.sqrt(5))/2,Sa=1/Ma,Ea=[new Ti(1,1,1),new Ti(-1,1,1),new Ti(1,1,-1),new Ti(-1,1,-1),new Ti(0,Ma,Sa),new Ti(0,Ma,-Sa),new Ti(Sa,0,Ma),new Ti(-Sa,0,Ma),new Ti(Ma,Sa,0),new Ti(-Ma,Sa,0)];class Ta{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){wa=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=La(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ra(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=ya[a-e+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];_.set(i,f*p*e),v.set(u,m*p*e);const r=[e,e,e,e,e,e];y.set(r,g*p*e)}const x=new xs;x.setAttribute("position",new ns(_,f)),x.setAttribute("uv",new ns(v,m)),x.setAttribute("faceIndex",new ns(y,g)),t.push(x),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new Ti(0,1,0);return new js({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new Bs(this._lodPlanes[0],e);this._renderer.compile(t,xa)}_sceneToCubeUV(e,t,n,i){const r=new qs(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(ba),o.toneMapping=Z,o.autoClear=!1;const h=new Yr({name:"PMREM.Background",side:m,depthWrite:!1,depthTest:!1}),u=new Bs(new zs,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(ba),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;Ca(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===re||e.mapping===se;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=La()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ra());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Bs(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;Ca(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,xa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(t),o.render(c,xa)}}function Aa(e,t,n){const i=new yi(e,t,n);return i.texture.mapping=le,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ca(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Ra(){return new js({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}function La(){return new js({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}function Pa(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===ae||s===oe,o=s===re||s===se;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Ta(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(s)){null===n&&(n=new Ta(e));const s=a?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,s),r.addEventListener("dispose",i),s.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Ia(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ua(e,t,n,i){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);for(const e in o.morphAttributes){const n=o.morphAttributes[e];for(let e=0,i=n.length;et.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);const m=new Float32Array(p*f*4*r),g=new xi(m,p,f,r);g.type=Ce,g.needsUpdate=!0;const _=4*d;for(let t=0;t0)return e;const r=t*n;let s=Wa[r];if(void 0===s&&(s=new Float32Array(r),Wa[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function Ja(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Yo(e,t){const n=function(e){switch(e){case Wt:return["Linear","( value )"];case Vt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Ko(e,t){let n;switch(t){case Q:n="Linear";break;case $:n="Reinhard";break;case ee:n="OptimizedCineon";break;case te:n="ACESFilmic";break;case ne:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Jo(e){return""!==e}function Zo(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Qo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const $o=/^[ \t]*#include +<([\w\d./]+)>/gm;function el(e){return e.replace($o,nl)}const tl=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function nl(e,t){let n=la[t];if(void 0===n){const e=tl.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=la[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return el(n)}const il=/#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 rl(e){return e.replace(il,sl)}function sl(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(y+="\n"),x=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Jo).join("\n"),x.length>0&&(x+="\n")):(y=[al(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Jo).join("\n"),x=[g,al(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Z?"#define TONE_MAPPING":"",n.toneMapping!==Z?la.tonemapping_pars_fragment:"",n.toneMapping!==Z?Ko("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",la.colorspace_pars_fragment,Yo("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Jo).join("\n")),a=el(a),a=Zo(a,n),a=Qo(a,n),o=el(o),o=Zo(o,n),o=Qo(o,n),a=rl(a),o=rl(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(b="#version 300 es\n",y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,x=["#define varying in",n.glslVersion===Cn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Cn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+x);const w=b+y+a,M=b+x+o,S=jo(r,r.VERTEX_SHADER,w),E=jo(r,r.FRAGMENT_SHADER,M);if(r.attachShader(v,S),r.attachShader(v,E),void 0!==n.index0AttributeName?r.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(v).trim(),n=r.getShaderInfoLog(S).trim(),i=r.getShaderInfoLog(E).trim();let s=!0,a=!0;if(!1===r.getProgramParameter(v,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,v,S,E);else{const e=qo(r,S,"vertex"),n=qo(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==i||(a=!1);a&&(this.diagnostics={runnable:s,programLog:t,vertexShader:{log:n,prefix:y},fragmentShader:{log:i,prefix:x}})}let T,A;return r.deleteShader(S),r.deleteShader(E),this.getUniforms=function(){return void 0===T&&(T=new Wo(r,v)),T},this.getAttributes=function(){return void 0===A&&(A=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,Y=s.clearcoat>0,K=s.iridescence>0,J=s.sheen>0,Q=s.transmission>0,$=q&&!!s.anisotropyMap,ee=Y&&!!s.clearcoatMap,te=Y&&!!s.clearcoatNormalMap,ne=Y&&!!s.clearcoatRoughnessMap,ie=K&&!!s.iridescenceMap,re=K&&!!s.iridescenceThicknessMap,se=J&&!!s.sheenColorMap,ae=J&&!!s.sheenRoughnessMap,oe=!!s.specularMap,ce=!!s.specularColorMap,he=!!s.specularIntensityMap,ue=Q&&!!s.transmissionMap,de=Q&&!!s.thicknessMap,pe=!!s.gradientMap,fe=!!s.alphaMap,me=s.alphaTest>0,ge=!!s.alphaHash,_e=!!s.extensions,ve=!!w.attributes.uv1,ye=!!w.attributes.uv2,xe=!!w.attributes.uv3;let be=Z;return s.toneMapped&&(null!==O&&!0!==O.isXRRenderTarget||(be=e.toneMapping)),{isWebGL2:h,shaderID:T,shaderType:s.type,shaderName:s.name,vertexShader:R,fragmentShader:L,defines:s.defines,customVertexShaderID:P,customFragmentShaderID:I,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:N,instancingColor:N&&null!==x.instanceColor,supportsVertexTextures:d,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:Wt,map:D,matcap:k,envMap:B,envMapMode:B&&S.mapping,envMapCubeUVHeight:E,aoMap:F,lightMap:z,bumpMap:G,normalMap:H,displacementMap:d&&V,emissiveMap:W,normalMapObjectSpace:H&&s.normalMapType===Gt,normalMapTangentSpace:H&&s.normalMapType===zt,metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:$,clearcoat:Y,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:J,sheenColorMap:se,sheenRoughnessMap:ae,specularMap:oe,specularColorMap:ce,specularIntensityMap:he,transmission:Q,transmissionMap:ue,thicknessMap:de,gradientMap:pe,opaque:!1===s.transparent&&s.blending===y,alphaMap:fe,alphaTest:me,alphaHash:ge,combine:s.combine,mapUv:D&&_(s.map.channel),aoMapUv:F&&_(s.aoMap.channel),lightMapUv:z&&_(s.lightMap.channel),bumpMapUv:G&&_(s.bumpMap.channel),normalMapUv:H&&_(s.normalMap.channel),displacementMapUv:V&&_(s.displacementMap.channel),emissiveMapUv:W&&_(s.emissiveMap.channel),metalnessMapUv:j&&_(s.metalnessMap.channel),roughnessMapUv:X&&_(s.roughnessMap.channel),anisotropyMapUv:$&&_(s.anisotropyMap.channel),clearcoatMapUv:ee&&_(s.clearcoatMap.channel),clearcoatNormalMapUv:te&&_(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&_(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&_(s.iridescenceMap.channel),iridescenceThicknessMapUv:re&&_(s.iridescenceThicknessMap.channel),sheenColorMapUv:se&&_(s.sheenColorMap.channel),sheenRoughnessMapUv:ae&&_(s.sheenRoughnessMap.channel),specularMapUv:oe&&_(s.specularMap.channel),specularColorMapUv:ce&&_(s.specularColorMap.channel),specularIntensityMapUv:he&&_(s.specularIntensityMap.channel),transmissionMapUv:ue&&_(s.transmissionMap.channel),thicknessMapUv:de&&_(s.thicknessMap.channel),alphaMapUv:fe&&_(s.alphaMap.channel),vertexTangents:!!w.attributes.tangent&&(H||q),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!w.attributes.color&&4===w.attributes.color.itemSize,vertexUv1s:ve,vertexUv2s:ye,vertexUv3s:xe,pointsUvs:!0===x.isPoints&&!!w.attributes.uv&&(D||fe),fog:!!b,useFog:!0===s.fog,fogExp2:b&&b.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===x.isSkinnedMesh,morphTargets:void 0!==w.morphAttributes.position,morphNormals:void 0!==w.morphAttributes.normal,morphColors:void 0!==w.morphAttributes.color,morphTargetsCount:C,morphTextureStride:U,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:be,useLegacyLights:e._useLegacyLights,decodeVideoTexture:D&&!0===s.map.isVideoTexture&&s.map.colorSpace===Vt,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===g,flipSided:s.side===m,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:_e&&!0===s.extensions.derivatives,extensionFragDepth:_e&&!0===s.extensions.fragDepth,extensionDrawBuffers:_e&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:_e&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=ha[t];n=Ws.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||pl),i.length>1&&i.sort(t||fl),r.length>1&&r.sort(t||fl)}}}function gl(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new ml,e.set(t,[r])):n>=i.length?(r=new ml,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function _l(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Ti,color:new Xr};break;case"SpotLight":n={position:new Ti,direction:new Ti,color:new Xr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ti,color:new Xr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ti,skyColor:new Xr,groundColor:new Xr};break;case"RectAreaLight":n={color:new Xr,position:new Ti,halfWidth:new Ti,halfHeight:new Ti}}return e[t.id]=n,n}}}let vl=0;function yl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function xl(e,t){const n=new _l,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)r.probe.push(new Ti);const s=new Ti,a=new nr,o=new nr;return{setup:function(s,a){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0;s.sort(yl);const x=!0===a?Math.PI:1;for(let e=0,t=s.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ca.LTC_FLOAT_1,r.rectAreaLTC2=ca.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=ca.LTC_HALF_1,r.rectAreaLTC2=ca.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const b=r.hash;b.directionalLength===h&&b.pointLength===u&&b.spotLength===d&&b.rectAreaLength===p&&b.hemiLength===f&&b.numDirectionalShadows===m&&b.numPointShadows===g&&b.numSpotShadows===_&&b.numSpotMaps===v||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=_+v-y,r.spotLightMap.length=v,r.numSpotLightShadowsWithMaps=y,b.directionalLength=h,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=f,b.numDirectionalShadows=m,b.numPointShadows=g,b.numSpotShadows=_,b.numSpotMaps=v,r.version=vl++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t=s.length?(a=new bl(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class Ml extends Gr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bt,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 Sl extends Gr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function El(e,t,n){let i=new ra;const r=new qn,s=new qn,a=new _i,o=new Ml({depthPacking:Ft}),l=new Sl,c={},h=n.maxTextureSize,d={[f]:m,[m]:f,[g]:g},_=new js({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),y=_.clone();y.defines.HORIZONTAL_PASS=1;const x=new xs;x.setAttribute("position",new ns(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Bs(x,_),w=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=u;let M=this.type;function S(n,i){const s=t.update(b);_.defines.VSM_SAMPLES!==n.blurSamples&&(_.defines.VSM_SAMPLES=n.blurSamples,y.defines.VSM_SAMPLES=n.blurSamples,_.needsUpdate=!0,y.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new yi(r.x,r.y)),_.uniforms.shadow_pass.value=n.map.texture,_.uniforms.resolution.value=n.mapSize,_.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,_,b,null),y.uniforms.shadow_pass.value=n.mapPass.texture,y.uniforms.resolution.value=n.mapSize,y.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,y,b,null)}function E(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===p?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(e.properties.get(s).light=i),s}function T(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===p)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/g.x),r.x=s.x*g.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/g.y),r.y=s.y*g.y,u.mapSize.y=s.y)),null===u.map||!0===f||!0===m){const e=this.type!==p?{minFilter:de,magFilter:de}:{};null!==u.map&&u.map.dispose(),u.map=new yi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const _=u.getViewportCount();for(let e=0;e<_;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(c,e),i=u.getFrustum(),T(n,o,u.camera,c,this.type)}!0!==u.isPointLightShadow&&this.type===p&&S(u,o),u.needsUpdate=!1}M=this.type,w.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function Tl(e,t,n){const i=n.isWebGL2,r=new function(){let t=!1;const n=new _i;let i=null;const r=new _i(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,s,a,o){!0===o&&(t*=a,i*=a,s*=a),n.set(t,i,s,a),!1===r.equals(n)&&(e.clearColor(t,i,s,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,n=null,i=null,r=null;return{setTest:function(t){t?be(e.DEPTH_TEST):we(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case z:e.depthFunc(e.NEVER);break;case G:e.depthFunc(e.ALWAYS);break;case H:e.depthFunc(e.LESS);break;case V:e.depthFunc(e.LEQUAL);break;case W:e.depthFunc(e.EQUAL);break;case j:e.depthFunc(e.GEQUAL);break;case X:e.depthFunc(e.GREATER);break;case q:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},c=new function(){let t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?be(e.STENCIL_TEST):we(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&s===a||(e.stencilFunc(t,n,a),i=t,r=n,s=a)},setOp:function(t,n,i){a===t&&o===n&&l===i||(e.stencilOp(t,n,i),a=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},h=new WeakMap,u=new WeakMap;let d={},p={},f=new WeakMap,_=[],Y=null,K=!1,J=null,Z=null,Q=null,$=null,ee=null,te=null,ne=null,ie=!1,re=null,se=null,ae=null,oe=null,le=null;const ce=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let he=!1,ue=0;const de=e.getParameter(e.VERSION);-1!==de.indexOf("WebGL")?(ue=parseFloat(/^WebGL (\d)/.exec(de)[1]),he=ue>=1):-1!==de.indexOf("OpenGL ES")&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),he=ue>=2);let pe=null,fe={};const me=e.getParameter(e.SCISSOR_BOX),ge=e.getParameter(e.VIEWPORT),_e=(new _i).fromArray(me),ve=(new _i).fromArray(ge);function ye(t,n,r,s){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?Vn:Math.floor,s=i(r*e.width),a=i(r*e.height);void 0===m&&(m=v(s,a));const o=n?v(s,a):m;return o.width=s,o.height=a,o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function x(e){return Gn(e.width)&&Gn(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==de&&e.minFilter!==_e}function w(t){e.generateMipmap(t)}function M(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(l=e.R8UI),r===e.UNSIGNED_SHORT&&(l=e.R16UI),r===e.UNSIGNED_INT&&(l=e.R32UI),r===e.BYTE&&(l=e.R8I),r===e.SHORT&&(l=e.R16I),r===e.INT&&(l=e.R32I)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=s===Vt&&!1===a?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function S(e,t,n){return!0===b(e,n)||e.isFramebufferTexture&&e.minFilter!==de&&e.minFilter!==_e?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===de||t===pe||t===me?e.NEAREST:e.LINEAR}function T(e){const t=e.target;t.removeEventListener("dispose",T),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=t.texture,r=i.get(t),s=i.get(n);if(void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(r.__webglFramebuffer[t]))for(let n=0;n0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void D(s,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const P={[ce]:e.REPEAT,[he]:e.CLAMP_TO_EDGE,[ue]:e.MIRRORED_REPEAT},I={[de]:e.NEAREST,[pe]:e.NEAREST_MIPMAP_NEAREST,[me]:e.NEAREST_MIPMAP_LINEAR,[_e]:e.LINEAR,[ve]:e.LINEAR_MIPMAP_NEAREST,[xe]:e.LINEAR_MIPMAP_LINEAR},U={[hn]:e.NEVER,[_n]:e.ALWAYS,[un]:e.LESS,[pn]:e.LEQUAL,[dn]:e.EQUAL,[gn]:e.GEQUAL,[fn]:e.GREATER,[mn]:e.NOTEQUAL};function O(n,s,a){if(a?(e.texParameteri(n,e.TEXTURE_WRAP_S,P[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,P[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,P[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[s.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),s.wrapS===he&&s.wrapT===he||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(s.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(s.minFilter)),s.minFilter!==de&&s.minFilter!==_e&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,U[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.magFilter===de)return;if(s.minFilter!==me&&s.minFilter!==xe)return;if(s.type===Ce&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===Re&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function N(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));const r=n.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function D(t,r,a){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=N(t,r),u=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!o&&(e.wrapS!==he||e.wrapT!==he||e.minFilter!==de&&e.minFilter!==_e)}(r)&&!1===x(r.image);let i=y(r.image,t,!1,h);i=H(r,i);const p=x(i)||o,f=s.convert(r.format,r.colorSpace);let m,g=s.convert(r.type),_=M(r.internalFormat,f,g,r.colorSpace,r.isVideoTexture);O(l,r,p);const v=r.mipmaps,E=o&&!0!==r.isVideoTexture,T=void 0===d.__version||!0===c,A=S(r,i,p);if(r.isDepthTexture)_=e.DEPTH_COMPONENT,o?_=r.type===Ce?e.DEPTH_COMPONENT32F:r.type===Ae?e.DEPTH_COMPONENT24:r.type===Ie?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===Ce&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===ke&&_===e.DEPTH_COMPONENT&&r.type!==Ee&&r.type!==Ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ae,g=s.convert(r.type)),r.format===Be&&_===e.DEPTH_COMPONENT&&(_=e.DEPTH_STENCIL,r.type!==Ie&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ie,g=s.convert(r.type))),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,_,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,_,i.width,i.height,0,f,g,null));else if(r.isDataTexture)if(v.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t>=1,r>>=1}}else if(v.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t>c),i=Math.max(1,r.height>>c);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,c,p,t,i,r.depth,0,h,u,null):n.texImage2D(l,c,p,t,i,0,h,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),G(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0,z(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function B(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||G(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Ce?r=e.DEPTH_COMPONENT32F:t.type===Ae&&(r=e.DEPTH_COMPONENT24));const i=z(n);G(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=z(n);i&&!1===G(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):G(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function H(e,n){const i=e.colorSpace,r=e.format,s=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===Rn||i!==Wt&&i!==Ht&&(i===Vt||i===jt?!1===o?!0===t.has("EXT_sRGB")&&r===Oe?(e.format=Rn,e.minFilter=_e,e.generateMipmaps=!1):n=ui.sRGBToLinear(n):r===Oe&&s===we||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=R;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=L,this.setTexture2DArray=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?D(s,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?D(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=i.get(h);if(h.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:y(r.image[e],!1,!0,c),d[e]=H(r,d[e]);const p=d[0],f=x(p)||o,m=s.convert(r.format,r.colorSpace),g=s.convert(r.type),_=M(r.internalFormat,m,g,r.colorSpace),v=o&&!0!==r.isVideoTexture,E=void 0===u.__version||!0===l;let T,A=S(r,p,f);if(O(e.TEXTURE_CUBE_MAP,r,f),t){v&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,p.width,p.height);for(let t=0;t<6;t++){T=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,m,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,d[t].width,d[t].height,0,m,g,d[t].data);for(let i=0;i0){c.__webglFramebuffer[t]=[];for(let n=0;n0){c.__webglFramebuffer=[];for(let t=0;t0&&!1===G(t)){const i=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0&&!1===G(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Pl)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Ll;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ul extends gi{constructor(e,t,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:ke)!==ke&&c!==Be)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===ke&&(n=Ae),void 0===n&&c===Be&&(n=Ie),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:de,this.minFilter=void 0!==o?o:de,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Ol extends In{constructor(e,t){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=t.getContextAttributes();let m=null,g=null;const _=[],v=[],y=new qs;y.layers.enable(1),y.viewport=new _i;const x=new qs;x.layers.enable(2),x.viewport=new _i;const b=[y,x],w=new Rl;w.layers.enable(1),w.layers.enable(2);let M=null,S=null;function E(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function T(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",A);for(let e=0;e<_.length;e++){const t=v[e];null!==t&&(v[e]=null,_[e].disconnect(t))}M=null,S=null,e.setRenderTarget(m),d=null,u=null,h=null,i=null,g=null,I.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function A(e){for(let t=0;t=0&&(v[i]=null,_[i].disconnect(n))}for(let t=0;t=v.length){v.push(n),i=e;break}if(null===v[e]){v[e]=n,i=e;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",E),i.addEventListener("selectstart",E),i.addEventListener("selectend",E),i.addEventListener("squeeze",E),i.addEventListener("squeezestart",E),i.addEventListener("squeezeend",E),i.addEventListener("end",T),i.addEventListener("inputsourceschange",A),!0!==f.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new yi(d.framebufferWidth,d.framebufferHeight,{format:Oe,type:we,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,s=null,a=null;f.depth&&(a=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?Be:ke,s=f.stencil?Ie:Ae);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new yi(u.textureWidth,u.textureHeight,{format:Oe,type:we,depthTexture:new Ul(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const C=new Ti,R=new Ti;function L(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;w.near=x.near=y.near=e.near,w.far=x.far=y.far=e.far,M===w.near&&S===w.far||(i.updateRenderState({depthNear:w.near,depthFar:w.far}),M=w.near,S=w.far);const t=e.parent,n=w.cameras;L(w,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const s=t.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Vs(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform)),t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===m&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Dl(e,t,n,i){let r={},s={},a=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0){i=n%16;const e=16-i;0!==i&&e-s.boundary<0&&(n+=16-i,r.__offset=n)}n+=s.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=Z;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(f=w.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,_=ne.get(i),v=y.state.lights;if(!0===V&&(!0===W||e!==C)){const t=e===C&&i.id===A;pe.setState(i,e,t)}let x=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version||_.outputColorSpace!==o||r.isInstancedMesh&&!1===_.instancing?x=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?x=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||_.envMap!==l||!0===i.fog&&_.fog!==s?x=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===pe.numPlanes&&_.numIntersection===pe.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==h||_.morphTargets!==u||_.morphNormals!==d||_.morphColors!==p||_.toneMapping!==f||!0===$.isWebGL2&&_.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:(x=!0,_.__version=i.version);let b=_.currentProgram;!0===x&&(b=Ze(i,t,r));let M=!1,S=!1,E=!1;const R=b.getUniforms(),L=_.uniforms;if(ee.useProgram(b.program)&&(M=!0,S=!0,E=!0),i.id!==A&&(A=i.id,S=!0),M||C!==e){R.setValue(Se,"projectionMatrix",e.projectionMatrix),R.setValue(Se,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(Se,Y.setFromMatrixPosition(e.matrixWorld)),$.logarithmicDepthBuffer&&R.setValue(Se,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(Se,"isOrthographic",!0===e.isOrthographicCamera),C!==e&&(C=e,S=!0,E=!0)}if(r.isSkinnedMesh){R.setOptional(Se,r,"bindMatrix"),R.setOptional(Se,r,"bindMatrixInverse");const e=r.skeleton;e&&($.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(Se,"boneTexture",e.boneTexture,ie),R.setValue(Se,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const P=n.morphAttributes;var I,U;if((void 0!==P.position||void 0!==P.normal||void 0!==P.color&&!0===$.isWebGL2)&&ge.update(r,n,b),(S||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Se,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),S&&(R.setValue(Se,"toneMappingExposure",w.toneMappingExposure),_.needsLights&&(U=E,(I=L).ambientLightColor.needsUpdate=U,I.lightProbe.needsUpdate=U,I.directionalLights.needsUpdate=U,I.directionalLightShadows.needsUpdate=U,I.pointLights.needsUpdate=U,I.pointLightShadows.needsUpdate=U,I.spotLights.needsUpdate=U,I.spotLightShadows.needsUpdate=U,I.rectAreaLights.needsUpdate=U,I.hemisphereLights.needsUpdate=U),s&&!0===i.fog&&he.refreshFogUniforms(L,s),he.refreshMaterialUniforms(L,i,D,N,j),Wo.upload(Se,_.uniformsList,L,ie)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Wo.upload(Se,_.uniformsList,L,ie),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(Se,"center",r.center),R.setValue(Se,"modelViewMatrix",r.modelViewMatrix),R.setValue(Se,"normalMatrix",r.normalMatrix),R.setValue(Se,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){const r=$.isWebGL2;null===j&&(j=new yi(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?Re:we,minFilter:xe,samples:r?4:0})),w.getDrawingBufferSize(q),r?j.setSize(q.x,q.y):j.setSize(Vn(q.x),Vn(q.y));const s=w.getRenderTarget();w.setRenderTarget(j),w.getClearColor(I),U=w.getClearAlpha(),U<1&&w.setClearColor(16777215,.5),w.clear();const a=w.toneMapping;w.toneMapping=Z,Ke(e,n,i),ie.updateMultisampleRenderTarget(j),ie.updateRenderTargetMipmap(j);let o=!1;for(let e=0,r=t.length;e0&&Ke(r,t,n),s.length>0&&Ke(s,t,n),a.length>0&&Ke(a,t,n),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function Ke(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r0?b[b.length-1]:null,x.pop(),v=x.length>0?x[x.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n;const i=ne.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===Q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=ne.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){T=e,S=t,E=n;let i=!0,r=null,s=!1,a=!1;if(e){const o=ne.get(e);void 0!==o.__useDefaultFramebuffer?(ee.bindFramebuffer(Se.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?ie.setupRenderTarget(e):o.__hasExternalTextures&&ie.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],s=!0):r=$.isWebGL2&&e.samples>0&&!1===ie.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,R.copy(e.viewport),L.copy(e.scissor),P=e.scissorTest}else R.copy(F).multiplyScalar(D).floor(),L.copy(z).multiplyScalar(D).floor(),P=G;if(ee.bindFramebuffer(Se.FRAMEBUFFER,r)&&$.drawBuffers&&i&&ee.drawBuffers(e,r),ee.viewport(R),ee.scissor(L),ee.setScissorTest(P),s){const i=ne.get(e.texture);Se.framebufferTexture2D(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,Se.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=ne.get(e.texture),r=t||0;Se.framebufferTextureLayer(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}A=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){ee.bindFramebuffer(Se.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(o!==Oe&&ye.convert(o)!==Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Re&&(Q.has("EXT_color_buffer_half_float")||$.isWebGL2&&Q.has("EXT_color_buffer_float"));if(!(l===we||ye.convert(l)===Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_TYPE)||l===Ce&&($.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Se.readPixels(t,n,i,r,ye.convert(o),ye.convert(l),s)}finally{const e=null!==T?ne.get(T).__webglFramebuffer:null;ee.bindFramebuffer(Se.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i);ie.setTexture2D(t,0),Se.copyTexSubImage2D(Se.TEXTURE_2D,n,0,0,e.x,e.y,r,s),ee.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,s=t.image.height,a=ye.convert(n.format),o=ye.convert(n.type);ie.setTexture2D(n,0),Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,n.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?Se.compressedTexSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,a,o,t.image),0===i&&n.generateMipmaps&&Se.generateMipmap(Se.TEXTURE_2D),ee.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(w.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=ye.convert(i.format),c=ye.convert(i.type);let h;if(i.isData3DTexture)ie.setTexture3D(i,0),h=Se.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");ie.setTexture2DArray(i,0),h=Se.TEXTURE_2D_ARRAY}Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,i.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Se.getParameter(Se.UNPACK_ROW_LENGTH),d=Se.getParameter(Se.UNPACK_IMAGE_HEIGHT),p=Se.getParameter(Se.UNPACK_SKIP_PIXELS),f=Se.getParameter(Se.UNPACK_SKIP_ROWS),m=Se.getParameter(Se.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Se.pixelStorei(Se.UNPACK_ROW_LENGTH,g.width),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,g.height),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,e.min.x),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,e.min.y),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Se.compressedTexSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,g.data)):Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g),Se.pixelStorei(Se.UNPACK_ROW_LENGTH,u),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,d),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,p),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,f),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&Se.generateMipmap(h),ee.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?ie.setTextureCube(e,0):e.isData3DTexture?ie.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ie.setTexture2DArray(e,0):ie.setTexture2D(e,0),ee.unbindTexture()},this.resetState=function(){S=0,E=0,T=null,ee.reset(),be.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ln}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Vt?kt:Dt}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===kt?Vt:Wt}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Bl extends kl{}Bl.prototype.isWebGL1Renderer=!0;class Fl{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Xr(e),this.density=t}clone(){return new Fl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class zl{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Xr(e),this.near=t,this.far=n}clone(){return new zl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Gl extends Ar{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class Hl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=vn,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=kn()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:ql.clone(),uv:Fr.getInterpolation(ql,$l,ec,tc,nc,ic,rc,new qn),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function ac(e,t,n,i,r,s){Jl.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Zl.x=s*Jl.x-r*Jl.y,Zl.y=r*Jl.x+s*Jl.y):Zl.copy(Jl),e.copy(t),e.x+=Zl.x,e.y+=Zl.y,e.applyMatrix4(Ql)}const oc=new Ti,lc=new Ti;class cc extends Ar{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){oc.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(oc);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){oc.setFromMatrixPosition(e.matrixWorld),lc.setFromMatrixPosition(this.matrixWorld);const n=oc.distanceTo(lc)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;io)continue;u.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(u);se.far||t.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,s.start),i=Math.min(f.count,s.start+s.count)-1;no)continue;u.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(u);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class Qc extends gi{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:_e,this.magFilter=void 0!==r?r:_e,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class $c extends gi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=de,this.minFilter=de,this.generateMipmaps=!1,this.needsUpdate=!0}}class eh extends gi{constructor(e,t,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class th extends eh{constructor(e,t,n,i,r,s){super(e,t,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=he}}class nh extends eh{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,re),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class ih extends gi{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let s;s=t||e*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new qn:new Ti);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Ti,i=[],r=[],s=[],a=new Ti,o=new nr;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Ti)}r[0]=new Ti,s[0]=new Ti;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Bn(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(Bn(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sh extends rh{constructor(e=0,t=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const n=t||new qn,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(lh.subVectors(i[0],i[1]).add(i[0]),a=lh);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(ph(a,o.x,l.x,c.x,h.x),ph(a,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Th extends xs{constructor(e=[new qn(0,-.5),new qn(.5,0),new qn(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Bn(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/t,h=new Ti,u=new qn,d=new Ti,p=new Ti,f=new Ti;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=t;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=e.length-1;n++){h.x=e[n].x*p,h.y=e[n].y,h.z=e[n].x*f,s.push(h.x,h.y,h.z),u.x=r/t,u.y=n/(e.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new us(h,3)),this.setAttribute("normal",new us(u,3)),this.setAttribute("uv",new us(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Lh extends Rh{constructor(e=1,t=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,e,t,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Lh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ph extends xs{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new us(r,3)),this.setAttribute("normal",new us(r.slice(),3)),this.setAttribute("uv",new us(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ph(e.vertices,e.indices,e.radius,e.details)}}class Ih extends Ph{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ih(e.radius,e.detail)}}const Uh=new Ti,Oh=new Ti,Nh=new Ti,Dh=new Fr;class kh extends xs{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(Nn*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let e=0;e0)for(s=t;s=t;s-=i)a=au(s,e[s],e[s+1],a);return a&&eu(a,a.next)&&(ou(a),a=a.next),a}function zh(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!eu(i,i.next)&&0!==$h(i.prev,i,i.next))i=i.next;else{if(ou(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Gh(e,t,n,i,r,s,a){if(!e)return;!a&&s&&function(e,t,n,i){let r=e;do{0===r.z&&(r.z=Kh(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,s,a,o,l,c=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(e,i,r,s);let o,l,c=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?Vh(e,i,r,s):Hh(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),ou(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Gh(e=Wh(zh(e),t,n),t,n,i,r,s,2):2===a&&jh(e,t,n,i,r,s):Gh(zh(e),t,n,i,r,s,1);break}}function Hh(e){const t=e.prev,n=e,i=e.next;if($h(t,n,i)>=0)return!1;const r=t.x,s=n.x,a=i.x,o=t.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Zh(r,o,s,l,a,c,f.x,f.y)&&$h(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Vh(e,t,n,i){const r=e.prev,s=e,a=e.next;if($h(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,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,_=Kh(p,f,t,n,i),v=Kh(m,g,t,n,i);let y=e.prevZ,x=e.nextZ;for(;y&&y.z>=_&&x&&x.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Zh(o,h,l,u,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zh(o,h,l,u,c,d,x.x,x.y)&&$h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Zh(o,h,l,u,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zh(o,h,l,u,c,d,x.x,x.y)&&$h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Wh(e,t,n){let i=e;do{const r=i.prev,s=i.next.next;!eu(r,s)&&tu(r,i,i.next,s)&&ru(r,s)&&ru(s,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(s.i/n|0),ou(i),ou(i.next),i=e=s),i=i.next}while(i!==e);return zh(i)}function jh(e,t,n,i,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Qh(a,e)){let o=su(a,e);return a=zh(a,a.next),o=zh(o,o.next),Gh(a,t,n,i,r,s,0),void Gh(o,t,n,i,r,s,0)}e=e.next}a=a.next}while(a!==e)}function Xh(e,t){return e.x-t.x}function qh(e,t){const n=function(e,t){let n,i=t,r=-1/0;const s=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,n=i.x=i.x&&i.x>=l&&s!==i.x&&Zh(an.x||i.x===n.x&&Yh(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(e,t);if(!n)return t;const i=su(n,e);return zh(i,i.next),zh(n,n.next)}function Yh(e,t){return $h(e.prev,e,t.prev)<0&&$h(t.next,e,e.next)<0}function Kh(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Jh(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(i-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function Qh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&tu(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(ru(e,t)&&ru(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&($h(e.prev,e,t.prev)||$h(e,t.prev,t))||eu(e,t)&&$h(e.prev,e,e.next)>0&&$h(t.prev,t,t.next)>0)}function $h(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function eu(e,t){return e.x===t.x&&e.y===t.y}function tu(e,t,n,i){const r=iu($h(e,t,n)),s=iu($h(e,t,i)),a=iu($h(n,i,e)),o=iu($h(n,i,t));return r!==s&&a!==o||!(0!==r||!nu(e,n,t))||!(0!==s||!nu(e,i,t))||!(0!==a||!nu(n,e,i))||!(0!==o||!nu(n,t,i))}function nu(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function iu(e){return e>0?1:e<0?-1:0}function ru(e,t){return $h(e.prev,e,e.next)<0?$h(e,t,e.next)>=0&&$h(e,e.prev,t)>=0:$h(e,t,e.prev)<0||$h(e,e.next,t)<0}function su(e,t){const n=new lu(e.i,e.x,e.y),i=new lu(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function au(e,t,n,i){const r=new lu(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ou(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function lu(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class cu{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){o=c=e[0],l=h=e[1];for(let t=n;tc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Gh(s,a,n,o,l,p,0),a}(n,i);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function uu(e,t){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-o/u,f=t.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-e.x,r=f+o*m-e.y;const g=i*i+r*r;if(g<=2)return new qn(i,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new qn(i/s,r/s)}const P=[];for(let e=0,t=T.length,n=t-1,i=e+1;e=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=T.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=o+2*p;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Lu extends Gr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Xr(16777215),this.specular=new Xr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,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 Pu extends Gr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Xr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Iu extends Gr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Uu extends Gr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,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 Ou extends Gr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Xr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Nu extends Oc{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 Du(e,t,n){return Bu(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function ku(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Fu(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function zu(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Gu(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}const Hu={arraySlice:Du,convertArray:ku,isTypedArray:Bu,getKeyframeOrder:Fu,sortedArray:zu,flattenJSON:Gu,subclip:function(e,t,n,i,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;ns.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e=i.times[u]){const e=u*l+o,t=e+l-o;d=Du(i.values,e,t)}else{const e=i.createInterpolant(),t=o,n=l-o;e.evaluate(s),d=Du(e.resultBuffer,t,n)}"quaternion"===r&&(new Ei).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let e=0;e=r)break e;{const a=t[1];e=r)break t}s=n,n=0}}for(;n>>1;et;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=Du(n,r,s),this.values=Du(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&Bu(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Du(this.times),t=Du(this.values),n=this.getValueSize(),i=this.getInterpolation()===At,r=e.length-1;let s=1;for(let a=1;a0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=Du(e,0,s),this.values=Du(t,0,s*n)):(this.times=e,this.values=t),this}clone(){const e=Du(this.times,0),t=Du(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}qu.prototype.TimeBufferType=Float32Array,qu.prototype.ValueBufferType=Float32Array,qu.prototype.DefaultInterpolation=Tt;class Yu extends qu{}Yu.prototype.ValueTypeName="bool",Yu.prototype.ValueBufferType=Array,Yu.prototype.DefaultInterpolation=Et,Yu.prototype.InterpolantFactoryMethodLinear=void 0,Yu.prototype.InterpolantFactoryMethodSmooth=void 0;class Ku extends qu{}Ku.prototype.ValueTypeName="color";class Ju extends qu{}Ju.prototype.ValueTypeName="number";class Zu extends Vu{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Ei.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Qu extends qu{InterpolantFactoryMethodLinear(e){return new Zu(this.times,this.values,this.getValueSize(),e)}}Qu.prototype.ValueTypeName="quaternion",Qu.prototype.DefaultInterpolation=Tt,Qu.prototype.InterpolantFactoryMethodSmooth=void 0;class $u extends qu{}$u.prototype.ValueTypeName="string",$u.prototype.ValueBufferType=Array,$u.prototype.DefaultInterpolation=Et,$u.prototype.InterpolantFactoryMethodLinear=void 0,$u.prototype.InterpolantFactoryMethodSmooth=void 0;class ed extends qu{}ed.prototype.ValueTypeName="vector";class td{constructor(e,t=-1,n,i=Pt){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=kn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(nd(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(qu.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const s=[],a=[];Gu(n,s,a,i),0!==s.length&&r.push(new e(t,s,a))}},i=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==od[e])return void od[e].push({onLoad:t,onProgress:n,onError:i});od[e]=[],od[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=od[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{id.add(e,t);const n=od[e];delete od[e];for(let e=0,i=n.length;e{const n=od[e];if(void 0===n)throw this.manager.itemError(e),t;delete od[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class hd extends ad{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new cd(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new Xr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new qn).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Ti).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new _i).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new Yn).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new nr).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new qn).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new qn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Tu,SpriteMaterial:jl,RawShaderMaterial:Au,ShaderMaterial:js,PointsMaterial:jc,MeshPhysicalMaterial:Ru,MeshStandardMaterial:Cu,MeshPhongMaterial:Lu,MeshToonMaterial:Pu,MeshNormalMaterial:Iu,MeshLambertMaterial:Uu,MeshDepthMaterial:Ml,MeshDistanceMaterial:Sl,MeshBasicMaterial:Yr,MeshMatcapMaterial:Ou,LineDashedMaterial:Nu,LineBasicMaterial:Oc,Material:Gr}[e]}}class Dd{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){const n=new rd(t);r=new dd(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new dd(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Ei.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const s=this._workIndex*r;Ei.multiplyQuaternionsFlat(e,s,e,t,e,n),Ei.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[n+s]*i}}}const fp=new RegExp("[\\[\\]\\.:\\/]","g"),mp="[^\\[\\]\\.:\\/]",gp="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",_p=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",mp)+/(WCOD+)?/.source.replace("WCOD",gp)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",mp)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",mp)+"$"),vp=["material","materials","bones","map"];class yp{constructor(e,t,n){this.path=t,this.parsedPath=n||yp.parseTrackName(t),this.node=yp.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new yp.Composite(e,t,n):new yp(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fp,"")}static parseTrackName(e){const t=_p.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==vp.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[o]=s,e[s]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[s],r=t[l];t[l]=i,t[s]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,s.push(e),a.push(t),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new yp(i,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class bp{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,s=r.length,a=new Array(s),o={endingStart:Ct,endingEnd:Ct};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Mt,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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=i/n,s=n/i;e.warp(1,r,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/s,l[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case It:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);break;case Pt:default:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const s=n===St;if(0===e)return-1===r?i:s&&1==(1&r)?t-i:i;if(n===wt){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Rt,i.endingEnd=Rt):(i.endingStart=e?this.zeroSlopeAtStart?Rt:Ct:Lt,i.endingEnd=t?this.zeroSlopeAtEnd?Rt:Ct:Lt)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}const wp=new Float32Array(1);class Mp extends In{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[e]=h;else{if(h=s[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;h=new pp(yp.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[e]=h}a[e].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==n;++a)t[a]._update(i,e,r,s);const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Op).distanceTo(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}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 Dp=new Ti,kp=new Ti;class Bp{constructor(e=new Ti,t=new Ti){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){Dp.subVectors(e,this.start),kp.subVectors(this.end,this.start);const n=kp.dot(kp);let i=kp.dot(Dp)/n;return t&&(i=Bn(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).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 Fp=new Ti;class zp extends Ar{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new xs,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{df.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(df,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class gf extends Vc{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new xs;n.setAttribute("position",new us(t,3)),n.setAttribute("color",new us([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Oc({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const i=new Xr,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class _f{constructor(){this.type="ShapePath",this.color=new Xr,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Eh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,s){return this.currentPath.bezierCurveTo(e,t,n,i,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[r],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const n=cu.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Bh,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=e?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let t=0,a=i.length;t1){let e=!1,n=0;for(let e=0,t=h.length;e0&&!1===e&&(p=c)}for(let e=0,t=h.length;e{"use strict";n.d(t,{z:()=>h});var i=n(477);const r={type:"change"},s={type:"start"},a={type:"end"},o=new i.Ray,l=new i.Plane,c=Math.cos(70*i.MathUtils.DEG2RAD);class h extends i.EventDispatcher{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new i.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN},this.touches={ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return p.phi},this.getAzimuthalAngle=function(){return p.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",$),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",$),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),u=h.NONE},this.update=function(){const t=new i.Vector3,s=(new i.Quaternion).setFromUnitVectors(e.up,new i.Vector3(0,1,0)),a=s.clone().invert(),_=new i.Vector3,v=new i.Quaternion,y=new i.Vector3,x=2*Math.PI;return function(b=null){const w=n.object.position;t.copy(w).sub(n.target),t.applyQuaternion(s),p.setFromVector3(t),n.autoRotate&&u===h.NONE&&I(function(e){return null!==e?2*Math.PI/60*n.autoRotateSpeed*e:2*Math.PI/60/60*n.autoRotateSpeed}(b)),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let M=n.minAzimuthAngle,S=n.maxAzimuthAngle;isFinite(M)&&isFinite(S)&&(M<-Math.PI?M+=x:M>Math.PI&&(M-=x),S<-Math.PI?S+=x:S>Math.PI&&(S-=x),p.theta=M<=S?Math.max(M,Math.min(S,p.theta)):p.theta>(M+S)/2?Math.max(M,p.theta):Math.min(S,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(g,n.dampingFactor):n.target.add(g),n.zoomToCursor&&C||n.object.isOrthographicCamera?p.radius=z(p.radius):p.radius=z(p.radius*m),t.setFromSpherical(p),t.applyQuaternion(a),w.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,g.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),g.set(0,0,0));let E=!1;if(n.zoomToCursor&&C){let r=null;if(n.object.isPerspectiveCamera){const e=t.length();r=z(e*m);const i=e-r;n.object.position.addScaledVector(T,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const e=new i.Vector3(A.x,A.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),E=!0;const s=new i.Vector3(A.x,A.y,0);s.unproject(n.object),n.object.position.sub(s).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==r&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(o.origin.copy(n.object.position),o.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(o.direction))d||8*(1-v.dot(n.object.quaternion))>d||y.distanceToSquared(n.target)>0)&&(n.dispatchEvent(r),_.copy(n.object.position),v.copy(n.object.quaternion),y.copy(n.target),E=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",ee),n.domElement.removeEventListener("pointerdown",K),n.domElement.removeEventListener("pointercancel",Z),n.domElement.removeEventListener("wheel",Q),n.domElement.removeEventListener("pointermove",J),n.domElement.removeEventListener("pointerup",Z),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",$),n._domElementKeyEvents=null)};const n=this,h={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=h.NONE;const d=1e-6,p=new i.Spherical,f=new i.Spherical;let m=1;const g=new i.Vector3,_=new i.Vector2,v=new i.Vector2,y=new i.Vector2,x=new i.Vector2,b=new i.Vector2,w=new i.Vector2,M=new i.Vector2,S=new i.Vector2,E=new i.Vector2,T=new i.Vector3,A=new i.Vector2;let C=!1;const R=[],L={};function P(){return Math.pow(.95,n.zoomSpeed)}function I(e){f.theta-=e}function U(e){f.phi-=e}const O=function(){const e=new i.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),g.add(e)}}(),N=function(){const e=new i.Vector3;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),g.add(e)}}(),D=function(){const e=new i.Vector3;return function(t,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const s=n.object.position;e.copy(s).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),O(2*t*a/r.clientHeight,n.object.matrix),N(2*i*a/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(O(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),N(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function k(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?m/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function B(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?m*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function F(e){if(!n.zoomToCursor)return;C=!0;const t=n.domElement.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=t.width,a=t.height;A.x=i/s*2-1,A.y=-r/a*2+1,T.set(A.x,A.y,1).unproject(n.object).sub(n.object.position).normalize()}function z(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function G(e){_.set(e.clientX,e.clientY)}function H(e){x.set(e.clientX,e.clientY)}function V(){if(1===R.length)_.set(R[0].pageX,R[0].pageY);else{const e=.5*(R[0].pageX+R[1].pageX),t=.5*(R[0].pageY+R[1].pageY);_.set(e,t)}}function W(){if(1===R.length)x.set(R[0].pageX,R[0].pageY);else{const e=.5*(R[0].pageX+R[1].pageX),t=.5*(R[0].pageY+R[1].pageY);x.set(e,t)}}function j(){const e=R[0].pageX-R[1].pageX,t=R[0].pageY-R[1].pageY,n=Math.sqrt(e*e+t*t);M.set(0,n)}function X(e){if(1==R.length)v.set(e.pageX,e.pageY);else{const t=ne(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);v.set(n,i)}y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const t=n.domElement;I(2*Math.PI*y.x/t.clientHeight),U(2*Math.PI*y.y/t.clientHeight),_.copy(v)}function q(e){if(1===R.length)b.set(e.pageX,e.pageY);else{const t=ne(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);b.set(n,i)}w.subVectors(b,x).multiplyScalar(n.panSpeed),D(w.x,w.y),x.copy(b)}function Y(e){const t=ne(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);S.set(0,s),E.set(0,Math.pow(S.y/M.y,n.zoomSpeed)),k(E.y),M.copy(S)}function K(e){!1!==n.enabled&&(0===R.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",J),n.domElement.addEventListener("pointerup",Z)),function(e){R.push(e)}(e),"touch"===e.pointerType?function(e){switch(te(e),R.length){case 1:switch(n.touches.ONE){case i.TOUCH.ROTATE:if(!1===n.enableRotate)return;V(),u=h.TOUCH_ROTATE;break;case i.TOUCH.PAN:if(!1===n.enablePan)return;W(),u=h.TOUCH_PAN;break;default:u=h.NONE}break;case 2:switch(n.touches.TWO){case i.TOUCH.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&j(),n.enablePan&&W(),u=h.TOUCH_DOLLY_PAN;break;case i.TOUCH.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&j(),n.enableRotate&&V(),u=h.TOUCH_DOLLY_ROTATE;break;default:u=h.NONE}break;default:u=h.NONE}u!==h.NONE&&n.dispatchEvent(s)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case i.MOUSE.DOLLY:if(!1===n.enableZoom)return;!function(e){F(e),M.set(e.clientX,e.clientY)}(e),u=h.DOLLY;break;case i.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;H(e),u=h.PAN}else{if(!1===n.enableRotate)return;G(e),u=h.ROTATE}break;case i.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;G(e),u=h.ROTATE}else{if(!1===n.enablePan)return;H(e),u=h.PAN}break;default:u=h.NONE}u!==h.NONE&&n.dispatchEvent(s)}(e))}function J(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(te(e),u){case h.TOUCH_ROTATE:if(!1===n.enableRotate)return;X(e),n.update();break;case h.TOUCH_PAN:if(!1===n.enablePan)return;q(e),n.update();break;case h.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&Y(e),n.enablePan&&q(e)}(e),n.update();break;case h.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&Y(e),n.enableRotate&&X(e)}(e),n.update();break;default:u=h.NONE}}(e):function(e){switch(u){case h.ROTATE:if(!1===n.enableRotate)return;!function(e){v.set(e.clientX,e.clientY),y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const t=n.domElement;I(2*Math.PI*y.x/t.clientHeight),U(2*Math.PI*y.y/t.clientHeight),_.copy(v),n.update()}(e);break;case h.DOLLY:if(!1===n.enableZoom)return;!function(e){S.set(e.clientX,e.clientY),E.subVectors(S,M),E.y>0?k(P()):E.y<0&&B(P()),M.copy(S),n.update()}(e);break;case h.PAN:if(!1===n.enablePan)return;!function(e){b.set(e.clientX,e.clientY),w.subVectors(b,x).multiplyScalar(n.panSpeed),D(w.x,w.y),x.copy(b),n.update()}(e)}}(e))}function Z(e){!function(e){delete L[e.pointerId];for(let t=0;t0&&k(P()),n.update()}(e),n.dispatchEvent(a))}function $(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?U(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?U(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?I(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?I(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function ee(e){!1!==n.enabled&&e.preventDefault()}function te(e){let t=L[e.pointerId];void 0===t&&(t=new i.Vector2,L[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ne(e){const t=e.pointerId===R[0].pointerId?R[1]:R[0];return L[t.pointerId]}n.domElement.addEventListener("contextmenu",ee),n.domElement.addEventListener("pointerdown",K),n.domElement.addEventListener("pointercancel",Z),n.domElement.addEventListener("wheel",Q,{passive:!1}),this.update()}}},976:(e,t,n)=>{"use strict";n.d(t,{G:()=>s});var i=n(477);class r extends i.DataTextureLoader{constructor(e){super(e)}parse(e){if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let t=0;const n=new Uint8Array(e),r={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};if(function(e){switch(e.image_type){case 1:case 9:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(r),r.id_length+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=r.id_length;let s=!1,a=!1,o=!1;switch(r.image_type){case 9:s=!0,a=!0;break;case 1:a=!0;break;case 10:s=!0;break;case 2:break;case 11:s=!0,o=!0;break;case 3:o=!0}const l=new Uint8Array(r.width*r.height*4),c=function(e,t,n,i,r){let s,a;const o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(a=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let a=0;const c=new Uint8Array(o);for(;a>4){default:case 2:a=0,c=1,u=t,l=0,h=1,d=n;break;case 0:a=0,c=1,u=t,l=n-1,h=-1,d=-1;break;case 3:a=t-1,c=-1,u=-1,l=0,h=1,d=n;break;case 1:a=t-1,c=-1,u=-1,l=n-1,h=-1,d=-1}if(o)switch(r.pixel_size){case 8:!function(e,t,n,i,s,a,o,l){let c,h,u,d=0;const p=r.width;for(u=t;u!==i;u+=n)for(h=s;h!==o;h+=a,d++)c=l[d],e[4*(h+p*u)+0]=c,e[4*(h+p*u)+1]=c,e[4*(h+p*u)+2]=c,e[4*(h+p*u)+3]=255}(e,l,h,d,a,c,u,i);break;case 16:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=2)e[4*(c+d*h)+0]=l[u+0],e[4*(c+d*h)+1]=l[u+0],e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+3]=l[u+1]}(e,l,h,d,a,c,u,i);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(r.pixel_size){case 8:!function(e,t,n,i,s,a,o,l,c){const h=c;let u,d,p,f=0;const m=r.width;for(p=t;p!==i;p+=n)for(d=s;d!==o;d+=a,f++)u=l[f],e[4*(d+m*p)+3]=255,e[4*(d+m*p)+2]=h[3*u+0],e[4*(d+m*p)+1]=h[3*u+1],e[4*(d+m*p)+0]=h[3*u+2]}(e,l,h,d,a,c,u,i,s);break;case 16:!function(e,t,n,i,s,a,o,l){let c,h,u,d=0;const p=r.width;for(u=t;u!==i;u+=n)for(h=s;h!==o;h+=a,d+=2)c=l[d+0]+(l[d+1]<<8),e[4*(h+p*u)+0]=(31744&c)>>7,e[4*(h+p*u)+1]=(992&c)>>2,e[4*(h+p*u)+2]=(31&c)<<3,e[4*(h+p*u)+3]=32768&c?0:255}(e,l,h,d,a,c,u,i);break;case 24:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=3)e[4*(c+d*h)+3]=255,e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+1]=l[u+1],e[4*(c+d*h)+0]=l[u+2]}(e,l,h,d,a,c,u,i);break;case 32:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=4)e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+1]=l[u+1],e[4*(c+d*h)+0]=l[u+2],e[4*(c+d*h)+3]=l[u+3]}(e,l,h,d,a,c,u,i);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(l,r.width,r.height,c.pixel_data,c.palettes),{data:l,width:r.width,height:r.height,flipY:!0,generateMipmaps:!0,minFilter:i.LinearMipmapLinearFilter}}}class s extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=""===s.path?i.LoaderUtils.extractUrlBase(e):s.path,o=new i.FileLoader(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,(function(n){try{t(s.parse(n,a))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}parse(e,t){function n(e,t){const n=[],i=e.childNodes;for(let e=0,r=i.length;e0&&t.push(new i.VectorKeyframeTrack(r+".position",s,a)),o.length>0&&t.push(new i.QuaternionKeyframeTrack(r+".quaternion",s,o)),l.length>0&&t.push(new i.VectorKeyframeTrack(r+".scale",s,l)),t}function S(e,t,n){let i,r,s,a=!0;for(r=0,s=e.length;r=0;){const i=e[t];if(null!==i.value[n])return i;t--}return null}function T(e,t,n){for(;t>>0));switch(n=n.toLowerCase(),n){case"tga":t=qe;break;default:t=Xe}return t}(s);if(void 0!==t){const r=t.load(s),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===c(a.technique)){const e=a.technique;r.wrapS=e.wrapU?i.RepeatWrapping:i.ClampToEdgeWrapping,r.wrapT=e.wrapV?i.RepeatWrapping:i.ClampToEdgeWrapping,r.offset.set(e.offsetU||0,e.offsetV||0),r.repeat.set(e.repeatU||1,e.repeatV||1)}else r.wrapS=i.RepeatWrapping,r.wrapT=i.RepeatWrapping;return null!==n&&(r.colorSpace=n),r}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",s),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}s.name=e.name||"";const o=r.parameters;for(const e in o){const t=o[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=a(t.texture,i.SRGBColorSpace));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=a(t.texture));break;case"bump":t.texture&&(s.normalMap=a(t.texture));break;case"ambient":t.texture&&(s.lightMap=a(t.texture,i.SRGBColorSpace));break;case"shininess":t.float&&s.shininess&&(s.shininess=t.float);break;case"emission":t.color&&s.emissive&&s.emissive.fromArray(t.color),t.texture&&(s.emissiveMap=a(t.texture,i.SRGBColorSpace))}}s.color.convertSRGBToLinear(),s.specular&&s.specular.convertSRGBToLinear(),s.emissive&&s.emissive.convertSRGBToLinear();let l=o.transparent,h=o.transparency;if(void 0===h&&l&&(h={float:1}),void 0===l&&h&&(l={opaque:"A_ONE",data:{color:[1,1,1,1]}}),l&&h)if(l.data.texture)s.transparent=!0;else{const e=l.data.color;switch(l.opaque){case"A_ONE":s.opacity=e[3]*h.float;break;case"RGB_ZERO":s.opacity=1-e[0]*h.float;break;case"A_ZERO":s.opacity=1-e[3]*h.float;break;case"RGB_ONE":s.opacity=e[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',l.opaque)}s.opacity<1&&(s.transparent=!0)}if(void 0!==r.extra&&void 0!==r.extra.technique){const e=r.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":s.side=1===n?i.DoubleSide:i.FrontSide;break;case"bump":s.normalMap=a(n.texture),s.normalScale=new i.Vector2(1,1)}}}return s}function Z(e){return f(Qe.materials[e],J)}function Q(e){for(let t=0;t0?n+s:n;t.inputs[a]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=o(i.textContent);break;case"p":t.p=o(i.textContent)}}return t}function he(e){let t=0;for(let n=0,i=e.length;n0&&t0&&d.setAttribute("position",new i.Float32BufferAttribute(s.array,s.stride)),a.array.length>0&&d.setAttribute("normal",new i.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&d.setAttribute("color",new i.Float32BufferAttribute(c.array,c.stride)),o.array.length>0&&d.setAttribute("uv",new i.Float32BufferAttribute(o.array,o.stride)),l.array.length>0&&d.setAttribute("uv1",new i.Float32BufferAttribute(l.array,l.stride)),h.length>0&&d.setAttribute("skinIndex",new i.Float32BufferAttribute(h,4)),u.length>0&&d.setAttribute("skinWeight",new i.Float32BufferAttribute(u,4)),r.data=d,r.type=e[0].type,r.materialKeys=p,r}function pe(e,t,n,i,r=!1){const s=e.p,a=e.stride,o=e.vcount;function l(e){let t=s[e+n]*h;const a=t+h;for(;t4)for(let t=1,i=n-2;t<=i;t++){const n=e+a*t,i=e+a*(t+1);l(e+0*a),l(n),l(i)}e+=a*n}}else for(let e=0,t=s.length;e=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ye(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;nr.limits.max||t{"use strict";n.d(t,{E:()=>s});var i=n(477),r=n(140);class s extends i.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new u(e)})),this.register((function(e){return new y(e)})),this.register((function(e){return new x(e)})),this.register((function(e){return new b(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new h(e)})),this.register((function(e){return new _(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new v(e)})),this.register((function(e){return new l(e)})),this.register((function(e){return new w(e)})),this.register((function(e){return new M(e)}))}load(e,t,n,r){const s=this;let a;a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:i.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){r?r(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},l=new i.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(n){try{s.parse(n,a,(function(n){t(n),s.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,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-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},a={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===S){try{s[o.KHR_BINARY_GLTF]=new E(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[o.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new q(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}h.setExtensions(s),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function a(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const o={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class l{constructor(e){this.parser=e,this.name=o.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class x{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class b{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class w{constructor(e){this.name=o.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class M{constructor(e){this.name=o.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==I.TRIANGLES&&e.mode!==I.TRIANGLE_STRIP&&e.mode!==I.TRIANGLE_FAN&&void 0!==e.mode)return null;const s=n.extensions[this.name].attributes,a=[],o={};for(const e in s)a.push(this.parser.getDependency("accessor",s[e]).then((t=>(o[e]=t,o[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,s=[];for(const e of n){const t=new i.Matrix4,n=new i.Vector3,a=new i.Quaternion,l=new i.Vector3(1,1,1),c=new i.InstancedMesh(e.geometry,e.material,r);for(let e=0;e-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&s<98?this.textureLoader=new i.TextureLoader(this.options.manager):this.textureLoader=new i.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new i.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};z(r,s,i),G(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&f.setY(t,u[e*a+1]),a>=3&&f.setZ(t,u[e*a+2]),a>=4&&f.setW(t,u[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const 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,n).then((function(t){t.flipY=!1,t.name=a.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(s.samplers||{})[a.sampler]||{};return t.magFilter=O[n.magFilter]||i.LinearFilter,t.minFilter=O[n.minFilter]||i.LinearMipmapLinearFilter,t.wrapS=N[n.wrapS]||i.RepeatWrapping,t.wrapT=N[n.wrapT]||i.RepeatWrapping,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=n.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=this.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,s){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new i.Texture(e);t.needsUpdate=!0,n(t)}),t.load(i.LoaderUtils.resolveURL(e,r.path),a,void 0,s)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[o.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[o.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[o.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new i.PointsMaterial,i.Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new i.LineBasicMaterial,i.Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||s||a){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return i.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let a;const l={},c=[];if((s.extensions||{})[o.KHR_MATERIALS_UNLIT]){const e=r[o.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(l,s,t))}else{const n=s.pbrMetallicRoughness||{};if(l.color=new i.Color(1,1,1),l.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;l.color.setRGB(e[0],e[1],e[2],i.LinearSRGBColorSpace),l.opacity=e[3]}void 0!==n.baseColorTexture&&c.push(t.assignTexture(l,"map",n.baseColorTexture,i.SRGBColorSpace)),l.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,l.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(c.push(t.assignTexture(l,"metalnessMap",n.metallicRoughnessTexture)),c.push(t.assignTexture(l,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),c.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)}))))}!0===s.doubleSided&&(l.side=i.DoubleSide);const h=s.alphaMode||"OPAQUE";if("BLEND"===h?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===h&&(l.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&a!==i.MeshBasicMaterial&&(c.push(t.assignTexture(l,"normalMap",s.normalTexture)),l.normalScale=new i.Vector2(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;l.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&a!==i.MeshBasicMaterial&&(c.push(t.assignTexture(l,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(l.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&a!==i.MeshBasicMaterial){const e=s.emissiveFactor;l.emissive=(new i.Color).setRGB(e[0],e[1],e[2],i.LinearSRGBColorSpace)}return void 0!==s.emissiveTexture&&a!==i.MeshBasicMaterial&&c.push(t.assignTexture(l,"emissiveMap",s.emissiveTexture,i.SRGBColorSpace)),Promise.all(c).then((function(){const n=new a(l);return s.name&&(n.name=s.name),G(n,s),t.associations.set(n,{materials:e}),s.extensions&&z(r,n,s),n}))}createUniqueName(e){const t=i.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function s(e){return n[o.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Y(n,e,t)}))}const a=[];for(let n=0,l=e.length;n0&&H(p,a),p.name=t.createUniqueName(a.name||"mesh_"+e),G(p,a),d.extensions&&z(s,p,d),t.assignFinalMaterial(p),h.push(p)}for(let n=0,i=h.length;n1?new i.Group:1===t.length?t[0]:new i.Object3D,o!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of r.associations)(e instanceof i.Material||e instanceof i.Texture)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}_createAnimationTracks(e,t,n,r,s){const a=[],o=e.name?e.name:e.uuid,l=[];let c;switch(B[s.path]===B.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),B[s.path]){case B.weights:c=i.NumberKeyframeTrack;break;case B.rotation:c=i.QuaternionKeyframeTrack;break;case B.position:case B.scale:c=i.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=i.NumberKeyframeTrack;break;case 2:case 3:default:c=i.VectorKeyframeTrack}}const h=void 0!==r.interpolation?F[r.interpolation]:i.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e{"use strict";n.d(t,{v:()=>r});var i=n(477);class r extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=""===this.path?i.LoaderUtils.extractUrlBase(e):this.path,o=new i.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(s.parse(n,a))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){const n=e.split("\n");let i={};const r=/\s+/,a={};for(let e=0;e=0?t.substring(0,s):t;o=o.toLowerCase();let l=s>=0?t.substring(s+1):"";if(l=l.trim(),"newmtl"===o)i={name:l},a[l]=i;else if("ka"===o||"kd"===o||"ks"===o||"ke"===o){const e=l.split(r,3);i[o]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else i[o]=l}const o=new s(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(a),o}}class s{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:i.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:i.RepeatWrapping}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],r={};t[n]=r;for(const e in i){let t=!0,n=i[e];const s=e.toLowerCase();switch(s){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(t=!1)}t&&(r[s]=n)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],r={name:e,side:this.side};function s(e,n){if(r[e])return;const s=t.getTextureParams(n,r),a=t.loadTexture((o=t.baseUrl,"string"!=typeof(l=s.url)||""===l?"":/^https?:\/\//i.test(l)?l:o+l));var o,l;a.repeat.copy(s.scale),a.offset.copy(s.offset),a.wrapS=t.wrap,a.wrapT=t.wrap,"map"!==e&&"emissiveMap"!==e||(a.colorSpace=i.SRGBColorSpace),r[e]=a}for(const e in n){const t=n[e];let a;if(""!==t)switch(e.toLowerCase()){case"kd":r.color=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"ks":r.specular=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"ke":r.emissive=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"map_kd":s("map",t);break;case"map_ks":s("specularMap",t);break;case"map_ke":s("emissiveMap",t);break;case"norm":s("normalMap",t);break;case"map_bump":case"bump":s("bumpMap",t);break;case"map_d":s("alphaMap",t),r.transparent=!0;break;case"ns":r.shininess=parseFloat(t);break;case"d":a=parseFloat(t),a<1&&(r.opacity=a,r.transparent=!0);break;case"tr":a=parseFloat(t),this.options&&this.options.invertTrProperty&&(a=1-a),a>0&&(r.opacity=1-a,r.transparent=!0)}}return this.materials[e]=new i.MeshPhongMaterial(r),this.materials[e]}getTextureParams(e,t){const n={scale:new i.Vector2(1,1),offset:new i.Vector2(0,0)},r=e.split(/\s+/);let s;return s=r.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(r[s+1]),r.splice(s,2)),s=r.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),s=r.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),n.url=r.join(" ").trim(),n}loadTexture(e,t,n,r,s){const a=void 0!==this.manager?this.manager:i.DefaultLoadingManager;let o=a.getHandler(e);null===o&&(o=new i.TextureLoader(a)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const l=o.load(e,n,r,s);return void 0!==t&&(l.mapping=t),l}}},476:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var i=n(477);class r extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new i.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(s.parse(n))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}parse(e){function t(e,t,n){for(let i=0,r=e.length;i>5&31)/31,a=(e>>10&31)/31):(r=l,s=c,a=h)}for(let l=1;l<=3;l++){const c=n+12*l,h=3*e*3+3*(l-1);f[h]=t.getFloat32(c,!0),f[h+1]=t.getFloat32(c+4,!0),f[h+2]=t.getFloat32(c+8,!0),m[h]=i,m[h+1]=u,m[h+2]=p,d&&(g.set(r,s,a).convertSRGBToLinear(),o[h]=g.r,o[h+1]=g.g,o[h+2]=g.b)}}return p.setAttribute("position",new i.BufferAttribute(f,3)),p.setAttribute("normal",new i.BufferAttribute(m,3)),d&&(p.setAttribute("color",new i.BufferAttribute(o,3)),p.hasColors=!0,p.alpha=u),p}(n):function(e){const t=new i.BufferGeometry,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,s=/solid\s(.+)/;let a=0;const o=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,l=new RegExp("vertex"+o+o+o,"g"),c=new RegExp("normal"+o+o+o,"g"),h=[],u=[],d=[],p=new i.Vector3;let f,m=0,g=0,_=0;for(;null!==(f=n.exec(e));){g=_;const e=f[0],n=null!==(f=s.exec(e))?f[1]:"";for(d.push(n);null!==(f=r.exec(e));){let e=0,t=0;const n=f[0];for(;null!==(f=c.exec(n));)p.x=parseFloat(f[1]),p.y=parseFloat(f[2]),p.z=parseFloat(f[3]),t++;for(;null!==(f=l.exec(n));)h.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(p.x,p.y,p.z),e++,_++;1!==t&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+a),3!==e&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+a),a++}const i=g,o=_-g;t.userData.groupNames=d,t.addGroup(i,o,m),m++}return t.setAttribute("position",new i.Float32BufferAttribute(h,3)),t.setAttribute("normal",new i.Float32BufferAttribute(u,3)),t}("string"!=typeof(r=e)?(new TextDecoder).decode(r):r);var r}}},140:(e,t,n)=>{"use strict";n.d(t,{qf:()=>a,Vs:()=>s});var i=n(477);function r(e){let t,n,r,s=-1,a=0;for(let i=0;i{"use strict";n.d(t,{N:()=>i});class i{static createButton(e){const t=document.createElement("button");function n(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",r(t),navigator.xr.isSessionSupported("immersive-vr").then((function(r){r?function(){let n=null;async function i(i){i.addEventListener("end",r),await e.xr.setSession(i),t.textContent="EXIT VR",n=i}function r(){n.removeEventListener("end",r),t.textContent="ENTER VR",n=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(null===n){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else n.end()}}():(n(),t.textContent="VR NOT SUPPORTED"),r&&i.xrSessionIsGranted&&t.click()})).catch((function(e){n(),console.warn("Exception when trying to call xr.isSessionSupported",e),t.textContent="VR NOT ALLOWED"})),t;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",r(e),e}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",(()=>{i.xrSessionIsGranted=!0}))}}}i.xrSessionIsGranted=!1,i.registerSessionGrantedListener()},904:(e,t,n)=>{"use strict";n.d(t,{v:()=>i});class i{static createButton(e){const t=document.createElement("button");function n(n){let i=null;async function r(n){n.addEventListener("end",s),await e.xr.setSession(n),t.textContent="STOP XR",i=n}function s(){i.removeEventListener("end",s),t.textContent="START XR",i=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="START XR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(null===i){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession(n,e).then(r)}else i.end()}}function i(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(e){i(),console.warn("Exception when trying to call xr.isSessionSupported",e),t.textContent="XR NOT ALLOWED"}function s(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return t.id="XRButton",t.style.display="none",s(t),navigator.xr.isSessionSupported("immersive-ar").then((function(e){e?n("immersive-ar"):navigator.xr.isSessionSupported("immersive-vr").then((function(e){e?n("immersive-vr"):(i(),t.textContent="XR NOT SUPPORTED")})).catch(r)})).catch(r),t;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",s(e),e}}}},925:(e,t,n)=>{"use strict";n.d(t,{i:()=>p});var i=n(477),r=n(217);const s={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function a(e){const t=await fetch(e);if(t.ok)return t.json();throw new Error(t.statusText)}const o={xAxis:0,yAxis:0,button:0,state:s.ComponentState.DEFAULT};class l{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===s.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(o)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:r,normalizedYAxis:a}=function(e=0,t=0){let n=e,i=t;if(Math.sqrt(e*e+t*t)>1){const r=Math.atan2(t,e);n=Math.cos(r),i=Math.sin(r)}return{normalizedXAxis:.5*n+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case s.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?r:.5;break;case s.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case s.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case s.ComponentProperty.STATE:this.valueNodeProperty===s.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class c{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const n=new l(t.visualResponses[e]);this.visualResponses[e]=n})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:s.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=s.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=s.ComponentState.PRESSED:(t.touched||this.values.button>s.ButtonTouchThreshold)&&(this.values.state=s.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===s.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>s.AxisTouchThreshold&&(this.values.state=s.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===s.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>s.AxisTouchThreshold&&(this.values.state=s.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class h{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new c(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class u extends i.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:n,maxNode:i,value:r,valueNodeProperty:a}=e;t&&(a===s.VisualResponseProperty.VISIBILITY?t.visible=r:a===s.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(n.quaternion,i.quaternion,r),t.position.lerpVectors(n.position,i.position,r)))}))})))}}function d(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:n,touchPointNodeName:r,visualResponses:a}=e;if(n===s.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){const t=new i.SphereGeometry(.001),n=new i.MeshBasicMaterial({color:255}),r=new i.Mesh(t,n);e.touchPointNode.add(r)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(a).forEach((e=>{const{valueNodeName:n,minNodeName:i,maxNodeName:r,valueNodeProperty:a}=e;if(a===s.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(r),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${r} in the model`)}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class p{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new r.E)}createControllerModel(e){const t=new u;let n=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&async function(e,t,n=null,i=!0){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const r=await async function(e){if(!e)throw new Error("No basePath supplied");return await a(`${e}/profilesList.json`)}(t);let s;if(e.profiles.some((e=>{const n=r[e];return n&&(s={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!s})),!s){if(!n)throw new Error("No matching profile name found");const e=r[n];if(!e)throw new Error(`No matching profile name found and default profile "${n}" missing.`);s={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const o=await a(s.profilePath);let l;if(i){let t;if(t="any"===e.handedness?o.layouts[Object.keys(o.layouts)[0]]:o.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${s.profileId}`);t.assetPath&&(l=s.profilePath.replace("profile.json",t.assetPath))}return{profile:o,assetPath:l}}(i,this.path,"generic-trigger").then((({profile:e,assetPath:r})=>{t.motionController=new h(i,e,r);const s=this._assetCache[t.motionController.assetUrl];if(s)n=s.scene.clone(),d(t,n);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),d(t,n)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(n),n=null})),t}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Viewer:()=>Viewer,THREE:()=>three__WEBPACK_IMPORTED_MODULE_2__,msgpack:()=>msgpack});var three__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(477),three_examples_jsm_utils_BufferGeometryUtils_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(140),wwobjloader2__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(973),three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(976),three_examples_jsm_loaders_GLTFLoader_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(217),three_examples_jsm_loaders_MTLLoader_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(23),three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(476),three_examples_jsm_controls_OrbitControls_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(365),three_examples_jsm_webxr_VRButton_js__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(18),three_examples_jsm_webxr_XRButton_js__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(904),three_examples_jsm_webxr_XRControllerModelFactory__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(925),msgpack=__webpack_require__(676),dat=__webpack_require__(376).ZP;__webpack_require__(583);const extensionCodec=new msgpack.ExtensionCodec;function merge_geometries(e,t=!1){let n=[],i=[],r=e.matrix.clone();!function e(t,r){let s=r.clone().multiply(t.matrix);"Mesh"===t.type&&(t.geometry.applyMatrix4(s),i.push(t.geometry),n.push(t.material));for(let n of t.children)e(n,s)}(e,r);let s=null;return 1==i.length?(s=i[0],t&&(s.material=n[0])):i.length>1?(s=(0,three_examples_jsm_utils_BufferGeometryUtils_js__WEBPACK_IMPORTED_MODULE_1__.qf)(i,!0),t&&(s.material=n)):s=new three__WEBPACK_IMPORTED_MODULE_2__.BufferGeometry,s}function handle_special_texture(e){if("_text"==e.type){let t=document.createElement("canvas");t.width=256,t.height=256;let n=t.getContext("2d");n.textAlign="center";let i=e.font_size;for(n.font=i+"px "+e.font_face;n.measureText(e.text).width>t.width;)i--,n.font=i+"px "+e.font_face;n.fillText(e.text,t.width/2,t.height/2);let r=new three__WEBPACK_IMPORTED_MODULE_2__.CanvasTexture(t);return r.uuid=e.uuid,r}return null}function handle_special_geometry(e){if("_meshfile"==e.type&&(console.warn("_meshfile is deprecated. Please use _meshfile_geometry for geometries and _meshfile_object for objects with geometry and material"),e.type="_meshfile_geometry"),"_meshfile_geometry"==e.type){if("obj"==e.format){let t=merge_geometries((new wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.oe).parse(e.data+"\n"));return t.uuid=e.uuid,t}if("dae"==e.format){let t=merge_geometries((new three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__.G).parse(e.data).scene);return t.uuid=e.uuid,t}if("stl"==e.format){let t=(new three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__.j).parse(e.data.buffer);return t.uuid=e.uuid,t}return console.error("Unsupported mesh type:",e),null}return null}extensionCodec.register({type:22,encode:e=>(console.error("Uint32Array encode not implemented"),null),decode:e=>{const t=new Uint32Array(e.byteLength/4);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e(console.error("Float32Array encode not implemented"),null),decode:e=>{const t=new Float32Array(e.byteLength/4);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;evoid 0!==e.resources[t]?e.resources[t]:t)),"obj"==e.format){let s=new wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.oe(i);if(e.mtl_library){let t=new three_examples_jsm_loaders_MTLLoader_js__WEBPACK_IMPORTED_MODULE_5__.v(i).parse(e.mtl_library+"\n",""),n=wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.eW.addMaterialsFromMtlLoader(t);s.setMaterials(n),this.onTextureLoad()}t=merge_geometries(s.parse(e.data+"\n",r),!0),t.uuid=e.uuid,n=t.material}else if("dae"==e.format){let s=new three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__.G(i);s.onTextureLoad=this.onTextureLoad,t=merge_geometries(s.parse(e.data,r).scene,!0),t.uuid=e.uuid,n=t.material}else{if("stl"!=e.format)return console.error("Unsupported mesh type:",e),null;t=(new three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__.j).parse(e.data.buffer,r),t.uuid=e.uuid,n=t.material}let s=new three__WEBPACK_IMPORTED_MODULE_2__.Mesh(t,n);return s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.userjson&&(s.userjson=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),s}return super.parseObject(e,t,n)}}class Background extends three__WEBPACK_IMPORTED_MODULE_2__.Object3D{constructor(){super(),this.isBackground=!0,this.type="Background",this.top_color=new dat.color.Color(135,206,250),this.bottom_color=new dat.color.Color(25,25,112),this.render_environment_map=!0,this.environment_map=null,this.visible=!0,this.use_ar_background=!1,this.textures={env_map:null,round:{gradient:env_texture(this.top_color,this.bottom_color,!0),white:env_texture([255,255,255],[255,255,255],!0)},flat:{gradient:env_texture(this.top_color,this.bottom_color,!1),white:env_texture([255,255,255],[255,255,255],!1)}},this.state={top_color:null,bottom_color:null,environment_map:null,render_map:null,visible:!0}}update(e,t,n){this.state.visible=t,this.state.render_map=this.render_environment_map,this.environment_map!==this.state.environment_map&&(""==this.environment_map||null==this.environment_map?(this.environment_map=this.state.environment_map=null,this.textures.env_map=null):(this.textures.env_map=load_env_texture(this.environment_map,this,e,t,n),null==this.textures.env_map?this.state.environment_map=this.environment_map=null:this.state.environment_map=this.environment_map));let i=!n||!this.render_environment_map||null==this.textures.env_map;if(t&&i&&(this.top_color!==this.state.top_color||this.bottom_color!==this.state.bottom_color)){this.state.top_color=this.top_color,this.state.bottom_color=this.bottom_color;let e=[this.state.top_color.r,this.state.top_color.g,this.state.top_color.b],t=[this.state.bottom_color.r,this.state.bottom_color.g,this.state.bottom_color.b];this.textures.flat.gradient=env_texture(e,t,!1),this.textures.round.gradient=env_texture(e,t,!0)}let r=n?"round":"flat";e.background=this.use_ar_background?null:this.state.visible?this.state.render_map&&null!=this.textures.env_map&&n?this.textures.env_map:this.textures[r].gradient:this.textures[r].white,e.environment=this.state.visible?null!=this.textures.env_map?this.textures.env_map:this.textures.round.gradient:this.textures.round.white}}class SceneNode{constructor(e,t,n){this.object=e,this.folder=t,this.children={},this.controllers=[],this.on_update=n,this.create_controls();for(let e of this.object.children)this.add_child(e)}add_child(e){let t=this.folder.addFolder(e.name),n=new SceneNode(e,t,this.on_update);return this.children[e.name]=n,n}create_child(e){let t=new three__WEBPACK_IMPORTED_MODULE_2__.Group;return t.name=e,this.object.add(t),this.add_child(t)}find(e){if(0==e.length)return this;{let t=e[0],n=this.children[t];return void 0===n&&(n=this.create_child(t)),n.find(e.slice(1))}}create_controls(){for(let e of this.controllers)this.folder.remove(e);if(this.controllers=[],void 0!==this.vis_controller&&this.folder.domElement.removeChild(this.vis_controller.domElement),this.vis_controller=new dat.controllers.BooleanController(this.object,"visible"),this.vis_controller.onChange((()=>this.on_update())),this.folder.domElement.prepend(this.vis_controller.domElement),this.vis_controller.domElement.style.height="0",this.vis_controller.domElement.style.float="right",this.vis_controller.domElement.classList.add("meshcat-visibility-checkbox"),this.vis_controller.domElement.children[0].addEventListener("change",(e=>{e.target.checked?this.folder.domElement.classList.remove("meshcat-hidden-scene-element"):this.folder.domElement.classList.add("meshcat-hidden-scene-element")})),this.object.isLight){let e=this.folder.add(this.object,"intensity").min(0).step(.01);if(e.onChange((()=>this.on_update())),this.controllers.push(e),void 0!==this.object.castShadow){let e=this.folder.add(this.object,"castShadow");if(e.onChange((()=>this.on_update())),this.controllers.push(e),void 0!==this.object.shadow){let e=this.folder.add(this.object.shadow,"radius").min(0).step(.05).max(3);e.onChange((()=>this.on_update())),this.controllers.push(e)}}if(void 0!==this.object.distance){let e=this.folder.add(this.object,"distance").min(0).step(.1).max(100);e.onChange((()=>this.on_update())),this.controllers.push(e)}}if(this.object.isCamera){let e=this.folder.add(this.object,"zoom").min(0).step(.1);e.onChange((()=>{this.on_update()})),this.controllers.push(e)}if(this.object.isEnvironment){let e=this.folder.add(this.object,"intensity").min(0).step(.1).max(100);e.onChange((()=>this.on_update())),this.controllers.push(e)}if(this.object.isBackground){let e=this.folder.addColor(this.object,"top_color");e.onChange((()=>this.on_update())),this.controllers.push(e);let t=this.folder.addColor(this.object,"bottom_color");t.onChange((()=>this.on_update())),this.controllers.push(t);let n=this.folder.add(this.object,"render_environment_map");n.onChange((()=>this.on_update())),this.controllers.push(n)}}cache_original_opacity(e){void 0===e.meshcat_base_opacity&&(e.meshcat_base_opacity=e.opacity)}set_opacity(e,t){this.cache_original_opacity(e),e.opacity=t,e.transparent=t<1,e.depthWrite=!0,e.needsUpdate=!0}visit_materials(e,t){e.isMaterial?t(e):e.material&&t(e.material);for(let n of e.children)this.visit_materials(n,t)}set_property(e,t){if("position"===e)this.object.position.set(t[0],t[1],t[2]);else if("quaternion"===e)this.object.quaternion.set(t[0],t[1],t[2],t[3]);else if("scale"===e)this.object.scale.set(t[0],t[1],t[2]);else if("color"===e){var n=this;function e(e){e.color.setRGB(t[0],t[1],t[2]),n.set_opacity(e,t[3])}this.visit_materials(this.object,e)}else if("opacity"==e){function e(e){n.set_opacity(e,t)}n=this,this.visit_materials(this.object,e)}else if("modulated_opacity"==e){function e(e){n.cache_original_opacity(e),n.set_opacity(e,e.meshcat_base_opacity*t)}n=this,this.visit_materials(this.object,e)}else this.object[e]="top_color"==e||"bottom_color"==e?new dat.color.Color(t.map((e=>255*e))):t;this.object.isBackground&&this.on_update(),this.vis_controller.updateDisplay(),this.controllers.forEach((e=>e.updateDisplay()))}set_transform(e){let t=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;t.fromArray(e),t.decompose(this.object.position,this.object.quaternion,this.object.scale)}set_object(e){let t=this.object.parent;this.dispose_recursive(),this.object.parent.remove(this.object),this.object=e,t.add(e),this.create_controls()}dispose_recursive(){for(let e of Object.keys(this.children))this.children[e].dispose_recursive();dispose(this.object)}delete(e){if(0==e.length)console.error("Can't delete an empty path");else{let t=this.find(e.slice(0,e.length-1)),n=e[e.length-1],i=t.children[n];void 0!==i&&(i.dispose_recursive(),t.object.remove(i.object),remove_folders(i.folder),t.folder.removeFolder(i.folder),delete t.children[n])}}}function remove_folders(e){for(let t of Object.keys(e.__folders)){let n=e.__folders[t];remove_folders(n),dat.dom.dom.unbind(window,"resize",n.__resizeHandler),e.removeFolder(n)}}function dispose(e){if(e&&(e.geometry&&e.geometry.dispose(),e.material))if(Array.isArray(e.material))for(let t of e.material)t.map&&t.map.dispose(),t.dispose();else e.material.map&&e.material.map.dispose(),e.material.dispose()}function create_default_scene(){var e=new three__WEBPACK_IMPORTED_MODULE_2__.Scene;return e.name="Scene",e.rotateX(-Math.PI/2),e}function download_data_uri(e,t){let n=document.createElement("a");n.download=e,n.href=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function download_file(e,t,n){n=n||"text/plain";let i=new Blob([t],{type:n}),r=document.createElement("a");document.body.appendChild(r),r.download=e,r.href=window.URL.createObjectURL(i),r.onclick=function(e){let t=this;setTimeout((function(){window.URL.revokeObjectURL(t.href)}),1500)},r.click(),r.remove()}class Animator{constructor(e){this.viewer=e,this.folder=this.viewer.gui.addFolder("Animations"),this.mixer=new three__WEBPACK_IMPORTED_MODULE_2__.AnimationMixer,this.loader=new three__WEBPACK_IMPORTED_MODULE_2__.ObjectLoader,this.clock=new three__WEBPACK_IMPORTED_MODULE_2__.Clock,this.actions=[],this.playing=!1,this.time=0,this.time_scrubber=null,this.setup_capturer("png"),this.duration=0}setup_capturer(e){this.capturer=new window.CCapture({format:e,name:"meshcat_"+String(Date.now())}),this.capturer.format=e}play(){this.clock.start();for(let e of this.actions)e.play();this.playing=!0}record(){this.reset(),this.play(),this.recording=!0,this.capturer.start()}pause(){this.clock.stop(),this.playing=!1,this.recording&&(this.stop_capture(),this.save_capture())}stop_capture(){this.recording=!1,this.capturer.stop(),this.viewer.animate()}save_capture(){this.capturer.save(),"png"===this.capturer.format?alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.png \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4"):"jpg"===this.capturer.format&&alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.jpg \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4")}display_progress(e){this.time=e,null!==this.time_scrubber&&this.time_scrubber.updateDisplay()}seek(e){this.actions.forEach((t=>{t.time=Math.max(0,Math.min(t._clip.duration,e))})),this.mixer.update(0),this.viewer.set_dirty()}reset(){for(let e of this.actions)e.reset();this.display_progress(0),this.mixer.update(0),this.setup_capturer(this.capturer.format),this.viewer.set_dirty()}clear(){remove_folders(this.folder),this.mixer.stopAllAction(),this.actions=[],this.duration=0,this.display_progress(0),this.mixer=new three__WEBPACK_IMPORTED_MODULE_2__.AnimationMixer}load(e,t){this.clear(),this.folder.open();let n=this.folder.addFolder("default");n.open(),n.add(this,"play"),n.add(this,"pause"),n.add(this,"reset"),this.time_scrubber=n.add(this,"time",0,1e9,.001),this.time_scrubber.onChange((e=>this.seek(e))),n.add(this.mixer,"timeScale").step(.01).min(0);let i=n.addFolder("Recording");i.add(this,"record"),i.add({format:"png"},"format",["png","jpg"]).onChange((e=>{this.setup_capturer(e)})),void 0===t.play&&(t.play=!0),void 0===t.loopMode&&(t.loopMode=three__WEBPACK_IMPORTED_MODULE_2__.LoopRepeat),void 0===t.repetitions&&(t.repetitions=1),void 0===t.clampWhenFinished&&(t.clampWhenFinished=!0),this.duration=0,this.progress=0;for(let n of e){let e=this.viewer.scene_tree.find(n.path).object,i=three__WEBPACK_IMPORTED_MODULE_2__.AnimationClip.parse(n.clip);i.uuid=three__WEBPACK_IMPORTED_MODULE_2__.MathUtils.generateUUID();let r=this.mixer.clipAction(i,e);r.clampWhenFinished=t.clampWhenFinished,r.setLoop(t.loopMode,t.repetitions),this.actions.push(r),this.duration=Math.max(this.duration,i.duration)}this.time_scrubber.min(0),this.time_scrubber.max(this.duration),this.reset(),t.play&&this.play()}update(){if(this.playing){if(this.mixer.update(this.clock.getDelta()),this.viewer.set_dirty(),0!=this.duration){let e=this.actions.reduce(((e,t)=>Math.max(e,t.time)),0);this.display_progress(e)}else this.display_progress(0);if(this.actions.every((e=>e.paused))){this.pause();for(let e of this.actions)e.reset()}}}after_render(){this.recording&&this.capturer.capture(this.viewer.renderer.domElement)}}function env_texture(e,t,n){if(null==e||null==t)return null;let i=new Uint8Array(512),r=0,s=256;for(let n=0;n<64;++n){for(let n=0;n<3;++n)i[r+n]=t[n],i[s+n]=e[n];i[r+3]=255,i[s+3]=255,r+=4,s+=4}let a=n?three__WEBPACK_IMPORTED_MODULE_2__.EquirectangularReflectionMapping:three__WEBPACK_IMPORTED_MODULE_2__.UVMapping,o=new three__WEBPACK_IMPORTED_MODULE_2__.DataTexture(i,64,2,three__WEBPACK_IMPORTED_MODULE_2__.RGBAFormat,three__WEBPACK_IMPORTED_MODULE_2__.UnsignedByteType,a,three__WEBPACK_IMPORTED_MODULE_2__.RepeatWrapping,three__WEBPACK_IMPORTED_MODULE_2__.ClampToEdgeWrapping,three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,1,three__WEBPACK_IMPORTED_MODULE_2__.LinearSRGBColorSpace);return n||(o.matrixAutoUpdate=!1,o.matrix.set(.5,0,.25,0,.5,.25,0,0,1),o.needsUpdate=!0),o.needsUpdate=!0,o.encoding=three__WEBPACK_IMPORTED_MODULE_2__.LinearEncoding,o}function load_env_texture(e,t,n,i,r){let s=(new three__WEBPACK_IMPORTED_MODULE_2__.TextureLoader).load(e,void 0,void 0,(()=>{console.error("Failure to load the requested environment map; reverting to none.",t.environment_map),t.environment_map=null,t.update(n,i,r)}));return null!=s&&(s.colorSpace=three__WEBPACK_IMPORTED_MODULE_2__.SRGBColorSpace,s.mapping=three__WEBPACK_IMPORTED_MODULE_2__.EquirectangularReflectionMapping),s}function wait_for_property(e,t,n){return new Promise((i=>{const r=new MutationObserver((()=>{var s=e[t];null!=s&&n(s)&&(r.disconnect(),i())}));r.observe(e,{childList:!0});var s=e[t];if(null!=s&&n(s))return r.disconnect(),i()}))}class Viewer{constructor(e,t,n){this.dom_element=e,void 0===n?(this.renderer=new three__WEBPACK_IMPORTED_MODULE_2__.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=three__WEBPACK_IMPORTED_MODULE_2__.PCFSoftShadowMap,this.dom_element.appendChild(this.renderer.domElement)):this.renderer=n,this.renderer.setPixelRatio(window.devicePixelRatio),this.webxr_session_active=!1,this.xr_button=null,this.scene=create_default_scene(),this.gui_controllers={},this.keydown_callbacks={},this.create_scene_tree(),this.add_default_scene_elements(),this.set_dirty(),this.create_camera(),this.num_messages_received=0,window.onload=e=>this.set_3d_pane_size(),window.addEventListener("resize",(e=>this.set_3d_pane_size()),!1),window.addEventListener("keydown",(e=>{this.on_keydown(e)})),requestAnimationFrame((()=>this.set_3d_pane_size())),(t||void 0===t)&&this.animate()}on_keydown(e){if(e.code in this.keydown_callbacks)for(const t of this.keydown_callbacks[e.code])t.callback(e)}update_background(){let e=this.scene_tree.find(["Background"]),t=this.scene_tree.find(["Background",""]),n=e.object.visible&&t.object.visible;t.object.update(this.scene,n,this.is_perspective()),this.set_dirty()}is_perspective(){return this.camera&&this.camera.isPerspectiveCamera}hide_background(){this.set_property(["Background"],"visible",!1)}show_background(){this.set_property(["Background"],"visible",!0),this.set_property(["Background",""],"visible",!0)}set_dirty(){this.needs_render=!0}create_camera(){let e=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;e.makeRotationX(Math.PI/2),this.set_transform(["Cameras","default","rotated"],e.toArray());let t=new three__WEBPACK_IMPORTED_MODULE_2__.PerspectiveCamera(75,1,.01,100);this.set_camera(t),this.set_object(["Cameras","default","rotated"],t),t.position.set(3,1,0)}create_default_spot_light(){var e=new three__WEBPACK_IMPORTED_MODULE_2__.SpotLight(16777215,.8);return e.position.set(1.5,1.5,2),e.castShadow=!1,e.shadow.mapSize.width=1024,e.shadow.mapSize.height=1024,e.shadow.camera.near=.5,e.shadow.camera.far=50,e.shadow.bias=-.001,e}add_default_scene_elements(){var e=this.create_default_spot_light();this.set_object(["Lights","SpotLight"],e),this.set_property(["Lights","SpotLight"],"visible",!1);var t=new three__WEBPACK_IMPORTED_MODULE_2__.PointLight(16777215,.4);t.position.set(1.5,1.5,2),t.castShadow=!1,t.distance=10,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,t.shadow.camera.near=.5,t.shadow.camera.far=10,t.shadow.bias=-.001,this.set_object(["Lights","PointLightNegativeX"],t);var n=new three__WEBPACK_IMPORTED_MODULE_2__.PointLight(16777215,.4);n.position.set(-1.5,-1.5,2),n.castShadow=!1,n.distance=10,n.shadow.mapSize.width=1024,n.shadow.mapSize.height=1024,n.shadow.camera.near=.5,n.shadow.camera.far=10,n.shadow.bias=-.001,this.set_object(["Lights","PointLightPositiveX"],n);var i=new three__WEBPACK_IMPORTED_MODULE_2__.AmbientLight(16777215,.3);i.intensity=.6,this.set_object(["Lights","AmbientLight"],i);var r=new three__WEBPACK_IMPORTED_MODULE_2__.DirectionalLight(16777215,.4);r.position.set(-10,-10,0),this.set_object(["Lights","FillLight"],r);var s=new three__WEBPACK_IMPORTED_MODULE_2__.GridHelper(20,40);s.rotateX(Math.PI/2),this.set_object(["Grid"],s);var a=new three__WEBPACK_IMPORTED_MODULE_2__.AxesHelper(.5);this.set_object(["Axes"],a)}create_scene_tree(){this.gui&&this.gui.destroy(),this.gui=new dat.GUI({autoPlace:!1,resizable:!0}),this.dom_element.parentElement.appendChild(this.gui.domElement),this.gui.domElement.style.position="absolute",this.gui.domElement.style.right=0,this.gui.domElement.style.top=0;let e=this.gui.addFolder("Scene");e.open(),this.scene_tree=new SceneNode(this.scene,e,(()=>this.set_dirty()));let t=this.gui.addFolder("Save / Load / Capture");t.add(this,"save_scene"),t.add(this,"load_scene"),t.add(this,"save_image"),this.animator=new Animator(this),this.gui.close(),this.set_object(["Background"],new Background);let n=this.scene_tree.find(["Background"]);n.object.isBackground=!0,n.on_update=()=>{this.update_background()},this.scene_tree.find(["Background",""]).on_update=()=>{this.update_background()},this.update_background()}set_3d_pane_size(e,t){void 0===e&&(e=this.dom_element.offsetWidth),void 0===t&&(t=this.dom_element.offsetHeight),"OrthographicCamera"==this.camera.type?this.camera.right=this.camera.left+e*(this.camera.top-this.camera.bottom)/t:this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.set_dirty()}render(){this.controls.update(),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this.animator.after_render(),this.needs_render=!1}animate(){requestAnimationFrame((()=>this.animate())),this.animator.update(),this.needs_render&&this.render()}capture_image(e,t){let n=this.dom_element.offsetWidth,i=this.dom_element.offsetHeight;this.set_3d_pane_size(e,t),this.render();let r=this.renderer.domElement.toDataURL();return this.set_3d_pane_size(n,i),r}save_image(){download_data_uri("meshcat.png",this.capture_image())}set_camera(e){this.webxr_session_active?console.warn("Can't set camera during an active WebXR session."):(this.camera=e,this.controls=new three_examples_jsm_controls_OrbitControls_js__WEBPACK_IMPORTED_MODULE_6__.z(e,this.dom_element),this.controls.enableKeys=!1,this.controls.screenSpacePanning=!0,this.controls.addEventListener("start",(()=>{this.set_dirty()})),this.controls.addEventListener("change",(()=>{this.set_dirty()})),this.update_webxr_buttons(),this.update_background())}set_camera_target(e){this.controls.target.set(e[0],e[1],e[2])}set_camera_from_json(e){(new ExtensibleObjectLoader).parse(e,(e=>{this.set_camera(e)}))}set_transform(e,t){this.scene_tree.find(e).set_transform(t)}set_object(e,t){this.scene_tree.find(e.concat([""])).set_object(t)}set_object_from_json(e,t){let n=e=>{"Mesh"===e.type&&(e.castShadow=!0,e.receiveShadow=!0);for(let t=0;t{n(t),this.set_object(e,t),this.set_dirty()};if("_meshfile_object"==t.object.type&&"gltf"==t.object.format)(new three_examples_jsm_loaders_GLTFLoader_js__WEBPACK_IMPORTED_MODULE_7__.E).parse(t.object.data,e,(e=>{let n=e.scene;if(null===n)console.error("Gltf parsed with no scene!");else{let e=t.object;if(void 0!==e.matrix){n.matrix.fromArray(e.matrix);let t=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;t=t.makeRotationX(Math.PI/2),n.matrix.multiply(t),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)}i(n)}}));else{let e=new ExtensibleObjectLoader;e.onTextureLoad=()=>{this.set_dirty()},e.parse(t,(e=>{void 0!==e.geometry&&"BufferGeometry"==e.geometry.type?void 0!==e.geometry.attributes.normal&&0!==e.geometry.attributes.normal.count||e.geometry.computeVertexNormals():e.type.includes("Camera")&&(this.set_camera(e),this.set_3d_pane_size()),i(e)}))}}delete_path(e){0==e.length?console.error("Deleting the entire scene is not implemented"):this.scene_tree.delete(e)}set_property(e,t,n){1===e.length&&"Background"===e[0]&&"visible"!==t&&(console.warn("To set the Background property "+t+', use the path "/Background/" instead of just "/Background".'),e=[e[0],""]),this.scene_tree.find(e).set_property(t,n)}set_animation(e,t){t=t||{},this.animator.load(e,t)}set_control(name,callback,value,min,max,step,keycode1,keycode2){let my_callback=eval(callback),handler={};if(name in this.gui_controllers&&this.gui.remove(this.gui_controllers[name]),void 0!==value){function e(e,t,n){if(null!=t){let i={name,callback:()=>{value=e.gui_controllers[name].getValue();let t=Math.min(Math.max(value+n,min),max);e.gui_controllers[name].setValue(t)}};t in e.keydown_callbacks?e.keydown_callbacks[t].push(i):e.keydown_callbacks[t]=[i]}}handler[name]=value,this.gui_controllers[name]=this.gui.add(handler,name,min,max,step),this.gui_controllers[name].onChange(my_callback),e(this,keycode1,-step),e(this,keycode2,+step)}else if(handler[name]=my_callback,this.gui_controllers[name]=this.gui.add(handler,name),this.gui_controllers[name].domElement.parentElement.querySelector(".property-name").style.width="100%",null!=keycode1){let e={name,callback:my_callback};keycode1 in this.keydown_callbacks?this.keydown_callbacks[keycode1].push(e):this.keydown_callbacks[keycode1]=[e]}}set_control_value(e,t,n=!0){e in this.gui_controllers&&this.gui_controllers[e]instanceof dat.controllers.NumberController&&(n?this.gui_controllers[e].setValue(t):(this.gui_controllers[e].object[e]=t,this.gui_controllers[e].updateDisplay()))}delete_control(e){e in this.gui_controllers&&(this.gui.remove(this.gui_controllers[e]),delete this.gui_controllers[e]);for(let t in this.keydown_callbacks){let n=this.keydown_callbacks[t].length;for(;n--;)this.keydown_callbacks[t][n].name==e&&this.keydown_callbacks[t].splice(n,1)}}handle_command(e){if("set_transform"==e.type){let t=split_path(e.path);this.set_transform(t,e.matrix)}else if("delete"==e.type){let t=split_path(e.path);this.delete_path(t)}else if("set_object"==e.type){let t=split_path(e.path);this.set_object_from_json(t,e.object)}else if("set_property"==e.type){let t=split_path(e.path);this.set_property(t,e.property,e.value)}else if("set_animation"==e.type)e.animations.forEach((e=>{e.path=split_path(e.path)})),this.set_animation(e.animations,e.options);else if("set_target"==e.type)this.set_camera_target(e.value);else if("set_control"==e.type)this.set_control(e.name,e.callback,e.value,e.min,e.max,e.step,e.keycode1,e.keycode2);else if("set_control_value"==e.type)this.set_control_value(e.name,e.value,e.invoke_callback);else if("delete_control"==e.type)this.delete_control(e.name);else if("capture_image"==e.type){let t=e.xres||1920,n=e.yres||1080;t/=this.renderer.getPixelRatio(),n/=this.renderer.getPixelRatio();let i=this.capture_image(t,n);this.connection.send(JSON.stringify({type:"img",data:i}))}else"save_image"==e.type?this.save_image():"enable_webxr"==e.type?this.enable_webxr(e.mode):"visualize_vr_controller"==e.type&&this.visualize_vr_controllers();this.set_dirty()}decode(e){return msgpack.decode(new Uint8Array(e.data),{extensionCodec})}handle_command_bytearray(e){let t=msgpack.decode(e,{extensionCodec});this.handle_command(t)}handle_command_message(e){this.num_messages_received++;let t=this.decode(e);this.handle_command(t)}connect(e){void 0===e&&(e=`ws://${location.host}`),"https:"==location.protocol&&(e=e.replace("ws:","wss:")),this.connection=new WebSocket(e),this.connection.binaryType="arraybuffer",this.connection.onmessage=e=>this.handle_command_message(e),this.connection.onclose=function(e){console.log("onclose:",e)}}save_scene(){download_file("scene.json",JSON.stringify(this.scene.toJSON()))}load_scene_from_json(e){let t=new ExtensibleObjectLoader;t.onTextureLoad=()=>{this.set_dirty()},this.scene_tree.dispose_recursive(),this.scene=t.parse(e),this.show_background(),this.create_scene_tree();let n=this.scene_tree.find(["Cameras","default","rotated",""]);n.object.isCamera?this.set_camera(n.object):this.create_camera()}handle_load_file(e){let t=e.files[0];if(!t)return;let n=new FileReader,i=this;n.onload=function(e){let t=this.result,n=JSON.parse(t);i.load_scene_from_json(n)},n.readAsText(t)}load_scene(){let e=document.createElement("input");e.type="file",document.body.appendChild(e);let t=this;e.addEventListener("change",(function(){console.log(this,t),t.handle_load_file(this)}),!1),e.click(),e.remove()}update_webxr_buttons(){const e=document.getElementById("XRButton"),t=document.getElementById("VRButton"),n=e||t;null!=n&&null!=n.textContent&&0!=n.textContent.length&&(null==n.original_content&&(n.original_content=n.textContent,n.original_disabled=n.disabled),this.is_perspective()?null!=n.original_content&&(n.textContent=n.original_content,n.disabled=n.original_disabled,n.original_content=null,n.original_disabled=null):(n.disabled=!0,n.textContent="AR/VR Disabled for Orthographic Cameras"))}visualize_vr_controllers(){const e=new three_examples_jsm_webxr_XRControllerModelFactory__WEBPACK_IMPORTED_MODULE_8__.i,t=(new three__WEBPACK_IMPORTED_MODULE_2__.BufferGeometry).setFromPoints([new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,0),new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,-1)]),n=new three__WEBPACK_IMPORTED_MODULE_2__.Line(t);n.scale.z=5;const i=[];for(let t=0;t<2;t++){const r=this.renderer.xr.getController(t);r.add(n.clone());const s=new three__WEBPACK_IMPORTED_MODULE_2__.Group;s.rotation.x=Math.PI/2,s.add(r),this.scene.add(s),i.push(s);const a=this.renderer.xr.getControllerGrip(t),o=new three__WEBPACK_IMPORTED_MODULE_2__.Group;o.rotation.x=Math.PI/2,o.add(a),this.scene.add(o);const l=e.createControllerModel(a);a.add(l)}return i}enable_webxr(e="ar"){if(this.renderer.xr.enabled)console.warn("WebXR/VR has already been enabled.");else{if("vr"==e)this.xr_button=three_examples_jsm_webxr_VRButton_js__WEBPACK_IMPORTED_MODULE_9__.N.createButton(this.renderer);else{if("ar"!=e)return void console.error(`enable_webxr takes either "ar" or "vr" as arguments. Given "${e}".`);this.xr_button=three_examples_jsm_webxr_XRButton_js__WEBPACK_IMPORTED_MODULE_10__.v.createButton(this.renderer)}this.renderer.xr.enabled=!0,document.body.appendChild(this.xr_button),wait_for_property(this.xr_button,"textContent",(e=>e.length>0)).then((()=>{this.update_webxr_buttons()}));var t=null;this.renderer.xr.addEventListener("sessionstart",(()=>{t=this.camera.updateProjectionMatrix,"ar"==e&&this.set_property(["Background"],"use_ar_background",!0),this.webxr_session_active=!0,console.info("Immersive session starting, controls are being removed."),this.renderer.xr.getSession().requestReferenceSpace("local").then((e=>{let t=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3;t.setFromMatrixColumn(this.camera.matrixWorld,2),Math.abs(t.y)>.5&&console.warn("The view camera was pointed up or down a significant amount when entering XR mode. Tilt the headset the same amount to see the camera's original target.");let n=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(t.x,0,t.z);n.normalize();let i=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,1),r=new three__WEBPACK_IMPORTED_MODULE_2__.Quaternion;r.setFromUnitVectors(n,i);const s=this.camera.position.clone().negate();s.applyQuaternion(r);let a=new XRRigidTransform(s,r);this.renderer.xr.setReferenceSpace(e.getOffsetReferenceSpace(a))})),this.camera.updateProjectionMatrix=()=>{console.warn("Updating the camera projection matrix is disallowed in immersive mode.")},this.renderer.setAnimationLoop((()=>{this.renderer.render(this.scene,this.camera)}))})),this.renderer.xr.addEventListener("sessionend",(()=>{this.webxr_session_active=!1,"ar"==e&&this.set_property(["Background"],"use_ar_background",!1),this.renderer.setAnimationLoop(null),this.camera.updateProjectionMatrix=t}))}}}function split_path(e){return e.split("/").filter((e=>e.length>0))}let style=document.createElement("style");style.appendChild(document.createTextNode("")),document.head.appendChild(style),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input {\n float: right;\n }"),style.sheet.insertRule("\n .meshcat-hidden-scene-element li .meshcat-visibility-checkbox {\n opacity: 0.25;\n pointer-events: none;\n }"),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input[type=checkbox] {\n height: 16px;\n width: 16px;\n display:inline-block;\n padding: 0 0 0 0px;\n }")})(),__webpack_exports__})()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MeshCat=t():e.MeshCat=t()}(self,(function(){return(()=>{var __webpack_modules__={583:(e,t,n)=>{var i;e=n.nmd(e),function(){if(void 0!==e.exports)var r=n(617),s=n(549),a=n(468);var o={function:!0,object:!0};function l(e){return e&&e.Object===Object?e:null}parseFloat,parseInt;var c=o[typeof t]&&t&&!t.nodeType?t:void 0,h=o.object&&e&&!e.nodeType?e:void 0,u=(h&&h.exports,l(c&&h&&"object"==typeof n.g&&n.g)),d=l(o[typeof self]&&self),p=l(o[typeof window]&&window),f=l(o[typeof this]&&this);function m(e){return String("0000000"+e).slice(-7)}u||p!==(f&&f.window)&&p||d||f||Function("return this")(),"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),r=i.length,s=new Uint8Array(r),a=0;a=c.frameLimit||c.timeLimit&&e>=c.timeLimit)&&(G(),W());var t=new Date(null);t.setSeconds(e),c.motionBlurFrames>2?v.textContent="CCapture "+c.format+" | "+d+" frames ("+p+" inter) | "+t.toISOString().substr(11,8):v.textContent="CCapture "+c.format+" | "+d+" frames | "+t.toISOString().substr(11,8)}(),j("Frame: "+d+" "+p);for(var s=0;s=h[s].triggerTime&&(H(h[s].callback),h.splice(s,1));for(s=0;s=u[s].triggerTime&&(H(u[s].callback),u[s].triggerTime+=u[s].time);f.forEach((function(e){H(e,n-g)})),f=[]}function W(e){e||(e=function(e){return s(e,l.filename+l.extension,l.mimeType),!1}),l.save(e)}function j(e){t&&console.log(e)}return{start:function(){!function(){function e(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),z.push(this)),this._hookedTime+c.startTime}j("Capturer start"),i=window.Date.now(),n=i+c.startTime,a=window.performance.now(),r=a+c.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(e,t){var i={callback:e,time:t,triggerTime:n+t};return h.push(i),j("Timeout set to "+i.time),i},window.clearTimeout=function(e){for(var t=0;t2?(function(e){A.width===e.width&&A.height===e.height||(A.width=e.width,A.height=e.height,E=new Uint16Array(A.height*A.width*4),C.fillStyle="#0",C.fillRect(0,0,A.width,A.height))}(e),function(e){C.drawImage(e,0,0),T=C.getImageData(0,0,A.width,A.height);for(var t=0;t=.5*c.motionBlurFrames?function(){for(var e=T.data,t=0;t0&&this.frames.length/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(e){this.filename=this.baseFilename+"-part-"+m(this.part),s(e,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+m(this.part),this.step()}.bind(this)):this.step()},b.prototype.save=function(e){this.videoWriter.complete().then(e)},b.prototype.dispose=function(e){this.frames=[]},w.prototype=Object.create(_.prototype),w.prototype.start=function(){this.encoder.start(this.settings)},w.prototype.add=function(e){this.encoder.add(e)},w.prototype.save=function(e){this.callback=e,this.encoder.end()},w.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},M.prototype=Object.create(_.prototype),M.prototype.add=function(e){this.stream||(this.stream=e.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(e){this.chunks.push(e.data)}.bind(this)),this.step()},M.prototype.save=function(e){this.mediaRecorder.onstop=function(t){var n=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],e(n)}.bind(this),this.mediaRecorder.stop()},S.prototype=Object.create(_.prototype),S.prototype.add=function(e){this.sizeSet||(this.encoder.setOption("width",e.width),this.encoder.setOption("height",e.height),this.sizeSet=!0),this.canvas.width=e.width,this.canvas.height=e.height,this.ctx.drawImage(e,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},S.prototype.save=function(e){this.callback=e,this.encoder.render()},(p||d||{}).CCapture=E,void 0===(i=function(){return E}.call(t,n,t,e))||(e.exports=i)}()},549:e=>{void 0!==e.exports&&(e.exports=function(e,t,n){var i,r,s,a=window,o="application/octet-stream",l=n||o,c=e,h=document,u=h.createElement("a"),d=function(e){return String(e)},p=a.Blob||a.MozBlob||a.WebKitBlob||d,f=a.MSBlobBuilder||a.WebKitBlobBuilder||a.BlobBuilder,m=t||"download";if("true"===String(this)&&(l=(c=[c,l])[0],c=c[1]),String(c).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(function(e){for(var t=e.split(/[:;,]/),n=t[1],i=("base64"==t[2]?atob:decodeURIComponent)(t.pop()),r=i.length,s=0,a=new Uint8Array(r);s{e.exports=function e(t,n,i){function r(a,o){if(!n[a]){if(!t[a]){if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return r(t[a][1][e]||e)}),c,c.exports,e,t,n,i)}return n[a].exports}for(var s=void 0,a=0;a0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},i.prototype.removeListener=function(e,t){var n,i,a,o;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(o=a;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){i=o;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,n){var i=e("./TypedNeuQuant.js"),r=e("./LZWEncoder.js");function s(){this.page=-1,this.pages=[],this.newPage()}s.pageSize=4096,s.charMap={};for(var a=0;a<256;a++)s.charMap[a]=String.fromCharCode(a);function o(e,t){this.width=~~e,this.height=~~t,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new s}s.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(s.pageSize),this.cursor=0},s.prototype.getData=function(){for(var e="",t=0;t=s.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=e},s.prototype.writeUTFBytes=function(e){for(var t=e.length,n=0;n=0&&(this.dispose=e)},o.prototype.setRepeat=function(e){this.repeat=e},o.prototype.setTransparent=function(e){this.transparent=e},o.prototype.addFrame=function(e){this.image=e,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},o.prototype.finish=function(){this.out.writeByte(59)},o.prototype.setQuality=function(e){e<1&&(e=1),this.sample=e},o.prototype.setDither=function(e){!0===e&&(e="FloydSteinberg"),this.dither=e},o.prototype.setGlobalPalette=function(e){this.globalPalette=e},o.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},o.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},o.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new i(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},o.prototype.indexPixels=function(e){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);for(var n=0,i=0;i=0&&b+h=0&&w+c>16,(65280&e)>>8,255&e,t)},o.prototype.findClosestRGB=function(e,t,n,i){if(null===this.colorTab)return-1;if(this.neuQuant&&!i)return this.neuQuant.lookupRGB(e,t,n);for(var r=0,s=16777216,a=this.colorTab.length,o=0,l=0;o=0&&(t=7&this.dispose),t<<=2,this.out.writeByte(0|t|e),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},o.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},o.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},o.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},o.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var e=768-this.colorTab.length,t=0;t>8&255)},o.prototype.writePixels=function(){new r(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this.out)},o.prototype.stream=function(){return this.out},t.exports=o},{"./LZWEncoder.js":3,"./TypedNeuQuant.js":4}],3:[function(e,t,n){var i=5003,r=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];t.exports=function(e,t,n,s){var a,o,l,c,h,u,d=Math.max(2,s),p=new Uint8Array(256),f=new Int32Array(i),m=new Int32Array(i),g=0,_=0,v=!1;function y(e,t){p[o++]=e,o>=254&&w(t)}function x(e){b(i),_=h+2,v=!0,E(h,e)}function b(e){for(var t=0;t0&&(e.writeByte(o),e.writeBytes(p,0,o),o=0)}function M(e){return(1<0?a|=e<=8;)y(255&a,t),a>>=8,g-=8;if((_>l||v)&&(v?(l=M(n_bits=c),v=!1):(++n_bits,l=12==n_bits?4096:M(n_bits))),e==u){for(;g>0;)y(255&a,t),a>>=8,g-=8;w(t)}}this.encode=function(n){n.writeByte(d),remaining=e*t,curPixel=0,function(e,t){var n,r,s,a,d,p;for(c=e,v=!1,n_bits=c,l=M(n_bits),u=1+(h=1<=0){d=5003-s,0===s&&(d=1);do{if((s-=d)<0&&(s+=5003),f[s]===n){a=m[s];continue e}}while(f[s]>=0)}E(a,t),a=r,_<4096?(m[s]=_++,f[s]=n):x(t)}else a=m[s];E(a,t),E(u,t)}(d+1,n),n.writeByte(0)}}},{}],4:[function(e,t,n){var i=256,r=1024,s=1<<18;t.exports=function(e,t){var n,a,o,l,c;function h(e,t,i,s,a){n[t][0]-=e*(n[t][0]-i)/r,n[t][1]-=e*(n[t][1]-s)/r,n[t][2]-=e*(n[t][2]-a)/r}function u(e,t,r,a,o){for(var l,h,u=Math.abs(t-e),d=Math.min(t+e,i),p=t+1,f=t-1,m=1;pu;)h=c[m++],pu&&((l=n[f--])[0]-=h*(l[0]-r)/s,l[1]-=h*(l[1]-a)/s,l[2]-=h*(l[2]-o)/s)}function d(e,t,r){var s,a,c,h,u,d=~(1<<31),p=d,f=-1,m=f;for(s=0;s>12))>10,l[s]-=u,o[s]+=u<<10;return l[f]+=64,o[f]-=65536,m}this.buildColormap=function(){(function(){var e,t;for(n=[],a=new Int32Array(256),o=new Int32Array(i),l=new Int32Array(i),c=new Int32Array(32),e=0;e>6;for(y<=1&&(y=0),n=0;n=p&&(x-=p),0===g&&(g=1),++n%g==0)for(_-=_/f,(y=(v-=v/30)>>6)<=1&&(y=0),l=0;l>=4,n[e][1]>>=4,n[e][2]>>=4,n[e][3]=e}(),function(){var e,t,r,s,o,l,c=0,h=0;for(e=0;e>1,t=c+1;t>1,t=c+1;t<256;t++)a[t]=255}()},this.getColormap=function(){for(var e=[],t=[],r=0;r=0;)u=c?u=i:(u++,l<0&&(l=-l),(s=o[0]-e)<0&&(s=-s),(l+=s)=0&&((l=t-(o=n[d])[1])>=c?d=-1:(d--,l<0&&(l=-l),(s=o[0]-e)<0&&(s=-s),(l+=s)t;0<=t?++e:--e)n.push(null);return n}.call(this),t=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(e=0,n=t;0<=n?en;0<=n?++e:--e)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},i.prototype.abort=function(){for(var e;null!=(e=this.activeWorkers.shift());)this.log("killing active worker"),e.terminate();return this.running=!1,this.emit("abort")},i.prototype.spawnWorkers=function(){var e,t,n,i;return e=Math.min(this.options.workers,this.frames.length),function(){n=[];for(var i=t=this.freeWorkers.length;t<=e?ie;t<=e?i++:i--)n.push(i);return n}.apply(this).forEach((i=this,function(e){var t;return i.log("spawning worker "+e),(t=new Worker(i.options.workerScript)).onmessage=function(e){return i.activeWorkers.splice(i.activeWorkers.indexOf(t),1),i.freeWorkers.push(t),i.frameFinished(e.data)},i.freeWorkers.push(t)})),e},i.prototype.frameFinished=function(e){var t,n;if(this.log("frame "+e.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[e.index]=e,!0===this.options.globalPalette&&(this.options.globalPalette=e.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(t=1,n=this.freeWorkers.length;1<=n?tn;1<=n?++t:--t)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},i.prototype.finishRendering=function(){var e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m;for(o=0,r=0,l=(p=this.imageParts).length;r=this.frames.length))return e=this.frames[this.nextFrame++],n=this.freeWorkers.shift(),t=this.getTask(e),this.log("starting frame "+(t.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(t)},i.prototype.getContextData=function(e){return e.getImageData(0,0,this.options.width,this.options.height).data},i.prototype.getImageData=function(e){var t;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(t=this._canvas.getContext("2d")).setFill=this.options.background,t.fillRect(0,0,this.options.width,this.options.height),t.drawImage(e,0,0),this.getContextData(t)},i.prototype.getTask=function(e){var t,n;if(n={index:t=this.frames.indexOf(e),last:t===this.frames.length-1,delay:e.delay,dispose:e.dispose,transparent:e.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:"chrome"===r.name},null!=e.data)n.data=e.data;else if(null!=e.context)n.data=this.getContextData(e.context);else{if(null==e.image)throw new Error("Invalid frame");n.data=this.getImageData(e.image)}return n},i.prototype.log=function(){var e;if(e=1<=arguments.length?o.call(arguments,0):[],this.options.debug)return console.log.apply(console,e)},i}(i)},{"./GIFEncoder.js":2,"./browser.coffee":5,"./gif.worker.coffee":7,events:1}],7:[function(e,t,n){var i,r;i=e("./GIFEncoder.js"),r=function(e){var t,n,r,s;return t=new i(e.width,e.height),0===e.index?t.writeHeader():t.firstFrame=!1,t.setTransparent(e.transparent),t.setDispose(e.dispose),t.setRepeat(e.repeat),t.setDelay(e.delay),t.setQuality(e.quality),t.setDither(e.dither),t.setGlobalPalette(e.globalPalette),t.addFrame(e.data),e.last&&t.finish(),!0===e.globalPalette&&(e.globalPalette=t.getGlobalPalette()),r=t.stream(),e.data=r.pages,e.cursor=r.cursor,e.pageSize=r.constructor.pageSize,e.canTransfer?(s=function(){var t,i,r,s;for(s=[],t=0,i=(r=e.data).length;t{!function(){"use strict";var e=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"];function t(e){var t,n=new Uint8Array(e);for(t=0;t>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];switch(o.length%4){case 1:o+="=";break;case 2:o+="=="}return o}}(),function(){"use strict";var e,t=window.utils;e=[{field:"fileName",length:100},{field:"fileMode",length:8},{field:"uid",length:8},{field:"gid",length:8},{field:"fileSize",length:12},{field:"mtime",length:12},{field:"checksum",length:8},{field:"type",length:1},{field:"linkName",length:100},{field:"ustar",length:8},{field:"owner",length:32},{field:"group",length:32},{field:"majorNumber",length:8},{field:"minorNumber",length:8},{field:"filenamePrefix",length:155},{field:"padding",length:12}],window.header={},window.header.structure=e,window.header.format=function(n,i){var r=t.clean(512),s=0;return e.forEach((function(e){var t,i,a=n[e.field]||"";for(t=0,i=a.length;ti&&(t.push({blocks:r,length:n}),r=[],n=0),r.push(e),n+=e.headerLength+e.inputLength})),t.push({blocks:r,length:n}),t.forEach((function(t){var n=new Uint8Array(t.length),i=0;t.blocks.forEach((function(e){n.set(e.header,i),i+=e.headerLength,n.set(e.input,i),i+=e.inputLength})),e.push(n)})),e.push(new Uint8Array(1024)),new Blob(e,{type:"octet/stream"})},s.prototype.clear=function(){this.written=0,this.out=i.clean(t)},void 0!==e.exports?e.exports=s:window.Tar=s}()},376:(e,t,n)=>{"use strict";function i(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),s=Math.round(e.b),a=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+s+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+s+","+a+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+s+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+s+","+a+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+s+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+s+",a:"+a+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+a+"}":"unknown format"}n.d(t,{ZP:()=>he});var r=Array.prototype.forEach,s=Array.prototype.slice,a={BREAK:{},extend:function(e){return this.each(s.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(s.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=s.call(arguments);return function(){for(var t=s.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(r&&e.forEach&&e.forEach===r)e.forEach(t,n);else if(e.length===e.length+0){var i,s=void 0;for(s=0,i=e.length;s1?a.toArray(arguments):arguments[0];return a.each(o,(function(t){if(t.litmus(e))return a.each(t.conversions,(function(t,n){if(l=t.read(e),!1===c&&!1!==l)return c=l,l.conversionName=n,l.conversion=t,a.BREAK})),a.BREAK})),c},u=void 0,d={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),s=n*(1-t),a=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,s],[a,n,s],[s,n,o],[s,a,n],[o,s,n],[n,s,a]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),s=r-i,a=void 0;return 0===r?{h:NaN,s:0,v:0}:(a=e===r?(t-n)/s:t===r?2+(n-e)/s:4+(e-t)/s,(a/=6)<0&&(a+=1),{h:360*a,s:s/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(u=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var P=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=i||{};return r.__min=s.min,r.__max=s.max,r.__step=s.step,a.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=L(r.__impliedStep),r}return _(t,e),m(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=L(e),this}}]),t}(w),I=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var s=r,o=void 0;function l(){s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function c(e){var t=o-e.clientY;s.setValue(s.getValue()+t*s.__impliedStep),o=e.clientY}function h(){T.unbind(window,"mousemove",c),T.unbind(window,"mouseup",h),l()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),T.bind(r.__input,"change",(function(){var e=parseFloat(s.__input.value);a.isNaN(e)||s.setValue(e)})),T.bind(r.__input,"blur",(function(){l()})),T.bind(r.__input,"mousedown",(function(e){T.bind(window,"mousemove",c),T.bind(window,"mouseup",h),o=e.clientY})),T.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(s.__truncationSuspended=!0,this.blur(),s.__truncationSuspended=!1,l())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(P);function U(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var O=function(e){function t(e,n,i,r,s){f(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:s})),o=a;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(U(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){T.unbind(window,"mousemove",l),T.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(U(t,n.left,n.right,o.__min,o.__max))}function u(){T.unbind(window,"touchmove",h),T.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),T.bind(a.__background,"mousedown",(function(e){document.activeElement.blur(),T.bind(window,"mousemove",l),T.bind(window,"mouseup",c),l(e)})),T.bind(a.__background,"touchstart",(function(e){1===e.touches.length&&(T.bind(window,"touchmove",h),T.bind(window,"touchend",u),h(e))})),T.addClass(a.__background,"slider"),T.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",g(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(P),N=function(e){function t(e,n,i){f(this,t);var r=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,T.bind(r.__button,"click",(function(e){return e.preventDefault(),s.fire(),!1})),T.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return _(t,e),m(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(w),D=function(e){function t(e,n){f(this,t);var i=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new y(i.getValue()),i.__temp=new y(0);var r=i;i.domElement=document.createElement("div"),T.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",T.bind(i.__input,"keydown",(function(e){13===e.keyCode&&p.call(this)})),T.bind(i.__input,"blur",p),T.bind(i.__selector,"mousedown",(function(){T.addClass(this,"drag").bind(window,"mouseup",(function(){T.removeClass(r.__selector,"drag")}))})),T.bind(i.__selector,"touchstart",(function(){T.addClass(this,"drag").bind(window,"touchend",(function(){T.removeClass(r.__selector,"drag")}))}));var s,o=document.createElement("div");function l(e){g(e),T.bind(window,"mousemove",g),T.bind(window,"touchmove",g),T.bind(window,"mouseup",u),T.bind(window,"touchend",u)}function c(e){_(e),T.bind(window,"mousemove",_),T.bind(window,"touchmove",_),T.bind(window,"mouseup",d),T.bind(window,"touchend",d)}function u(){T.unbind(window,"mousemove",g),T.unbind(window,"touchmove",g),T.unbind(window,"mouseup",u),T.unbind(window,"touchend",u),m()}function d(){T.unbind(window,"mousemove",_),T.unbind(window,"touchmove",_),T.unbind(window,"mouseup",d),T.unbind(window,"touchend",d),m()}function p(){var e=h(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function m(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function g(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,s=n.clientY,a=(i-t.left)/(t.right-t.left),o=1-(s-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),a>1?a=1:a<0&&(a=0),r.__color.v=o,r.__color.s=a,r.setValue(r.__color.toOriginal()),!1}function _(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return a.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),a.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),a.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),a.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),a.extend(o.style,{width:"100%",height:"100%",background:"none"}),B(o,"top","rgba(0,0,0,0)","#000"),a.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(s=i.__hue_field).style.background="",s.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",s.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),T.bind(i.__saturation_field,"mousedown",l),T.bind(i.__saturation_field,"touchstart",l),T.bind(i.__field_knob,"mousedown",l),T.bind(i.__field_knob,"touchstart",l),T.bind(i.__hue_field,"mousedown",c),T.bind(i.__hue_field,"touchstart",c),i.__saturation_field.appendChild(o),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return _(t,e),m(t,[{key:"updateDisplay",value:function(){var e=h(this.getValue());if(!1!==e){var t=!1;a.each(y.COMPONENTS,(function(n){if(!a.isUndefined(e[n])&&!a.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&a.extend(this.__color.__state,e)}a.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;a.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,B(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),a.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(w),k=["-moz-","-o-","-webkit-","-ms-",""];function B(e,t,n,i){e.style.background="",a.each(k,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var F='
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
',z=function(e,t){var n=e[t];return a.isArray(arguments[2])||a.isObject(arguments[2])?new C(e,t,arguments[2]):a.isNumber(n)?a.isNumber(arguments[2])&&a.isNumber(arguments[3])?a.isNumber(arguments[4])?new O(e,t,arguments[2],arguments[3],arguments[4]):new O(e,t,arguments[2],arguments[3]):a.isNumber(arguments[4])?new I(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new I(e,t,{min:arguments[2],max:arguments[3]}):a.isString(n)?new R(e,t):a.isFunction(n)?new N(e,t,""):a.isBoolean(n)?new A(e,t):null},G=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},H=function(){function e(){f(this,e),this.backgroundElement=document.createElement("div"),a.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),T.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),a.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;T.bind(this.backgroundElement,"click",(function(){t.hide()}))}return m(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),a.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",T.unbind(e.domElement,"webkitTransitionEnd",t),T.unbind(e.domElement,"transitionend",t),T.unbind(e.domElement,"oTransitionEnd",t)};T.bind(this.domElement,"webkitTransitionEnd",t),T.bind(this.domElement,"transitionend",t),T.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-T.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-T.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var V="Default",W=function(){try{return!!window.localStorage}catch(e){return!1}}(),j=void 0,X=!0,q=void 0,Y=!1,K=[],J=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),T.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=a.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=a.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),a.isUndefined(i.load)?i.load={preset:V}:i.preset&&(i.load.preset=i.preset),a.isUndefined(i.parent)&&i.hideable&&K.push(this),i.resizable=a.isUndefined(i.parent)&&i.resizable,i.autoPlace&&a.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,s=W&&"true"===localStorage.getItem(ne(0,"isLocal")),o=void 0,l=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),te(e,n.object,n.property,{before:i,factoryArgs:[a.toArray(arguments)]})}if(a.isArray(t)||a.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),te(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof O){var i=new I(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});a.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),T.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof I){var r=function(t){if(a.isNumber(n.__min)&&a.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var s=te(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return s.name(i),r&&s.listen(),s}return t};n.min=a.compose(r,n.min),n.max=a.compose(r,n.max)}else n instanceof A?(T.bind(t,"click",(function(){T.fakeEvent(n.__checkbox,"click")})),T.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof N?(T.bind(t,"click",(function(){T.fakeEvent(n.__button,"click")})),T.bind(t,"mouseover",(function(){T.addClass(n.__button,"hover")})),T.bind(t,"mouseout",(function(){T.removeClass(n.__button,"hover")}))):n instanceof D&&(T.addClass(t,"color"),n.updateDisplay=a.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=a.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&$(e.getRoot(),!0),t}),n.setValue)}(e,c,r),e.__controllers.push(r),r}function ne(e,t){return document.location.href+"."+t}function ie(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function re(e,t){t.style.display=e.useLocalStorage?"block":"none"}function se(e){var t=e.__save_row=document.createElement("li");T.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),T.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",T.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",T.addClass(i,"button"),T.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",T.addClass(r,"button"),T.addClass(r,"save-as");var s=document.createElement("span");s.innerHTML="Revert",T.addClass(s,"button"),T.addClass(s,"revert");var o=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?a.each(e.load.remembered,(function(t,n){ie(e,n,n===e.preset)})):ie(e,V,!1),T.bind(o,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=le(this)),e.folders={},a.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=le(this),$(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=le(this,!0)),this.load.remembered[e]=le(this),this.preset=e,ie(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){a.each(this.__controllers,(function(t){this.getRoot().load.remembered?ee(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),a.each(this.__folders,(function(e){e.revert(e)})),e||$(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&ce(this.__listening)},updateDisplay:function(){a.each(this.__controllers,(function(e){e.updateDisplay()})),a.each(this.__folders,(function(e){e.updateDisplay()}))}});const he={color:{Color:y,math:d,interpret:h},controllers:{Controller:w,BooleanController:A,OptionController:C,StringController:R,NumberController:P,NumberControllerBox:I,NumberControllerSlider:O,FunctionController:N,ColorController:D},dom:{dom:T},gui:{GUI:J},GUI:J}},973:(e,t,n)=>{"use strict";n.d(t,{eW:()=>S,oe:()=>x});var i=n(477);class r{static addMaterial(e,t,n,i,r){let s;t.name=n,i?(e[n]=t,r&&console.info('Material with name "'+n+'" was forcefully overridden.')):(s=e[n],s?s.uuid!=s.uuid&&r&&console.log('Same material name "'+s.name+'" different uuid ['+s.uuid+"|"+t.uuid+"]"):(e[n]=t,r&&console.info('Material with name "'+n+'" was added.')))}static getMaterialsJSON(e){const t={};let n;for(const i in e)n=e[i],"function"==typeof n.toJSON&&(t[i]=n.toJSON());return t}static cloneMaterial(e,t,n){let i;if(t){let s=t.materialNameOrg;s=null!=s?s:"";const a=e[s];a?(i=a.clone(),Object.assign(i,t.materialProperties),r.addMaterial(e,i,t.materialProperties.name,!0)):n&&console.info('Requested material "'+s+'" is not available!')}return i}}class s{static buildThreeConst(){return"const EventDispatcher = THREE.EventDispatcher;\nconst BufferGeometry = THREE.BufferGeometry;\nconst BufferAttribute = THREE.BufferAttribute;\nconst Box3 = THREE.Box3;\nconst Sphere = THREE.Sphere;\nconst Texture = THREE.Texture;\nconst MaterialLoader = THREE.MaterialLoader;\n"}static buildUglifiedThreeMapping(){return s.buildUglifiedNameAssignment((function(){return i.BufferGeometry}),"BufferGeometry",/_BufferGeometry/,!1)+s.buildUglifiedNameAssignment((function(){return i.BufferAttribute}),"BufferAttribute",/_BufferAttribute/,!1)+s.buildUglifiedNameAssignment((function(){return i.Box3}),"Box3",/_Box3/,!1)+s.buildUglifiedNameAssignment((function(){return i.Sphere}),"Sphere",/_Sphere/,!1)+s.buildUglifiedNameAssignment((function(){return i.Texture}),"Texture",/_Texture/,!1)+s.buildUglifiedNameAssignment((function(){return i.MaterialLoader}),"MaterialLoader",/_MaterialLoader/,!1)}static buildUglifiedThreeWtmMapping(){return s.buildUglifiedNameAssignment((function(){return a}),"DataTransport",/_DataTransport/,!0)+s.buildUglifiedNameAssignment((function(){return l}),"GeometryTransport",/_GeometryTransport/,!0)+s.buildUglifiedNameAssignment((function(){return c}),"MeshTransport",/_MeshTransport/,!0)+s.buildUglifiedNameAssignment((function(){return o}),"MaterialsTransport",/_MaterialsTransport/,!0)+s.buildUglifiedNameAssignment((function(){return r}),"MaterialUtils",/_MaterialUtils/,!0)}static buildUglifiedNameAssignment(e,t,n,i){let r=e.toString();r=r.replace(n,"").replace(/[\r\n]+/gm,""),r=r.replace(/.*return/,"").replace(/\}/,"").replace(/;/gm,"");const s=r.trim();let a="";return s!==t&&(a="const "+(i?t:s)+" = "+(i?s:t)+";\n"),a}}class a{constructor(e,t){this.main={cmd:void 0!==e?e:"unknown",id:void 0!==t?t:0,type:"DataTransport",progress:0,buffers:{},params:{}},this.transferables=[]}loadData(e){return this.main.cmd=e.cmd,this.main.id=e.id,this.main.type="DataTransport",this.setProgress(e.progress),this.setParams(e.params),e.buffers&&Object.entries(e.buffers).forEach((([e,t])=>{this.main.buffers[e]=t})),this}getCmd(){return this.main.cmd}getId(){return this.main.id}setParams(e){return null!=e&&(this.main.params=e),this}getParams(){return this.main.params}setProgress(e){return this.main.progress=e,this}addBuffer(e,t){return this.main.buffers[e]=t,this}getBuffer(e){return this.main.buffers[e]}package(e){for(let t of Object.values(this.main.buffers))if(null!=t){const n=e?t.slice(0):t;this.transferables.push(n)}return this}getMain(){return this.main}getTransferables(){return this.transferables}postMessage(e){return e.postMessage(this.main,this.transferables),this}}class o extends a{constructor(e,t){super(e,t),this.main.type="MaterialsTransport",this.main.materials={},this.main.multiMaterialNames={},this.main.cloneInstructions=[]}loadData(e){super.loadData(e),this.main.type="MaterialsTransport",Object.assign(this.main,e);const t=new i.MaterialLoader;return Object.entries(this.main.materials).forEach((([e,n])=>{this.main.materials[e]=t.parse(n)})),this}_cleanMaterial(e){return Object.entries(e).forEach((([t,n])=>{(n instanceof i.Texture||null===n)&&(e[t]=void 0)})),e}addBuffer(e,t){return super.addBuffer(e,t),this}setParams(e){return super.setParams(e),this}setMaterials(e){return null!=e&&Object.keys(e).length>0&&(this.main.materials=e),this}getMaterials(){return this.main.materials}cleanMaterials(){let e,t={};for(let n of Object.values(this.main.materials))"function"==typeof n.clone&&(e=n.clone(),t[e.name]=this._cleanMaterial(e));return this.setMaterials(t),this}package(e){return super.package(e),this.main.materials=r.getMaterialsJSON(this.main.materials),this}hasMultiMaterial(){return Object.keys(this.main.multiMaterialNames).length>0}getSingleMaterial(){return Object.keys(this.main.materials).length>0?Object.entries(this.main.materials)[0][1]:null}processMaterialTransport(e,t){for(let n=0;n{n[t]=e[i]}));else{const t=this.getSingleMaterial();null!==t&&(n=e[t.name],n||(n=t))}return n}}class l extends a{constructor(e,t){super(e,t),this.main.type="GeometryTransport",this.main.geometryType=0,this.main.geometry={},this.main.bufferGeometry=null}loadData(e){return super.loadData(e),this.main.type="GeometryTransport",this.setGeometry(e.geometry,e.geometryType)}getGeometryType(){return this.main.geometryType}setParams(e){return super.setParams(e),this}setGeometry(e,t){return this.main.geometry=e,this.main.geometryType=t,e instanceof i.BufferGeometry&&(this.main.bufferGeometry=e),this}package(e){super.package(e);const t=this.main.geometry.getAttribute("position"),n=this.main.geometry.getAttribute("normal"),i=this.main.geometry.getAttribute("uv"),r=this.main.geometry.getAttribute("color"),s=this.main.geometry.getAttribute("skinIndex"),a=this.main.geometry.getAttribute("skinWeight"),o=this.main.geometry.getIndex();return this._addBufferAttributeToTransferable(t,e),this._addBufferAttributeToTransferable(n,e),this._addBufferAttributeToTransferable(i,e),this._addBufferAttributeToTransferable(r,e),this._addBufferAttributeToTransferable(s,e),this._addBufferAttributeToTransferable(a,e),this._addBufferAttributeToTransferable(o,e),this}reconstruct(e){if(this.main.bufferGeometry instanceof i.BufferGeometry)return this;this.main.bufferGeometry=new i.BufferGeometry;const t=this.main.geometry;this._assignAttribute(t.attributes.position,"position",e),this._assignAttribute(t.attributes.normal,"normal",e),this._assignAttribute(t.attributes.uv,"uv",e),this._assignAttribute(t.attributes.color,"color",e),this._assignAttribute(t.attributes.skinIndex,"skinIndex",e),this._assignAttribute(t.attributes.skinWeight,"skinWeight",e);const n=t.index;if(null!=n){const t=e?n.array.slice(0):n.array;this.main.bufferGeometry.setIndex(new i.BufferAttribute(t,n.itemSize,n.normalized))}const r=t.boundingBox;null!==r&&(this.main.bufferGeometry.boundingBox=Object.assign(new i.Box3,r));const s=t.boundingSphere;return null!==s&&(this.main.bufferGeometry.boundingSphere=Object.assign(new i.Sphere,s)),this.main.bufferGeometry.uuid=t.uuid,this.main.bufferGeometry.name=t.name,this.main.bufferGeometry.type=t.type,this.main.bufferGeometry.groups=t.groups,this.main.bufferGeometry.drawRange=t.drawRange,this.main.bufferGeometry.userData=t.userData,this}getBufferGeometry(){return this.main.bufferGeometry}_addBufferAttributeToTransferable(e,t){if(null!=e){const n=t?e.array.slice(0):e.array;this.transferables.push(n.buffer)}return this}_assignAttribute(e,t,n){if(e){const r=n?e.array.slice(0):e.array;this.main.bufferGeometry.setAttribute(t,new i.BufferAttribute(r,e.itemSize,e.normalized))}return this}}class c extends l{constructor(e,t){super(e,t),this.main.type="MeshTransport",this.main.materialsTransport=new o}loadData(e){return super.loadData(e),this.main.type="MeshTransport",this.main.meshName=e.meshName,this.main.materialsTransport=(new o).loadData(e.materialsTransport.main),this}setParams(e){return super.setParams(e),this}setMaterialsTransport(e){return e instanceof o&&(this.main.materialsTransport=e),this}getMaterialsTransport(){return this.main.materialsTransport}setMesh(e,t){return this.main.meshName=e.name,super.setGeometry(e.geometry,t),this}package(e){return super.package(e),null!==this.main.materialsTransport&&this.main.materialsTransport.package(e),this}reconstruct(e){return super.reconstruct(e),this}}class h{static serializePrototype(e,t,n,i){let r,s=[],a="";i?(a=e.toString()+"\n\n",r=t):r=e;for(let e in r){let t=r[e],n=t.toString();"function"==typeof t&&s.push("\t"+e+": "+n+",\n\n")}a+=n+(i?".prototype":"")+" = {\n\n";for(let e=0;e0){let n;for(const i in e)n=e[i],r.addMaterial(this.materials,n,i,!0===t)}}getMaterials(){return this.materials}getMaterial(e){return this.materials[e]}clearMaterials(){this.materials={}}}class p{static comRouting(e,t,n,i,r){let s=t.data;"init"===s.cmd?null!=n?n[i](e,s.workerId,s.config):i(e,s.workerId,s.config):"execute"===s.cmd&&(null!=n?n[r](e,s.workerId,s.config):r(e,s.workerId,s.config))}}class f{constructor(e){this.taskTypes=new Map,this.verbose=!1,this.maxParallelExecutions=e||4,this.actualExecutionCount=0,this.storedExecutions=[],this.teardown=!1}setVerbose(e){return this.verbose=e,this}setMaxParallelExecutions(e){return this.maxParallelExecutions=e,this}getMaxParallelExecutions(){return this.maxParallelExecutions}supportsTaskType(e){return this.taskTypes.has(e)}registerTaskType(e,t,n,i,r,s){let a=!this.supportsTaskType(e);if(a){let a=new m(e,this.maxParallelExecutions,r,this.verbose);a.setFunctions(t,n,i),a.setDependencyDescriptions(s),this.taskTypes.set(e,a)}return a}registerTaskTypeModule(e,t){let n=!this.supportsTaskType(e);if(n){let n=new m(e,this.maxParallelExecutions,!1,this.verbose);n.setWorkerModule(t),this.taskTypes.set(e,n)}return n}async initTaskType(e,t,n){let i=this.taskTypes.get(e);if(i)if(i.status.initStarted)for(;!i.status.initComplete;)await this._wait(10);else i.status.initStarted=!0,i.isWorkerModule()?await i.createWorkerModules().then((()=>i.initWorkers(t,n))).then((()=>i.status.initComplete=!0)).catch((e=>console.error(e))):await i.loadDependencies().then((()=>i.createWorkers())).then((()=>i.initWorkers(t,n))).then((()=>i.status.initComplete=!0)).catch((e=>console.error(e)))}async _wait(e){return new Promise((t=>{setTimeout(t,e)}))}async enqueueForExecution(e,t,n,i){return new Promise(((r,s)=>{this.storedExecutions.push(new g(e,t,n,r,s,i)),this._depleteExecutions()}))}_depleteExecutions(){let e=0;for(;this.actualExecutionCount{i.onmessage=n=>{"assetAvailable"===n.data.cmd?t.assetAvailableFunction instanceof Function&&t.assetAvailableFunction(n.data):e(n)},i.onerror=n,i.postMessage({cmd:"execute",workerId:i.getId(),config:t.config},t.transferables)})).then((e=>{n.returnAvailableTask(i),t.resolve(e.data),this.actualExecutionCount--,this._depleteExecutions()})).catch((e=>{t.reject("Execution error: "+e)}))):e++}}dispose(){this.teardown=!0;for(let e of this.taskTypes.values())e.dispose();return this}}class m{constructor(e,t,n,i){this.taskType=e,this.fallback=n,this.verbose=!0===i,this.initialised=!1,this.functions={init:null,execute:null,comRouting:null,dependencies:{descriptions:[],code:[]},workerModuleUrl:null},this.workers={code:[],instances:new Array(t),available:[]},this.status={initStarted:!1,initComplete:!1}}getTaskType(){return this.taskType}setFunctions(e,t,n){this.functions.init=e,this.functions.execute=t,this.functions.comRouting=n,void 0!==this.functions.comRouting&&null!==this.functions.comRouting||(this.functions.comRouting=p.comRouting),this._addWorkerCode("init",this.functions.init.toString()),this._addWorkerCode("execute",this.functions.execute.toString()),this._addWorkerCode("comRouting",this.functions.comRouting.toString()),this.workers.code.push('self.addEventListener( "message", message => comRouting( self, message, null, init, execute ), false );')}_addWorkerCode(e,t){t.startsWith("function")?this.workers.code.push("const "+e+" = "+t+";\n\n"):this.workers.code.push("function "+t+";\n\n")}setDependencyDescriptions(e){e&&e.forEach((e=>{this.functions.dependencies.descriptions.push(e)}))}setWorkerModule(e){this.functions.workerModuleUrl=new URL(e,window.location.href)}isWorkerModule(){return null!==this.functions.workerModuleUrl}async loadDependencies(){let e=[],t=new i.FileLoader;t.setResponseType("arraybuffer");for(let n of this.functions.dependencies.descriptions){if(n.url){let i=new URL(n.url,window.location.href);e.push(t.loadAsync(i.href,(e=>{this.verbose&&console.log(e)})))}n.code&&e.push(new Promise((e=>e(n.code))))}this.verbose&&console.log("Task: "+this.getTaskType()+": Waiting for completion of loading of all dependencies."),this.functions.dependencies.code=await Promise.all(e)}async createWorkers(){let e;if(this.fallback)for(let t=0;t{let s;if(i.onmessage=e=>{this.verbose&&console.log("Init Complete: "+e.data.id),n(e)},i.onerror=r,t){s=[];for(let e=0;e0}returnAvailableTask(e){this.workers.available.push(e)}dispose(){for(let e of this.workers.instances)e.terminate()}}class g{constructor(e,t,n,i,r,s){this.taskType=e,this.config=t,this.assetAvailableFunction=n,this.resolve=i,this.reject=r,this.transferables=s}}class _ extends Worker{constructor(e,t,n){super(t,n),this.id=e}getId(){return this.id}}class v{constructor(e,t,n){this.id=e,this.functions={init:t,execute:n}}getId(){return this.id}postMessage(e,t){let n=this,i={postMessage:function(e){n.onmessage({data:e})}};p.comRouting(i,{data:e},null,n.functions.init,n.functions.execute)}terminate(){}}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class x extends i.Loader{constructor(e){super(e),this.parser=new b,this.materialStore=new d(!0),this.parser.materials=this.materialStore.getMaterials()}setLogging(e,t){return this.parser.logging.enabled=!0===e,this.parser.logging.debug=!0===t,this}setMaterialPerSmoothingGroup(e){return this.parser.aterialPerSmoothingGroup=!0===e,this}setUseOAsMesh(e){return this.parser.useOAsMesh=!0===e,this}setUseIndices(e){return this.parser.useIndices=!0===e,this}setDisregardNormals(e){return this.parser.disregardNormals=!0===e,this}setModelName(e){return e&&(this.parser.modelName=e),this}getModelName(){return this.parser.modelName}setBaseObject3d(e){return this.parser.baseObject3d=null==e?this.parser.baseObject3d:e,this}setMaterials(e){return this.materialStore.addMaterials(e,!1),this.parser.materials=this.materialStore.getMaterials(),this}setCallbackOnProgress(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onProgress=e),this}setCallbackOnError(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onError=e),this}setCallbackOnLoad(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onLoad=e),this}setCallbackOnMeshAlter(e){return null!=e&&e instanceof Function&&(this.parser.callbacks.onMeshAlter=e),this}load(e,t,n,r,s){if(!(null!=t&&t instanceof Function)){const e="onLoad is not a function! Aborting...";throw this.parser._onError(e),e}this.setCallbackOnLoad(t);const a=this;null!=r&&r instanceof Function||(r=function(e){let t=e;e.currentTarget&&null!==e.currentTarget.statusText&&(t="Error occurred while downloading!\nurl: "+e.currentTarget.responseURL+"\nstatus: "+e.currentTarget.statusText),a.parser._onError(t)}),e||r("An invalid url was provided. Unable to continue!");const o=new URL(e,window.location.href).href;let l=o;const c=o.split("/");if(c.length>2){l=c[c.length-1];let e=c.slice(0,c.length-1).join("/")+"/";void 0!==e&&(this.path=e)}if(null==n||!(n instanceof Function)){let t=0,i=0;n=function(n){if(n.lengthComputable&&(i=n.loaded/n.total,i>t)){t=i;const n='Download of "'+e+'": '+(100*i).toFixed(2)+"%";a.parser._onProgress("progressLoad",n,i)}}}this.setCallbackOnMeshAlter(s);const h=new i.FileLoader(this.manager);h.setPath(this.path||this.resourcePath),h.setResponseType("arraybuffer"),h.load(l,(function(e){a.parse(e)}),n,r)}parse(e){if(this.parser.logging.enabled&&console.info("Using OBJLoader2 version: "+x.OBJLOADER2_VERSION),null==e)throw"Provided content is not a valid ArrayBuffer or String. Unable to continue parsing";return this.parser.logging.enabled&&console.time("OBJLoader parse: "+this.modelName),e instanceof ArrayBuffer||e instanceof Uint8Array?(this.parser.logging.enabled&&console.info("Parsing arrayBuffer..."),this.parser._execute(e)):"string"==typeof e||e instanceof String?(this.parser.logging.enabled&&console.info("Parsing text..."),this.parser._executeLegacy(e)):this.parser._onError("Provided content was neither of type String nor Uint8Array! Aborting..."),this.parser.logging.enabled&&console.timeEnd("OBJLoader parse: "+this.modelName),this.parser.baseObject3d}}y(x,"OBJLOADER2_VERSION","4.0.0-dev");class b{constructor(){this.logging={enabled:!1,debug:!1},this.usedBefore=!1,this._init(),this.callbacks={onLoad:null,onError:null,onProgress:null,onMeshAlter:null}}_init(){this.contentRef=null,this.legacyMode=!1,this.materials={},this.baseObject3d=new i.Object3D,this.modelName="noname",this.materialPerSmoothingGroup=!1,this.useOAsMesh=!1,this.useIndices=!1,this.disregardNormals=!1,this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.objectId=0,this.rawMesh={objectName:"",groupName:"",activeMtlName:"",mtllibName:"",faceType:-1,subGroups:[],subGroupInUse:null,smoothingGroup:{splitMaterials:!1,normalized:-1,real:-1},counts:{doubleIndicesCount:0,faceCount:0,mtlCount:0,smoothingGroupCount:0}},this.inputObjectCount=1,this.outputObjectCount=1,this.globalCounts={vertices:0,faces:0,doubleIndicesCount:0,lineByte:0,currentByte:0,totalBytes:0}}_resetRawMesh(){this.rawMesh.subGroups=[],this.rawMesh.subGroupInUse=null,this.rawMesh.smoothingGroup.normalized=-1,this.rawMesh.smoothingGroup.real=-1,this._pushSmoothingGroup(1),this.rawMesh.counts.doubleIndicesCount=0,this.rawMesh.counts.faceCount=0,this.rawMesh.counts.mtlCount=0,this.rawMesh.counts.smoothingGroupCount=0}_configure(){if(this.usedBefore=!0,this._pushSmoothingGroup(1),this.logging.enabled){const e=Object.keys(this.materials);let t="OBJLoader2 Parser configuration:"+(e.length>0?"\n\tmaterialNames:\n\t\t- "+e.join("\n\t\t- "):"\n\tmaterialNames: None")+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseOAsMesh: "+this.useOAsMesh+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals;null!==this.callbacks.onProgress&&(t+="\n\tcallbacks.onProgress: "+this.callbacks.onProgress.name),null!==this.callbacks.onError&&(t+="\n\tcallbacks.onError: "+this.callbacks.onError.name),null!==this.callbacks.onMeshAlter&&(t+="\n\tcallbacks.onMeshAlter: "+this.callbacks.onMeshAlter.name),null!==this.callbacks.onLoad&&(t+="\n\tcallbacks.onLoad: "+this.callbacks.onLoad.name),console.info(t)}}_execute(e){this.logging.enabled&&console.time("OBJLoader2Parser.execute"),this._configure();const t=new Uint8Array(e);this.contentRef=t;const n=t.byteLength;this.globalCounts.totalBytes=n;const i=new Array(128);let r,s=0,a=0,o="",l=0;for(;l0&&(i[s++]=o),o="";break;case 47:o.length>0&&(i[s++]=o),a++,o="";break;case 10:this._processLine(i,s,a,o,l),o="",s=0,a=0;break;case 13:break;default:o+=String.fromCharCode(r)}this._processLine(i,s,a,o,l),this._finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2Parser.execute")}_executeLegacy(e){this.logging.enabled&&console.time("OBJLoader2Parser.executeLegacy"),this._configure(),this.legacyMode=!0,this.contentRef=e;const t=e.length;this.globalCounts.totalBytes=t;const n=new Array(128);let i,r=0,s=0,a="",o=0;for(;o0&&(n[r++]=a),a="";break;case"/":a.length>0&&(n[r++]=a),s++,a="";break;case"\n":this._processLine(n,r,s,a,o),a="",r=0,s=0;break;case"\r":break;default:a+=i}this._processLine(n,r,a,s),this._finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2Parser.executeLegacy")}_processLine(e,t,n,i,r){if(this.globalCounts.lineByte=this.globalCounts.currentByte,this.globalCounts.currentByte=r,t<1)return;i.length>0&&(e[t++]=i);const s=function(e,t,n,i){let r="";if(i>n){let s;if(t)for(s=n;s4&&(this.colors.push(parseFloat(e[4])),this.colors.push(parseFloat(e[5])),this.colors.push(parseFloat(e[6])));break;case"vt":this.uvs.push(parseFloat(e[1])),this.uvs.push(parseFloat(e[2]));break;case"vn":this.normals.push(parseFloat(e[1])),this.normals.push(parseFloat(e[2])),this.normals.push(parseFloat(e[3]));break;case"f":if(a=t-1,0===n)for(this._checkFaceType(0),l=2,o=a;l0?s-1:s+r.vertices.length/3),o=r.colors.length>0?a:null;const l=i.vertices;if(l.push(r.vertices[a++]),l.push(r.vertices[a++]),l.push(r.vertices[a]),null!==o){const e=i.colors;e.push(r.colors[o++]),e.push(r.colors[o++]),e.push(r.colors[o])}if(t){const e=parseInt(t);let n=2*(e>0?e-1:e+r.uvs.length/2);const s=i.uvs;s.push(r.uvs[n++]),s.push(r.uvs[n])}if(n&&!r.disregardNormals){const e=parseInt(n);let t=3*(e>0?e-1:e+r.normals.length/3);const s=i.normals;s.push(r.normals[t++]),s.push(r.normals[t++]),s.push(r.normals[t])}};if(this.useIndices){this.disregardNormals&&(n=void 0);const r=e+(t?"_"+t:"_n")+(n?"_"+n:"_n");let a=i.indexMappings[r];null==a?(a=this.rawMesh.subGroupInUse.vertices.length/3,s(),i.indexMappings[r]=a,i.indexMappingsCount++):this.rawMesh.counts.doubleIndicesCount++,i.indices.push(a)}else s();this.rawMesh.counts.faceCount++}_createRawMeshReport(e){return"Input Object number: "+e+"\n\tObject name: "+this.rawMesh.objectName+"\n\tGroup name: "+this.rawMesh.groupName+"\n\tMtllib name: "+this.rawMesh.mtllibName+"\n\tVertex count: "+this.vertices.length/3+"\n\tNormal count: "+this.normals.length/3+"\n\tUV count: "+this.uvs.length/2+"\n\tSmoothingGroup count: "+this.rawMesh.counts.smoothingGroupCount+"\n\tMaterial count: "+this.rawMesh.counts.mtlCount+"\n\tReal MeshOutputGroup count: "+this.rawMesh.subGroups.length}_finalizeRawMesh(){const e=[];let t,n,i=0,r=0,s=0,a=0,o=0,l=0;for(const c in this.rawMesh.subGroups)if(t=this.rawMesh.subGroups[c],t.vertices.length>0){if(n=t.indices,n.length>0&&r>0)for(let e=0;e0&&(c={name:""!==this.rawMesh.groupName?this.rawMesh.groupName:this.rawMesh.objectName,subGroups:e,absoluteVertexCount:i,absoluteIndexCount:s,absoluteColorCount:a,absoluteNormalCount:o,absoluteUvCount:l,faceCount:this.rawMesh.counts.faceCount,doubleIndicesCount:this.rawMesh.counts.doubleIndicesCount}),c}_processCompletedMesh(){const e=this._finalizeRawMesh(),t=null!==e;if(t){this.colors.length>0&&this.colors.length!==this.vertices.length&&this._onError("Vertex Colors were detected, but vertex count and color count do not match!"),this.logging.enabled&&this.logging.debug&&console.debug(this._createRawMeshReport(this.inputObjectCount)),this.inputObjectCount++,this._buildMesh(e);const t=this.globalCounts.currentByte/this.globalCounts.totalBytes;this._onProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*t).toFixed(2)+"%"),this._resetRawMesh()}return t}_buildMesh(e){const t=e.subGroups;this.globalCounts.vertices+=e.absoluteVertexCount/3,this.globalCounts.faces+=e.faceCount,this.globalCounts.doubleIndicesCount+=e.doubleIndicesCount;const n=new i.BufferGeometry,s=new Float32Array(e.absoluteVertexCount),a=e.absoluteIndexCount>0?new Uint32Array(e.absoluteIndexCount):null,o=e.absoluteColorCount>0?new Float32Array(e.absoluteColorCount):null,l=e.absoluteNormalCount>0?new Float32Array(e.absoluteNormalCount):null,c=e.absoluteUvCount>0?new Float32Array(e.absoluteUvCount):null;let h;n.setAttribute("position",new i.BufferAttribute(s,3,!1)),null!=l&&n.setAttribute("normal",new i.BufferAttribute(l,3,!1)),null!=c&&n.setAttribute("uv",new i.BufferAttribute(c,2,!1)),null!=o&&n.setAttribute("color",new i.BufferAttribute(o,3,!1)),null!==a&&n.setIndex(new i.BufferAttribute(a,1,!1));let u=0,d=0,p=0,f=0,m=0,g=0,_=0;const v=t.length>1,y=[],x=null!==o;let b,w,M,S,E,T=0;const A={cloneInstructions:[],multiMaterialNames:{},modelName:this.modelName,progress:this.globalCounts.currentByte/this.globalCounts.totalBytes,geometryType:this.rawMesh.faceType<4?0:6===this.rawMesh.faceType?2:1,objectId:this.objectId};for(const e in t)if(t.hasOwnProperty(e)){if(h=t[e],E=h.materialName,b=0===h.smoothingGroup,this.rawMesh.faceType<4?(S=E,x&&(S+="_vertexColor"),b&&(S+="_flat")):S=6===this.rawMesh.faceType?"defaultPointMaterial":"defaultLineMaterial",w=this.materials[E],M=this.materials[S],null==w&&null==M&&(S=x?"defaultVertexColorMaterial":"defaultMaterial",M=this.materials[S],this.logging.enabled&&console.info('object_group "'+h.objectName+"_"+h.groupName+'" was defined with unresolvable material "'+E+'"! Assigning "'+S+'".')),null==M){const e={materialNameOrg:E,materialProperties:{name:S,vertexColors:x?2:0,flatShading:b}};M=r.cloneMaterial(this.materials,e,this.logging.enabled&&this.logging.debug),A.cloneInstructions.push(e)}if(v&&(_=this.useIndices?h.indices.length:h.vertices.length/3,n.addGroup(g,_,T),M=this.materials[S],y[T]=M,A.multiMaterialNames[T]=M.name,g+=_,T++),s.set(h.vertices,u),u+=h.vertices.length,null!==a&&(a.set(h.indices,d),d+=h.indices.length),null!==o&&(o.set(h.colors,p),p+=h.colors.length),null!==l&&(l.set(h.normals,f),f+=h.normals.length),null!==c&&(c.set(h.uvs,m),m+=h.uvs.length),this.logging.enabled&&this.logging.debug){let e="";T>0&&(e="\n\t\tmaterialIndex: "+T);const t="\tOutput Object no.: "+this.outputObjectCount+"\n\t\tgroupName: "+h.groupName+"\n\t\tIndex: "+h.index+"\n\t\tfaceType: "+this.rawMesh.faceType+"\n\t\tmaterialName: "+h.materialName+"\n\t\tsmoothingGroup: "+h.smoothingGroup+e+"\n\t\tobjectName: "+h.objectName+"\n\t\t#vertices: "+h.vertices.length/3+"\n\t\t#indices: "+h.indices.length+"\n\t\t#colors: "+h.colors.length/3+"\n\t\t#uvs: "+h.uvs.length/2+"\n\t\t#normals: "+h.normals.length/3;console.debug(t)}}let C;this.outputObjectCount++,null==n.getAttribute("normal")&&n.computeVertexNormals();const R=v?y:M;C=0===A.geometryType?new i.Mesh(n,R):1===A.geometryType?new i.LineSegments(n,R):new i.Points(n,R),C.name=e.name,this._onAssetAvailable(C,A)}_finalizeParsing(){if(this.logging.enabled&&console.info("Global output object count: "+this.outputObjectCount),this._processCompletedMesh()&&this.logging.enabled){const e="Overall counts: \n\tVertices: "+this.globalCounts.vertices+"\n\tFaces: "+this.globalCounts.faces+"\n\tMultiple definitions: "+this.globalCounts.doubleIndicesCount;console.info(e)}this._onLoad()}_onProgress(e){if(null!==this.callbacks.onProgress)this.callbacks.onProgress(e);else{const t=e||"";this.logging.enabled&&this.logging.debug&&console.log(t)}}_onError(e){null!==this.callbacks.onError?this.callbacks.onError(e):this.logging.enabled&&this.logging.debug&&console.error(e)}_onAssetAvailable(e,t){this._onMeshAlter(e,t),this.baseObject3d.add(e)}_onMeshAlter(e){null!==this.callbacks.onMeshAlter&&this.callbacks.onMeshAlter(e,this.baseObject3d)}_onLoad(){null!==this.callbacks.onLoad&&this.callbacks.onLoad(this.baseObject3d,this.objectId)}static buildUglifiedMapping(){return s.buildUglifiedNameAssignment((function(){return b}),"OBJLoader2Parser",/_OBJLoader2Parser/,!0)}}class w{static buildStandardWorkerDependencies(e){return[{url:e},{code:s.buildThreeConst()},{code:w.buildThreeExtraConst()},{code:"\n\n"},{code:s.buildUglifiedThreeMapping()},{code:w.buildUglifiedThreeExtraMapping()},{code:"\n\n"},{code:h.serializeClass(a)},{code:h.serializeClass(l)},{code:h.serializeClass(c)},{code:h.serializeClass(o)},{code:h.serializeClass(r)},{code:h.serializeClass(b)},{code:h.serializeClass(u)},{code:s.buildUglifiedThreeWtmMapping()},{code:"\n\n"},{code:b.buildUglifiedMapping()},{code:"\n\n"}]}static buildThreeExtraConst(){return"const MathUtils = THREE.MathUtils;\nconst Material = THREE.Material;\nconst Object3D = THREE.Object3D;\nconst Mesh = THREE.Mesh;\n"}static buildUglifiedThreeExtraMapping(){return s.buildUglifiedNameAssignment((function(){return i.MathUtils}),"MathUtils",/_MathUtils/,!1)+s.buildUglifiedNameAssignment((function(){return i.Material}),"Material",/_Material/,!1)+s.buildUglifiedNameAssignment((function(){return i.Object3D}),"Object3D",/_Object3D/,!1)+s.buildUglifiedNameAssignment((function(){return i.Mesh}),"Mesh",/_Mesh/,!1)}static init(e,t,n){const i=(new o).loadData(n);e.obj2={parser:new b,buffer:null,materials:i.getMaterials()},e.obj2.parser._onMeshAlter=(t,n)=>{const i=new o;if(i.main.multiMaterialNames=n.multiMaterialNames,0===Object.keys(i.main.multiMaterialNames).length){const e=t.material;r.addMaterial(i.main.materials,e,e.name,!1,!1)}i.main.cloneInstructions=n.cloneInstructions,i.cleanMaterials(),new c("assetAvailable",n.objectId).setProgress(n.progress).setParams({modelName:n.modelName}).setMesh(t,n.geometryType).setMaterialsTransport(i).postMessage(e)},e.obj2.parser.callbacks.onLoad=()=>{new a("execComplete",e.obj2.parser.objectId).postMessage(e)},e.obj2.parser.callbacks.onProgress=t=>{e.obj2.parser.logging.debug&&console.debug("WorkerRunner: progress: "+t)},u.applyProperties(e.obj2.parser,i.getParams(),!1);const s=i.getBuffer("modelData");null!=s&&(e.obj2.buffer=s),new a("init",t).postMessage(e)}static execute(e,t,n){e.obj2.parser.usedBefore&&e.obj2.parser._init(),e.obj2.parser.materials=e.obj2.materials;const i=(new a).loadData(n);u.applyProperties(e.obj2.parser,i.getParams(),!1);const r=i.getBuffer("modelData");null!=r&&(e.obj2.buffer=r),e.obj2.buffer&&(e.obj2.parser.objectId=i.getId(),e.obj2.parser._execute(e.obj2.buffer))}}class M extends x{constructor(e){super(e),this.preferJsmWorker=!1,this.urls={jsmWorker:new URL(M.DEFAULT_JSM_WORKER_PATH,window.location.href),threejs:new URL(M.DEFAULT_JSM_THREEJS_PATH,window.location.href)},this.workerTaskManager=null,this.taskName="tmOBJLoader2"}setWorkerTaskManager(e,t){return this.workerTaskManager=e,t&&(this.taskName=t),this}setJsmWorker(e,t){if(this.preferJsmWorker=!0===e,!(null!=t&&t instanceof URL))throw"The url to the jsm worker is not valid. Aborting...";return this.urls.jsmWorker=t,this}setThreejsLocation(e){if(!(null!=e&&e instanceof URL))throw"The url to the jsm worker is not valid. Aborting...";return this.urls.threejs=e,this}setTerminateWorkerOnLoad(e){return this.terminateWorkerOnLoad=!0===e,this}async _buildWorkerCode(e){null!==this.workerTaskManager&&this.workerTaskManager instanceof f||(this.parser.logging.debug&&console.log("Needed to create new WorkerTaskManager"),this.workerTaskManager=new f(1),this.workerTaskManager.setVerbose(this.parser.logging.enabled&&this.parser.logging.debug)),this.workerTaskManager.supportsTaskType(this.taskName)||(this.preferJsmWorker?this.workerTaskManager.registerTaskTypeModule(this.taskName,this.urls.jsmWorker):this.workerTaskManager.registerTaskType(this.taskName,w.init,w.execute,null,!1,w.buildStandardWorkerDependencies(this.urls.threejs)),await this.workerTaskManager.initTaskType(this.taskName,e.getMain()))}load(e,t,n,i,r){const s=this;x.prototype.load.call(this,e,(function(e,n){"OBJLoader2ParallelDummy"===e.name?s.parser.logging.enabled&&s.parser.logging.debug&&console.debug("Received dummy answer from OBJLoader2Parallel#parse"):t(e,n)}),n,i,r)}parse(e){this.parser.logging.enabled&&console.info("Using OBJLoader2Parallel version: "+M.OBJLOADER2_PARALLEL_VERSION);const t=(new a).setParams({logging:{enabled:this.parser.logging.enabled,debug:this.parser.logging.debug}});this._buildWorkerCode(t).then((()=>{this.parser.logging.debug&&console.log("OBJLoader2Parallel init was performed"),this._executeWorkerParse(e)})).catch((e=>console.error(e)));let n=new i.Object3D;return n.name="OBJLoader2ParallelDummy",n}_executeWorkerParse(e){const t=new a("execute",Math.floor(Math.random()*Math.floor(65536)));t.setParams({modelName:this.parser.modelName,useIndices:this.parser.useIndices,disregardNormals:this.parser.disregardNormals,materialPerSmoothingGroup:this.parser.materialPerSmoothingGroup,useOAsMesh:this.parser.useOAsMesh,materials:r.getMaterialsJSON(this.materialStore.getMaterials())}).addBuffer("modelData",e).package(!1),this.workerTaskManager.enqueueForExecution(this.taskName,t.getMain(),(e=>this._onLoad(e)),t.getTransferables()).then((e=>{this._onLoad(e),this.terminateWorkerOnLoad&&this.workerTaskManager.dispose()})).catch((e=>console.error(e)))}_onLoad(e){let t=e.cmd;if("assetAvailable"===t){let t;if("MeshTransport"===e.type?t=(new c).loadData(e).reconstruct(!1):console.error("Received unknown asset.type: "+e.type),t){let e,n=t.getMaterialsTransport().processMaterialTransport(this.materialStore.getMaterials(),this.parser.logging.enabled);null===n&&(n=new i.MeshStandardMaterial({color:16711680})),e=0===t.getGeometryType()?new i.Mesh(t.getBufferGeometry(),n):1===t.getGeometryType()?new i.LineSegments(t.getBufferGeometry(),n):new i.Points(t.getBufferGeometry(),n),this.parser._onMeshAlter(e),this.parser.baseObject3d.add(e)}}else if("execComplete"===t){let t;"DataTransport"===e.type?(t=(new a).loadData(e),t instanceof a&&null!==this.parser.callbacks.onLoad&&this.parser.callbacks.onLoad(this.parser.baseObject3d,t.getId())):console.error("Received unknown asset.type: "+e.type)}else console.error("Received unknown command: "+t)}}y(M,"OBJLOADER2_PARALLEL_VERSION",x.OBJLOADER2_VERSION),y(M,"DEFAULT_JSM_WORKER_PATH","/src/loaders/tmOBJLoader2.js"),y(M,"DEFAULT_JSM_THREEJS_PATH","/node_modules/three/build/three.min.js");class S{static link(e,t){"function"==typeof t.setMaterials&&t.setMaterials(S.addMaterialsFromMtlLoader(e),!0)}static addMaterialsFromMtlLoader(e){let t={};return void 0!==e.preload&&e.preload instanceof Function&&(e.preload(),t=e.materials),t}}},676:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DataViewIndexOutOfBoundsError:()=>G,DecodeError:()=>x,Decoder:()=>W,EXT_TIMESTAMP:()=>b,Encoder:()=>L,ExtData:()=>v,ExtensionCodec:()=>C,decode:()=>X,decodeArrayStream:()=>ee,decodeAsync:()=>$,decodeMulti:()=>q,decodeMultiStream:()=>te,decodeStream:()=>ne,decodeTimestampExtension:()=>T,decodeTimestampToTimeSpec:()=>E,encode:()=>I,encodeDateToTimeSpec:()=>M,encodeTimeSpecToTimestamp:()=>w,encodeTimestampExtension:()=>S});var i,r,s,a=4294967295;function o(e,t,n){var i=Math.floor(n/4294967296),r=n;e.setUint32(t,i),e.setUint32(t+4,r)}function l(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var c=("undefined"==typeof process||"never"!==(null===(i=null===process||void 0===process?void 0:process.env)||void 0===i?void 0:i.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function h(e){for(var t=e.length,n=0,i=0;i=55296&&r<=56319&&i65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h)}else s.push(o);s.length>=4096&&(a+=String.fromCharCode.apply(String,s),s.length=0)}return s.length>0&&(a+=String.fromCharCode.apply(String,s)),a}var m,g=c?new TextDecoder:null,_=c?"undefined"!=typeof process&&"force"!==(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.TEXT_DECODER)?200:0:a,v=function(e,t){this.type=e,this.data=t},y=(m=function(e,t){return(m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}m(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),x=function(e){function t(n){var i=e.call(this,n)||this,r=Object.create(t.prototype);return Object.setPrototypeOf(i,r),Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:t.name}),i}return y(t,e),t}(Error),b=-1;function w(e){var t,n=e.sec,i=e.nsec;if(n>=0&&i>=0&&n<=17179869183){if(0===i&&n<=4294967295){var r=new Uint8Array(4);return(t=new DataView(r.buffer)).setUint32(0,n),r}var s=n/4294967296,a=4294967295&n;return r=new Uint8Array(8),(t=new DataView(r.buffer)).setUint32(0,i<<2|3&s),t.setUint32(4,a),r}return r=new Uint8Array(12),(t=new DataView(r.buffer)).setUint32(0,i),o(t,4,n),r}function M(e){var t=e.getTime(),n=Math.floor(t/1e3),i=1e6*(t-1e3*n),r=Math.floor(i/1e9);return{sec:n+r,nsec:i-1e9*r}}function S(e){return e instanceof Date?w(M(e)):null}function E(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:l(t,4),nsec:t.getUint32(0)};default:throw new x("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}function T(e){var t=E(e);return new Date(1e3*t.sec+t.nsec/1e6)}var A={type:b,encode:S,decode:T},C=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(A)}return e.prototype.register=function(e){var t=e.type,n=e.encode,i=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=i;else{var r=1+t;this.builtInEncoders[r]=n,this.builtInDecoders[r]=i}},e.prototype.tryToEncode=function(e,t){for(var n=0;nthis.maxDepth)throw new Error("Too deep objects in depth ".concat(t));null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: ".concat(e," bytes in UTF-8"));this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){if(e.length>d){var t=h(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),p(e,this.bytes,this.pos),this.pos+=t}else t=h(e),this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,n){for(var i=e.length,r=n,s=0;s>6&31|192;else{if(a>=55296&&a<=56319&&s>12&15|224,t[r++]=a>>6&63|128):(t[r++]=a>>18&7|240,t[r++]=a>>12&63|128,t[r++]=a>>6&63|128)}t[r++]=63&a|128}else t[r++]=a}}(e,this.bytes,this.pos),this.pos+=t},e.prototype.encodeObject=function(e,t){var n=this.extensionCodec.tryToEncode(e,this.context);if(null!=n)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: ".concat(t));this.writeU8(198),this.writeU32(t)}var n=R(e);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else{if(!(n<4294967296))throw new Error("Too large array: ".concat(n));this.writeU8(221),this.writeU32(n)}for(var i=0,r=e;i0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var i=0,r=this.caches[n-1];i=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)},e.prototype.decode=function(e,t,n){var i=this.find(e,t,n);if(null!=i)return this.hit++,i;this.miss++;var r=f(e,t,n),s=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(s,r),r},e}(),N=function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]1||o(e,t)}))})}function o(e,t){try{(n=r[e](t)).value instanceof k?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(e){h(s[0][3],e)}var n}function l(e){o("next",e)}function c(e){o("throw",e)}function h(e,t){e(t),s.shift(),s.length&&o(s[0][0],s[0][1])}},F=new DataView(new ArrayBuffer(0)),z=new Uint8Array(F.buffer),G=function(){try{F.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),H=new G("Insufficient data"),V=new O,W=function(){function e(e,t,n,i,r,s,o,l){void 0===e&&(e=C.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=a),void 0===i&&(i=a),void 0===r&&(r=a),void 0===s&&(s=a),void 0===o&&(o=a),void 0===l&&(l=V),this.extensionCodec=e,this.context=t,this.maxStrLength=n,this.maxBinLength=i,this.maxArrayLength=r,this.maxMapLength=s,this.maxExtLength=o,this.keyDecoder=l,this.totalPos=0,this.pos=0,this.view=F,this.bytes=z,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1,this.stack.length=0},e.prototype.setBuffer=function(e){this.bytes=R(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=R(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining(1)){var t=this.bytes.subarray(this.pos),n=R(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return N(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,i,r,s,a,o,l;return s=this,a=void 0,l=function(){var s,a,o,l,c,h,u,d;return N(this,(function(p){switch(p.label){case 0:s=!1,p.label=1;case 1:p.trys.push([1,6,7,12]),t=D(e),p.label=2;case 2:return[4,t.next()];case 3:if((n=p.sent()).done)return[3,5];if(o=n.value,s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o);try{a=this.doDecodeSync(),s=!0}catch(e){if(!(e instanceof G))throw e}this.totalPos+=this.pos,p.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return l=p.sent(),i={error:l},[3,12];case 7:return p.trys.push([7,,10,11]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,9];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(i)throw i.error;return[7];case 11:return[7];case 12:if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,a]}throw h=(c=this).headByte,u=c.pos,d=c.totalPos,new RangeError("Insufficient data in parsing ".concat(U(h)," at ").concat(d," (").concat(u," in the current buffer)"))}}))},new((o=void 0)||(o=Promise))((function(e,t){function n(e){try{r(l.next(e))}catch(e){t(e)}}function i(e){try{r(l.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(n,i)}r((l=l.apply(s,a||[])).next())}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return B(this,arguments,(function(){var n,i,r,s,a,o,l,c,h;return N(this,(function(u){switch(u.label){case 0:n=t,i=-1,u.label=1;case 1:u.trys.push([1,13,14,19]),r=D(e),u.label=2;case 2:return[4,k(r.next())];case 3:if((s=u.sent()).done)return[3,12];if(a=s.value,t&&0===i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(i=this.readArraySize(),n=!1,this.complete()),u.label=4;case 4:u.trys.push([4,9,,10]),u.label=5;case 5:return[4,k(this.doDecodeSync())];case 6:return[4,u.sent()];case 7:return u.sent(),0==--i?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((o=u.sent())instanceof G))throw o;return[3,10];case 10:this.totalPos+=this.pos,u.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return l=u.sent(),c={error:l},[3,19];case 14:return u.trys.push([14,,17,18]),s&&!s.done&&(h=r.return)?[4,k(h.call(r))]:[3,16];case 15:u.sent(),u.label=16;case 16:return[3,18];case 17:if(c)throw c.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!=(i=e-128)){this.pushMapState(i),this.complete();continue e}t={}}else if(e<160){if(0!=(i=e-144)){this.pushArrayState(i),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e)n=this.lookU8(),t=this.decodeUtf8String(n,1);else if(218===e)n=this.lookU16(),t=this.decodeUtf8String(n,2);else if(219===e)n=this.lookU32(),t=this.decodeUtf8String(n,4);else if(220===e){if(0!==(i=this.readU16())){this.pushArrayState(i),this.complete();continue e}t=[]}else if(221===e){if(0!==(i=this.readU32())){this.pushArrayState(i),this.complete();continue e}t=[]}else if(222===e){if(0!==(i=this.readU16())){this.pushMapState(i),this.complete();continue e}t={}}else if(223===e){if(0!==(i=this.readU32())){this.pushMapState(i),this.complete();continue e}t={}}else if(196===e){var i=this.lookU8();t=this.decodeBinary(i,1)}else if(197===e)i=this.lookU16(),t=this.decodeBinary(i,2);else if(198===e)i=this.lookU32(),t=this.decodeBinary(i,4);else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e)i=this.lookU8(),t=this.decodeExtension(i,1);else if(200===e)i=this.lookU16(),t=this.decodeExtension(i,2);else{if(201!==e)throw new x("Unrecognized type byte: ".concat(U(e)));i=this.lookU32(),t=this.decodeExtension(i,4)}this.complete();for(var r=this.stack;r.length>0;){var s=r[r.length-1];if(0===s.type){if(s.array[s.position]=t,s.position++,s.position!==s.size)continue e;r.pop(),t=s.array}else{if(1===s.type){if(void 0,"string"!=(a=typeof t)&&"number"!==a)throw new x("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new x("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}if(s.map[s.key]=t,s.readCount++,s.readCount!==s.size){s.key=null,s.type=1;continue e}r.pop(),t=s.map}}return t}var a},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new x("Unrecognized array type byte: ".concat(U(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new x("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new x("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new x("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength_?function(e,t,n){var i=e.subarray(t,t+n);return g.decode(i)}(this.bytes,r,e):f(this.bytes,r,e),this.pos+=t+e,i},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new x("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw H;var n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new x("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=l(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),j={};function X(e,t){return void 0===t&&(t=j),new W(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decode(e)}function q(e,t){return void 0===t&&(t=j),new W(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeMulti(e)}var Y=function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]1||o(e,t)}))})}function o(e,t){try{(n=r[e](t)).value instanceof K?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(e){h(s[0][3],e)}var n}function l(e){o("next",e)}function c(e){o("throw",e)}function h(e,t){e(t),s.shift(),s.length&&o(s[0][0],s[0][1])}};function Z(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function Q(e){return null!=e[Symbol.asyncIterator]?e:function(e){return J(this,arguments,(function(){var t,n,i,r;return Y(this,(function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,K(t.read())];case 3:return n=s.sent(),i=n.done,r=n.value,i?[4,K(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return Z(r),[4,K(r)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}function $(e,t){return void 0===t&&(t=j),n=this,i=void 0,s=function(){var n;return function(e,t){var n,i,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]{"use strict";n.r(t),n.d(t,{ACESFilmicToneMapping:()=>te,AddEquation:()=>S,AddOperation:()=>J,AdditiveAnimationBlendMode:()=>It,AdditiveBlending:()=>x,AlphaFormat:()=>Ue,AlwaysCompare:()=>_n,AlwaysDepth:()=>G,AlwaysStencilFunc:()=>cn,AmbientLight:()=>Pd,AmbientLightProbe:()=>Yd,AnimationAction:()=>bp,AnimationClip:()=>td,AnimationLoader:()=>hd,AnimationMixer:()=>Mp,AnimationObjectGroup:()=>xp,AnimationUtils:()=>Hu,ArcCurve:()=>ah,ArrayCamera:()=>Rl,ArrowHelper:()=>mf,Audio:()=>ap,AudioAnalyser:()=>dp,AudioContext:()=>jd,AudioListener:()=>sp,AudioLoader:()=>Xd,AxesHelper:()=>gf,BackSide:()=>m,BasicDepthPacking:()=>Bt,BasicShadowMap:()=>h,Bone:()=>xc,BooleanKeyframeTrack:()=>Yu,Box2:()=>Np,Box3:()=>Ri,Box3Helper:()=>hf,BoxGeometry:()=>zs,BoxHelper:()=>cf,BufferAttribute:()=>ns,BufferGeometry:()=>xs,BufferGeometryLoader:()=>Bd,ByteType:()=>Me,Cache:()=>id,Camera:()=>Xs,CameraHelper:()=>af,CanvasTexture:()=>ih,CapsuleGeometry:()=>Ah,CatmullRomCurve3:()=>dh,CineonToneMapping:()=>ee,CircleGeometry:()=>Ch,ClampToEdgeWrapping:()=>he,Clock:()=>$d,Color:()=>Xr,ColorKeyframeTrack:()=>Ku,ColorManagement:()=>ci,CompressedArrayTexture:()=>th,CompressedCubeTexture:()=>nh,CompressedTexture:()=>eh,CompressedTextureLoader:()=>ud,ConeGeometry:()=>Lh,CubeCamera:()=>Ks,CubeReflectionMapping:()=>re,CubeRefractionMapping:()=>se,CubeTexture:()=>Js,CubeTextureLoader:()=>pd,CubeUVReflectionMapping:()=>le,CubicBezierCurve:()=>gh,CubicBezierCurve3:()=>_h,CubicInterpolant:()=>Wu,CullFaceBack:()=>o,CullFaceFront:()=>l,CullFaceFrontBack:()=>c,CullFaceNone:()=>a,Curve:()=>rh,CurvePath:()=>Sh,CustomBlending:()=>M,CustomToneMapping:()=>ne,CylinderGeometry:()=>Rh,Cylindrical:()=>Up,Data3DTexture:()=>wi,DataArrayTexture:()=>xi,DataTexture:()=>bc,DataTextureLoader:()=>fd,DataUtils:()=>$r,DecrementStencilOp:()=>Zt,DecrementWrapStencilOp:()=>$t,DefaultLoadingManager:()=>sd,DepthFormat:()=>ke,DepthStencilFormat:()=>Be,DepthTexture:()=>Ul,DirectionalLight:()=>Ld,DirectionalLightHelper:()=>nf,DiscreteInterpolant:()=>Xu,DisplayP3ColorSpace:()=>jt,DodecahedronGeometry:()=>Ih,DoubleSide:()=>g,DstAlphaFactor:()=>N,DstColorFactor:()=>k,DynamicCopyUsage:()=>En,DynamicDrawUsage:()=>yn,DynamicReadUsage:()=>wn,EdgesGeometry:()=>kh,EllipseCurve:()=>sh,EqualCompare:()=>dn,EqualDepth:()=>W,EqualStencilFunc:()=>rn,EquirectangularReflectionMapping:()=>ae,EquirectangularRefractionMapping:()=>oe,Euler:()=>dr,EventDispatcher:()=>In,ExtrudeGeometry:()=>du,FileLoader:()=>cd,Float16BufferAttribute:()=>hs,Float32BufferAttribute:()=>us,Float64BufferAttribute:()=>ds,FloatType:()=>Ce,Fog:()=>zl,FogExp2:()=>Fl,FramebufferTexture:()=>$c,FrontSide:()=>f,Frustum:()=>ra,GLBufferAttribute:()=>Cp,GLSL1:()=>An,GLSL3:()=>Cn,GreaterCompare:()=>fn,GreaterDepth:()=>X,GreaterEqualCompare:()=>gn,GreaterEqualDepth:()=>j,GreaterEqualStencilFunc:()=>ln,GreaterStencilFunc:()=>an,GridHelper:()=>Zp,Group:()=>Ll,HalfFloatType:()=>Re,HemisphereLight:()=>_d,HemisphereLightHelper:()=>Jp,HemisphereLightProbe:()=>qd,IcosahedronGeometry:()=>fu,ImageBitmapLoader:()=>Vd,ImageLoader:()=>dd,ImageUtils:()=>ui,IncrementStencilOp:()=>Jt,IncrementWrapStencilOp:()=>Qt,InstancedBufferAttribute:()=>Ec,InstancedBufferGeometry:()=>kd,InstancedInterleavedBuffer:()=>Ap,InstancedMesh:()=>Uc,Int16BufferAttribute:()=>as,Int32BufferAttribute:()=>ls,Int8BufferAttribute:()=>is,IntType:()=>Te,InterleavedBuffer:()=>Hl,InterleavedBufferAttribute:()=>Wl,Interpolant:()=>Vu,InterpolateDiscrete:()=>Et,InterpolateLinear:()=>Tt,InterpolateSmooth:()=>At,InvertStencilOp:()=>en,KeepStencilOp:()=>Yt,KeyframeTrack:()=>qu,LOD:()=>cc,LatheGeometry:()=>Th,Layers:()=>pr,LessCompare:()=>un,LessDepth:()=>H,LessEqualCompare:()=>pn,LessEqualDepth:()=>V,LessEqualStencilFunc:()=>sn,LessStencilFunc:()=>nn,Light:()=>gd,LightProbe:()=>Od,Line:()=>zc,Line3:()=>Bp,LineBasicMaterial:()=>Oc,LineCurve:()=>vh,LineCurve3:()=>yh,LineDashedMaterial:()=>Nu,LineLoop:()=>Wc,LineSegments:()=>Vc,LinearDisplayP3ColorSpace:()=>Xt,LinearEncoding:()=>Dt,LinearFilter:()=>_e,LinearInterpolant:()=>ju,LinearMipMapLinearFilter:()=>be,LinearMipMapNearestFilter:()=>ye,LinearMipmapLinearFilter:()=>xe,LinearMipmapNearestFilter:()=>ve,LinearSRGBColorSpace:()=>Wt,LinearToneMapping:()=>Q,Loader:()=>ad,LoaderUtils:()=>Dd,LoadingManager:()=>rd,LoopOnce:()=>wt,LoopPingPong:()=>St,LoopRepeat:()=>Mt,LuminanceAlphaFormat:()=>De,LuminanceFormat:()=>Ne,MOUSE:()=>r,Material:()=>Gr,MaterialLoader:()=>Nd,MathUtils:()=>Xn,Matrix3:()=>Yn,Matrix4:()=>nr,MaxEquation:()=>C,Mesh:()=>Bs,MeshBasicMaterial:()=>Yr,MeshDepthMaterial:()=>Ml,MeshDistanceMaterial:()=>Sl,MeshLambertMaterial:()=>Uu,MeshMatcapMaterial:()=>Ou,MeshNormalMaterial:()=>Iu,MeshPhongMaterial:()=>Lu,MeshPhysicalMaterial:()=>Ru,MeshStandardMaterial:()=>Cu,MeshToonMaterial:()=>Pu,MinEquation:()=>A,MirroredRepeatWrapping:()=>ue,MixOperation:()=>K,MultiplyBlending:()=>w,MultiplyOperation:()=>Y,NearestFilter:()=>de,NearestMipMapLinearFilter:()=>ge,NearestMipMapNearestFilter:()=>fe,NearestMipmapLinearFilter:()=>me,NearestMipmapNearestFilter:()=>pe,NeverCompare:()=>hn,NeverDepth:()=>z,NeverStencilFunc:()=>tn,NoBlending:()=>v,NoColorSpace:()=>Ht,NoToneMapping:()=>Z,NormalAnimationBlendMode:()=>Pt,NormalBlending:()=>y,NotEqualCompare:()=>mn,NotEqualDepth:()=>q,NotEqualStencilFunc:()=>on,NumberKeyframeTrack:()=>Ju,Object3D:()=>Ar,ObjectLoader:()=>Fd,ObjectSpaceNormalMap:()=>Gt,OctahedronGeometry:()=>mu,OneFactor:()=>L,OneMinusDstAlphaFactor:()=>D,OneMinusDstColorFactor:()=>B,OneMinusSrcAlphaFactor:()=>O,OneMinusSrcColorFactor:()=>I,OrthographicCamera:()=>va,PCFShadowMap:()=>u,PCFSoftShadowMap:()=>d,PMREMGenerator:()=>Ta,Path:()=>Eh,PerspectiveCamera:()=>qs,Plane:()=>ta,PlaneGeometry:()=>oa,PlaneHelper:()=>uf,PointLight:()=>Cd,PointLightHelper:()=>Xp,Points:()=>Jc,PointsMaterial:()=>jc,PolarGridHelper:()=>Qp,PolyhedronGeometry:()=>Ph,PositionalAudio:()=>up,PropertyBinding:()=>yp,PropertyMixer:()=>pp,QuadraticBezierCurve:()=>xh,QuadraticBezierCurve3:()=>bh,Quaternion:()=>Ei,QuaternionKeyframeTrack:()=>Qu,QuaternionLinearInterpolant:()=>Zu,RED_GREEN_RGTC2_Format:()=>xt,RED_RGTC1_Format:()=>vt,REVISION:()=>i,RGBADepthPacking:()=>Ft,RGBAFormat:()=>Oe,RGBAIntegerFormat:()=>Ve,RGBA_ASTC_10x10_Format:()=>dt,RGBA_ASTC_10x5_Format:()=>ct,RGBA_ASTC_10x6_Format:()=>ht,RGBA_ASTC_10x8_Format:()=>ut,RGBA_ASTC_12x10_Format:()=>pt,RGBA_ASTC_12x12_Format:()=>ft,RGBA_ASTC_4x4_Format:()=>tt,RGBA_ASTC_5x4_Format:()=>nt,RGBA_ASTC_5x5_Format:()=>it,RGBA_ASTC_6x5_Format:()=>rt,RGBA_ASTC_6x6_Format:()=>st,RGBA_ASTC_8x5_Format:()=>at,RGBA_ASTC_8x6_Format:()=>ot,RGBA_ASTC_8x8_Format:()=>lt,RGBA_BPTC_Format:()=>mt,RGBA_ETC2_EAC_Format:()=>et,RGBA_PVRTC_2BPPV1_Format:()=>Ze,RGBA_PVRTC_4BPPV1_Format:()=>Je,RGBA_S3TC_DXT1_Format:()=>je,RGBA_S3TC_DXT3_Format:()=>Xe,RGBA_S3TC_DXT5_Format:()=>qe,RGB_BPTC_SIGNED_Format:()=>gt,RGB_BPTC_UNSIGNED_Format:()=>_t,RGB_ETC1_Format:()=>Qe,RGB_ETC2_Format:()=>$e,RGB_PVRTC_2BPPV1_Format:()=>Ke,RGB_PVRTC_4BPPV1_Format:()=>Ye,RGB_S3TC_DXT1_Format:()=>We,RGFormat:()=>Ge,RGIntegerFormat:()=>He,RawShaderMaterial:()=>Au,Ray:()=>tr,Raycaster:()=>Rp,RectAreaLight:()=>Id,RedFormat:()=>Fe,RedIntegerFormat:()=>ze,ReinhardToneMapping:()=>$,RenderTarget:()=>vi,RepeatWrapping:()=>ce,ReplaceStencilOp:()=>Kt,ReverseSubtractEquation:()=>T,RingGeometry:()=>gu,SIGNED_RED_GREEN_RGTC2_Format:()=>bt,SIGNED_RED_RGTC1_Format:()=>yt,SRGBColorSpace:()=>Vt,Scene:()=>Gl,ShaderChunk:()=>la,ShaderLib:()=>ha,ShaderMaterial:()=>js,ShadowMaterial:()=>Tu,Shape:()=>Bh,ShapeGeometry:()=>_u,ShapePath:()=>_f,ShapeUtils:()=>cu,ShortType:()=>Se,Skeleton:()=>Sc,SkeletonHelper:()=>Wp,SkinnedMesh:()=>yc,Source:()=>pi,Sphere:()=>qi,SphereGeometry:()=>vu,Spherical:()=>Ip,SphericalHarmonics3:()=>Ud,SplineCurve:()=>wh,SpotLight:()=>Md,SpotLightHelper:()=>zp,Sprite:()=>sc,SpriteMaterial:()=>jl,SrcAlphaFactor:()=>U,SrcAlphaSaturateFactor:()=>F,SrcColorFactor:()=>P,StaticCopyUsage:()=>Sn,StaticDrawUsage:()=>vn,StaticReadUsage:()=>bn,StereoCamera:()=>Qd,StreamCopyUsage:()=>Tn,StreamDrawUsage:()=>xn,StreamReadUsage:()=>Mn,StringKeyframeTrack:()=>$u,SubtractEquation:()=>E,SubtractiveBlending:()=>b,TOUCH:()=>s,TangentSpaceNormalMap:()=>zt,TetrahedronGeometry:()=>yu,Texture:()=>gi,TextureLoader:()=>md,TorusGeometry:()=>xu,TorusKnotGeometry:()=>bu,Triangle:()=>Fr,TriangleFanDrawMode:()=>Nt,TriangleStripDrawMode:()=>Ot,TrianglesDrawMode:()=>Ut,TubeGeometry:()=>wu,TwoPassDoubleSide:()=>_,UVMapping:()=>ie,Uint16BufferAttribute:()=>os,Uint32BufferAttribute:()=>cs,Uint8BufferAttribute:()=>rs,Uint8ClampedBufferAttribute:()=>ss,Uniform:()=>Sp,UniformsGroup:()=>Tp,UniformsLib:()=>ca,UniformsUtils:()=>Ws,UnsignedByteType:()=>we,UnsignedInt248Type:()=>Ie,UnsignedIntType:()=>Ae,UnsignedShort4444Type:()=>Le,UnsignedShort5551Type:()=>Pe,UnsignedShortType:()=>Ee,VSMShadowMap:()=>p,Vector2:()=>qn,Vector3:()=>Ti,Vector4:()=>_i,VectorKeyframeTrack:()=>ed,VideoTexture:()=>Qc,WebGL1Renderer:()=>Bl,WebGL3DRenderTarget:()=>Mi,WebGLArrayRenderTarget:()=>bi,WebGLCoordinateSystem:()=>Ln,WebGLCubeRenderTarget:()=>Zs,WebGLMultipleRenderTargets:()=>Si,WebGLRenderTarget:()=>yi,WebGLRenderer:()=>kl,WebGLUtils:()=>Cl,WebGPUCoordinateSystem:()=>Pn,WireframeGeometry:()=>Mu,WrapAroundEnding:()=>Lt,ZeroCurvatureEnding:()=>Ct,ZeroFactor:()=>R,ZeroSlopeEnding:()=>Rt,ZeroStencilOp:()=>qt,_SRGBAFormat:()=>Rn,createCanvasElement:()=>ei,sRGBEncoding:()=>kt});const i="156",r={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},s={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},a=0,o=1,l=2,c=3,h=0,u=1,d=2,p=3,f=0,m=1,g=2,_=2,v=0,y=1,x=2,b=3,w=4,M=5,S=100,E=101,T=102,A=103,C=104,R=200,L=201,P=202,I=203,U=204,O=205,N=206,D=207,k=208,B=209,F=210,z=0,G=1,H=2,V=3,W=4,j=5,X=6,q=7,Y=0,K=1,J=2,Z=0,Q=1,$=2,ee=3,te=4,ne=5,ie=300,re=301,se=302,ae=303,oe=304,le=306,ce=1e3,he=1001,ue=1002,de=1003,pe=1004,fe=1004,me=1005,ge=1005,_e=1006,ve=1007,ye=1007,xe=1008,be=1008,we=1009,Me=1010,Se=1011,Ee=1012,Te=1013,Ae=1014,Ce=1015,Re=1016,Le=1017,Pe=1018,Ie=1020,Ue=1021,Oe=1023,Ne=1024,De=1025,ke=1026,Be=1027,Fe=1028,ze=1029,Ge=1030,He=1031,Ve=1033,We=33776,je=33777,Xe=33778,qe=33779,Ye=35840,Ke=35841,Je=35842,Ze=35843,Qe=36196,$e=37492,et=37496,tt=37808,nt=37809,it=37810,rt=37811,st=37812,at=37813,ot=37814,lt=37815,ct=37816,ht=37817,ut=37818,dt=37819,pt=37820,ft=37821,mt=36492,gt=36494,_t=36495,vt=36283,yt=36284,xt=36285,bt=36286,wt=2200,Mt=2201,St=2202,Et=2300,Tt=2301,At=2302,Ct=2400,Rt=2401,Lt=2402,Pt=2500,It=2501,Ut=0,Ot=1,Nt=2,Dt=3e3,kt=3001,Bt=3200,Ft=3201,zt=0,Gt=1,Ht="",Vt="srgb",Wt="srgb-linear",jt="display-p3",Xt="display-p3-linear",qt=0,Yt=7680,Kt=7681,Jt=7682,Zt=7683,Qt=34055,$t=34056,en=5386,tn=512,nn=513,rn=514,sn=515,an=516,on=517,ln=518,cn=519,hn=512,un=513,dn=514,pn=515,fn=516,mn=517,gn=518,_n=519,vn=35044,yn=35048,xn=35040,bn=35045,wn=35049,Mn=35041,Sn=35046,En=35050,Tn=35042,An="100",Cn="300 es",Rn=1035,Ln=2e3,Pn=2001;class In{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+Un[e>>16&255]+Un[e>>24&255]+"-"+Un[255&t]+Un[t>>8&255]+"-"+Un[t>>16&15|64]+Un[t>>24&255]+"-"+Un[63&n|128]+Un[n>>8&255]+"-"+Un[n>>16&255]+Un[n>>24&255]+Un[255&i]+Un[i>>8&255]+Un[i>>16&255]+Un[i>>24&255]).toLowerCase()}function Bn(e,t,n){return Math.max(t,Math.min(n,e))}function Fn(e,t){return(e%t+t)%t}function zn(e,t,n){return(1-n)*e+n*t}function Gn(e){return 0==(e&e-1)&&0!==e}function Hn(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Vn(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Wn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function jn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Xn={DEG2RAD:Nn,RAD2DEG:Dn,generateUUID:kn,clamp:Bn,euclideanModulo:Fn,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:zn,damp:function(e,t,n,i){return zn(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(Fn(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(On=e);let t=On+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Nn},radToDeg:function(e){return e*Dn},isPowerOfTwo:Gn,ceilPowerOfTwo:Hn,floorPowerOfTwo:Vn,setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),f=a((i-t)/2);switch(r){case"XYX":e.set(o*h,l*u,l*d,o*c);break;case"YZY":e.set(l*d,o*h,l*u,o*c);break;case"ZXZ":e.set(l*u,l*d,o*h,o*c);break;case"XZX":e.set(o*h,l*f,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*f,o*c);break;case"ZYZ":e.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:jn,denormalize:Wn};class qn{constructor(e=0,t=0){qn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yn{constructor(e,t,n,i,r,s,a,o,l){Yn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],_=i[1],v=i[4],y=i[7],x=i[2],b=i[5],w=i[8];return r[0]=s*f+a*_+o*x,r[3]=s*m+a*v+o*b,r[6]=s*g+a*y+o*w,r[1]=l*f+c*_+h*x,r[4]=l*m+c*v+h*b,r[7]=l*g+c*y+h*w,r[2]=u*f+d*_+p*x,r[5]=u*m+d*v+p*b,r[8]=u*g+d*y+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(a*n-i*s)*f,e[3]=u*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-a*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(s*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Kn.makeScale(e,t)),this}rotate(e){return this.premultiply(Kn.makeRotation(-e)),this}translate(e,t){return this.premultiply(Kn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Kn=new Yn;function Jn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const Zn={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Qn(e,t){return new Zn[e](t)}function $n(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ei(){const e=$n("canvas");return e.style.display="block",e}const ti={};function ni(e){e in ti||(ti[e]=!0,console.warn(e))}function ii(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ri(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const si=(new Yn).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),ai=(new Yn).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]),oi={[Wt]:e=>e,[Vt]:e=>e.convertSRGBToLinear(),[jt]:function(e){return e.convertSRGBToLinear().applyMatrix3(ai)}},li={[Wt]:e=>e,[Vt]:e=>e.convertLinearToSRGB(),[jt]:function(e){return e.applyMatrix3(si).convertLinearToSRGB()}},ci={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Wt},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=oi[t],r=li[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let hi;class ui{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===hi&&(hi=$n("canvas")),hi.width=e.width,hi.height=e.height;const n=hi.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=hi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=$n("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ie)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ce:e.x=e.x-Math.floor(e.x);break;case he:e.x=e.x<0?0:1;break;case ue:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case ce:e.y=e.y-Math.floor(e.y);break;case he:e.y=e.y<0?0:1;break;case ue:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return ni("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Vt?kt:Dt}set encoding(e){ni("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===kt?Vt:Ht}}gi.DEFAULT_IMAGE=null,gi.DEFAULT_MAPPING=ie,gi.DEFAULT_ANISOTROPY=1;class _i{constructor(e=0,t=0,n=0,i=1){_i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&e>_?e_?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,t*n);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+f*r,e===1-a){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*h+o*d-l*u,e[t+1]=o*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-o*h,e[t+3]=c*p-a*h-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ti{constructor(e=0,t=0,n=0){Ti.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ci.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ci.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=o*t+s*i-a*n,c=o*n+a*t-r*i,h=o*i+r*n-s*t,u=-r*t-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ai.copy(this).projectOnVector(e),this.sub(Ai)}reflect(e){return this.sub(Ai.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ai=new Ti,Ci=new Ei;class Ri{constructor(e=new Ti(1/0,1/0,1/0),t=new Ti(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;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,Pi),Pi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Fi),zi.subVectors(this.max,Fi),Ui.subVectors(e.a,Fi),Oi.subVectors(e.b,Fi),Ni.subVectors(e.c,Fi),Di.subVectors(Oi,Ui),ki.subVectors(Ni,Oi),Bi.subVectors(Ui,Ni);let t=[0,-Di.z,Di.y,0,-ki.z,ki.y,0,-Bi.z,Bi.y,Di.z,0,-Di.x,ki.z,0,-ki.x,Bi.z,0,-Bi.x,-Di.y,Di.x,0,-ki.y,ki.x,0,-Bi.y,Bi.x,0];return!!Vi(t,Ui,Oi,Ni,zi)&&(t=[1,0,0,0,1,0,0,0,1],!!Vi(t,Ui,Oi,Ni,zi)&&(Gi.crossVectors(Di,ki),t=[Gi.x,Gi.y,Gi.z],Vi(t,Ui,Oi,Ni,zi)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Pi).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Li[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Li[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Li[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Li[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Li[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Li[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Li[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Li[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Li)),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 Li=[new Ti,new Ti,new Ti,new Ti,new Ti,new Ti,new Ti,new Ti],Pi=new Ti,Ii=new Ri,Ui=new Ti,Oi=new Ti,Ni=new Ti,Di=new Ti,ki=new Ti,Bi=new Ti,Fi=new Ti,zi=new Ti,Gi=new Ti,Hi=new Ti;function Vi(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){Hi.fromArray(e,s);const a=r.x*Math.abs(Hi.x)+r.y*Math.abs(Hi.y)+r.z*Math.abs(Hi.z),o=t.dot(Hi),l=n.dot(Hi),c=i.dot(Hi);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Wi=new Ri,ji=new Ti,Xi=new Ti;class qi{constructor(e=new Ti,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Wi.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ji.subVectors(e,this.center);const t=ji.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(ji,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Xi.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ji.copy(e.center).add(Xi)),this.expandByPoint(ji.copy(e.center).sub(Xi))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Yi=new Ti,Ki=new Ti,Ji=new Ti,Zi=new Ti,Qi=new Ti,$i=new Ti,er=new Ti;class tr{constructor(e=new Ti,t=new Ti(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yi.copy(this.origin).addScaledVector(this.direction,t),Yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ki.copy(e).add(t).multiplyScalar(.5),Ji.copy(t).sub(e).normalize(),Zi.copy(this.origin).sub(Ki);const r=.5*e.distanceTo(t),s=-this.direction.dot(Ji),a=Zi.dot(this.direction),o=-Zi.dot(Ji),l=Zi.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Ki).addScaledVector(Ji,u),d}intersectSphere(e,t){Yi.subVectors(e.center,this.origin);const n=Yi.dot(this.direction),i=Yi.dot(Yi)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(e.min.z-u.z)*h,o=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,o=(e.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Yi)}intersectTriangle(e,t,n,i,r){Qi.subVectors(t,e),$i.subVectors(n,e),er.crossVectors(Qi,$i);let s,a=this.direction.dot(er);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Zi.subVectors(this.origin,e);const o=s*this.direction.dot($i.crossVectors(Zi,$i));if(o<0)return null;const l=s*this.direction.dot(Qi.cross(Zi));if(l<0)return null;if(o+l>a)return null;const c=-s*Zi.dot(er);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class nr{constructor(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m){nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new nr).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/ir.setFromMatrixColumn(e,0).length(),r=1/ir.setFromMatrixColumn(e,1).length(),s=1/ir.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*h,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-s*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=s*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(sr,e,ar)}lookAt(e,t,n){const i=this.elements;return cr.subVectors(e,t),0===cr.lengthSq()&&(cr.z=1),cr.normalize(),or.crossVectors(n,cr),0===or.lengthSq()&&(1===Math.abs(n.z)?cr.x+=1e-4:cr.z+=1e-4,cr.normalize(),or.crossVectors(n,cr)),or.normalize(),lr.crossVectors(cr,or),i[0]=or.x,i[4]=lr.x,i[8]=cr.x,i[1]=or.y,i[5]=lr.y,i[9]=cr.y,i[2]=or.z,i[6]=lr.z,i[10]=cr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],v=n[7],y=n[11],x=n[15],b=i[0],w=i[4],M=i[8],S=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],L=i[6],P=i[10],I=i[14],U=i[3],O=i[7],N=i[11],D=i[15];return r[0]=s*b+a*E+o*R+l*U,r[4]=s*w+a*T+o*L+l*O,r[8]=s*M+a*A+o*P+l*N,r[12]=s*S+a*C+o*I+l*D,r[1]=c*b+h*E+u*R+d*U,r[5]=c*w+h*T+u*L+d*O,r[9]=c*M+h*A+u*P+d*N,r[13]=c*S+h*C+u*I+d*D,r[2]=p*b+f*E+m*R+g*U,r[6]=p*w+f*T+m*L+g*O,r[10]=p*M+f*A+m*P+g*N,r[14]=p*S+f*C+m*I+g*D,r[3]=_*b+v*E+y*R+x*U,r[7]=_*w+v*T+y*L+x*O,r[11]=_*M+v*A+y*P+x*N,r[15]=_*S+v*C+y*I+x*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+e[11]*(+t*l*h-t*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*o*h+t*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],_=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,x=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,b=t*_+n*v+i*y+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return e[0]=_*w,e[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,e[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,e[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,e[4]=v*w,e[5]=(c*m*r-p*u*r+p*i*d-t*m*d-c*i*g+t*u*g)*w,e[6]=(p*o*r-s*m*r-p*i*l+t*m*l+s*i*g-t*o*g)*w,e[7]=(s*u*r-c*o*r+c*i*l-t*u*l-s*i*d+t*o*d)*w,e[8]=y*w,e[9]=(p*h*r-c*f*r-p*n*d+t*f*d+c*n*g-t*h*g)*w,e[10]=(s*f*r-p*a*r+p*n*l-t*f*l-s*n*g+t*a*g)*w,e[11]=(c*a*r-s*h*r-c*n*l+t*h*l+s*n*d-t*a*d)*w,e[12]=x*w,e[13]=(c*f*i-p*h*i+p*n*u-t*f*u-c*n*m+t*h*m)*w,e[14]=(p*a*i-s*f*i-p*n*o+t*f*o+s*n*m-t*a*m)*w,e[15]=(s*h*i-c*a*i+c*n*o-t*h*o-s*n*u+t*a*u)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,_=o*l,v=o*c,y=o*h,x=n.x,b=n.y,w=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+y)*x,i[2]=(p-v)*x,i[3]=0,i[4]=(d-y)*b,i[5]=(1-(u+g))*b,i[6]=(m+_)*b,i[7]=0,i[8]=(p+v)*w,i[9]=(m-_)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=ir.set(i[0],i[1],i[2]).length();const s=ir.set(i[4],i[5],i[6]).length(),a=ir.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],rr.copy(this);const o=1/r,l=1/s,c=1/a;return rr.elements[0]*=o,rr.elements[1]*=o,rr.elements[2]*=o,rr.elements[4]*=l,rr.elements[5]*=l,rr.elements[6]*=l,rr.elements[8]*=c,rr.elements[9]*=c,rr.elements[10]*=c,t.setFromRotationMatrix(rr),n.x=r,n.y=s,n.z=a,this}makePerspective(e,t,n,i,r,s,a=Ln){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let d,p;if(a===Ln)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Pn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=Ln){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(s-r),u=(t+e)*l,d=(n+i)*c;let p,f;if(a===Ln)p=(s+r)*h,f=-2*h;else{if(a!==Pn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ir=new Ti,rr=new nr,sr=new Ti(0,0,0),ar=new Ti(1,1,1),or=new Ti,lr=new Ti,cr=new Ti,hr=new nr,ur=new Ei;class dr{constructor(e=0,t=0,n=0,i=dr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Bn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Bn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Bn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Bn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Bn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return hr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ur.setFromEuler(this),this.setFromQuaternion(ur,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}dr.DEFAULT_ORDER="XYZ";class pr{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yr,e,xr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yr,br,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Cr.subVectors(i,t),Rr.subVectors(n,t),Lr.subVectors(e,t);const s=Cr.dot(Cr),a=Cr.dot(Rr),o=Cr.dot(Lr),l=Rr.dot(Rr),c=Rr.dot(Lr),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Pr),Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getUV(e,t,n,i,r,s,a,o){return!1===Br&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Br=!0),this.getInterpolation(e,t,n,i,r,s,a,o)}static getInterpolation(e,t,n,i,r,s,a,o){return this.getBarycoord(e,t,n,i,Pr),o.setScalar(0),o.addScaledVector(r,Pr.x),o.addScaledVector(s,Pr.y),o.addScaledVector(a,Pr.z),o}static isFrontFacing(e,t,n,i){return Cr.subVectors(n,t),Rr.subVectors(e,t),Cr.cross(Rr).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cr.subVectors(this.c,this.b),Rr.subVectors(this.a,this.b),.5*Cr.cross(Rr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Fr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Fr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===Br&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Br=!0),Fr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return Fr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Fr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Fr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Ir.subVectors(i,n),Ur.subVectors(r,n),Nr.subVectors(e,n);const o=Ir.dot(Nr),l=Ur.dot(Nr);if(o<=0&&l<=0)return t.copy(n);Dr.subVectors(e,i);const c=Ir.dot(Dr),h=Ur.dot(Dr);if(c>=0&&h<=c)return t.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Ir,s);kr.subVectors(e,r);const d=Ir.dot(kr),p=Ur.dot(kr);if(p>=0&&d<=p)return t.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Ur,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return Or.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(Or,a);const g=1/(m+f+u);return s=f*g,a=u*g,t.copy(n).addScaledVector(Ir,s).addScaledVector(Ur,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let zr=0;class Gr extends In{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zr++}),this.uuid=kn(),this.name="",this.type="Material",this.blending=y,this.side=f,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=U,this.blendDst=O,this.blendEquation=S,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=V,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=cn,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yt,this.stencilZFail=Yt,this.stencilZPass=Yt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==y&&(n.blending=this.blending),this.side!==f&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const Hr={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},Vr={h:0,s:0,l:0},Wr={h:0,s:0,l:0};function jr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class Xr{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ci.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=ci.workingColorSpace){return this.r=e,this.g=t,this.b=n,ci.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=ci.workingColorSpace){if(e=Fn(e,1),t=Bn(t,0,1),n=Bn(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=jr(r,i,e+1/3),this.g=jr(r,i,e),this.b=jr(r,i,e-1/3)}return ci.toWorkingColorSpace(this,i),this}setStyle(e,t=Vt){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vt){const n=Hr[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ii(e.r),this.g=ii(e.g),this.b=ii(e.b),this}copyLinearToSRGB(e){return this.r=ri(e.r),this.g=ri(e.g),this.b=ri(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vt){return ci.fromWorkingColorSpace(qr.copy(this),e),65536*Math.round(Bn(255*qr.r,0,255))+256*Math.round(Bn(255*qr.g,0,255))+Math.round(Bn(255*qr.b,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ci.workingColorSpace){ci.fromWorkingColorSpace(qr.copy(this),t);const n=qr.r,i=qr.g,r=qr.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Zr(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Bn(e,-65504,65504),Kr.floatView[0]=e;const t=Kr.uint32View[0],n=t>>23&511;return Kr.baseTable[n]+((8388607&t)>>Kr.shiftTable[n])}function Qr(e){const t=e>>10;return Kr.uint32View[0]=Kr.mantissaTable[Kr.offsetTable[t]+(1023&e)]+Kr.exponentTable[t],Kr.floatView[0]}const $r={toHalfFloat:Zr,fromHalfFloat:Qr},es=new Ti,ts=new qn;class ns{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=vn,this.updateRange={offset:0,count:-1},this.gpuType=Ce,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}bs.copy(r).invert(),ws.copy(e.ray).applyMatrix4(bs),null!==n.boundingBox&&!1===ws.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,ws)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:ks.clone(),object:e}}(e,t,n,i,Es,Ts,As,Ds);if(h){r&&(Ls.fromBufferAttribute(r,o),Ps.fromBufferAttribute(r,l),Is.fromBufferAttribute(r,c),h.uv=Fr.getInterpolation(Ds,Es,Ts,As,Ls,Ps,Is,new qn)),s&&(Ls.fromBufferAttribute(s,o),Ps.fromBufferAttribute(s,l),Is.fromBufferAttribute(s,c),h.uv1=Fr.getInterpolation(Ds,Es,Ts,As,Ls,Ps,Is,new qn),h.uv2=h.uv1),a&&(Us.fromBufferAttribute(a,o),Os.fromBufferAttribute(a,l),Ns.fromBufferAttribute(a,c),h.normal=Fr.getInterpolation(Ds,Es,Ts,As,Us,Os,Ns,new Ti),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Ti,materialIndex:0};Fr.getNormal(Es,Ts,As,e.normal),h.face=e}return h}class zs extends xs{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,s,p,f,m,g,_){const v=s/m,y=p/g,x=s/2,b=p/2,w=f/2,M=m+1,S=g+1;let E=0,T=0;const A=new Ti;for(let s=0;s0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-s/g),E+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Xs extends Ar{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new nr,this.projectionMatrix=new nr,this.projectionMatrixInverse=new nr,this.coordinateSystem=Ln}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class qs extends Xs{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Dn*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Nn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Dn*Math.atan(Math.tan(.5*Nn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Nn*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ys=-90;class Ks extends Ar{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new qs(Ys,1,e,t);i.layers=this.layers,this.add(i);const r=new qs(Ys,1,e,t);r.layers=this.layers,this.add(r);const s=new qs(Ys,1,e,t);s.layers=this.layers,this.add(s);const a=new qs(Ys,1,e,t);a.layers=this.layers,this.add(a);const o=new qs(Ys,1,e,t);o.layers=this.layers,this.add(o);const l=new qs(Ys,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Ln)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Pn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,r,s,a,o,l]=this.children,c=e.getRenderTarget(),h=e.xr.enabled;e.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=u,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}}class Js extends gi{constructor(e,t,n,i,r,s,a,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:re,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Zs extends yi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(ni("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===kt?Vt:Ht),this.texture=new Js(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:_e}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new zs(5,5,5),a=new js({name:"CubemapFromEquirect",uniforms:Gs(n),vertexShader:i,fragmentShader:r,side:m,blending:v});a.uniforms.tEquirect.value=t;const o=new Bs(s,a),l=t.minFilter;return t.minFilter===xe&&(t.minFilter=_e),new Ks(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const Qs=new Ti,$s=new Ti,ea=new Yn;class ta{constructor(e=new Ti(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Qs.subVectors(n,t).cross($s.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Qs),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||ea.getNormalMatrix(e),i=this.coplanarPoint(Qs).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const na=new qi,ia=new Ti;class ra{constructor(e=new ta,t=new ta,n=new ta,i=new ta,r=new ta,s=new ta){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ln){const n=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],_=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+_).normalize(),n[3].setComponents(o-s,u-c,m-p,y-_).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),t===Ln)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(t!==Pn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),na.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),na.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(na)}intersectsSprite(e){return na.center.set(0,0,0),na.radius=.7071067811865476,na.applyMatrix4(e.matrixWorld),this.intersectsSphere(na)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ia.y=i.normal.y>0?e.max.y:e.min.y,ia.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ia)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function sa(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function aa(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},ca={common:{diffuse:{value:new Xr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yn},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yn},normalScale:{value:new qn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xr(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 Xr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0},uvTransform:{value:new Yn}},sprite:{diffuse:{value:new Xr(16777215)},opacity:{value:1},center:{value:new qn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yn},alphaMap:{value:null},alphaMapTransform:{value:new Yn},alphaTest:{value:0}}},ha={basic:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.fog]),vertexShader:la.meshbasic_vert,fragmentShader:la.meshbasic_frag},lambert:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)}}]),vertexShader:la.meshlambert_vert,fragmentShader:la.meshlambert_frag},phong:{uniforms:Hs([ca.common,ca.specularmap,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)},specular:{value:new Xr(1118481)},shininess:{value:30}}]),vertexShader:la.meshphong_vert,fragmentShader:la.meshphong_frag},standard:{uniforms:Hs([ca.common,ca.envmap,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.roughnessmap,ca.metalnessmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:la.meshphysical_vert,fragmentShader:la.meshphysical_frag},toon:{uniforms:Hs([ca.common,ca.aomap,ca.lightmap,ca.emissivemap,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.gradientmap,ca.fog,ca.lights,{emissive:{value:new Xr(0)}}]),vertexShader:la.meshtoon_vert,fragmentShader:la.meshtoon_frag},matcap:{uniforms:Hs([ca.common,ca.bumpmap,ca.normalmap,ca.displacementmap,ca.fog,{matcap:{value:null}}]),vertexShader:la.meshmatcap_vert,fragmentShader:la.meshmatcap_frag},points:{uniforms:Hs([ca.points,ca.fog]),vertexShader:la.points_vert,fragmentShader:la.points_frag},dashed:{uniforms:Hs([ca.common,ca.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:la.linedashed_vert,fragmentShader:la.linedashed_frag},depth:{uniforms:Hs([ca.common,ca.displacementmap]),vertexShader:la.depth_vert,fragmentShader:la.depth_frag},normal:{uniforms:Hs([ca.common,ca.bumpmap,ca.normalmap,ca.displacementmap,{opacity:{value:1}}]),vertexShader:la.meshnormal_vert,fragmentShader:la.meshnormal_frag},sprite:{uniforms:Hs([ca.sprite,ca.fog]),vertexShader:la.sprite_vert,fragmentShader:la.sprite_frag},background:{uniforms:{uvTransform:{value:new Yn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:la.background_vert,fragmentShader:la.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:la.backgroundCube_vert,fragmentShader:la.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:la.cube_vert,fragmentShader:la.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:la.equirect_vert,fragmentShader:la.equirect_frag},distanceRGBA:{uniforms:Hs([ca.common,ca.displacementmap,{referencePosition:{value:new Ti},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:la.distanceRGBA_vert,fragmentShader:la.distanceRGBA_frag},shadow:{uniforms:Hs([ca.lights,ca.fog,{color:{value:new Xr(0)},opacity:{value:1}}]),vertexShader:la.shadow_vert,fragmentShader:la.shadow_frag}};ha.physical={uniforms:Hs([ha.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yn},clearcoatNormalScale:{value:new qn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yn},sheen:{value:0},sheenColor:{value:new Xr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yn},transmissionSamplerSize:{value:new qn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yn},attenuationDistance:{value:0},attenuationColor:{value:new Xr(0)},specularColor:{value:new Xr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yn},anisotropyVector:{value:new qn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yn}}]),vertexShader:la.meshphysical_vert,fragmentShader:la.meshphysical_frag};const ua={r:0,b:0,g:0};function da(e,t,n,i,r,s,a){const o=new Xr(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function g(t,n){t.getRGB(ua,Vs(e)),i.buffers.color.setClear(ua.r,ua.g,ua.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,g(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,g(o,h)},render:function(s,_){let v=!1,y=!0===_.isScene?_.background:null;y&&y.isTexture&&(y=(_.backgroundBlurriness>0?n:t).get(y)),null===y?g(o,h):y&&y.isColor&&(g(y,1),v=!0);const x=e.xr.getEnvironmentBlendMode();"additive"===x?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===x&&i.buffers.color.setClear(0,0,0,0,a),(e.autoClear||v)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),y&&(y.isCubeTexture||y.mapping===le)?(void 0===c&&(c=new Bs(new zs(1,1,1),new js({name:"BackgroundCubeMaterial",uniforms:Gs(ha.backgroundCube.uniforms),vertexShader:ha.backgroundCube.vertexShader,fragmentShader:ha.backgroundCube.fragmentShader,side:m,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&!1===y.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=y.colorSpace!==Vt,u===y&&d===y.version&&p===e.toneMapping||(c.material.needsUpdate=!0,u=y,d=y.version,p=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(void 0===l&&(l=new Bs(new oa(2,2),new js({name:"BackgroundMaterial",uniforms:Gs(ha.background.uniforms),vertexShader:ha.background.vertexShader,fragmentShader:ha.background.fragmentShader,side:f,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=y.colorSpace!==Vt,!0===y.matrixAutoUpdate&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),u===y&&d===y.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=y,d=y.version,p=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function pa(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}return c.attributesNum!==a||c.index!==i}(r,y,d,x),b&&function(e,t,n,i){const r={},s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o)if(o[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}c.attributes=r,c.attributesNum=a,c.index=i}(r,y,d,x)}else{const e=!0===l.wireframe;c.geometry===y.id&&c.program===d.id&&c.wireframe===e||(c.geometry=y.id,c.program=d.id,c.wireframe=e,b=!0)}null!==x&&n.update(x,e.ELEMENT_ARRAY_BUFFER),(b||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const t in c){const s=c[t];if(s.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||a.gpuType===Te);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),_=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,y=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?e.getParameter(e.MAX_SAMPLES):0}}function ga(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new ta,o=new Yn,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=s?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(u,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function _a(e){let t=new WeakMap;function n(e,t){return t===ae?e.mapping=re:t===oe&&(e.mapping=se),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===ae||s===oe){if(t.has(r))return n(t.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new Zs(s.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class va extends Xs{constructor(e=-1,t=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const ya=[.125,.215,.35,.446,.526,.582],xa=new va,ba=new Xr;let wa=null;const Ma=(1+Math.sqrt(5))/2,Sa=1/Ma,Ea=[new Ti(1,1,1),new Ti(-1,1,1),new Ti(1,1,-1),new Ti(-1,1,-1),new Ti(0,Ma,Sa),new Ti(0,Ma,-Sa),new Ti(Sa,0,Ma),new Ti(-Sa,0,Ma),new Ti(Ma,Sa,0),new Ti(-Ma,Sa,0)];class Ta{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){wa=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=La(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ra(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=ya[a-e+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];_.set(i,f*p*e),v.set(u,m*p*e);const r=[e,e,e,e,e,e];y.set(r,g*p*e)}const x=new xs;x.setAttribute("position",new ns(_,f)),x.setAttribute("uv",new ns(v,m)),x.setAttribute("faceIndex",new ns(y,g)),t.push(x),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new Ti(0,1,0);return new js({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new Bs(this._lodPlanes[0],e);this._renderer.compile(t,xa)}_sceneToCubeUV(e,t,n,i){const r=new qs(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(ba),o.toneMapping=Z,o.autoClear=!1;const h=new Yr({name:"PMREM.Background",side:m,depthWrite:!1,depthTest:!1}),u=new Bs(new zs,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(ba),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;Ca(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===re||e.mapping===se;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=La()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ra());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Bs(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;Ca(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,xa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(t),o.render(c,xa)}}function Aa(e,t,n){const i=new yi(e,t,n);return i.texture.mapping=le,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ca(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Ra(){return new js({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}function La(){return new js({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:v,depthTest:!1,depthWrite:!1})}function Pa(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===ae||s===oe,o=s===re||s===se;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Ta(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(s)){null===n&&(n=new Ta(e));const s=a?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,s),r.addEventListener("dispose",i),s.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Ia(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ua(e,t,n,i){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);for(const e in o.morphAttributes){const n=o.morphAttributes[e];for(let e=0,i=n.length;et.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);const m=new Float32Array(p*f*4*r),g=new xi(m,p,f,r);g.type=Ce,g.needsUpdate=!0;const _=4*d;for(let t=0;t0)return e;const r=t*n;let s=Wa[r];if(void 0===s&&(s=new Float32Array(r),Wa[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function Ja(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Yo(e,t){const n=function(e){switch(e){case Wt:return["Linear","( value )"];case Vt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Ko(e,t){let n;switch(t){case Q:n="Linear";break;case $:n="Reinhard";break;case ee:n="OptimizedCineon";break;case te:n="ACESFilmic";break;case ne:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Jo(e){return""!==e}function Zo(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Qo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const $o=/^[ \t]*#include +<([\w\d./]+)>/gm;function el(e){return e.replace($o,nl)}const tl=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function nl(e,t){let n=la[t];if(void 0===n){const e=tl.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=la[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return el(n)}const il=/#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 rl(e){return e.replace(il,sl)}function sl(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(y+="\n"),x=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Jo).join("\n"),x.length>0&&(x+="\n")):(y=[al(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Jo).join("\n"),x=[g,al(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Z?"#define TONE_MAPPING":"",n.toneMapping!==Z?la.tonemapping_pars_fragment:"",n.toneMapping!==Z?Ko("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",la.colorspace_pars_fragment,Yo("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Jo).join("\n")),a=el(a),a=Zo(a,n),a=Qo(a,n),o=el(o),o=Zo(o,n),o=Qo(o,n),a=rl(a),o=rl(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(b="#version 300 es\n",y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,x=["#define varying in",n.glslVersion===Cn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Cn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+x);const w=b+y+a,M=b+x+o,S=jo(r,r.VERTEX_SHADER,w),E=jo(r,r.FRAGMENT_SHADER,M);if(r.attachShader(v,S),r.attachShader(v,E),void 0!==n.index0AttributeName?r.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(v).trim(),n=r.getShaderInfoLog(S).trim(),i=r.getShaderInfoLog(E).trim();let s=!0,a=!0;if(!1===r.getProgramParameter(v,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,v,S,E);else{const e=qo(r,S,"vertex"),n=qo(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==i||(a=!1);a&&(this.diagnostics={runnable:s,programLog:t,vertexShader:{log:n,prefix:y},fragmentShader:{log:i,prefix:x}})}let T,A;return r.deleteShader(S),r.deleteShader(E),this.getUniforms=function(){return void 0===T&&(T=new Wo(r,v)),T},this.getAttributes=function(){return void 0===A&&(A=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,Y=s.clearcoat>0,K=s.iridescence>0,J=s.sheen>0,Q=s.transmission>0,$=q&&!!s.anisotropyMap,ee=Y&&!!s.clearcoatMap,te=Y&&!!s.clearcoatNormalMap,ne=Y&&!!s.clearcoatRoughnessMap,ie=K&&!!s.iridescenceMap,re=K&&!!s.iridescenceThicknessMap,se=J&&!!s.sheenColorMap,ae=J&&!!s.sheenRoughnessMap,oe=!!s.specularMap,ce=!!s.specularColorMap,he=!!s.specularIntensityMap,ue=Q&&!!s.transmissionMap,de=Q&&!!s.thicknessMap,pe=!!s.gradientMap,fe=!!s.alphaMap,me=s.alphaTest>0,ge=!!s.alphaHash,_e=!!s.extensions,ve=!!w.attributes.uv1,ye=!!w.attributes.uv2,xe=!!w.attributes.uv3;let be=Z;return s.toneMapped&&(null!==O&&!0!==O.isXRRenderTarget||(be=e.toneMapping)),{isWebGL2:h,shaderID:T,shaderType:s.type,shaderName:s.name,vertexShader:R,fragmentShader:L,defines:s.defines,customVertexShaderID:P,customFragmentShaderID:I,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:N,instancingColor:N&&null!==x.instanceColor,supportsVertexTextures:d,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:Wt,map:D,matcap:k,envMap:B,envMapMode:B&&S.mapping,envMapCubeUVHeight:E,aoMap:F,lightMap:z,bumpMap:G,normalMap:H,displacementMap:d&&V,emissiveMap:W,normalMapObjectSpace:H&&s.normalMapType===Gt,normalMapTangentSpace:H&&s.normalMapType===zt,metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:$,clearcoat:Y,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:J,sheenColorMap:se,sheenRoughnessMap:ae,specularMap:oe,specularColorMap:ce,specularIntensityMap:he,transmission:Q,transmissionMap:ue,thicknessMap:de,gradientMap:pe,opaque:!1===s.transparent&&s.blending===y,alphaMap:fe,alphaTest:me,alphaHash:ge,combine:s.combine,mapUv:D&&_(s.map.channel),aoMapUv:F&&_(s.aoMap.channel),lightMapUv:z&&_(s.lightMap.channel),bumpMapUv:G&&_(s.bumpMap.channel),normalMapUv:H&&_(s.normalMap.channel),displacementMapUv:V&&_(s.displacementMap.channel),emissiveMapUv:W&&_(s.emissiveMap.channel),metalnessMapUv:j&&_(s.metalnessMap.channel),roughnessMapUv:X&&_(s.roughnessMap.channel),anisotropyMapUv:$&&_(s.anisotropyMap.channel),clearcoatMapUv:ee&&_(s.clearcoatMap.channel),clearcoatNormalMapUv:te&&_(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&_(s.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&_(s.iridescenceMap.channel),iridescenceThicknessMapUv:re&&_(s.iridescenceThicknessMap.channel),sheenColorMapUv:se&&_(s.sheenColorMap.channel),sheenRoughnessMapUv:ae&&_(s.sheenRoughnessMap.channel),specularMapUv:oe&&_(s.specularMap.channel),specularColorMapUv:ce&&_(s.specularColorMap.channel),specularIntensityMapUv:he&&_(s.specularIntensityMap.channel),transmissionMapUv:ue&&_(s.transmissionMap.channel),thicknessMapUv:de&&_(s.thicknessMap.channel),alphaMapUv:fe&&_(s.alphaMap.channel),vertexTangents:!!w.attributes.tangent&&(H||q),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!w.attributes.color&&4===w.attributes.color.itemSize,vertexUv1s:ve,vertexUv2s:ye,vertexUv3s:xe,pointsUvs:!0===x.isPoints&&!!w.attributes.uv&&(D||fe),fog:!!b,useFog:!0===s.fog,fogExp2:b&&b.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===x.isSkinnedMesh,morphTargets:void 0!==w.morphAttributes.position,morphNormals:void 0!==w.morphAttributes.normal,morphColors:void 0!==w.morphAttributes.color,morphTargetsCount:C,morphTextureStride:U,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:be,useLegacyLights:e._useLegacyLights,decodeVideoTexture:D&&!0===s.map.isVideoTexture&&s.map.colorSpace===Vt,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===g,flipSided:s.side===m,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:_e&&!0===s.extensions.derivatives,extensionFragDepth:_e&&!0===s.extensions.fragDepth,extensionDrawBuffers:_e&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:_e&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=ha[t];n=Ws.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||pl),i.length>1&&i.sort(t||fl),r.length>1&&r.sort(t||fl)}}}function gl(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new ml,e.set(t,[r])):n>=i.length?(r=new ml,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function _l(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Ti,color:new Xr};break;case"SpotLight":n={position:new Ti,direction:new Ti,color:new Xr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ti,color:new Xr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ti,skyColor:new Xr,groundColor:new Xr};break;case"RectAreaLight":n={color:new Xr,position:new Ti,halfWidth:new Ti,halfHeight:new Ti}}return e[t.id]=n,n}}}let vl=0;function yl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function xl(e,t){const n=new _l,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)r.probe.push(new Ti);const s=new Ti,a=new nr,o=new nr;return{setup:function(s,a){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0;s.sort(yl);const x=!0===a?Math.PI:1;for(let e=0,t=s.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ca.LTC_FLOAT_1,r.rectAreaLTC2=ca.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=ca.LTC_HALF_1,r.rectAreaLTC2=ca.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const b=r.hash;b.directionalLength===h&&b.pointLength===u&&b.spotLength===d&&b.rectAreaLength===p&&b.hemiLength===f&&b.numDirectionalShadows===m&&b.numPointShadows===g&&b.numSpotShadows===_&&b.numSpotMaps===v||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=_+v-y,r.spotLightMap.length=v,r.numSpotLightShadowsWithMaps=y,b.directionalLength=h,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=f,b.numDirectionalShadows=m,b.numPointShadows=g,b.numSpotShadows=_,b.numSpotMaps=v,r.version=vl++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t=s.length?(a=new bl(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class Ml extends Gr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bt,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 Sl extends Gr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function El(e,t,n){let i=new ra;const r=new qn,s=new qn,a=new _i,o=new Ml({depthPacking:Ft}),l=new Sl,c={},h=n.maxTextureSize,d={[f]:m,[m]:f,[g]:g},_=new js({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),y=_.clone();y.defines.HORIZONTAL_PASS=1;const x=new xs;x.setAttribute("position",new ns(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Bs(x,_),w=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=u;let M=this.type;function S(n,i){const s=t.update(b);_.defines.VSM_SAMPLES!==n.blurSamples&&(_.defines.VSM_SAMPLES=n.blurSamples,y.defines.VSM_SAMPLES=n.blurSamples,_.needsUpdate=!0,y.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new yi(r.x,r.y)),_.uniforms.shadow_pass.value=n.map.texture,_.uniforms.resolution.value=n.mapSize,_.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,_,b,null),y.uniforms.shadow_pass.value=n.mapPass.texture,y.uniforms.resolution.value=n.mapSize,y.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,y,b,null)}function E(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===p?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(e.properties.get(s).light=i),s}function T(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===p)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/g.x),r.x=s.x*g.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/g.y),r.y=s.y*g.y,u.mapSize.y=s.y)),null===u.map||!0===f||!0===m){const e=this.type!==p?{minFilter:de,magFilter:de}:{};null!==u.map&&u.map.dispose(),u.map=new yi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const _=u.getViewportCount();for(let e=0;e<_;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(c,e),i=u.getFrustum(),T(n,o,u.camera,c,this.type)}!0!==u.isPointLightShadow&&this.type===p&&S(u,o),u.needsUpdate=!1}M=this.type,w.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function Tl(e,t,n){const i=n.isWebGL2,r=new function(){let t=!1;const n=new _i;let i=null;const r=new _i(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,s,a,o){!0===o&&(t*=a,i*=a,s*=a),n.set(t,i,s,a),!1===r.equals(n)&&(e.clearColor(t,i,s,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,n=null,i=null,r=null;return{setTest:function(t){t?be(e.DEPTH_TEST):we(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case z:e.depthFunc(e.NEVER);break;case G:e.depthFunc(e.ALWAYS);break;case H:e.depthFunc(e.LESS);break;case V:e.depthFunc(e.LEQUAL);break;case W:e.depthFunc(e.EQUAL);break;case j:e.depthFunc(e.GEQUAL);break;case X:e.depthFunc(e.GREATER);break;case q:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},c=new function(){let t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?be(e.STENCIL_TEST):we(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&s===a||(e.stencilFunc(t,n,a),i=t,r=n,s=a)},setOp:function(t,n,i){a===t&&o===n&&l===i||(e.stencilOp(t,n,i),a=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},h=new WeakMap,u=new WeakMap;let d={},p={},f=new WeakMap,_=[],Y=null,K=!1,J=null,Z=null,Q=null,$=null,ee=null,te=null,ne=null,ie=!1,re=null,se=null,ae=null,oe=null,le=null;const ce=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let he=!1,ue=0;const de=e.getParameter(e.VERSION);-1!==de.indexOf("WebGL")?(ue=parseFloat(/^WebGL (\d)/.exec(de)[1]),he=ue>=1):-1!==de.indexOf("OpenGL ES")&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),he=ue>=2);let pe=null,fe={};const me=e.getParameter(e.SCISSOR_BOX),ge=e.getParameter(e.VIEWPORT),_e=(new _i).fromArray(me),ve=(new _i).fromArray(ge);function ye(t,n,r,s){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?Vn:Math.floor,s=i(r*e.width),a=i(r*e.height);void 0===m&&(m=v(s,a));const o=n?v(s,a):m;return o.width=s,o.height=a,o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function x(e){return Gn(e.width)&&Gn(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==de&&e.minFilter!==_e}function w(t){e.generateMipmap(t)}function M(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(l=e.R8UI),r===e.UNSIGNED_SHORT&&(l=e.R16UI),r===e.UNSIGNED_INT&&(l=e.R32UI),r===e.BYTE&&(l=e.R8I),r===e.SHORT&&(l=e.R16I),r===e.INT&&(l=e.R32I)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=s===Vt&&!1===a?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function S(e,t,n){return!0===b(e,n)||e.isFramebufferTexture&&e.minFilter!==de&&e.minFilter!==_e?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===de||t===pe||t===me?e.NEAREST:e.LINEAR}function T(e){const t=e.target;t.removeEventListener("dispose",T),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=t.texture,r=i.get(t),s=i.get(n);if(void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(r.__webglFramebuffer[t]))for(let n=0;n0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void D(s,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const P={[ce]:e.REPEAT,[he]:e.CLAMP_TO_EDGE,[ue]:e.MIRRORED_REPEAT},I={[de]:e.NEAREST,[pe]:e.NEAREST_MIPMAP_NEAREST,[me]:e.NEAREST_MIPMAP_LINEAR,[_e]:e.LINEAR,[ve]:e.LINEAR_MIPMAP_NEAREST,[xe]:e.LINEAR_MIPMAP_LINEAR},U={[hn]:e.NEVER,[_n]:e.ALWAYS,[un]:e.LESS,[pn]:e.LEQUAL,[dn]:e.EQUAL,[gn]:e.GEQUAL,[fn]:e.GREATER,[mn]:e.NOTEQUAL};function O(n,s,a){if(a?(e.texParameteri(n,e.TEXTURE_WRAP_S,P[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,P[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,P[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[s.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),s.wrapS===he&&s.wrapT===he||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(s.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(s.minFilter)),s.minFilter!==de&&s.minFilter!==_e&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,U[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.magFilter===de)return;if(s.minFilter!==me&&s.minFilter!==xe)return;if(s.type===Ce&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===Re&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function N(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));const r=n.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function D(t,r,a){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=N(t,r),u=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!o&&(e.wrapS!==he||e.wrapT!==he||e.minFilter!==de&&e.minFilter!==_e)}(r)&&!1===x(r.image);let i=y(r.image,t,!1,h);i=H(r,i);const p=x(i)||o,f=s.convert(r.format,r.colorSpace);let m,g=s.convert(r.type),_=M(r.internalFormat,f,g,r.colorSpace,r.isVideoTexture);O(l,r,p);const v=r.mipmaps,E=o&&!0!==r.isVideoTexture,T=void 0===d.__version||!0===c,A=S(r,i,p);if(r.isDepthTexture)_=e.DEPTH_COMPONENT,o?_=r.type===Ce?e.DEPTH_COMPONENT32F:r.type===Ae?e.DEPTH_COMPONENT24:r.type===Ie?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===Ce&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===ke&&_===e.DEPTH_COMPONENT&&r.type!==Ee&&r.type!==Ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ae,g=s.convert(r.type)),r.format===Be&&_===e.DEPTH_COMPONENT&&(_=e.DEPTH_STENCIL,r.type!==Ie&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ie,g=s.convert(r.type))),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,_,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,_,i.width,i.height,0,f,g,null));else if(r.isDataTexture)if(v.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t>=1,r>>=1}}else if(v.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,_,v[0].width,v[0].height);for(let t=0,i=v.length;t>c),i=Math.max(1,r.height>>c);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,c,p,t,i,r.depth,0,h,u,null):n.texImage2D(l,c,p,t,i,0,h,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),G(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0,z(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function B(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||G(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Ce?r=e.DEPTH_COMPONENT32F:t.type===Ae&&(r=e.DEPTH_COMPONENT24));const i=z(n);G(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=z(n);i&&!1===G(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):G(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function H(e,n){const i=e.colorSpace,r=e.format,s=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===Rn||i!==Wt&&i!==Ht&&(i===Vt||i===jt?!1===o?!0===t.has("EXT_sRGB")&&r===Oe?(e.format=Rn,e.minFilter=_e,e.generateMipmaps=!1):n=ui.sRGBToLinear(n):r===Oe&&s===we||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=R;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=L,this.setTexture2DArray=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?D(s,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?D(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=i.get(h);if(h.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:y(r.image[e],!1,!0,c),d[e]=H(r,d[e]);const p=d[0],f=x(p)||o,m=s.convert(r.format,r.colorSpace),g=s.convert(r.type),_=M(r.internalFormat,m,g,r.colorSpace),v=o&&!0!==r.isVideoTexture,E=void 0===u.__version||!0===l;let T,A=S(r,p,f);if(O(e.TEXTURE_CUBE_MAP,r,f),t){v&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,p.width,p.height);for(let t=0;t<6;t++){T=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,_,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){v?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,m,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,d[t].width,d[t].height,0,m,g,d[t].data);for(let i=0;i0){c.__webglFramebuffer[t]=[];for(let n=0;n0){c.__webglFramebuffer=[];for(let t=0;t0&&!1===G(t)){const i=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0&&!1===G(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Pl)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Ll;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ul extends gi{constructor(e,t,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:ke)!==ke&&c!==Be)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===ke&&(n=Ae),void 0===n&&c===Be&&(n=Ie),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:de,this.minFilter=void 0!==o?o:de,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Ol extends In{constructor(e,t){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=t.getContextAttributes();let m=null,g=null;const _=[],v=[],y=new qs;y.layers.enable(1),y.viewport=new _i;const x=new qs;x.layers.enable(2),x.viewport=new _i;const b=[y,x],w=new Rl;w.layers.enable(1),w.layers.enable(2);let M=null,S=null;function E(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function T(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",A);for(let e=0;e<_.length;e++){const t=v[e];null!==t&&(v[e]=null,_[e].disconnect(t))}M=null,S=null,e.setRenderTarget(m),d=null,u=null,h=null,i=null,g=null,I.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function A(e){for(let t=0;t=0&&(v[i]=null,_[i].disconnect(n))}for(let t=0;t=v.length){v.push(n),i=e;break}if(null===v[e]){v[e]=n,i=e;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new Il,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",E),i.addEventListener("selectstart",E),i.addEventListener("selectend",E),i.addEventListener("squeeze",E),i.addEventListener("squeezestart",E),i.addEventListener("squeezeend",E),i.addEventListener("end",T),i.addEventListener("inputsourceschange",A),!0!==f.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new yi(d.framebufferWidth,d.framebufferHeight,{format:Oe,type:we,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,s=null,a=null;f.depth&&(a=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?Be:ke,s=f.stencil?Ie:Ae);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new yi(u.textureWidth,u.textureHeight,{format:Oe,type:we,depthTexture:new Ul(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const C=new Ti,R=new Ti;function L(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;w.near=x.near=y.near=e.near,w.far=x.far=y.far=e.far,M===w.near&&S===w.far||(i.updateRenderState({depthNear:w.near,depthFar:w.far}),M=w.near,S=w.far);const t=e.parent,n=w.cameras;L(w,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const s=t.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Vs(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform)),t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===m&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Dl(e,t,n,i){let r={},s={},a=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0){i=n%16;const e=16-i;0!==i&&e-s.boundary<0&&(n+=16-i,r.__offset=n)}n+=s.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=Z;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(f=w.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,_=ne.get(i),v=y.state.lights;if(!0===V&&(!0===W||e!==C)){const t=e===C&&i.id===A;pe.setState(i,e,t)}let x=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version||_.outputColorSpace!==o||r.isInstancedMesh&&!1===_.instancing?x=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?x=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||_.envMap!==l||!0===i.fog&&_.fog!==s?x=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===pe.numPlanes&&_.numIntersection===pe.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==h||_.morphTargets!==u||_.morphNormals!==d||_.morphColors!==p||_.toneMapping!==f||!0===$.isWebGL2&&_.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:(x=!0,_.__version=i.version);let b=_.currentProgram;!0===x&&(b=Ze(i,t,r));let M=!1,S=!1,E=!1;const R=b.getUniforms(),L=_.uniforms;if(ee.useProgram(b.program)&&(M=!0,S=!0,E=!0),i.id!==A&&(A=i.id,S=!0),M||C!==e){R.setValue(Se,"projectionMatrix",e.projectionMatrix),R.setValue(Se,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(Se,Y.setFromMatrixPosition(e.matrixWorld)),$.logarithmicDepthBuffer&&R.setValue(Se,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(Se,"isOrthographic",!0===e.isOrthographicCamera),C!==e&&(C=e,S=!0,E=!0)}if(r.isSkinnedMesh){R.setOptional(Se,r,"bindMatrix"),R.setOptional(Se,r,"bindMatrixInverse");const e=r.skeleton;e&&($.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(Se,"boneTexture",e.boneTexture,ie),R.setValue(Se,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const P=n.morphAttributes;var I,U;if((void 0!==P.position||void 0!==P.normal||void 0!==P.color&&!0===$.isWebGL2)&&ge.update(r,n,b),(S||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Se,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),S&&(R.setValue(Se,"toneMappingExposure",w.toneMappingExposure),_.needsLights&&(U=E,(I=L).ambientLightColor.needsUpdate=U,I.lightProbe.needsUpdate=U,I.directionalLights.needsUpdate=U,I.directionalLightShadows.needsUpdate=U,I.pointLights.needsUpdate=U,I.pointLightShadows.needsUpdate=U,I.spotLights.needsUpdate=U,I.spotLightShadows.needsUpdate=U,I.rectAreaLights.needsUpdate=U,I.hemisphereLights.needsUpdate=U),s&&!0===i.fog&&he.refreshFogUniforms(L,s),he.refreshMaterialUniforms(L,i,D,N,j),Wo.upload(Se,_.uniformsList,L,ie)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Wo.upload(Se,_.uniformsList,L,ie),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(Se,"center",r.center),R.setValue(Se,"modelViewMatrix",r.modelViewMatrix),R.setValue(Se,"normalMatrix",r.normalMatrix),R.setValue(Se,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){const r=$.isWebGL2;null===j&&(j=new yi(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?Re:we,minFilter:xe,samples:r?4:0})),w.getDrawingBufferSize(q),r?j.setSize(q.x,q.y):j.setSize(Vn(q.x),Vn(q.y));const s=w.getRenderTarget();w.setRenderTarget(j),w.getClearColor(I),U=w.getClearAlpha(),U<1&&w.setClearColor(16777215,.5),w.clear();const a=w.toneMapping;w.toneMapping=Z,Ke(e,n,i),ie.updateMultisampleRenderTarget(j),ie.updateRenderTargetMipmap(j);let o=!1;for(let e=0,r=t.length;e0&&Ke(r,t,n),s.length>0&&Ke(s,t,n),a.length>0&&Ke(a,t,n),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function Ke(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r0?b[b.length-1]:null,x.pop(),v=x.length>0?x[x.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n;const i=ne.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===Q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=ne.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){T=e,S=t,E=n;let i=!0,r=null,s=!1,a=!1;if(e){const o=ne.get(e);void 0!==o.__useDefaultFramebuffer?(ee.bindFramebuffer(Se.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?ie.setupRenderTarget(e):o.__hasExternalTextures&&ie.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],s=!0):r=$.isWebGL2&&e.samples>0&&!1===ie.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,R.copy(e.viewport),L.copy(e.scissor),P=e.scissorTest}else R.copy(F).multiplyScalar(D).floor(),L.copy(z).multiplyScalar(D).floor(),P=G;if(ee.bindFramebuffer(Se.FRAMEBUFFER,r)&&$.drawBuffers&&i&&ee.drawBuffers(e,r),ee.viewport(R),ee.scissor(L),ee.setScissorTest(P),s){const i=ne.get(e.texture);Se.framebufferTexture2D(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,Se.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=ne.get(e.texture),r=t||0;Se.framebufferTextureLayer(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}A=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){ee.bindFramebuffer(Se.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(o!==Oe&&ye.convert(o)!==Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Re&&(Q.has("EXT_color_buffer_half_float")||$.isWebGL2&&Q.has("EXT_color_buffer_float"));if(!(l===we||ye.convert(l)===Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_TYPE)||l===Ce&&($.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Se.readPixels(t,n,i,r,ye.convert(o),ye.convert(l),s)}finally{const e=null!==T?ne.get(T).__webglFramebuffer:null;ee.bindFramebuffer(Se.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i);ie.setTexture2D(t,0),Se.copyTexSubImage2D(Se.TEXTURE_2D,n,0,0,e.x,e.y,r,s),ee.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,s=t.image.height,a=ye.convert(n.format),o=ye.convert(n.type);ie.setTexture2D(n,0),Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,n.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?Se.compressedTexSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,a,o,t.image),0===i&&n.generateMipmaps&&Se.generateMipmap(Se.TEXTURE_2D),ee.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(w.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=ye.convert(i.format),c=ye.convert(i.type);let h;if(i.isData3DTexture)ie.setTexture3D(i,0),h=Se.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");ie.setTexture2DArray(i,0),h=Se.TEXTURE_2D_ARRAY}Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,i.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Se.getParameter(Se.UNPACK_ROW_LENGTH),d=Se.getParameter(Se.UNPACK_IMAGE_HEIGHT),p=Se.getParameter(Se.UNPACK_SKIP_PIXELS),f=Se.getParameter(Se.UNPACK_SKIP_ROWS),m=Se.getParameter(Se.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Se.pixelStorei(Se.UNPACK_ROW_LENGTH,g.width),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,g.height),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,e.min.x),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,e.min.y),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Se.compressedTexSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,g.data)):Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g),Se.pixelStorei(Se.UNPACK_ROW_LENGTH,u),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,d),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,p),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,f),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&Se.generateMipmap(h),ee.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?ie.setTextureCube(e,0):e.isData3DTexture?ie.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ie.setTexture2DArray(e,0):ie.setTexture2D(e,0),ee.unbindTexture()},this.resetState=function(){S=0,E=0,T=null,ee.reset(),be.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ln}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Vt?kt:Dt}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===kt?Vt:Wt}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Bl extends kl{}Bl.prototype.isWebGL1Renderer=!0;class Fl{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Xr(e),this.density=t}clone(){return new Fl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class zl{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Xr(e),this.near=t,this.far=n}clone(){return new zl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Gl extends Ar{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class Hl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=vn,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=kn()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:ql.clone(),uv:Fr.getInterpolation(ql,$l,ec,tc,nc,ic,rc,new qn),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function ac(e,t,n,i,r,s){Jl.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Zl.x=s*Jl.x-r*Jl.y,Zl.y=r*Jl.x+s*Jl.y):Zl.copy(Jl),e.copy(t),e.x+=Zl.x,e.y+=Zl.y,e.applyMatrix4(Ql)}const oc=new Ti,lc=new Ti;class cc extends Ar{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){oc.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(oc);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){oc.setFromMatrixPosition(e.matrixWorld),lc.setFromMatrixPosition(this.matrixWorld);const n=oc.distanceTo(lc)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;io)continue;u.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(u);se.far||t.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,s.start),i=Math.min(f.count,s.start+s.count)-1;no)continue;u.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(u);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class Qc extends gi{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:_e,this.magFilter=void 0!==r?r:_e,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class $c extends gi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=de,this.minFilter=de,this.generateMipmaps=!1,this.needsUpdate=!0}}class eh extends gi{constructor(e,t,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class th extends eh{constructor(e,t,n,i,r,s){super(e,t,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=he}}class nh extends eh{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,re),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class ih extends gi{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let s;s=t||e*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new qn:new Ti);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Ti,i=[],r=[],s=[],a=new Ti,o=new nr;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Ti)}r[0]=new Ti,s[0]=new Ti;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Bn(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(Bn(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sh extends rh{constructor(e=0,t=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const n=t||new qn,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(lh.subVectors(i[0],i[1]).add(i[0]),a=lh);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(ph(a,o.x,l.x,c.x,h.x),ph(a,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Th extends xs{constructor(e=[new qn(0,-.5),new qn(.5,0),new qn(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Bn(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/t,h=new Ti,u=new qn,d=new Ti,p=new Ti,f=new Ti;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=t;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=e.length-1;n++){h.x=e[n].x*p,h.y=e[n].y,h.z=e[n].x*f,s.push(h.x,h.y,h.z),u.x=r/t,u.y=n/(e.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new us(h,3)),this.setAttribute("normal",new us(u,3)),this.setAttribute("uv",new us(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Lh extends Rh{constructor(e=1,t=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,e,t,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Lh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ph extends xs{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new us(r,3)),this.setAttribute("normal",new us(r.slice(),3)),this.setAttribute("uv",new us(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ph(e.vertices,e.indices,e.radius,e.details)}}class Ih extends Ph{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ih(e.radius,e.detail)}}const Uh=new Ti,Oh=new Ti,Nh=new Ti,Dh=new Fr;class kh extends xs{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(Nn*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let e=0;e0)for(s=t;s=t;s-=i)a=au(s,e[s],e[s+1],a);return a&&eu(a,a.next)&&(ou(a),a=a.next),a}function zh(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!eu(i,i.next)&&0!==$h(i.prev,i,i.next))i=i.next;else{if(ou(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Gh(e,t,n,i,r,s,a){if(!e)return;!a&&s&&function(e,t,n,i){let r=e;do{0===r.z&&(r.z=Kh(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,s,a,o,l,c=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(e,i,r,s);let o,l,c=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?Vh(e,i,r,s):Hh(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),ou(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Gh(e=Wh(zh(e),t,n),t,n,i,r,s,2):2===a&&jh(e,t,n,i,r,s):Gh(zh(e),t,n,i,r,s,1);break}}function Hh(e){const t=e.prev,n=e,i=e.next;if($h(t,n,i)>=0)return!1;const r=t.x,s=n.x,a=i.x,o=t.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Zh(r,o,s,l,a,c,f.x,f.y)&&$h(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Vh(e,t,n,i){const r=e.prev,s=e,a=e.next;if($h(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,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,_=Kh(p,f,t,n,i),v=Kh(m,g,t,n,i);let y=e.prevZ,x=e.nextZ;for(;y&&y.z>=_&&x&&x.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Zh(o,h,l,u,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zh(o,h,l,u,c,d,x.x,x.y)&&$h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Zh(o,h,l,u,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Zh(o,h,l,u,c,d,x.x,x.y)&&$h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Wh(e,t,n){let i=e;do{const r=i.prev,s=i.next.next;!eu(r,s)&&tu(r,i,i.next,s)&&ru(r,s)&&ru(s,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(s.i/n|0),ou(i),ou(i.next),i=e=s),i=i.next}while(i!==e);return zh(i)}function jh(e,t,n,i,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Qh(a,e)){let o=su(a,e);return a=zh(a,a.next),o=zh(o,o.next),Gh(a,t,n,i,r,s,0),void Gh(o,t,n,i,r,s,0)}e=e.next}a=a.next}while(a!==e)}function Xh(e,t){return e.x-t.x}function qh(e,t){const n=function(e,t){let n,i=t,r=-1/0;const s=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,n=i.x=i.x&&i.x>=l&&s!==i.x&&Zh(an.x||i.x===n.x&&Yh(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(e,t);if(!n)return t;const i=su(n,e);return zh(i,i.next),zh(n,n.next)}function Yh(e,t){return $h(e.prev,e,t.prev)<0&&$h(t.next,e,e.next)<0}function Kh(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Jh(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(i-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function Qh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&tu(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(ru(e,t)&&ru(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&($h(e.prev,e,t.prev)||$h(e,t.prev,t))||eu(e,t)&&$h(e.prev,e,e.next)>0&&$h(t.prev,t,t.next)>0)}function $h(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function eu(e,t){return e.x===t.x&&e.y===t.y}function tu(e,t,n,i){const r=iu($h(e,t,n)),s=iu($h(e,t,i)),a=iu($h(n,i,e)),o=iu($h(n,i,t));return r!==s&&a!==o||!(0!==r||!nu(e,n,t))||!(0!==s||!nu(e,i,t))||!(0!==a||!nu(n,e,i))||!(0!==o||!nu(n,t,i))}function nu(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function iu(e){return e>0?1:e<0?-1:0}function ru(e,t){return $h(e.prev,e,e.next)<0?$h(e,t,e.next)>=0&&$h(e,e.prev,t)>=0:$h(e,t,e.prev)<0||$h(e,e.next,t)<0}function su(e,t){const n=new lu(e.i,e.x,e.y),i=new lu(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function au(e,t,n,i){const r=new lu(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ou(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function lu(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class cu{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){o=c=e[0],l=h=e[1];for(let t=n;tc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Gh(s,a,n,o,l,p,0),a}(n,i);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function uu(e,t){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-o/u,f=t.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-e.x,r=f+o*m-e.y;const g=i*i+r*r;if(g<=2)return new qn(i,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new qn(i/s,r/s)}const P=[];for(let e=0,t=T.length,n=t-1,i=e+1;e=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=T.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=o+2*p;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Lu extends Gr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Xr(16777215),this.specular=new Xr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,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 Pu extends Gr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Xr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Iu extends Gr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Uu extends Gr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,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 Ou extends Gr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Xr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new qn(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 Nu extends Oc{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 Du(e,t,n){return Bu(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function ku(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Fu(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function zu(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Gu(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}const Hu={arraySlice:Du,convertArray:ku,isTypedArray:Bu,getKeyframeOrder:Fu,sortedArray:zu,flattenJSON:Gu,subclip:function(e,t,n,i,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;ns.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e=i.times[u]){const e=u*l+o,t=e+l-o;d=Du(i.values,e,t)}else{const e=i.createInterpolant(),t=o,n=l-o;e.evaluate(s),d=Du(e.resultBuffer,t,n)}"quaternion"===r&&(new Ei).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let e=0;e=r)break e;{const a=t[1];e=r)break t}s=n,n=0}}for(;n>>1;et;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=Du(n,r,s),this.values=Du(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&Bu(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Du(this.times),t=Du(this.values),n=this.getValueSize(),i=this.getInterpolation()===At,r=e.length-1;let s=1;for(let a=1;a0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=Du(e,0,s),this.values=Du(t,0,s*n)):(this.times=e,this.values=t),this}clone(){const e=Du(this.times,0),t=Du(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}qu.prototype.TimeBufferType=Float32Array,qu.prototype.ValueBufferType=Float32Array,qu.prototype.DefaultInterpolation=Tt;class Yu extends qu{}Yu.prototype.ValueTypeName="bool",Yu.prototype.ValueBufferType=Array,Yu.prototype.DefaultInterpolation=Et,Yu.prototype.InterpolantFactoryMethodLinear=void 0,Yu.prototype.InterpolantFactoryMethodSmooth=void 0;class Ku extends qu{}Ku.prototype.ValueTypeName="color";class Ju extends qu{}Ju.prototype.ValueTypeName="number";class Zu extends Vu{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Ei.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Qu extends qu{InterpolantFactoryMethodLinear(e){return new Zu(this.times,this.values,this.getValueSize(),e)}}Qu.prototype.ValueTypeName="quaternion",Qu.prototype.DefaultInterpolation=Tt,Qu.prototype.InterpolantFactoryMethodSmooth=void 0;class $u extends qu{}$u.prototype.ValueTypeName="string",$u.prototype.ValueBufferType=Array,$u.prototype.DefaultInterpolation=Et,$u.prototype.InterpolantFactoryMethodLinear=void 0,$u.prototype.InterpolantFactoryMethodSmooth=void 0;class ed extends qu{}ed.prototype.ValueTypeName="vector";class td{constructor(e,t=-1,n,i=Pt){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=kn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(nd(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(qu.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const s=[],a=[];Gu(n,s,a,i),0!==s.length&&r.push(new e(t,s,a))}},i=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==od[e])return void od[e].push({onLoad:t,onProgress:n,onError:i});od[e]=[],od[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=od[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{id.add(e,t);const n=od[e];delete od[e];for(let e=0,i=n.length;e{const n=od[e];if(void 0===n)throw this.manager.itemError(e),t;delete od[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class hd extends ad{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new cd(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new Xr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new qn).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Ti).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new _i).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new Yn).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new nr).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new qn).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new qn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Tu,SpriteMaterial:jl,RawShaderMaterial:Au,ShaderMaterial:js,PointsMaterial:jc,MeshPhysicalMaterial:Ru,MeshStandardMaterial:Cu,MeshPhongMaterial:Lu,MeshToonMaterial:Pu,MeshNormalMaterial:Iu,MeshLambertMaterial:Uu,MeshDepthMaterial:Ml,MeshDistanceMaterial:Sl,MeshBasicMaterial:Yr,MeshMatcapMaterial:Ou,LineDashedMaterial:Nu,LineBasicMaterial:Oc,Material:Gr}[e]}}class Dd{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){const n=new rd(t);r=new dd(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new dd(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Ei.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const s=this._workIndex*r;Ei.multiplyQuaternionsFlat(e,s,e,t,e,n),Ei.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[n+s]*i}}}const fp=new RegExp("[\\[\\]\\.:\\/]","g"),mp="[^\\[\\]\\.:\\/]",gp="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",_p=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",mp)+/(WCOD+)?/.source.replace("WCOD",gp)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",mp)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",mp)+"$"),vp=["material","materials","bones","map"];class yp{constructor(e,t,n){this.path=t,this.parsedPath=n||yp.parseTrackName(t),this.node=yp.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new yp.Composite(e,t,n):new yp(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fp,"")}static parseTrackName(e){const t=_p.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==vp.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[o]=s,e[s]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[s],r=t[l];t[l]=i,t[s]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,s.push(e),a.push(t),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new yp(i,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class bp{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,s=r.length,a=new Array(s),o={endingStart:Ct,endingEnd:Ct};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Mt,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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=i/n,s=n/i;e.warp(1,r,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/s,l[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case It:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);break;case Pt:default:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const s=n===St;if(0===e)return-1===r?i:s&&1==(1&r)?t-i:i;if(n===wt){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Rt,i.endingEnd=Rt):(i.endingStart=e?this.zeroSlopeAtStart?Rt:Ct:Lt,i.endingEnd=t?this.zeroSlopeAtEnd?Rt:Ct:Lt)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}const wp=new Float32Array(1);class Mp extends In{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[e]=h;else{if(h=s[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;h=new pp(yp.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[e]=h}a[e].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==n;++a)t[a]._update(i,e,r,s);const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Op).distanceTo(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}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 Dp=new Ti,kp=new Ti;class Bp{constructor(e=new Ti,t=new Ti){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){Dp.subVectors(e,this.start),kp.subVectors(this.end,this.start);const n=kp.dot(kp);let i=kp.dot(Dp)/n;return t&&(i=Bn(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).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 Fp=new Ti;class zp extends Ar{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new xs,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{df.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(df,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class gf extends Vc{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new xs;n.setAttribute("position",new us(t,3)),n.setAttribute("color",new us([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Oc({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const i=new Xr,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class _f{constructor(){this.type="ShapePath",this.color=new Xr,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Eh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,s){return this.currentPath.bezierCurveTo(e,t,n,i,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[r],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const n=cu.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Bh,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=e?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let t=0,a=i.length;t1){let e=!1,n=0;for(let e=0,t=h.length;e0&&!1===e&&(p=c)}for(let e=0,t=h.length;e{"use strict";n.d(t,{z:()=>h});var i=n(477);const r={type:"change"},s={type:"start"},a={type:"end"},o=new i.Ray,l=new i.Plane,c=Math.cos(70*i.MathUtils.DEG2RAD);class h extends i.EventDispatcher{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new i.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN},this.touches={ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return p.phi},this.getAzimuthalAngle=function(){return p.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",$),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",$),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),u=h.NONE},this.update=function(){const t=new i.Vector3,s=(new i.Quaternion).setFromUnitVectors(e.up,new i.Vector3(0,1,0)),a=s.clone().invert(),_=new i.Vector3,v=new i.Quaternion,y=new i.Vector3,x=2*Math.PI;return function(b=null){const w=n.object.position;t.copy(w).sub(n.target),t.applyQuaternion(s),p.setFromVector3(t),n.autoRotate&&u===h.NONE&&I(function(e){return null!==e?2*Math.PI/60*n.autoRotateSpeed*e:2*Math.PI/60/60*n.autoRotateSpeed}(b)),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let M=n.minAzimuthAngle,S=n.maxAzimuthAngle;isFinite(M)&&isFinite(S)&&(M<-Math.PI?M+=x:M>Math.PI&&(M-=x),S<-Math.PI?S+=x:S>Math.PI&&(S-=x),p.theta=M<=S?Math.max(M,Math.min(S,p.theta)):p.theta>(M+S)/2?Math.max(M,p.theta):Math.min(S,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(g,n.dampingFactor):n.target.add(g),n.zoomToCursor&&C||n.object.isOrthographicCamera?p.radius=z(p.radius):p.radius=z(p.radius*m),t.setFromSpherical(p),t.applyQuaternion(a),w.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,g.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),g.set(0,0,0));let E=!1;if(n.zoomToCursor&&C){let r=null;if(n.object.isPerspectiveCamera){const e=t.length();r=z(e*m);const i=e-r;n.object.position.addScaledVector(T,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const e=new i.Vector3(A.x,A.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),E=!0;const s=new i.Vector3(A.x,A.y,0);s.unproject(n.object),n.object.position.sub(s).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==r&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(o.origin.copy(n.object.position),o.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(o.direction))d||8*(1-v.dot(n.object.quaternion))>d||y.distanceToSquared(n.target)>0)&&(n.dispatchEvent(r),_.copy(n.object.position),v.copy(n.object.quaternion),y.copy(n.target),E=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",ee),n.domElement.removeEventListener("pointerdown",K),n.domElement.removeEventListener("pointercancel",Z),n.domElement.removeEventListener("wheel",Q),n.domElement.removeEventListener("pointermove",J),n.domElement.removeEventListener("pointerup",Z),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",$),n._domElementKeyEvents=null)};const n=this,h={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=h.NONE;const d=1e-6,p=new i.Spherical,f=new i.Spherical;let m=1;const g=new i.Vector3,_=new i.Vector2,v=new i.Vector2,y=new i.Vector2,x=new i.Vector2,b=new i.Vector2,w=new i.Vector2,M=new i.Vector2,S=new i.Vector2,E=new i.Vector2,T=new i.Vector3,A=new i.Vector2;let C=!1;const R=[],L={};function P(){return Math.pow(.95,n.zoomSpeed)}function I(e){f.theta-=e}function U(e){f.phi-=e}const O=function(){const e=new i.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),g.add(e)}}(),N=function(){const e=new i.Vector3;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),g.add(e)}}(),D=function(){const e=new i.Vector3;return function(t,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const s=n.object.position;e.copy(s).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),O(2*t*a/r.clientHeight,n.object.matrix),N(2*i*a/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(O(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),N(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function k(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?m/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function B(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?m*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function F(e){if(!n.zoomToCursor)return;C=!0;const t=n.domElement.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=t.width,a=t.height;A.x=i/s*2-1,A.y=-r/a*2+1,T.set(A.x,A.y,1).unproject(n.object).sub(n.object.position).normalize()}function z(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function G(e){_.set(e.clientX,e.clientY)}function H(e){x.set(e.clientX,e.clientY)}function V(){if(1===R.length)_.set(R[0].pageX,R[0].pageY);else{const e=.5*(R[0].pageX+R[1].pageX),t=.5*(R[0].pageY+R[1].pageY);_.set(e,t)}}function W(){if(1===R.length)x.set(R[0].pageX,R[0].pageY);else{const e=.5*(R[0].pageX+R[1].pageX),t=.5*(R[0].pageY+R[1].pageY);x.set(e,t)}}function j(){const e=R[0].pageX-R[1].pageX,t=R[0].pageY-R[1].pageY,n=Math.sqrt(e*e+t*t);M.set(0,n)}function X(e){if(1==R.length)v.set(e.pageX,e.pageY);else{const t=ne(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);v.set(n,i)}y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const t=n.domElement;I(2*Math.PI*y.x/t.clientHeight),U(2*Math.PI*y.y/t.clientHeight),_.copy(v)}function q(e){if(1===R.length)b.set(e.pageX,e.pageY);else{const t=ne(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);b.set(n,i)}w.subVectors(b,x).multiplyScalar(n.panSpeed),D(w.x,w.y),x.copy(b)}function Y(e){const t=ne(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);S.set(0,s),E.set(0,Math.pow(S.y/M.y,n.zoomSpeed)),k(E.y),M.copy(S)}function K(e){!1!==n.enabled&&(0===R.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",J),n.domElement.addEventListener("pointerup",Z)),function(e){R.push(e)}(e),"touch"===e.pointerType?function(e){switch(te(e),R.length){case 1:switch(n.touches.ONE){case i.TOUCH.ROTATE:if(!1===n.enableRotate)return;V(),u=h.TOUCH_ROTATE;break;case i.TOUCH.PAN:if(!1===n.enablePan)return;W(),u=h.TOUCH_PAN;break;default:u=h.NONE}break;case 2:switch(n.touches.TWO){case i.TOUCH.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&j(),n.enablePan&&W(),u=h.TOUCH_DOLLY_PAN;break;case i.TOUCH.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&j(),n.enableRotate&&V(),u=h.TOUCH_DOLLY_ROTATE;break;default:u=h.NONE}break;default:u=h.NONE}u!==h.NONE&&n.dispatchEvent(s)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case i.MOUSE.DOLLY:if(!1===n.enableZoom)return;!function(e){F(e),M.set(e.clientX,e.clientY)}(e),u=h.DOLLY;break;case i.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;H(e),u=h.PAN}else{if(!1===n.enableRotate)return;G(e),u=h.ROTATE}break;case i.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;G(e),u=h.ROTATE}else{if(!1===n.enablePan)return;H(e),u=h.PAN}break;default:u=h.NONE}u!==h.NONE&&n.dispatchEvent(s)}(e))}function J(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(te(e),u){case h.TOUCH_ROTATE:if(!1===n.enableRotate)return;X(e),n.update();break;case h.TOUCH_PAN:if(!1===n.enablePan)return;q(e),n.update();break;case h.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&Y(e),n.enablePan&&q(e)}(e),n.update();break;case h.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&Y(e),n.enableRotate&&X(e)}(e),n.update();break;default:u=h.NONE}}(e):function(e){switch(u){case h.ROTATE:if(!1===n.enableRotate)return;!function(e){v.set(e.clientX,e.clientY),y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const t=n.domElement;I(2*Math.PI*y.x/t.clientHeight),U(2*Math.PI*y.y/t.clientHeight),_.copy(v),n.update()}(e);break;case h.DOLLY:if(!1===n.enableZoom)return;!function(e){S.set(e.clientX,e.clientY),E.subVectors(S,M),E.y>0?k(P()):E.y<0&&B(P()),M.copy(S),n.update()}(e);break;case h.PAN:if(!1===n.enablePan)return;!function(e){b.set(e.clientX,e.clientY),w.subVectors(b,x).multiplyScalar(n.panSpeed),D(w.x,w.y),x.copy(b),n.update()}(e)}}(e))}function Z(e){!function(e){delete L[e.pointerId];for(let t=0;t0&&k(P()),n.update()}(e),n.dispatchEvent(a))}function $(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?U(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?U(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?I(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?I(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):D(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function ee(e){!1!==n.enabled&&e.preventDefault()}function te(e){let t=L[e.pointerId];void 0===t&&(t=new i.Vector2,L[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ne(e){const t=e.pointerId===R[0].pointerId?R[1]:R[0];return L[t.pointerId]}n.domElement.addEventListener("contextmenu",ee),n.domElement.addEventListener("pointerdown",K),n.domElement.addEventListener("pointercancel",Z),n.domElement.addEventListener("wheel",Q,{passive:!1}),this.update()}}},976:(e,t,n)=>{"use strict";n.d(t,{G:()=>s});var i=n(477);class r extends i.DataTextureLoader{constructor(e){super(e)}parse(e){if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let t=0;const n=new Uint8Array(e),r={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};if(function(e){switch(e.image_type){case 1:case 9:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(r),r.id_length+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=r.id_length;let s=!1,a=!1,o=!1;switch(r.image_type){case 9:s=!0,a=!0;break;case 1:a=!0;break;case 10:s=!0;break;case 2:break;case 11:s=!0,o=!0;break;case 3:o=!0}const l=new Uint8Array(r.width*r.height*4),c=function(e,t,n,i,r){let s,a;const o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(a=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let a=0;const c=new Uint8Array(o);for(;a>4){default:case 2:a=0,c=1,u=t,l=0,h=1,d=n;break;case 0:a=0,c=1,u=t,l=n-1,h=-1,d=-1;break;case 3:a=t-1,c=-1,u=-1,l=0,h=1,d=n;break;case 1:a=t-1,c=-1,u=-1,l=n-1,h=-1,d=-1}if(o)switch(r.pixel_size){case 8:!function(e,t,n,i,s,a,o,l){let c,h,u,d=0;const p=r.width;for(u=t;u!==i;u+=n)for(h=s;h!==o;h+=a,d++)c=l[d],e[4*(h+p*u)+0]=c,e[4*(h+p*u)+1]=c,e[4*(h+p*u)+2]=c,e[4*(h+p*u)+3]=255}(e,l,h,d,a,c,u,i);break;case 16:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=2)e[4*(c+d*h)+0]=l[u+0],e[4*(c+d*h)+1]=l[u+0],e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+3]=l[u+1]}(e,l,h,d,a,c,u,i);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(r.pixel_size){case 8:!function(e,t,n,i,s,a,o,l,c){const h=c;let u,d,p,f=0;const m=r.width;for(p=t;p!==i;p+=n)for(d=s;d!==o;d+=a,f++)u=l[f],e[4*(d+m*p)+3]=255,e[4*(d+m*p)+2]=h[3*u+0],e[4*(d+m*p)+1]=h[3*u+1],e[4*(d+m*p)+0]=h[3*u+2]}(e,l,h,d,a,c,u,i,s);break;case 16:!function(e,t,n,i,s,a,o,l){let c,h,u,d=0;const p=r.width;for(u=t;u!==i;u+=n)for(h=s;h!==o;h+=a,d+=2)c=l[d+0]+(l[d+1]<<8),e[4*(h+p*u)+0]=(31744&c)>>7,e[4*(h+p*u)+1]=(992&c)>>2,e[4*(h+p*u)+2]=(31&c)<<3,e[4*(h+p*u)+3]=32768&c?0:255}(e,l,h,d,a,c,u,i);break;case 24:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=3)e[4*(c+d*h)+3]=255,e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+1]=l[u+1],e[4*(c+d*h)+0]=l[u+2]}(e,l,h,d,a,c,u,i);break;case 32:!function(e,t,n,i,s,a,o,l){let c,h,u=0;const d=r.width;for(h=t;h!==i;h+=n)for(c=s;c!==o;c+=a,u+=4)e[4*(c+d*h)+2]=l[u+0],e[4*(c+d*h)+1]=l[u+1],e[4*(c+d*h)+0]=l[u+2],e[4*(c+d*h)+3]=l[u+3]}(e,l,h,d,a,c,u,i);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(l,r.width,r.height,c.pixel_data,c.palettes),{data:l,width:r.width,height:r.height,flipY:!0,generateMipmaps:!0,minFilter:i.LinearMipmapLinearFilter}}}class s extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=""===s.path?i.LoaderUtils.extractUrlBase(e):s.path,o=new i.FileLoader(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,(function(n){try{t(s.parse(n,a))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}parse(e,t){function n(e,t){const n=[],i=e.childNodes;for(let e=0,r=i.length;e0&&t.push(new i.VectorKeyframeTrack(r+".position",s,a)),o.length>0&&t.push(new i.QuaternionKeyframeTrack(r+".quaternion",s,o)),l.length>0&&t.push(new i.VectorKeyframeTrack(r+".scale",s,l)),t}function S(e,t,n){let i,r,s,a=!0;for(r=0,s=e.length;r=0;){const i=e[t];if(null!==i.value[n])return i;t--}return null}function T(e,t,n){for(;t>>0));switch(n=n.toLowerCase(),n){case"tga":t=qe;break;default:t=Xe}return t}(s);if(void 0!==t){const r=t.load(s),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===c(a.technique)){const e=a.technique;r.wrapS=e.wrapU?i.RepeatWrapping:i.ClampToEdgeWrapping,r.wrapT=e.wrapV?i.RepeatWrapping:i.ClampToEdgeWrapping,r.offset.set(e.offsetU||0,e.offsetV||0),r.repeat.set(e.repeatU||1,e.repeatV||1)}else r.wrapS=i.RepeatWrapping,r.wrapT=i.RepeatWrapping;return null!==n&&(r.colorSpace=n),r}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",s),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}s.name=e.name||"";const o=r.parameters;for(const e in o){const t=o[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=a(t.texture,i.SRGBColorSpace));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=a(t.texture));break;case"bump":t.texture&&(s.normalMap=a(t.texture));break;case"ambient":t.texture&&(s.lightMap=a(t.texture,i.SRGBColorSpace));break;case"shininess":t.float&&s.shininess&&(s.shininess=t.float);break;case"emission":t.color&&s.emissive&&s.emissive.fromArray(t.color),t.texture&&(s.emissiveMap=a(t.texture,i.SRGBColorSpace))}}s.color.convertSRGBToLinear(),s.specular&&s.specular.convertSRGBToLinear(),s.emissive&&s.emissive.convertSRGBToLinear();let l=o.transparent,h=o.transparency;if(void 0===h&&l&&(h={float:1}),void 0===l&&h&&(l={opaque:"A_ONE",data:{color:[1,1,1,1]}}),l&&h)if(l.data.texture)s.transparent=!0;else{const e=l.data.color;switch(l.opaque){case"A_ONE":s.opacity=e[3]*h.float;break;case"RGB_ZERO":s.opacity=1-e[0]*h.float;break;case"A_ZERO":s.opacity=1-e[3]*h.float;break;case"RGB_ONE":s.opacity=e[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',l.opaque)}s.opacity<1&&(s.transparent=!0)}if(void 0!==r.extra&&void 0!==r.extra.technique){const e=r.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":s.side=1===n?i.DoubleSide:i.FrontSide;break;case"bump":s.normalMap=a(n.texture),s.normalScale=new i.Vector2(1,1)}}}return s}function Z(e){return f(Qe.materials[e],J)}function Q(e){for(let t=0;t0?n+s:n;t.inputs[a]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=o(i.textContent);break;case"p":t.p=o(i.textContent)}}return t}function he(e){let t=0;for(let n=0,i=e.length;n0&&t0&&d.setAttribute("position",new i.Float32BufferAttribute(s.array,s.stride)),a.array.length>0&&d.setAttribute("normal",new i.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&d.setAttribute("color",new i.Float32BufferAttribute(c.array,c.stride)),o.array.length>0&&d.setAttribute("uv",new i.Float32BufferAttribute(o.array,o.stride)),l.array.length>0&&d.setAttribute("uv1",new i.Float32BufferAttribute(l.array,l.stride)),h.length>0&&d.setAttribute("skinIndex",new i.Float32BufferAttribute(h,4)),u.length>0&&d.setAttribute("skinWeight",new i.Float32BufferAttribute(u,4)),r.data=d,r.type=e[0].type,r.materialKeys=p,r}function pe(e,t,n,i,r=!1){const s=e.p,a=e.stride,o=e.vcount;function l(e){let t=s[e+n]*h;const a=t+h;for(;t4)for(let t=1,i=n-2;t<=i;t++){const n=e+a*t,i=e+a*(t+1);l(e+0*a),l(n),l(i)}e+=a*n}}else for(let e=0,t=s.length;e=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ye(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;nr.limits.max||t{"use strict";n.d(t,{E:()=>s});var i=n(477),r=n(140);class s extends i.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new u(e)})),this.register((function(e){return new y(e)})),this.register((function(e){return new x(e)})),this.register((function(e){return new b(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new h(e)})),this.register((function(e){return new _(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new v(e)})),this.register((function(e){return new l(e)})),this.register((function(e){return new w(e)})),this.register((function(e){return new M(e)}))}load(e,t,n,r){const s=this;let a;a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:i.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){r?r(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},l=new i.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(n){try{s.parse(n,a,(function(n){t(n),s.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,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-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},a={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===S){try{s[o.KHR_BINARY_GLTF]=new E(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[o.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new q(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}h.setExtensions(s),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function a(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const o={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class l{constructor(e){this.parser=e,this.name=o.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class x{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class b{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class w{constructor(e){this.name=o.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class M{constructor(e){this.name=o.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==I.TRIANGLES&&e.mode!==I.TRIANGLE_STRIP&&e.mode!==I.TRIANGLE_FAN&&void 0!==e.mode)return null;const s=n.extensions[this.name].attributes,a=[],o={};for(const e in s)a.push(this.parser.getDependency("accessor",s[e]).then((t=>(o[e]=t,o[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,s=[];for(const e of n){const t=new i.Matrix4,n=new i.Vector3,a=new i.Quaternion,l=new i.Vector3(1,1,1),c=new i.InstancedMesh(e.geometry,e.material,r);for(let e=0;e-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&s<98?this.textureLoader=new i.TextureLoader(this.options.manager):this.textureLoader=new i.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new i.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};z(r,s,i),G(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&f.setY(t,u[e*a+1]),a>=3&&f.setZ(t,u[e*a+2]),a>=4&&f.setW(t,u[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const 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,n).then((function(t){t.flipY=!1,t.name=a.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(s.samplers||{})[a.sampler]||{};return t.magFilter=O[n.magFilter]||i.LinearFilter,t.minFilter=O[n.minFilter]||i.LinearMipmapLinearFilter,t.wrapS=N[n.wrapS]||i.RepeatWrapping,t.wrapT=N[n.wrapT]||i.RepeatWrapping,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=n.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=this.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,s){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new i.Texture(e);t.needsUpdate=!0,n(t)}),t.load(i.LoaderUtils.resolveURL(e,r.path),a,void 0,s)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[o.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[o.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[o.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new i.PointsMaterial,i.Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new i.LineBasicMaterial,i.Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||s||a){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return i.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let a;const l={},c=[];if((s.extensions||{})[o.KHR_MATERIALS_UNLIT]){const e=r[o.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(l,s,t))}else{const n=s.pbrMetallicRoughness||{};if(l.color=new i.Color(1,1,1),l.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;l.color.setRGB(e[0],e[1],e[2],i.LinearSRGBColorSpace),l.opacity=e[3]}void 0!==n.baseColorTexture&&c.push(t.assignTexture(l,"map",n.baseColorTexture,i.SRGBColorSpace)),l.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,l.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(c.push(t.assignTexture(l,"metalnessMap",n.metallicRoughnessTexture)),c.push(t.assignTexture(l,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),c.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)}))))}!0===s.doubleSided&&(l.side=i.DoubleSide);const h=s.alphaMode||"OPAQUE";if("BLEND"===h?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===h&&(l.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&a!==i.MeshBasicMaterial&&(c.push(t.assignTexture(l,"normalMap",s.normalTexture)),l.normalScale=new i.Vector2(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;l.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&a!==i.MeshBasicMaterial&&(c.push(t.assignTexture(l,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(l.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&a!==i.MeshBasicMaterial){const e=s.emissiveFactor;l.emissive=(new i.Color).setRGB(e[0],e[1],e[2],i.LinearSRGBColorSpace)}return void 0!==s.emissiveTexture&&a!==i.MeshBasicMaterial&&c.push(t.assignTexture(l,"emissiveMap",s.emissiveTexture,i.SRGBColorSpace)),Promise.all(c).then((function(){const n=new a(l);return s.name&&(n.name=s.name),G(n,s),t.associations.set(n,{materials:e}),s.extensions&&z(r,n,s),n}))}createUniqueName(e){const t=i.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function s(e){return n[o.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Y(n,e,t)}))}const a=[];for(let n=0,l=e.length;n0&&H(p,a),p.name=t.createUniqueName(a.name||"mesh_"+e),G(p,a),d.extensions&&z(s,p,d),t.assignFinalMaterial(p),h.push(p)}for(let n=0,i=h.length;n1?new i.Group:1===t.length?t[0]:new i.Object3D,o!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of r.associations)(e instanceof i.Material||e instanceof i.Texture)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}_createAnimationTracks(e,t,n,r,s){const a=[],o=e.name?e.name:e.uuid,l=[];let c;switch(B[s.path]===B.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),B[s.path]){case B.weights:c=i.NumberKeyframeTrack;break;case B.rotation:c=i.QuaternionKeyframeTrack;break;case B.position:case B.scale:c=i.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=i.NumberKeyframeTrack;break;case 2:case 3:default:c=i.VectorKeyframeTrack}}const h=void 0!==r.interpolation?F[r.interpolation]:i.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let e=0,n=l.length;e{"use strict";n.d(t,{v:()=>r});var i=n(477);class r extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=""===this.path?i.LoaderUtils.extractUrlBase(e):this.path,o=new i.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(s.parse(n,a))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){const n=e.split("\n");let i={};const r=/\s+/,a={};for(let e=0;e=0?t.substring(0,s):t;o=o.toLowerCase();let l=s>=0?t.substring(s+1):"";if(l=l.trim(),"newmtl"===o)i={name:l},a[l]=i;else if("ka"===o||"kd"===o||"ks"===o||"ke"===o){const e=l.split(r,3);i[o]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else i[o]=l}const o=new s(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(a),o}}class s{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:i.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:i.RepeatWrapping}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],r={};t[n]=r;for(const e in i){let t=!0,n=i[e];const s=e.toLowerCase();switch(s){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(t=!1)}t&&(r[s]=n)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],r={name:e,side:this.side};function s(e,n){if(r[e])return;const s=t.getTextureParams(n,r),a=t.loadTexture((o=t.baseUrl,"string"!=typeof(l=s.url)||""===l?"":/^https?:\/\//i.test(l)?l:o+l));var o,l;a.repeat.copy(s.scale),a.offset.copy(s.offset),a.wrapS=t.wrap,a.wrapT=t.wrap,"map"!==e&&"emissiveMap"!==e||(a.colorSpace=i.SRGBColorSpace),r[e]=a}for(const e in n){const t=n[e];let a;if(""!==t)switch(e.toLowerCase()){case"kd":r.color=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"ks":r.specular=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"ke":r.emissive=(new i.Color).fromArray(t).convertSRGBToLinear();break;case"map_kd":s("map",t);break;case"map_ks":s("specularMap",t);break;case"map_ke":s("emissiveMap",t);break;case"norm":s("normalMap",t);break;case"map_bump":case"bump":s("bumpMap",t);break;case"map_d":s("alphaMap",t),r.transparent=!0;break;case"ns":r.shininess=parseFloat(t);break;case"d":a=parseFloat(t),a<1&&(r.opacity=a,r.transparent=!0);break;case"tr":a=parseFloat(t),this.options&&this.options.invertTrProperty&&(a=1-a),a>0&&(r.opacity=1-a,r.transparent=!0)}}return this.materials[e]=new i.MeshPhongMaterial(r),this.materials[e]}getTextureParams(e,t){const n={scale:new i.Vector2(1,1),offset:new i.Vector2(0,0)},r=e.split(/\s+/);let s;return s=r.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(r[s+1]),r.splice(s,2)),s=r.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),s=r.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),n.url=r.join(" ").trim(),n}loadTexture(e,t,n,r,s){const a=void 0!==this.manager?this.manager:i.DefaultLoadingManager;let o=a.getHandler(e);null===o&&(o=new i.TextureLoader(a)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const l=o.load(e,n,r,s);return void 0!==t&&(l.mapping=t),l}}},476:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var i=n(477);class r extends i.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new i.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(s.parse(n))}catch(t){r?r(t):console.error(t),s.manager.itemError(e)}}),n,r)}parse(e){function t(e,t,n){for(let i=0,r=e.length;i>5&31)/31,a=(e>>10&31)/31):(r=l,s=c,a=h)}for(let l=1;l<=3;l++){const c=n+12*l,h=3*e*3+3*(l-1);f[h]=t.getFloat32(c,!0),f[h+1]=t.getFloat32(c+4,!0),f[h+2]=t.getFloat32(c+8,!0),m[h]=i,m[h+1]=u,m[h+2]=p,d&&(g.set(r,s,a).convertSRGBToLinear(),o[h]=g.r,o[h+1]=g.g,o[h+2]=g.b)}}return p.setAttribute("position",new i.BufferAttribute(f,3)),p.setAttribute("normal",new i.BufferAttribute(m,3)),d&&(p.setAttribute("color",new i.BufferAttribute(o,3)),p.hasColors=!0,p.alpha=u),p}(n):function(e){const t=new i.BufferGeometry,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,s=/solid\s(.+)/;let a=0;const o=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,l=new RegExp("vertex"+o+o+o,"g"),c=new RegExp("normal"+o+o+o,"g"),h=[],u=[],d=[],p=new i.Vector3;let f,m=0,g=0,_=0;for(;null!==(f=n.exec(e));){g=_;const e=f[0],n=null!==(f=s.exec(e))?f[1]:"";for(d.push(n);null!==(f=r.exec(e));){let e=0,t=0;const n=f[0];for(;null!==(f=c.exec(n));)p.x=parseFloat(f[1]),p.y=parseFloat(f[2]),p.z=parseFloat(f[3]),t++;for(;null!==(f=l.exec(n));)h.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(p.x,p.y,p.z),e++,_++;1!==t&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+a),3!==e&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+a),a++}const i=g,o=_-g;t.userData.groupNames=d,t.addGroup(i,o,m),m++}return t.setAttribute("position",new i.Float32BufferAttribute(h,3)),t.setAttribute("normal",new i.Float32BufferAttribute(u,3)),t}("string"!=typeof(r=e)?(new TextDecoder).decode(r):r);var r}}},140:(e,t,n)=>{"use strict";n.d(t,{qf:()=>a,Vs:()=>s});var i=n(477);function r(e){let t,n,r,s=-1,a=0;for(let i=0;i{"use strict";n.d(t,{N:()=>i});class i{static createButton(e){const t=document.createElement("button");function n(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",r(t),navigator.xr.isSessionSupported("immersive-vr").then((function(r){r?function(){let n=null;async function i(i){i.addEventListener("end",r),await e.xr.setSession(i),t.textContent="EXIT VR",n=i}function r(){n.removeEventListener("end",r),t.textContent="ENTER VR",n=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(null===n){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else n.end()}}():(n(),t.textContent="VR NOT SUPPORTED"),r&&i.xrSessionIsGranted&&t.click()})).catch((function(e){n(),console.warn("Exception when trying to call xr.isSessionSupported",e),t.textContent="VR NOT ALLOWED"})),t;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",r(e),e}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",(()=>{i.xrSessionIsGranted=!0}))}}}i.xrSessionIsGranted=!1,i.registerSessionGrantedListener()},904:(e,t,n)=>{"use strict";n.d(t,{v:()=>i});class i{static createButton(e){const t=document.createElement("button");function n(n){let i=null;async function r(n){n.addEventListener("end",s),await e.xr.setSession(n),t.textContent="STOP XR",i=n}function s(){i.removeEventListener("end",s),t.textContent="START XR",i=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="START XR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(null===i){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession(n,e).then(r)}else i.end()}}function i(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(e){i(),console.warn("Exception when trying to call xr.isSessionSupported",e),t.textContent="XR NOT ALLOWED"}function s(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return t.id="XRButton",t.style.display="none",s(t),navigator.xr.isSessionSupported("immersive-ar").then((function(e){e?n("immersive-ar"):navigator.xr.isSessionSupported("immersive-vr").then((function(e){e?n("immersive-vr"):(i(),t.textContent="XR NOT SUPPORTED")})).catch(r)})).catch(r),t;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",s(e),e}}}},925:(e,t,n)=>{"use strict";n.d(t,{i:()=>p});var i=n(477),r=n(217);const s={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function a(e){const t=await fetch(e);if(t.ok)return t.json();throw new Error(t.statusText)}const o={xAxis:0,yAxis:0,button:0,state:s.ComponentState.DEFAULT};class l{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===s.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(o)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:r,normalizedYAxis:a}=function(e=0,t=0){let n=e,i=t;if(Math.sqrt(e*e+t*t)>1){const r=Math.atan2(t,e);n=Math.cos(r),i=Math.sin(r)}return{normalizedXAxis:.5*n+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case s.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?r:.5;break;case s.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case s.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case s.ComponentProperty.STATE:this.valueNodeProperty===s.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class c{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const n=new l(t.visualResponses[e]);this.visualResponses[e]=n})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:s.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=s.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=s.ComponentState.PRESSED:(t.touched||this.values.button>s.ButtonTouchThreshold)&&(this.values.state=s.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===s.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>s.AxisTouchThreshold&&(this.values.state=s.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===s.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>s.AxisTouchThreshold&&(this.values.state=s.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class h{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new c(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class u extends i.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:n,maxNode:i,value:r,valueNodeProperty:a}=e;t&&(a===s.VisualResponseProperty.VISIBILITY?t.visible=r:a===s.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(n.quaternion,i.quaternion,r),t.position.lerpVectors(n.position,i.position,r)))}))})))}}function d(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:n,touchPointNodeName:r,visualResponses:a}=e;if(n===s.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){const t=new i.SphereGeometry(.001),n=new i.MeshBasicMaterial({color:255}),r=new i.Mesh(t,n);e.touchPointNode.add(r)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(a).forEach((e=>{const{valueNodeName:n,minNodeName:i,maxNodeName:r,valueNodeProperty:a}=e;if(a===s.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(r),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${r} in the model`)}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class p{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new r.E)}createControllerModel(e){const t=new u;let n=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&async function(e,t,n=null,i=!0){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const r=await async function(e){if(!e)throw new Error("No basePath supplied");return await a(`${e}/profilesList.json`)}(t);let s;if(e.profiles.some((e=>{const n=r[e];return n&&(s={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!s})),!s){if(!n)throw new Error("No matching profile name found");const e=r[n];if(!e)throw new Error(`No matching profile name found and default profile "${n}" missing.`);s={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const o=await a(s.profilePath);let l;if(i){let t;if(t="any"===e.handedness?o.layouts[Object.keys(o.layouts)[0]]:o.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${s.profileId}`);t.assetPath&&(l=s.profilePath.replace("profile.json",t.assetPath))}return{profile:o,assetPath:l}}(i,this.path,"generic-trigger").then((({profile:e,assetPath:r})=>{t.motionController=new h(i,e,r);const s=this._assetCache[t.motionController.assetUrl];if(s)n=s.scene.clone(),d(t,n);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),d(t,n)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(n),n=null})),t}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Viewer:()=>Viewer,THREE:()=>three__WEBPACK_IMPORTED_MODULE_2__,msgpack:()=>msgpack});var three__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(477),three_examples_jsm_utils_BufferGeometryUtils_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(140),wwobjloader2__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(973),three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(976),three_examples_jsm_loaders_GLTFLoader_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(217),three_examples_jsm_loaders_MTLLoader_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(23),three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(476),three_examples_jsm_controls_OrbitControls_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(365),three_examples_jsm_webxr_VRButton_js__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(18),three_examples_jsm_webxr_XRButton_js__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(904),three_examples_jsm_webxr_XRControllerModelFactory__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(925),msgpack=__webpack_require__(676),dat=__webpack_require__(376).ZP;__webpack_require__(583);const extensionCodec=new msgpack.ExtensionCodec;function merge_geometries(e,t=!1){let n=[],i=[],r=e.matrix.clone();!function e(t,r){let s=r.clone().multiply(t.matrix);"Mesh"===t.type&&(t.geometry.applyMatrix4(s),i.push(t.geometry),n.push(t.material));for(let n of t.children)e(n,s)}(e,r);let s=null;return 1==i.length?(s=i[0],t&&(s.material=n[0])):i.length>1?(s=(0,three_examples_jsm_utils_BufferGeometryUtils_js__WEBPACK_IMPORTED_MODULE_1__.qf)(i,!0),t&&(s.material=n)):s=new three__WEBPACK_IMPORTED_MODULE_2__.BufferGeometry,s}function handle_special_texture(e){if("_text"==e.type){let t=document.createElement("canvas");t.width=256,t.height=256;let n=t.getContext("2d");n.textAlign="center";let i=e.font_size;for(n.font=i+"px "+e.font_face;n.measureText(e.text).width>t.width;)i--,n.font=i+"px "+e.font_face;n.fillText(e.text,t.width/2,t.height/2);let r=new three__WEBPACK_IMPORTED_MODULE_2__.CanvasTexture(t);return r.uuid=e.uuid,r}return null}function handle_special_geometry(e){if("_meshfile"==e.type&&(console.warn("_meshfile is deprecated. Please use _meshfile_geometry for geometries and _meshfile_object for objects with geometry and material"),e.type="_meshfile_geometry"),"_meshfile_geometry"==e.type){if("obj"==e.format){let t=merge_geometries((new wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.oe).parse(e.data+"\n"));return t.uuid=e.uuid,t}if("dae"==e.format){let t=merge_geometries((new three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__.G).parse(e.data).scene);return t.uuid=e.uuid,t}if("stl"==e.format){let t=(new three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__.j).parse(e.data.buffer);return t.uuid=e.uuid,t}return console.error("Unsupported mesh type:",e),null}return null}extensionCodec.register({type:22,encode:e=>(console.error("Uint32Array encode not implemented"),null),decode:e=>{const t=new Uint32Array(e.byteLength/4);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e(console.error("Float32Array encode not implemented"),null),decode:e=>{const t=new Float32Array(e.byteLength/4);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;evoid 0!==e.resources[t]?e.resources[t]:t)),"obj"==e.format){let s=new wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.oe(i);if(e.mtl_library){let t=new three_examples_jsm_loaders_MTLLoader_js__WEBPACK_IMPORTED_MODULE_5__.v(i).parse(e.mtl_library+"\n",""),n=wwobjloader2__WEBPACK_IMPORTED_MODULE_0__.eW.addMaterialsFromMtlLoader(t);s.setMaterials(n),this.onTextureLoad()}t=merge_geometries(s.parse(e.data+"\n",r),!0),t.uuid=e.uuid,n=t.material}else if("dae"==e.format){let s=new three_examples_jsm_loaders_ColladaLoader_js__WEBPACK_IMPORTED_MODULE_3__.G(i);s.onTextureLoad=this.onTextureLoad,t=merge_geometries(s.parse(e.data,r).scene,!0),t.uuid=e.uuid,n=t.material}else{if("stl"!=e.format)return console.error("Unsupported mesh type:",e),null;t=(new three_examples_jsm_loaders_STLLoader_js__WEBPACK_IMPORTED_MODULE_4__.j).parse(e.data.buffer,r),t.uuid=e.uuid,n=t.material}let s=new three__WEBPACK_IMPORTED_MODULE_2__.Mesh(t,n);return s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.userjson&&(s.userjson=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),s}return super.parseObject(e,t,n)}}class Background extends three__WEBPACK_IMPORTED_MODULE_2__.Object3D{constructor(){super(),this.isBackground=!0,this.type="Background",this.top_color=new dat.color.Color(135,206,250),this.bottom_color=new dat.color.Color(25,25,112),this.render_environment_map=!0,this.environment_map=null,this.visible=!0,this.use_ar_background=!1,this.textures={env_map:null,round:{gradient:env_texture(this.top_color,this.bottom_color,!0),white:env_texture([255,255,255],[255,255,255],!0)},flat:{gradient:env_texture(this.top_color,this.bottom_color,!1),white:env_texture([255,255,255],[255,255,255],!1)}},this.state={top_color:null,bottom_color:null,environment_map:null,render_map:null,visible:!0}}update(e,t,n){this.state.visible=t,this.state.render_map=this.render_environment_map,this.environment_map!==this.state.environment_map&&(""==this.environment_map||null==this.environment_map?(this.environment_map=this.state.environment_map=null,this.textures.env_map=null):(this.textures.env_map=load_env_texture(this.environment_map,this,e,t,n),null==this.textures.env_map?this.state.environment_map=this.environment_map=null:this.state.environment_map=this.environment_map));let i=!n||!this.render_environment_map||null==this.textures.env_map;if(t&&i&&(this.top_color!==this.state.top_color||this.bottom_color!==this.state.bottom_color)){this.state.top_color=this.top_color,this.state.bottom_color=this.bottom_color;let e=[this.state.top_color.r,this.state.top_color.g,this.state.top_color.b],t=[this.state.bottom_color.r,this.state.bottom_color.g,this.state.bottom_color.b];this.textures.flat.gradient=env_texture(e,t,!1),this.textures.round.gradient=env_texture(e,t,!0)}let r=n?"round":"flat";e.background=this.use_ar_background?null:this.state.visible?this.state.render_map&&null!=this.textures.env_map&&n?this.textures.env_map:this.textures[r].gradient:this.textures[r].white,e.environment=this.state.visible?null!=this.textures.env_map?this.textures.env_map:this.textures.round.gradient:this.textures.round.white}}class SceneNode{constructor(e,t,n){this.object=e,this.folder=t,this.children={},this.controllers=[],this.on_update=n,this.create_controls();for(let e of this.object.children)this.add_child(e)}add_child(e){let t=this.folder.addFolder(e.name),n=new SceneNode(e,t,this.on_update);return this.children[e.name]=n,n}create_child(e){let t=new three__WEBPACK_IMPORTED_MODULE_2__.Group;return t.name=e,this.object.add(t),this.add_child(t)}find(e){if(0==e.length)return this;{let t=e[0],n=this.children[t];return void 0===n&&(n=this.create_child(t)),n.find(e.slice(1))}}create_controls(){for(let e of this.controllers)this.folder.remove(e);if(this.controllers=[],void 0!==this.vis_controller&&this.folder.domElement.removeChild(this.vis_controller.domElement),this.vis_controller=new dat.controllers.BooleanController(this.object,"visible"),this.vis_controller.onChange((()=>this.on_update())),this.folder.domElement.prepend(this.vis_controller.domElement),this.vis_controller.domElement.style.height="0",this.vis_controller.domElement.style.float="right",this.vis_controller.domElement.classList.add("meshcat-visibility-checkbox"),this.vis_controller.domElement.children[0].addEventListener("change",(e=>{e.target.checked?this.folder.domElement.classList.remove("meshcat-hidden-scene-element"):this.folder.domElement.classList.add("meshcat-hidden-scene-element")})),this.object.isLight){let e=this.folder.add(this.object,"intensity").min(0).step(.01).name("intensity (cd)");if(e.onChange((()=>this.on_update())),this.controllers.push(e),void 0!==this.object.castShadow){let e=this.folder.add(this.object,"castShadow");if(e.onChange((()=>this.on_update())),this.controllers.push(e),void 0!==this.object.shadow){let e=this.folder.add(this.object.shadow,"radius").min(0).step(.05).max(3);e.onChange((()=>this.on_update())),this.controllers.push(e)}}if(void 0!==this.object.distance){let e=this.folder.add(this.object,"distance").min(0).step(.1).max(100);e.onChange((()=>this.on_update())),this.controllers.push(e)}}if(this.object.isCamera){let e=this.folder.add(this.object,"zoom").min(0).step(.1);e.onChange((()=>{this.on_update()})),this.controllers.push(e)}if(this.object.isEnvironment){let e=this.folder.add(this.object,"intensity").min(0).step(.1).max(100);e.onChange((()=>this.on_update())),this.controllers.push(e)}if(this.object.isBackground){let e=this.folder.addColor(this.object,"top_color");e.onChange((()=>this.on_update())),this.controllers.push(e);let t=this.folder.addColor(this.object,"bottom_color");t.onChange((()=>this.on_update())),this.controllers.push(t);let n=this.folder.add(this.object,"render_environment_map");n.onChange((()=>this.on_update())),this.controllers.push(n)}}cache_original_opacity(e){void 0===e.meshcat_base_opacity&&(e.meshcat_base_opacity=e.opacity)}set_opacity(e,t){this.cache_original_opacity(e),e.opacity=t,e.transparent=t<1,e.depthWrite=!0,e.needsUpdate=!0}visit_materials(e,t){e.isMaterial?t(e):e.material&&t(e.material);for(let n of e.children)this.visit_materials(n,t)}set_property(e,t){if("position"===e)this.object.position.set(t[0],t[1],t[2]);else if("quaternion"===e)this.object.quaternion.set(t[0],t[1],t[2],t[3]);else if("scale"===e)this.object.scale.set(t[0],t[1],t[2]);else if("color"===e){var n=this;function e(e){e.color.setRGB(t[0],t[1],t[2]),n.set_opacity(e,t[3])}this.visit_materials(this.object,e)}else if("opacity"==e){function e(e){n.set_opacity(e,t)}n=this,this.visit_materials(this.object,e)}else if("modulated_opacity"==e){function e(e){n.cache_original_opacity(e),n.set_opacity(e,e.meshcat_base_opacity*t)}n=this,this.visit_materials(this.object,e)}else this.object[e]="top_color"==e||"bottom_color"==e?new dat.color.Color(t.map((e=>255*e))):t;this.object.isBackground&&this.on_update(),this.vis_controller.updateDisplay(),this.controllers.forEach((e=>e.updateDisplay()))}set_transform(e){let t=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;t.fromArray(e),t.decompose(this.object.position,this.object.quaternion,this.object.scale)}set_object(e){let t=this.object.parent;this.dispose_recursive(),this.object.parent.remove(this.object),this.object=e,t.add(e),this.create_controls()}dispose_recursive(){for(let e of Object.keys(this.children))this.children[e].dispose_recursive();dispose(this.object)}delete(e){if(0==e.length)console.error("Can't delete an empty path");else{let t=this.find(e.slice(0,e.length-1)),n=e[e.length-1],i=t.children[n];void 0!==i&&(i.dispose_recursive(),t.object.remove(i.object),remove_folders(i.folder),t.folder.removeFolder(i.folder),delete t.children[n])}}}function remove_folders(e){for(let t of Object.keys(e.__folders)){let n=e.__folders[t];remove_folders(n),dat.dom.dom.unbind(window,"resize",n.__resizeHandler),e.removeFolder(n)}}function dispose(e){if(e&&(e.geometry&&e.geometry.dispose(),e.material))if(Array.isArray(e.material))for(let t of e.material)t.map&&t.map.dispose(),t.dispose();else e.material.map&&e.material.map.dispose(),e.material.dispose()}function create_default_scene(){var e=new three__WEBPACK_IMPORTED_MODULE_2__.Scene;return e.name="Scene",e.rotateX(-Math.PI/2),e}function download_data_uri(e,t){let n=document.createElement("a");n.download=e,n.href=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function download_file(e,t,n){n=n||"text/plain";let i=new Blob([t],{type:n}),r=document.createElement("a");document.body.appendChild(r),r.download=e,r.href=window.URL.createObjectURL(i),r.onclick=function(e){let t=this;setTimeout((function(){window.URL.revokeObjectURL(t.href)}),1500)},r.click(),r.remove()}class Animator{constructor(e){this.viewer=e,this.folder=this.viewer.gui.addFolder("Animations"),this.mixer=new three__WEBPACK_IMPORTED_MODULE_2__.AnimationMixer,this.loader=new three__WEBPACK_IMPORTED_MODULE_2__.ObjectLoader,this.clock=new three__WEBPACK_IMPORTED_MODULE_2__.Clock,this.actions=[],this.playing=!1,this.time=0,this.time_scrubber=null,this.setup_capturer("png"),this.duration=0}setup_capturer(e){this.capturer=new window.CCapture({format:e,name:"meshcat_"+String(Date.now())}),this.capturer.format=e}play(){this.clock.start();for(let e of this.actions)e.play();this.playing=!0}record(){this.reset(),this.play(),this.recording=!0,this.capturer.start()}pause(){this.clock.stop(),this.playing=!1,this.recording&&(this.stop_capture(),this.save_capture())}stop_capture(){this.recording=!1,this.capturer.stop(),this.viewer.animate()}save_capture(){this.capturer.save(),"png"===this.capturer.format?alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.png \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4"):"jpg"===this.capturer.format&&alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.jpg \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4")}display_progress(e){this.time=e,null!==this.time_scrubber&&this.time_scrubber.updateDisplay()}seek(e){this.actions.forEach((t=>{t.time=Math.max(0,Math.min(t._clip.duration,e))})),this.mixer.update(0),this.viewer.set_dirty()}reset(){for(let e of this.actions)e.reset();this.display_progress(0),this.mixer.update(0),this.setup_capturer(this.capturer.format),this.viewer.set_dirty()}clear(){remove_folders(this.folder),this.mixer.stopAllAction(),this.actions=[],this.duration=0,this.display_progress(0),this.mixer=new three__WEBPACK_IMPORTED_MODULE_2__.AnimationMixer}load(e,t){this.clear(),this.folder.open();let n=this.folder.addFolder("default");n.open(),n.add(this,"play"),n.add(this,"pause"),n.add(this,"reset"),this.time_scrubber=n.add(this,"time",0,1e9,.001),this.time_scrubber.onChange((e=>this.seek(e))),n.add(this.mixer,"timeScale").step(.01).min(0);let i=n.addFolder("Recording");i.add(this,"record"),i.add({format:"png"},"format",["png","jpg"]).onChange((e=>{this.setup_capturer(e)})),void 0===t.play&&(t.play=!0),void 0===t.loopMode&&(t.loopMode=three__WEBPACK_IMPORTED_MODULE_2__.LoopRepeat),void 0===t.repetitions&&(t.repetitions=1),void 0===t.clampWhenFinished&&(t.clampWhenFinished=!0),this.duration=0,this.progress=0;for(let n of e){let e=this.viewer.scene_tree.find(n.path).object,i=three__WEBPACK_IMPORTED_MODULE_2__.AnimationClip.parse(n.clip);i.uuid=three__WEBPACK_IMPORTED_MODULE_2__.MathUtils.generateUUID();let r=this.mixer.clipAction(i,e);r.clampWhenFinished=t.clampWhenFinished,r.setLoop(t.loopMode,t.repetitions),this.actions.push(r),this.duration=Math.max(this.duration,i.duration)}this.time_scrubber.min(0),this.time_scrubber.max(this.duration),this.reset(),t.play&&this.play()}update(){if(this.playing){if(this.mixer.update(this.clock.getDelta()),this.viewer.set_dirty(),0!=this.duration){let e=this.actions.reduce(((e,t)=>Math.max(e,t.time)),0);this.display_progress(e)}else this.display_progress(0);if(this.actions.every((e=>e.paused))){this.pause();for(let e of this.actions)e.reset()}}}after_render(){this.recording&&this.capturer.capture(this.viewer.renderer.domElement)}}function env_texture(e,t,n){if(null==e||null==t)return null;let i=new Uint8Array(512),r=0,s=256;for(let n=0;n<64;++n){for(let n=0;n<3;++n)i[r+n]=t[n],i[s+n]=e[n];i[r+3]=255,i[s+3]=255,r+=4,s+=4}let a=n?three__WEBPACK_IMPORTED_MODULE_2__.EquirectangularReflectionMapping:three__WEBPACK_IMPORTED_MODULE_2__.UVMapping,o=new three__WEBPACK_IMPORTED_MODULE_2__.DataTexture(i,64,2,three__WEBPACK_IMPORTED_MODULE_2__.RGBAFormat,three__WEBPACK_IMPORTED_MODULE_2__.UnsignedByteType,a,three__WEBPACK_IMPORTED_MODULE_2__.RepeatWrapping,three__WEBPACK_IMPORTED_MODULE_2__.ClampToEdgeWrapping,three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,1,three__WEBPACK_IMPORTED_MODULE_2__.SRGBColorSpace);return n||(o.matrixAutoUpdate=!1,o.matrix.set(.5,0,.25,0,.5,.25,0,0,1),o.needsUpdate=!0),o.needsUpdate=!0,o}function load_env_texture(e,t,n,i,r){let s=(new three__WEBPACK_IMPORTED_MODULE_2__.TextureLoader).load(e,void 0,void 0,(()=>{console.error("Failure to load the requested environment map; reverting to none.",t.environment_map),t.environment_map=null,t.update(n,i,r)}));return null!=s&&(s.colorSpace=three__WEBPACK_IMPORTED_MODULE_2__.SRGBColorSpace,s.mapping=three__WEBPACK_IMPORTED_MODULE_2__.EquirectangularReflectionMapping),s}function wait_for_property(e,t,n){return new Promise((i=>{const r=new MutationObserver((()=>{var s=e[t];null!=s&&n(s)&&(r.disconnect(),i())}));r.observe(e,{childList:!0});var s=e[t];if(null!=s&&n(s))return r.disconnect(),i()}))}class Viewer{constructor(e,t,n){this.dom_element=e,void 0===n?(this.renderer=new three__WEBPACK_IMPORTED_MODULE_2__.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=three__WEBPACK_IMPORTED_MODULE_2__.PCFSoftShadowMap,this.dom_element.appendChild(this.renderer.domElement)):this.renderer=n,this.renderer.setPixelRatio(window.devicePixelRatio),this.webxr_session_active=!1,this.xr_button=null,this.scene=create_default_scene(),this.gui_controllers={},this.keydown_callbacks={},this.create_scene_tree(),this.add_default_scene_elements(),this.set_dirty(),this.create_camera(),this.num_messages_received=0,window.onload=e=>this.set_3d_pane_size(),window.addEventListener("resize",(e=>this.set_3d_pane_size()),!1),window.addEventListener("keydown",(e=>{this.on_keydown(e)})),requestAnimationFrame((()=>this.set_3d_pane_size())),(t||void 0===t)&&this.animate()}on_keydown(e){if(e.code in this.keydown_callbacks)for(const t of this.keydown_callbacks[e.code])t.callback(e)}update_background(){let e=this.scene_tree.find(["Background"]),t=this.scene_tree.find(["Background",""]),n=e.object.visible&&t.object.visible;t.object.update(this.scene,n,this.is_perspective()),this.set_dirty()}is_perspective(){return this.camera&&this.camera.isPerspectiveCamera}hide_background(){this.set_property(["Background"],"visible",!1)}show_background(){this.set_property(["Background"],"visible",!0),this.set_property(["Background",""],"visible",!0)}set_dirty(){this.needs_render=!0}create_camera(){let e=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;e.makeRotationX(Math.PI/2),this.set_transform(["Cameras","default","rotated"],e.toArray());let t=new three__WEBPACK_IMPORTED_MODULE_2__.PerspectiveCamera(75,1,.01,100);this.set_camera(t),this.set_object(["Cameras","default","rotated"],t),t.position.set(3,1,0)}upgrade_intensity(e){return e*Math.PI}create_default_spot_light(){var e=new three__WEBPACK_IMPORTED_MODULE_2__.SpotLight(16777215,this.upgrade_intensity(.8));return e.position.set(1.5,1.5,2),e.castShadow=!1,e.shadow.mapSize.width=1024,e.shadow.mapSize.height=1024,e.shadow.camera.near=.5,e.shadow.camera.far=50,e.shadow.bias=-.001,e}add_default_scene_elements(){var e=this.create_default_spot_light();this.set_object(["Lights","SpotLight"],e),this.set_property(["Lights","SpotLight"],"visible",!1);var t=new three__WEBPACK_IMPORTED_MODULE_2__.PointLight(16777215,this.upgrade_intensity(.4));t.position.set(1.5,1.5,2),t.castShadow=!1,t.distance=10,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,t.shadow.camera.near=.5,t.shadow.camera.far=10,t.shadow.bias=-.001,this.set_object(["Lights","PointLightNegativeX"],t);var n=new three__WEBPACK_IMPORTED_MODULE_2__.PointLight(16777215,this.upgrade_intensity(.4));n.position.set(-1.5,-1.5,2),n.castShadow=!1,n.distance=10,n.shadow.mapSize.width=1024,n.shadow.mapSize.height=1024,n.shadow.camera.near=.5,n.shadow.camera.far=10,n.shadow.bias=-.001,this.set_object(["Lights","PointLightPositiveX"],n);var i=new three__WEBPACK_IMPORTED_MODULE_2__.AmbientLight(16777215,this.upgrade_intensity(.3));i.intensity=.6,this.set_object(["Lights","AmbientLight"],i);var r=new three__WEBPACK_IMPORTED_MODULE_2__.DirectionalLight(16777215,this.upgrade_intensity(.4));r.position.set(-10,-10,0),this.set_object(["Lights","FillLight"],r);var s=new three__WEBPACK_IMPORTED_MODULE_2__.GridHelper(20,40);s.rotateX(Math.PI/2),this.set_object(["Grid"],s);var a=new three__WEBPACK_IMPORTED_MODULE_2__.AxesHelper(.5);this.set_object(["Axes"],a)}create_scene_tree(){this.gui&&this.gui.destroy(),this.gui=new dat.GUI({autoPlace:!1,resizable:!0}),this.dom_element.parentElement.appendChild(this.gui.domElement),this.gui.domElement.style.position="absolute",this.gui.domElement.style.right=0,this.gui.domElement.style.top=0;let e=this.gui.addFolder("Scene");e.open(),this.scene_tree=new SceneNode(this.scene,e,(()=>this.set_dirty()));let t=this.gui.addFolder("Save / Load / Capture");t.add(this,"save_scene"),t.add(this,"load_scene"),t.add(this,"save_image"),this.animator=new Animator(this),this.gui.close(),this.set_object(["Background"],new Background);let n=this.scene_tree.find(["Background"]);n.object.isBackground=!0,n.on_update=()=>{this.update_background()},this.scene_tree.find(["Background",""]).on_update=()=>{this.update_background()},this.update_background()}set_3d_pane_size(e,t){void 0===e&&(e=this.dom_element.offsetWidth),void 0===t&&(t=this.dom_element.offsetHeight),"OrthographicCamera"==this.camera.type?this.camera.right=this.camera.left+e*(this.camera.top-this.camera.bottom)/t:this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.set_dirty()}render(){this.controls.update(),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this.animator.after_render(),this.needs_render=!1}animate(){requestAnimationFrame((()=>this.animate())),this.animator.update(),this.needs_render&&this.render()}capture_image(e,t){let n=this.dom_element.offsetWidth,i=this.dom_element.offsetHeight;this.set_3d_pane_size(e,t),this.render();let r=this.renderer.domElement.toDataURL();return this.set_3d_pane_size(n,i),r}save_image(){download_data_uri("meshcat.png",this.capture_image())}set_camera(e){this.webxr_session_active?console.warn("Can't set camera during an active WebXR session."):(this.camera=e,this.controls=new three_examples_jsm_controls_OrbitControls_js__WEBPACK_IMPORTED_MODULE_6__.z(e,this.dom_element),this.controls.enableKeys=!1,this.controls.screenSpacePanning=!0,this.controls.addEventListener("start",(()=>{this.set_dirty()})),this.controls.addEventListener("change",(()=>{this.set_dirty()})),this.update_webxr_buttons(),this.update_background())}set_camera_target(e){this.controls.target.set(e[0],e[1],e[2])}set_camera_from_json(e){(new ExtensibleObjectLoader).parse(e,(e=>{this.set_camera(e)}))}set_transform(e,t){this.scene_tree.find(e).set_transform(t)}set_object(e,t){this.scene_tree.find(e.concat([""])).set_object(t)}set_object_from_json(e,t){let n=e=>{"Mesh"===e.type&&(e.castShadow=!0,e.receiveShadow=!0);for(let t=0;t{n(t),this.set_object(e,t),this.set_dirty()};if("_meshfile_object"==t.object.type&&"gltf"==t.object.format)(new three_examples_jsm_loaders_GLTFLoader_js__WEBPACK_IMPORTED_MODULE_7__.E).parse(t.object.data,e,(e=>{let n=e.scene;if(null===n)console.error("Gltf parsed with no scene!");else{let e=t.object;if(void 0!==e.matrix){n.matrix.fromArray(e.matrix);let t=new three__WEBPACK_IMPORTED_MODULE_2__.Matrix4;t=t.makeRotationX(Math.PI/2),n.matrix.multiply(t),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)}i(n)}}));else{let e=new ExtensibleObjectLoader;e.onTextureLoad=()=>{this.set_dirty()},e.parse(t,(e=>{void 0!==e.geometry&&"BufferGeometry"==e.geometry.type?void 0!==e.geometry.attributes.normal&&0!==e.geometry.attributes.normal.count||e.geometry.computeVertexNormals():e.type.includes("Camera")&&(this.set_camera(e),this.set_3d_pane_size()),i(e)}))}}delete_path(e){0==e.length?console.error("Deleting the entire scene is not implemented"):this.scene_tree.delete(e)}set_property(e,t,n){1===e.length&&"Background"===e[0]&&"visible"!==t&&(console.warn("To set the Background property "+t+', use the path "/Background/" instead of just "/Background".'),e=[e[0],""]),this.scene_tree.find(e).set_property(t,n)}set_animation(e,t){t=t||{},this.animator.load(e,t)}set_control(name,callback,value,min,max,step,keycode1,keycode2){let my_callback=eval(callback),handler={};if(name in this.gui_controllers&&this.gui.remove(this.gui_controllers[name]),void 0!==value){function e(e,t,n){if(null!=t){let i={name,callback:()=>{value=e.gui_controllers[name].getValue();let t=Math.min(Math.max(value+n,min),max);e.gui_controllers[name].setValue(t)}};t in e.keydown_callbacks?e.keydown_callbacks[t].push(i):e.keydown_callbacks[t]=[i]}}handler[name]=value,this.gui_controllers[name]=this.gui.add(handler,name,min,max,step),this.gui_controllers[name].onChange(my_callback),e(this,keycode1,-step),e(this,keycode2,+step)}else if(handler[name]=my_callback,this.gui_controllers[name]=this.gui.add(handler,name),this.gui_controllers[name].domElement.parentElement.querySelector(".property-name").style.width="100%",null!=keycode1){let e={name,callback:my_callback};keycode1 in this.keydown_callbacks?this.keydown_callbacks[keycode1].push(e):this.keydown_callbacks[keycode1]=[e]}}set_control_value(e,t,n=!0){e in this.gui_controllers&&this.gui_controllers[e]instanceof dat.controllers.NumberController&&(n?this.gui_controllers[e].setValue(t):(this.gui_controllers[e].object[e]=t,this.gui_controllers[e].updateDisplay()))}delete_control(e){e in this.gui_controllers&&(this.gui.remove(this.gui_controllers[e]),delete this.gui_controllers[e]);for(let t in this.keydown_callbacks){let n=this.keydown_callbacks[t].length;for(;n--;)this.keydown_callbacks[t][n].name==e&&this.keydown_callbacks[t].splice(n,1)}}handle_command(e){if("set_transform"==e.type){let t=split_path(e.path);this.set_transform(t,e.matrix)}else if("delete"==e.type){let t=split_path(e.path);this.delete_path(t)}else if("set_object"==e.type){let t=split_path(e.path);this.set_object_from_json(t,e.object)}else if("set_property"==e.type){let t=split_path(e.path);this.set_property(t,e.property,e.value)}else if("set_animation"==e.type)e.animations.forEach((e=>{e.path=split_path(e.path)})),this.set_animation(e.animations,e.options);else if("set_target"==e.type)this.set_camera_target(e.value);else if("set_control"==e.type)this.set_control(e.name,e.callback,e.value,e.min,e.max,e.step,e.keycode1,e.keycode2);else if("set_control_value"==e.type)this.set_control_value(e.name,e.value,e.invoke_callback);else if("delete_control"==e.type)this.delete_control(e.name);else if("capture_image"==e.type){let t=e.xres||1920,n=e.yres||1080;t/=this.renderer.getPixelRatio(),n/=this.renderer.getPixelRatio();let i=this.capture_image(t,n);this.connection.send(JSON.stringify({type:"img",data:i}))}else"save_image"==e.type?this.save_image():"enable_webxr"==e.type?this.enable_webxr(e.mode):"visualize_vr_controller"==e.type&&this.visualize_vr_controllers();this.set_dirty()}decode(e){return msgpack.decode(new Uint8Array(e.data),{extensionCodec})}handle_command_bytearray(e){let t=msgpack.decode(e,{extensionCodec});this.handle_command(t)}handle_command_message(e){this.num_messages_received++;let t=this.decode(e);this.handle_command(t)}connect(e){void 0===e&&(e=`ws://${location.host}`),"https:"==location.protocol&&(e=e.replace("ws:","wss:")),this.connection=new WebSocket(e),this.connection.binaryType="arraybuffer",this.connection.onmessage=e=>this.handle_command_message(e),this.connection.onclose=function(e){console.log("onclose:",e)}}save_scene(){download_file("scene.json",JSON.stringify(this.scene.toJSON()))}load_scene_from_json(e){let t=new ExtensibleObjectLoader;t.onTextureLoad=()=>{this.set_dirty()},this.scene_tree.dispose_recursive(),this.scene=t.parse(e),this.show_background(),this.create_scene_tree();let n=this.scene_tree.find(["Cameras","default","rotated",""]);n.object.isCamera?this.set_camera(n.object):this.create_camera()}handle_load_file(e){let t=e.files[0];if(!t)return;let n=new FileReader,i=this;n.onload=function(e){let t=this.result,n=JSON.parse(t);i.load_scene_from_json(n)},n.readAsText(t)}load_scene(){let e=document.createElement("input");e.type="file",document.body.appendChild(e);let t=this;e.addEventListener("change",(function(){console.log(this,t),t.handle_load_file(this)}),!1),e.click(),e.remove()}update_webxr_buttons(){const e=document.getElementById("XRButton"),t=document.getElementById("VRButton"),n=e||t;null!=n&&null!=n.textContent&&0!=n.textContent.length&&(null==n.original_content&&(n.original_content=n.textContent,n.original_disabled=n.disabled),this.is_perspective()?null!=n.original_content&&(n.textContent=n.original_content,n.disabled=n.original_disabled,n.original_content=null,n.original_disabled=null):(n.disabled=!0,n.textContent="AR/VR Disabled for Orthographic Cameras"))}visualize_vr_controllers(){const e=new three_examples_jsm_webxr_XRControllerModelFactory__WEBPACK_IMPORTED_MODULE_8__.i,t=(new three__WEBPACK_IMPORTED_MODULE_2__.BufferGeometry).setFromPoints([new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,0),new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,-1)]),n=new three__WEBPACK_IMPORTED_MODULE_2__.Line(t);n.scale.z=5;const i=[];for(let t=0;t<2;t++){const r=this.renderer.xr.getController(t);r.add(n.clone());const s=new three__WEBPACK_IMPORTED_MODULE_2__.Group;s.rotation.x=Math.PI/2,s.add(r),this.scene.add(s),i.push(s);const a=this.renderer.xr.getControllerGrip(t),o=new three__WEBPACK_IMPORTED_MODULE_2__.Group;o.rotation.x=Math.PI/2,o.add(a),this.scene.add(o);const l=e.createControllerModel(a);a.add(l)}return i}enable_webxr(e="ar"){if(this.renderer.xr.enabled)console.warn("WebXR/VR has already been enabled.");else{if("vr"==e)this.xr_button=three_examples_jsm_webxr_VRButton_js__WEBPACK_IMPORTED_MODULE_9__.N.createButton(this.renderer);else{if("ar"!=e)return void console.error(`enable_webxr takes either "ar" or "vr" as arguments. Given "${e}".`);this.xr_button=three_examples_jsm_webxr_XRButton_js__WEBPACK_IMPORTED_MODULE_10__.v.createButton(this.renderer)}this.renderer.xr.enabled=!0,document.body.appendChild(this.xr_button),wait_for_property(this.xr_button,"textContent",(e=>e.length>0)).then((()=>{this.update_webxr_buttons()}));var t=null;this.renderer.xr.addEventListener("sessionstart",(()=>{t=this.camera.updateProjectionMatrix,"ar"==e&&this.set_property(["Background"],"use_ar_background",!0),this.webxr_session_active=!0,console.info("Immersive session starting, controls are being removed."),this.renderer.xr.getSession().requestReferenceSpace("local").then((e=>{let t=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3;t.setFromMatrixColumn(this.camera.matrixWorld,2),Math.abs(t.y)>.5&&console.warn("The view camera was pointed up or down a significant amount when entering XR mode. Tilt the headset the same amount to see the camera's original target.");let n=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(t.x,0,t.z);n.normalize();let i=new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0,0,1),r=new three__WEBPACK_IMPORTED_MODULE_2__.Quaternion;r.setFromUnitVectors(n,i);const s=this.camera.position.clone().negate();s.applyQuaternion(r);let a=new XRRigidTransform(s,r);this.renderer.xr.setReferenceSpace(e.getOffsetReferenceSpace(a))})),this.camera.updateProjectionMatrix=()=>{console.warn("Updating the camera projection matrix is disallowed in immersive mode.")},this.renderer.setAnimationLoop((()=>{this.renderer.render(this.scene,this.camera)}))})),this.renderer.xr.addEventListener("sessionend",(()=>{this.webxr_session_active=!1,"ar"==e&&this.set_property(["Background"],"use_ar_background",!1),this.renderer.setAnimationLoop(null),this.camera.updateProjectionMatrix=t}))}}}function split_path(e){return e.split("/").filter((e=>e.length>0))}let style=document.createElement("style");style.appendChild(document.createTextNode("")),document.head.appendChild(style),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input {\n float: right;\n }"),style.sheet.insertRule("\n .meshcat-hidden-scene-element li .meshcat-visibility-checkbox {\n opacity: 0.25;\n pointer-events: none;\n }"),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input[type=checkbox] {\n height: 16px;\n width: 16px;\n display:inline-block;\n padding: 0 0 0 0px;\n }")})(),__webpack_exports__})()})); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 6513f3e2..cf86019e 100644 --- a/src/index.js +++ b/src/index.js @@ -475,7 +475,8 @@ class SceneNode { } }); if (this.object.isLight) { - let intensity_controller = this.folder.add(this.object, "intensity").min(0).step(0.01); + let intensity_controller = this.folder.add(this.object, "intensity") + .min(0).step(0.01).name("intensity (cd)"); intensity_controller.onChange(() => this.on_update()); this.controllers.push(intensity_controller); if (this.object.castShadow !== undefined){ @@ -936,11 +937,6 @@ function env_texture(top_color, bottom_color, is_perspective) { j += 4; } - // TODO(SeanCurtis-TRI): There is something about equirectangular mapping - // that can make the *actual* colors in the background different from the - // specified colors. Typically, saturation is lower. This may be due to - // hdr vs ldr images. This needs investigation. - // When we are using an orthographic camera, we can't use environment // mapping. It must be UVMapping so it covers the screen. let mapping = is_perspective ? THREE.EquirectangularReflectionMapping : @@ -949,7 +945,7 @@ function env_texture(top_color, bottom_color, is_perspective) { THREE.UnsignedByteType, mapping, THREE.RepeatWrapping, THREE.ClampToEdgeWrapping, THREE.LinearFilter, THREE.LinearFilter, 1, - THREE.LinearSRGBColorSpace); + THREE.SRGBColorSpace); if (!is_perspective) { // By default, the points in our texture map to the center of // the pixels, which means that the gradient only occupies @@ -962,9 +958,6 @@ function env_texture(top_color, bottom_color, is_perspective) { texture.needsUpdate = true } texture.needsUpdate = true; - // Although both encoding and LinearEncoding are deprecated, THREE.js gets - // *really* cranky if you don't include it. - texture.encoding = THREE.LinearEncoding; return texture; } @@ -1098,8 +1091,20 @@ class Viewer { camera.position.set(3, 1, 0); } + upgrade_intensity(legacy_intensity) { + // When we upgraded three.js from 0.149 to 0.156 we inherited a host of + // changes to lighting. See + // https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733 + // We're taking the old legacy values (which are *not* physical) and + // simply scaling them to be *functionally* equivalent as advised above. + // For point and spot lights this is insufficient. Those lights decay + // and will not be physically correct. + return legacy_intensity * Math.PI; + } + create_default_spot_light() { - var spot_light = new THREE.SpotLight(0xffffff, 0.8); + var spot_light = new THREE.SpotLight(0xffffff, + this.upgrade_intensity(0.8)); spot_light.position.set(1.5, 1.5, 2); // Make light not cast shadows by default (effectively // disabling them, as there are no shadow-casting light @@ -1121,7 +1126,8 @@ class Viewer { // it's primarily used for casting detailed shadows this.set_property(["Lights", "SpotLight"], "visible", false); - var point_light_px = new THREE.PointLight(0xffffff, 0.4); + var point_light_px = new THREE.PointLight(0xffffff, + this.upgrade_intensity(0.4)); point_light_px.position.set(1.5, 1.5, 2); point_light_px.castShadow = false; point_light_px.distance = 10.0; @@ -1132,7 +1138,8 @@ class Viewer { point_light_px.shadow.bias = -0.001; // Default 0 this.set_object(["Lights", "PointLightNegativeX"], point_light_px); - var point_light_nx = new THREE.PointLight(0xffffff, 0.4); + var point_light_nx = new THREE.PointLight(0xffffff, + this.upgrade_intensity(0.4)); point_light_nx.position.set(-1.5, -1.5, 2); point_light_nx.castShadow = false; point_light_nx.distance = 10.0; @@ -1143,11 +1150,13 @@ class Viewer { point_light_nx.shadow.bias = -0.001; // Default 0 this.set_object(["Lights", "PointLightPositiveX"], point_light_nx); - var ambient_light = new THREE.AmbientLight(0xffffff, 0.3); + var ambient_light = new THREE.AmbientLight(0xffffff, + this.upgrade_intensity(0.3)); ambient_light.intensity = 0.6; this.set_object(["Lights", "AmbientLight"], ambient_light); - var fill_light = new THREE.DirectionalLight(0xffffff, 0.4); + var fill_light = new THREE.DirectionalLight(0xffffff, + this.upgrade_intensity(0.4)); fill_light.position.set(-10, -10, 0); this.set_object(["Lights", "FillLight"], fill_light);